Browse Source

refactoring

pull/11394/head
mpetrov 2 years ago
parent
commit
647210b346
  1. 43
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts

43
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts

@ -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…
Cancel
Save