UI: Refactoring

This commit is contained in:
Artem Dzhereleiko 2024-09-10 11:20:52 +03:00
parent e3b63f9f36
commit 24a3375848
3 changed files with 13 additions and 9 deletions

View File

@ -255,8 +255,17 @@ const parseScadaSymbolMetadataFromDom = (svgDoc: Document): ScadaSymbolMetadata
if (elements.length) { if (elements.length) {
return JSON.parse(elements[0].textContent); return JSON.parse(elements[0].textContent);
} else { } else {
const viewBox = svgDoc.getElementsByTagName('svg')[0].viewBox.baseVal; const svg = svgDoc.getElementsByTagName('svg')[0];
return emptyMetadata(viewBox.width, viewBox.height); let width = null;
let height = null;
if (svg.viewBox.baseVal.width && svg.viewBox.baseVal.height) {
width = svg.viewBox.baseVal.width;
height = svg.viewBox.baseVal.height;
} else if (svg.width.baseVal.value && svg.height.baseVal.value) {
width = svg.width.baseVal.value;
height = svg.height.baseVal.value;
}
return emptyMetadata(width, height);
} }
} catch (_e) { } catch (_e) {
console.error(_e); console.error(_e);

View File

@ -114,8 +114,7 @@ const routes: Routes = [
data: { data: {
auth: [Authority.TENANT_ADMIN, Authority.SYS_ADMIN], auth: [Authority.TENANT_ADMIN, Authority.SYS_ADMIN],
title: 'scada.symbols', title: 'scada.symbols',
imageSubType: ResourceSubType.SCADA_SYMBOL, imageSubType: ResourceSubType.SCADA_SYMBOL
editOnRowClick: true
} }
}, },
{ {

View File

@ -181,8 +181,6 @@ export class ImageGalleryComponent extends PageComponent implements OnInit, OnDe
return this.imageSubType === ResourceSubType.SCADA_SYMBOL; return this.imageSubType === ResourceSubType.SCADA_SYMBOL;
} }
private editOnRowClick = false;
private updateDataSubscription: Subscription; private updateDataSubscription: Subscription;
private widgetResize$: ResizeObserver; private widgetResize$: ResizeObserver;
@ -219,7 +217,6 @@ export class ImageGalleryComponent extends PageComponent implements OnInit, OnDe
const routerQueryParams: PageQueryParam = this.route.snapshot.queryParams; const routerQueryParams: PageQueryParam = this.route.snapshot.queryParams;
if (this.pageMode) { if (this.pageMode) {
this.imageSubType = this.route.snapshot.data.imageSubType || ResourceSubType.IMAGE; this.imageSubType = this.route.snapshot.data.imageSubType || ResourceSubType.IMAGE;
this.editOnRowClick = this.route.snapshot.data.editOnRowClick || false;
if (routerQueryParams.hasOwnProperty('direction') if (routerQueryParams.hasOwnProperty('direction')
|| routerQueryParams.hasOwnProperty('property')) { || routerQueryParams.hasOwnProperty('property')) {
sortOrder = { sortOrder = {
@ -642,9 +639,8 @@ export class ImageGalleryComponent extends PageComponent implements OnInit, OnDe
} }
rowClick($event, image: ImageResourceInfo) { rowClick($event, image: ImageResourceInfo) {
if (this.editOnRowClick) { if (this.isScada) {
this.editImage($event, image); this.editImage($event, image);
} else { } else {
if (this.selectionMode) { if (this.selectionMode) {
this.selectImage($event, image); this.selectImage($event, image);