Browse Source

UI: Refactoring error msg

pull/13110/head
Artem Dzhereleiko 1 year ago
parent
commit
b854dcf0c7
  1. 2
      ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts
  2. 8
      ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts

2
ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts

@ -271,7 +271,7 @@ export const updateScadaSymbolMetadataInContent = (svgContent: string, metadata:
const svgDoc = new DOMParser().parseFromString(svgContent, 'image/svg+xml');
const parsererror = svgDoc.getElementsByTagName('parsererror');
if (parsererror?.length) {
return parsererror[0].outerHTML;
throw Error(parsererror[0].textContent)
}
updateScadaSymbolMetadataInDom(svgDoc, metadata);
return svgDoc.documentElement.outerHTML;

8
ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts

@ -214,10 +214,8 @@ export class ScadaSymbolComponent extends PageComponent
this.editObjectCallbacks.tagsUpdated(tags);
}
const metadata: ScadaSymbolMetadata = this.scadaSymbolFormGroup.get('metadata').value;
const scadaSymbolContent = this.prepareScadaSymbolContent(metadata);
if (scadaSymbolContent.includes('parsererror')) {
this.store.dispatch(new ActionNotificationShow({ message: scadaSymbolContent, type: 'error' }));
} else {
try {
const scadaSymbolContent = this.prepareScadaSymbolContent(metadata);
const file = createFileFromContent(scadaSymbolContent, this.symbolData.imageResource.fileName,
this.symbolData.imageResource.descriptor.mediaType);
const type = imageResourceType(this.symbolData.imageResource);
@ -243,6 +241,8 @@ export class ScadaSymbolComponent extends PageComponent
this.init(data);
this.updateBreadcrumbs.emit();
});
} catch (e) {
this.store.dispatch(new ActionNotificationShow({ message: e.message, type: 'error' }));
}
}
}

Loading…
Cancel
Save