Skip to content

Commit

Permalink
using confirmation dialog if no connector is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Oct 2, 2024
1 parent f397a7a commit 4ff7c11
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
4 changes: 2 additions & 2 deletions dynamic-mapping-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ import { FormControl, FormGroup } from '@angular/forms';
import { AlertService, C8yStepper } from '@c8y/ngx-components';
import { FormlyFieldConfig } from '@ngx-formly/core';
import * as _ from 'lodash';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { BehaviorSubject, Subject } from 'rxjs';
import { Content } from 'vanilla-jsoneditor';
import { ExtensionService } from '../../extension';
import {
API,
COLOR_HIGHLIGHTED,
ConfirmationModalComponent,
DeploymentMapEntry,
Direction,
Extension,
Expand Down Expand Up @@ -666,9 +667,31 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
this.deploymentMapEntry.connectors &&
this.deploymentMapEntry.connectors.length == 0
) {
this.alertService.warning(
'To apply the mapping to messages you have to select at least one connector. Go back, unless you only want to assign a connector later!'
const initialState = {
title: 'No connector selected',
message:
'To apply the mapping to messages you should select at least one connector, unless you want to change this later! Do you want to continue?',
labels: {
ok: 'Continue',
cancel: 'Close'
}
};
const confirmContinuingModalRef: BsModalRef = this.bsModalService.show(
ConfirmationModalComponent,
{ initialState }
);
confirmContinuingModalRef.content.closeSubject.subscribe(
async (confirmation: boolean) => {
// console.log('Confirmation result:', confirmation);
if (confirmation) {
event.stepper.next();
}
confirmContinuingModalRef.hide();
}
);
// this.alertService.warning(
// 'To apply the mapping to messages you have to select at least one connector. Go back, unless you only want to assign a connector later!'
// );
}
event.stepper.next();
} else if (this.step == 'General settings') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,32 @@ export class SnoopingStepperComponent implements OnInit, OnDestroy {
this.deploymentMapEntry.connectors &&
this.deploymentMapEntry.connectors.length == 0
) {
// const initialState = {
// title: 'No connector selected',
// message:
// 'To snoop for messages you have to select at least one connector!',
// labels: {
// cancel: 'Close'
// }
// };
// // eslint-disable-next-line @typescript-eslint/no-unused-vars
// const confirmDeletionModalRef: BsModalRef = this.bsModalService.show(
// ConfirmationModalComponent,
// { initialState }
// );
this.alertService.warning(
'To snoop for messages you have to select at least one connector. Go back, unless you only want to assign a connector later!'
const initialState = {
title: 'No connector selected',
message:
'To snoop for messages you should select at least one connector, unless you want to change this later! Do you want to continue?',
labels: {
ok: 'Continue',
cancel: 'Close'
}
};
const confirmContinuingModalRef: BsModalRef = this.bsModalService.show(
ConfirmationModalComponent,
{ initialState }
);
confirmContinuingModalRef.content.closeSubject.subscribe(
async (confirmation: boolean) => {
// console.log('Confirmation result:', confirmation);
if (confirmation) {
event.stepper.next();
}
confirmContinuingModalRef.hide();
}
);
// this.alertService.warning(
// 'To snoop for messages you have to select at least one connector. Go back, unless you only want to assign a connector later!'
// );
}
event.stepper.next();
}
}

Expand Down

0 comments on commit 4ff7c11

Please sign in to comment.