refactoring
This commit is contained in:
parent
bc35466e03
commit
647210b346
@ -392,27 +392,30 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
|
|||||||
const title = `Delete connector \"${attribute.key}\"?`;
|
const title = `Delete connector \"${attribute.key}\"?`;
|
||||||
const content = `All connector data will be deleted.`;
|
const content = `All connector data will be deleted.`;
|
||||||
|
|
||||||
this.dialogService.confirm(title, content, 'Cancel', 'Delete').pipe(take(1)).subscribe(result => {
|
this.dialogService.confirm(title, content, 'Cancel', 'Delete').pipe(
|
||||||
if (!result) {
|
take(1),
|
||||||
return;
|
switchMap((result) => {
|
||||||
}
|
if (!result) {
|
||||||
const tasks: Array<Observable<any>> = [];
|
return;
|
||||||
const scope = this.activeConnectors.includes(attribute.value?.name) ?
|
|
||||||
AttributeScope.SHARED_SCOPE :
|
|
||||||
AttributeScope.SERVER_SCOPE;
|
|
||||||
tasks.push(this.attributeService.deleteEntityAttributes(this.device, scope, [attribute]));
|
|
||||||
this.removeConnectorFromList(attribute.key, true);
|
|
||||||
this.removeConnectorFromList(attribute.key, false);
|
|
||||||
tasks.push(this.getSaveEntityAttributesTask(scope));
|
|
||||||
|
|
||||||
forkJoin(tasks).pipe(take(1)).subscribe(() => {
|
|
||||||
if (this.initialConnector ? this.initialConnector.name === attribute.key : true) {
|
|
||||||
this.clearOutConnectorForm();
|
|
||||||
this.cd.detectChanges();
|
|
||||||
this.connectorForm.disable();
|
|
||||||
}
|
}
|
||||||
this.updateData(true);
|
const tasks: Array<Observable<any>> = [];
|
||||||
});
|
const scope = this.activeConnectors.includes(attribute.value?.name) ?
|
||||||
|
AttributeScope.SHARED_SCOPE :
|
||||||
|
AttributeScope.SERVER_SCOPE;
|
||||||
|
tasks.push(this.attributeService.deleteEntityAttributes(this.device, scope, [attribute]));
|
||||||
|
this.removeConnectorFromList(attribute.key, true);
|
||||||
|
this.removeConnectorFromList(attribute.key, false);
|
||||||
|
tasks.push(this.getSaveEntityAttributesTask(scope));
|
||||||
|
|
||||||
|
return forkJoin(tasks);
|
||||||
|
})
|
||||||
|
).subscribe(() => {
|
||||||
|
if (this.initialConnector ? this.initialConnector.name === attribute.key : true) {
|
||||||
|
this.clearOutConnectorForm();
|
||||||
|
this.cd.detectChanges();
|
||||||
|
this.connectorForm.disable();
|
||||||
|
}
|
||||||
|
this.updateData(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user