Browse Source

UI: Show error for bad xml scada symbols

pull/13110/head
Artem Dzhereleiko 1 year ago
parent
commit
5b8c8d1aed
  1. 51
      ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.ts

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

@ -79,6 +79,7 @@ import {
SaveWidgetTypeAsDialogResult SaveWidgetTypeAsDialogResult
} from '@home/pages/widget/save-widget-type-as-dialog.component'; } from '@home/pages/widget/save-widget-type-as-dialog.component';
import { WidgetService } from '@core/http/widget.service'; import { WidgetService } from '@core/http/widget.service';
import { ActionNotificationShow } from '@core/notification/notification.actions';
@Component({ @Component({
selector: 'tb-scada-symbol', selector: 'tb-scada-symbol',
@ -214,31 +215,35 @@ export class ScadaSymbolComponent extends PageComponent
} }
const metadata: ScadaSymbolMetadata = this.scadaSymbolFormGroup.get('metadata').value; const metadata: ScadaSymbolMetadata = this.scadaSymbolFormGroup.get('metadata').value;
const scadaSymbolContent = this.prepareScadaSymbolContent(metadata); const scadaSymbolContent = this.prepareScadaSymbolContent(metadata);
const file = createFileFromContent(scadaSymbolContent, this.symbolData.imageResource.fileName, if (scadaSymbolContent.includes('parsererror')) {
this.symbolData.imageResource.descriptor.mediaType); this.store.dispatch(new ActionNotificationShow({ message: scadaSymbolContent, type: 'error' }));
const type = imageResourceType(this.symbolData.imageResource); } else {
let imageInfoObservable = const file = createFileFromContent(scadaSymbolContent, this.symbolData.imageResource.fileName,
this.imageService.updateImage(type, this.symbolData.imageResource.resourceKey, file); this.symbolData.imageResource.descriptor.mediaType);
if (metadata.title !== this.symbolData.imageResource.title) { const type = imageResourceType(this.symbolData.imageResource);
imageInfoObservable = imageInfoObservable.pipe( let imageInfoObservable =
switchMap(imageInfo => { this.imageService.updateImage(type, this.symbolData.imageResource.resourceKey, file);
imageInfo.title = metadata.title; if (metadata.title !== this.symbolData.imageResource.title) {
return this.imageService.updateImageInfo(imageInfo); imageInfoObservable = imageInfoObservable.pipe(
}) switchMap(imageInfo => {
); imageInfo.title = metadata.title;
} return this.imageService.updateImageInfo(imageInfo);
imageInfoObservable.pipe( })
switchMap(imageInfo => this.imageService.getImageString( );
}
imageInfoObservable.pipe(
switchMap(imageInfo => this.imageService.getImageString(
`${IMAGES_URL_PREFIX}/${type}/${encodeURIComponent(imageInfo.resourceKey)}`).pipe( `${IMAGES_URL_PREFIX}/${type}/${encodeURIComponent(imageInfo.resourceKey)}`).pipe(
map(content => ({ map(content => ({
imageResource: imageInfo, imageResource: imageInfo,
scadaSymbolContent: content scadaSymbolContent: content
})) }))
)) ))
).subscribe(data => { ).subscribe(data => {
this.init(data); this.init(data);
this.updateBreadcrumbs.emit(); this.updateBreadcrumbs.emit();
}); });
}
} }
} }

Loading…
Cancel
Save