UI: Handle error on apply preview upload and download
This commit is contained in:
parent
9bcdc86d09
commit
413cc12126
@ -253,6 +253,7 @@ export class ScadaSymbolComponent extends PageComponent
|
||||
|
||||
enterPreviewMode() {
|
||||
this.previewMetadata = this.scadaSymbolFormGroup.get('metadata').value;
|
||||
try {
|
||||
this.symbolData.scadaSymbolContent = this.prepareScadaSymbolContent(this.previewMetadata);
|
||||
this.previewScadaSymbolObjectSettings = {
|
||||
behavior: {},
|
||||
@ -290,6 +291,9 @@ export class ScadaSymbolComponent extends PageComponent
|
||||
};
|
||||
this.previewWidgets = [this.previewWidget];
|
||||
this.previewMode = true;
|
||||
} catch (e) {
|
||||
this.store.dispatch(new ActionNotificationShow({ message: e.message, type: 'error' }));
|
||||
}
|
||||
}
|
||||
|
||||
exitPreviewMode() {
|
||||
@ -379,6 +383,7 @@ export class ScadaSymbolComponent extends PageComponent
|
||||
metadata = parseScadaSymbolMetadataFromContent(this.origSymbolData.scadaSymbolContent);
|
||||
}
|
||||
const linkElement = document.createElement('a');
|
||||
try {
|
||||
const scadaSymbolContent = this.prepareScadaSymbolContent(metadata);
|
||||
const blob = new Blob([scadaSymbolContent], { type: this.symbolData.imageResource.descriptor.mediaType });
|
||||
const url = URL.createObjectURL(blob);
|
||||
@ -392,6 +397,9 @@ export class ScadaSymbolComponent extends PageComponent
|
||||
}
|
||||
);
|
||||
linkElement.dispatchEvent(clickEvent);
|
||||
} catch (e) {
|
||||
this.store.dispatch(new ActionNotificationShow({ message: e.message, type: 'error' }));
|
||||
}
|
||||
}
|
||||
|
||||
createWidget() {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<form [formGroup]="uploadImageFormGroup" (ngSubmit)="upload()" style="width: 560px;">
|
||||
<form [formGroup]="uploadImageFormGroup" (ngSubmit)="upload()" style="width: 560px;" tb-toast toastTarget="uploadRoot">
|
||||
<mat-toolbar color="primary">
|
||||
<h2>{{ ( uploadImage ? (isScada ? 'scada.upload-symbol' : 'image.upload-image') : (isScada ? 'scada.update-symbol' : 'image.update-image') ) | translate }}</h2>
|
||||
<span class="flex-1"></span>
|
||||
|
||||
@ -41,6 +41,7 @@ import {
|
||||
updateScadaSymbolMetadataInContent
|
||||
} from '@home/components/widget/lib/scada/scada-symbol.models';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
||||
|
||||
export interface UploadImageDialogData {
|
||||
imageSubType: ResourceSubType;
|
||||
@ -135,6 +136,7 @@ export class UploadImageDialogComponent extends
|
||||
upload(): void {
|
||||
this.submitted = true;
|
||||
let file: File = this.uploadImageFormGroup.get('file').value;
|
||||
try {
|
||||
if (this.uploadImage) {
|
||||
const title: string = this.uploadImageFormGroup.get('title').value;
|
||||
if (this.isScada) {
|
||||
@ -168,5 +170,14 @@ export class UploadImageDialogComponent extends
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.store.dispatch(new ActionNotificationShow({
|
||||
message: e.message,
|
||||
type: 'error',
|
||||
verticalPosition: 'bottom',
|
||||
horizontalPosition: 'right',
|
||||
target: 'uploadRoot'
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user