diff --git a/ui-ngx/src/app/core/utils.ts b/ui-ngx/src/app/core/utils.ts index 9b45cf5f21..490f157ac3 100644 --- a/ui-ngx/src/app/core/utils.ts +++ b/ui-ngx/src/app/core/utils.ts @@ -464,7 +464,7 @@ export function parseArray(input: any[]): any[] { time: el[0], deviceType: null }; - entityArray.filter(el=>el.data.length).forEach(entity => { + entityArray.filter(el => el.data.length).forEach(entity => { obj[entity?.dataKey?.label] = entity?.data[i][1]; obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0]; if (entity?.dataKey?.label === 'type') { @@ -485,7 +485,7 @@ export function parseData(input: any[]): any[] { dsIndex: i, deviceType: null }; - entityArray.filter(el=>el.data.length).forEach(el => { + entityArray.filter(el => el.data.length).forEach(el => { obj[el?.dataKey?.label] = el?.data[0][1]; obj[el?.dataKey?.label + '|ts'] = el?.data[0][0]; if (el?.dataKey?.label === 'type') { @@ -525,22 +525,19 @@ export function parseFunction(source: any, params: string[] = ['def']): Function export function parseTemplate(template: string, data: object, translateFn?: (key: string) => string) { let res = ''; - let variables = ''; try { if (template.match(//g, 'a>').replace(/name=(\'|")(.*?)(\'|")/g, `class='tb-custom-action' id='$2'`); } - if (template.includes('i18n')) { - const translateRegexp = /\{i18n:(.*?)\}/; - template.match(new RegExp(translateRegexp.source, translateRegexp.flags + 'g')).forEach(match => { - template = template.replace(match, translateFn(match.match(translateRegexp)[1])); - }); + if (translateFn) { + template = translateFn(template); } const formatted = template.match(/\$\{([^}]*)\:\d*\}/g); if (formatted) formatted.forEach(value => { const [variable, digits] = value.replace('${', '').replace('}', '').split(':'); - data[variable] = padValue(data[variable], +digits) + data[variable] = padValue(data[variable], +digits); + if (isNaN(data[variable])) data[value] = ''; template = template.replace(value, '${' + variable + '}'); }); const variables = template.match(/\$\{.*?\}/g); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts index 24564d9759..b50ff189fb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts @@ -52,7 +52,9 @@ export type MapSettings = { animate: boolean, maxClusterRadius: number, chunkedLoading: boolean, - removeOutsideVisibleBounds: boolean + removeOutsideVisibleBounds: boolean, + useCustomProvider: boolean, + customProviderTileUrl: string; } export enum MapProviders { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts index ac74263a7d..3bd31d3c1f 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts @@ -170,7 +170,7 @@ export class MapWidgetController implements MapWidgetInterface { const timeseries = []; const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName]; e.$datasource.dataKeys.forEach(key => { - if (latLngProperties.includes(key)) { + if (latLngProperties.includes(key.name)) { const value = { key: key.name, value: e[key.name] diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts index ac9c31295c..9f20d3ff68 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts @@ -73,11 +73,14 @@ export class Polyline { getPolyStyle(settings: PolylineSettings): L.PolylineOptions { return { color: settings.useColorFunction ? - safeExecute(settings.colorFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.color, + safeExecute(settings.colorFunction, + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.color, opacity: settings.useStrokeOpacityFunction ? - safeExecute(settings.strokeOpacityFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeOpacity, + safeExecute(settings.strokeOpacityFunction, + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeOpacity, weight: settings.useStrokeWeightFunction ? - safeExecute(settings.strokeWeightFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeWeight, + safeExecute(settings.strokeWeightFunction, + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeWeight, } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts index 38db40208a..443e565e61 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/openstreet-map.ts @@ -22,7 +22,11 @@ export class OpenStreetMap extends LeafletMap { constructor($container, options: UnitedMapSettings) { super($container, options); const map = L.map($container).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); - const tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik'); + let tileLayer; + if (options.useCustomProvider) + tileLayer = L.tileLayer(options.customProviderTileUrl); + else + tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik'); tileLayer.addTo(map); super.setMap(map); super.initSettings(options);