Commit 73b03394f0d056ac64a1f1522dd929ad5e3819bb

Authored by Artem Halushko
1 parent 1e0e1bd5

tile layers and locations set fixes

@@ -464,7 +464,7 @@ export function parseArray(input: any[]): any[] { @@ -464,7 +464,7 @@ export function parseArray(input: any[]): any[] {
464 time: el[0], 464 time: el[0],
465 deviceType: null 465 deviceType: null
466 }; 466 };
467 - entityArray.filter(el=>el.data.length).forEach(entity => { 467 + entityArray.filter(el => el.data.length).forEach(entity => {
468 obj[entity?.dataKey?.label] = entity?.data[i][1]; 468 obj[entity?.dataKey?.label] = entity?.data[i][1];
469 obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0]; 469 obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0];
470 if (entity?.dataKey?.label === 'type') { 470 if (entity?.dataKey?.label === 'type') {
@@ -485,7 +485,7 @@ export function parseData(input: any[]): any[] { @@ -485,7 +485,7 @@ export function parseData(input: any[]): any[] {
485 dsIndex: i, 485 dsIndex: i,
486 deviceType: null 486 deviceType: null
487 }; 487 };
488 - entityArray.filter(el=>el.data.length).forEach(el => { 488 + entityArray.filter(el => el.data.length).forEach(el => {
489 obj[el?.dataKey?.label] = el?.data[0][1]; 489 obj[el?.dataKey?.label] = el?.data[0][1];
490 obj[el?.dataKey?.label + '|ts'] = el?.data[0][0]; 490 obj[el?.dataKey?.label + '|ts'] = el?.data[0][0];
491 if (el?.dataKey?.label === 'type') { 491 if (el?.dataKey?.label === 'type') {
@@ -525,22 +525,19 @@ export function parseFunction(source: any, params: string[] = ['def']): Function @@ -525,22 +525,19 @@ export function parseFunction(source: any, params: string[] = ['def']): Function
525 525
526 export function parseTemplate(template: string, data: object, translateFn?: (key: string) => string) { 526 export function parseTemplate(template: string, data: object, translateFn?: (key: string) => string) {
527 let res = ''; 527 let res = '';
528 - let variables = '';  
529 try { 528 try {
530 if (template.match(/<link-act/g)) { 529 if (template.match(/<link-act/g)) {
531 template = template.replace(/<link-act/g, '<a').replace(/link-act>/g, 'a>').replace(/name=(\'|")(.*?)(\'|")/g, `class='tb-custom-action' id='$2'`); 530 template = template.replace(/<link-act/g, '<a').replace(/link-act>/g, 'a>').replace(/name=(\'|")(.*?)(\'|")/g, `class='tb-custom-action' id='$2'`);
532 } 531 }
533 - if (template.includes('i18n')) {  
534 - const translateRegexp = /\{i18n:(.*?)\}/;  
535 - template.match(new RegExp(translateRegexp.source, translateRegexp.flags + 'g')).forEach(match => {  
536 - template = template.replace(match, translateFn(match.match(translateRegexp)[1]));  
537 - }); 532 + if (translateFn) {
  533 + template = translateFn(template);
538 } 534 }
539 const formatted = template.match(/\$\{([^}]*)\:\d*\}/g); 535 const formatted = template.match(/\$\{([^}]*)\:\d*\}/g);
540 if (formatted) 536 if (formatted)
541 formatted.forEach(value => { 537 formatted.forEach(value => {
542 const [variable, digits] = value.replace('${', '').replace('}', '').split(':'); 538 const [variable, digits] = value.replace('${', '').replace('}', '').split(':');
543 - data[variable] = padValue(data[variable], +digits) 539 + data[variable] = padValue(data[variable], +digits);
  540 + if (isNaN(data[variable])) data[value] = '';
544 template = template.replace(value, '${' + variable + '}'); 541 template = template.replace(value, '${' + variable + '}');
545 }); 542 });
546 const variables = template.match(/\$\{.*?\}/g); 543 const variables = template.match(/\$\{.*?\}/g);
@@ -52,7 +52,9 @@ export type MapSettings = { @@ -52,7 +52,9 @@ export type MapSettings = {
52 animate: boolean, 52 animate: boolean,
53 maxClusterRadius: number, 53 maxClusterRadius: number,
54 chunkedLoading: boolean, 54 chunkedLoading: boolean,
55 - removeOutsideVisibleBounds: boolean 55 + removeOutsideVisibleBounds: boolean,
  56 + useCustomProvider: boolean,
  57 + customProviderTileUrl: string;
56 } 58 }
57 59
58 export enum MapProviders { 60 export enum MapProviders {
@@ -170,7 +170,7 @@ export class MapWidgetController implements MapWidgetInterface { @@ -170,7 +170,7 @@ export class MapWidgetController implements MapWidgetInterface {
170 const timeseries = []; 170 const timeseries = [];
171 const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName]; 171 const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
172 e.$datasource.dataKeys.forEach(key => { 172 e.$datasource.dataKeys.forEach(key => {
173 - if (latLngProperties.includes(key)) { 173 + if (latLngProperties.includes(key.name)) {
174 const value = { 174 const value = {
175 key: key.name, 175 key: key.name,
176 value: e[key.name] 176 value: e[key.name]
@@ -73,11 +73,14 @@ export class Polyline { @@ -73,11 +73,14 @@ export class Polyline {
73 getPolyStyle(settings: PolylineSettings): L.PolylineOptions { 73 getPolyStyle(settings: PolylineSettings): L.PolylineOptions {
74 return { 74 return {
75 color: settings.useColorFunction ? 75 color: settings.useColorFunction ?
76 - safeExecute(settings.colorFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.color, 76 + safeExecute(settings.colorFunction,
  77 + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.color,
77 opacity: settings.useStrokeOpacityFunction ? 78 opacity: settings.useStrokeOpacityFunction ?
78 - safeExecute(settings.strokeOpacityFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeOpacity, 79 + safeExecute(settings.strokeOpacityFunction,
  80 + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeOpacity,
79 weight: settings.useStrokeWeightFunction ? 81 weight: settings.useStrokeWeightFunction ?
80 - safeExecute(settings.strokeWeightFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeWeight, 82 + safeExecute(settings.strokeWeightFunction,
  83 + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeWeight,
81 } 84 }
82 } 85 }
83 86
@@ -22,7 +22,11 @@ export class OpenStreetMap extends LeafletMap { @@ -22,7 +22,11 @@ export class OpenStreetMap extends LeafletMap {
22 constructor($container, options: UnitedMapSettings) { 22 constructor($container, options: UnitedMapSettings) {
23 super($container, options); 23 super($container, options);
24 const map = L.map($container).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); 24 const map = L.map($container).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
25 - const tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik'); 25 + let tileLayer;
  26 + if (options.useCustomProvider)
  27 + tileLayer = L.tileLayer(options.customProviderTileUrl);
  28 + else
  29 + tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik');
26 tileLayer.addTo(map); 30 tileLayer.addTo(map);
27 super.setMap(map); 31 super.setMap(map);
28 super.initSettings(options); 32 super.initSettings(options);