Commit 47c29f27e0188a815ffb31c2e3660ab386e63c7e

Authored by Artem Halushko
1 parent ea184ec5

typing & small fixes

... ... @@ -14,7 +14,7 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import L, { FeatureGroup, LatLngBounds, LatLngTuple, markerClusterGroup, MarkerClusterGroupOptions } from 'leaflet';
  17 +import L, { FeatureGroup, LatLngBounds, LatLngTuple, markerClusterGroup, MarkerClusterGroupOptions, MarkerClusterGroup } from 'leaflet';
18 18
19 19 import 'leaflet-providers';
20 20 import 'leaflet.markercluster/dist/leaflet.markercluster';
... ... @@ -45,9 +45,9 @@ export default abstract class LeafletMap {
45 45 options: UnitedMapSettings;
46 46 bounds: L.LatLngBounds;
47 47 datasources: FormattedData[];
48   - markersCluster;
  48 + markersCluster: MarkerClusterGroup;
49 49 points: FeatureGroup;
50   - markersData = [];
  50 + markersData: FormattedData[] = [];
51 51
52 52 protected constructor(public $container: HTMLElement, options: UnitedMapSettings) {
53 53 this.options = options;
... ... @@ -245,7 +245,7 @@ export default abstract class LeafletMap {
245 245 }
246 246
247 247 // Markers
248   - updateMarkers(markersData, callback?) {
  248 + updateMarkers(markersData: FormattedData[], callback?) {
249 249 markersData.filter(mdata => !!this.convertPosition(mdata)).forEach(data => {
250 250 if (data.rotationAngle || data.rotationAngle === 0) {
251 251 const currentImage = this.options.useMarkerImageFunction ?
... ... @@ -272,7 +272,7 @@ export default abstract class LeafletMap {
272 272 this.markersData = markersData;
273 273 }
274 274
275   - dragMarker = (e, data?) => {
  275 + dragMarker = (e, data = {}) => {
276 276 if (e.type !== 'dragend') return;
277 277 this.saveMarkerLocation({ ...data, ...this.convertToCustomFormat(e.target._latlng) });
278 278 }
... ...
... ... @@ -34,7 +34,8 @@ import {
34 34 DatasourceType,
35 35 JsonSettingsSchema,
36 36 WidgetActionDescriptor,
37   - widgetType
  37 + widgetType,
  38 + DatasourceData
38 39 } from '@shared/models/widget.models';
39 40 import { EntityId } from '@shared/models/id/entity-id';
40 41 import { AttributeScope, DataKeyType, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
... ... @@ -83,7 +84,7 @@ export class MapWidgetController implements MapWidgetInterface {
83 84 map: LeafletMap;
84 85 provider: MapProviders;
85 86 schema: JsonSettingsSchema;
86   - data;
  87 + data: DatasourceData[];
87 88 settings: UnitedMapSettings;
88 89
89 90 public static dataKeySettingsSchema(): object {
... ...
... ... @@ -22,8 +22,8 @@ import { isDefined } from '@core/utils';
22 22
23 23 export class Marker {
24 24 leafletMarker: L.Marker;
25   - tooltipOffset: [number, number];
26   - markerOffset: [number, number];
  25 + tooltipOffset: L.LatLngTuple;
  26 + markerOffset: L.LatLngTuple;
27 27 tooltip: L.Popup;
28 28 location: L.LatLngExpression;
29 29 data: FormattedData;
... ...
... ... @@ -409,7 +409,10 @@ export const commonMapSettingsSchema =
409 409 condition: 'model.provider !== "image-map"'
410 410 },
411 411 'draggableMarker',
412   - 'disableScrollZooming',
  412 + {
  413 + key: 'disableScrollZooming',
  414 + condition: 'model.provider !== "image-map"'
  415 + },
413 416 {
414 417 key: 'latKeyName',
415 418 condition: 'model.provider !== "image-map"'
... ...
... ... @@ -159,10 +159,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
159 159 calculateIntervals() {
160 160 this.historicalData.forEach((dataSource, index) => {
161 161 this.minTime = dataSource[0]?.time || Infinity;
162   - const minTimeFormat = this.minTime !== Infinity ? moment(this.minTime).format('YYYY-MM-DD HH:mm:ss') : '';
163 162 this.maxTime = dataSource[dataSource.length - 1]?.time || -Infinity;
164   - const maxTimeFormat = this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '';
165   - this.interpolatedTimeData[index] = this.interpolateArray(dataSource, minTimeFormat, maxTimeFormat);
  163 + this.interpolatedTimeData[index] = this.interpolateArray(dataSource);
166 164 });
167 165 if(!this.activeTrip){
168 166 this.activeTrip = this.interpolatedTimeData.map(dataSource => dataSource[this.minTime]).filter(ds => ds)[0];
... ... @@ -194,7 +192,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
194 192 this.label = (parseWithTranslation.parseTemplate(labelText, data, true));
195 193 }
196 194
197   - interpolateArray(originData: FormattedData[], minTimeFormat?: string, maxTimeFormat?: string) {
  195 + interpolateArray(originData: FormattedData[]) {
198 196 const result = {};
199 197 const latKeyName = this.settings.latKeyName;
200 198 const lngKeyName = this.settings.lngKeyName;
... ... @@ -203,8 +201,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
203 201 const normalizeTime = this.minTime + Math.ceil((currentTime - this.minTime) / this.normalizationStep) * this.normalizationStep;
204 202 result[normalizeTime] = {
205 203 ...data,
206   - minTime: minTimeFormat,
207   - maxTime: maxTimeFormat,
  204 + minTime: this.minTime !== Infinity ? moment(this.minTime).format('YYYY-MM-DD HH:mm:ss') : '',
  205 + maxTime: this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '',
208 206 rotationAngle: this.settings.rotationAngle
209 207 };
210 208 }
... ...