Skip to content

Commit

Permalink
proposed waring messages for #266
Browse files Browse the repository at this point in the history
  • Loading branch information
ck-c8y committed Oct 1, 2024
1 parent 0b645e8 commit 9cc15be
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
this.substitutionModel.targetExpression.severity = 'text-info';
} else if (path == '$') {
this.substitutionModel.targetExpression.msgTxt = `By specifying "$" you selected the root of the target
template and this rersults in merging the source expression with the target template.`;
template and this result in merging the source expression with the target template.`;
this.substitutionModel.targetExpression.severity = 'text-warning';
}
} catch (error) {
Expand Down Expand Up @@ -661,7 +661,17 @@ export class MappingStepperComponent implements OnInit, OnDestroy {
}): Promise<void> {
// ('OnNextStep', event.step.label, this.mapping);
this.step = event.step.label;
if (this.step == 'General settings') {
if (this.step == 'Add and select connector') {
if (
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!'
);
}
event.stepper.next();
} else if (this.step == 'General settings') {
this.templateModel.mapping = this.mapping;
// console.log(
// 'Populate jsonPath if wildcard:',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@
<span [c8yIcon]="'hand-peace-o'"></span>
</ng-template>
<cdk-step label="Add and select connector">
<div class="p-16 p-t-0 flex-no-shrink separator-bottom col-xs-12">
<div class="row">
<div class="col-lg-12">
<h4 class="text-medium">
<div class="text-center">
<span
*ngIf="stepperConfiguration.editorMode !== EditorMode.READ_ONLY"
>Select connector for snooping (at least one is required)</span
>
<div
*ngIf="stepperConfiguration.editorMode === EditorMode.READ_ONLY"
>
Selected connectors for snooping
<span class="label label-primary">{{ 'Read Only' }}</span>
</div>
</div>
</h4>
</div>
</div>
</div>

<div class="col-xs-12 flex-grow no-gutter">
<d11r-mapping-connector
[stepperConfiguration]="stepperConfiguration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ import {
ViewEncapsulation
} from '@angular/core';
import { FormGroup } from '@angular/forms';
import { C8yStepper } from '@c8y/ngx-components';
import { BsModalService } from 'ngx-bootstrap/modal';
import { AlertService, C8yStepper } from '@c8y/ngx-components';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { BehaviorSubject, Subject } from 'rxjs';
import { Direction, Mapping, SharedService } from '../../shared';
import {
ConfirmationModalComponent,
Direction,
Mapping,
SharedService
} from '../../shared';
import { MappingService } from '../core/mapping.service';
import { countDeviceIdentifiers, isDisabled } from '../shared/util';
import { EditorMode } from '../shared/stepper-model';
Expand Down Expand Up @@ -85,6 +90,7 @@ export class SnoopingStepperComponent implements OnInit, OnDestroy {
constructor(
public bsModalService: BsModalService,
public mappingService: MappingService,
public alertService: AlertService,
public sharedService: SharedService
) {}

Expand Down Expand Up @@ -120,6 +126,27 @@ export class SnoopingStepperComponent implements OnInit, OnDestroy {
if (this.step == 'Properties snooping') {
event.stepper.next();
} else {
if (
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!'
);
}
event.stepper.next();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import {
OnInit,
Output,
ViewChild,
AfterViewInit,
ElementRef,
Renderer2
AfterViewInit
} from '@angular/core';
import {
ActionControl,
Expand Down Expand Up @@ -105,9 +103,7 @@ export class ConnectorConfigurationComponent implements OnInit, AfterViewInit {
constructor(
private bsModalService: BsModalService,
private connectorConfigurationService: ConnectorConfigurationService,
private alertService: AlertService,
private el: ElementRef,
private renderer: Renderer2
private alertService: AlertService
) {}

ngAfterViewInit(): void {
Expand Down Expand Up @@ -192,7 +188,7 @@ export class ConnectorConfigurationComponent implements OnInit, AfterViewInit {
filterable: false,
sortable: true,
cellRendererComponent: ConnectorStatusRendererComponent,
gridTrackSize: '20%'
gridTrackSize: '10%'
},
{
header: 'Enabled',
Expand All @@ -201,7 +197,7 @@ export class ConnectorConfigurationComponent implements OnInit, AfterViewInit {
filterable: false,
sortable: true,
cellRendererComponent: StatusEnabledRendererComponent,
gridTrackSize: '15%'
gridTrackSize: '10%'
}
);
this.selected = this.deploymentMapEntry?.connectors ?? [];
Expand Down

0 comments on commit 9cc15be

Please sign in to comment.