@aggdirect/coolmap-services 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -140,36 +140,71 @@ class UtilsService {
140
140
  getDateFormat(strVal, seprater) {
141
141
  seprater = seprater ? seprater : '-';
142
142
  const mydate = strVal;
143
- return mydate?.getFullYear() + seprater + ((mydate ? mydate.getMonth() : 0) + 1) + seprater + mydate?.getDate();
143
+ return (mydate?.getFullYear() +
144
+ seprater +
145
+ ((mydate ? mydate.getMonth() : 0) + 1) +
146
+ seprater +
147
+ mydate?.getDate());
148
+ }
149
+ getData(path) {
150
+ const url = this.http.get(`${this.analyticsRESTURL}${this.config.repository}/${path}`);
151
+ return url;
152
+ }
153
+ postdata(path, data) {
154
+ return this.http.post(`${this.analyticsRESTURL}${this.config.repository}/${path}`, data);
155
+ }
156
+ postDataWithRestUrl(path, data) {
157
+ return this.http.post(`${this.RESTURLPrefix}${path}`, data);
144
158
  }
145
- getData(path) { return this.http.get(`${this.analyticsRESTURL}${this.config.repository}/${path}`); }
146
- postdata(path, data) { return this.http.post(`${this.analyticsRESTURL}${this.config.repository}/${path}`, data); }
147
- postDataWithRestUrl(path, data) { return this.http.post(`${this.RESTURLPrefix}${path}`, data); }
148
159
  fetchAutoCompleteLocations(keyword) {
149
160
  return this.http.get(`https://api.mapbox.com/geocoding/v5/mapbox.places/${keyword}.json?access_token=${this.config.mapboxAccessToken}&country=US`);
150
161
  }
151
162
  openSnackBar(message, className) {
152
163
  this.snackBar.open(message, '', {
153
- duration: 5000, verticalPosition: 'top', horizontalPosition: 'center', panelClass: [className ? className : 'default']
164
+ duration: 5000,
165
+ verticalPosition: 'top',
166
+ horizontalPosition: 'center',
167
+ panelClass: [className ? className : 'default'],
154
168
  });
155
169
  }
156
170
  makeOptions(item) {
157
171
  if (item.order_number) {
158
- (this.jcodeOptions.findIndex((elem) => elem.job_id === item.job_id) === -1) ? this.jcodeOptions.push({ job_code: item.order_number, job_id: item.job_id }) : null;
172
+ this.jcodeOptions.findIndex((elem) => elem.job_id === item.job_id) === -1
173
+ ? this.jcodeOptions.push({
174
+ job_code: item.order_number,
175
+ job_id: item.job_id,
176
+ })
177
+ : null;
159
178
  if (item.driver_list && item.driver_list?.length > 0) {
160
179
  item.driver_list.forEach((driver) => {
161
- this.driverOption.findIndex(elem => elem === driver['driver_name']) === -1 ? this.driverOption.push(driver['driver_name']) : null;
162
- this.truckingCompanayOption.findIndex(elem => elem === driver['trucking_company']) === -1 ? this.truckingCompanayOption.push(driver['trucking_company']) : null;
180
+ this.driverOption.findIndex((elem) => elem === driver['driver_name']) === -1
181
+ ? this.driverOption.push(driver['driver_name'])
182
+ : null;
183
+ this.truckingCompanayOption.findIndex((elem) => elem === driver['trucking_company']) === -1
184
+ ? this.truckingCompanayOption.push(driver['trucking_company'])
185
+ : null;
163
186
  });
164
187
  }
165
188
  }
166
- ((this.pickupOptions.findIndex((elem) => elem === item.pickup_location)) === -1) ? this.pickupOptions.push(item.pickup_location) : null;
167
- ((this.destOptions.findIndex((elem) => elem === item.delivery_location)) === -1) ? this.destOptions.push(item.delivery_location) : null;
168
- (this.customerOptions.findIndex((customer) => customer === item.customer_name) === -1) ? this.customerOptions.push(item.customer_name) : null;
169
- (this.unitOptions.findIndex((elem) => elem === item.unit) === -1) ? this.unitOptions.push(item.unit) : null;
170
- (this.materialOptions.findIndex((elem) => elem === item.material) === -1) ? this.materialOptions.push(item.material) : null;
189
+ this.pickupOptions.findIndex((elem) => elem === item.pickup_location) === -1
190
+ ? this.pickupOptions.push(item.pickup_location)
191
+ : null;
192
+ this.destOptions.findIndex((elem) => elem === item.delivery_location) === -1
193
+ ? this.destOptions.push(item.delivery_location)
194
+ : null;
195
+ this.customerOptions.findIndex((customer) => customer === item.customer_name) === -1
196
+ ? this.customerOptions.push(item.customer_name)
197
+ : null;
198
+ this.unitOptions.findIndex((elem) => elem === item.unit) === -1
199
+ ? this.unitOptions.push(item.unit)
200
+ : null;
201
+ this.materialOptions.findIndex((elem) => elem === item.material) === -1
202
+ ? this.materialOptions.push(item.material)
203
+ : null;
171
204
  if (item.route_name)
172
- this.routeNameOptions.findIndex(elem => elem === item.route_name) === -1 ? this.routeNameOptions.push(item.route_name) : null;
205
+ this.routeNameOptions.findIndex((elem) => elem === item.route_name) === -1
206
+ ? this.routeNameOptions.push(item.route_name)
207
+ : null;
173
208
  }
174
209
  filter(value, filters) {
175
210
  if (typeof value !== 'string') {
@@ -180,49 +215,65 @@ class UtilsService {
180
215
  return [];
181
216
  }
182
217
  const searchResults = [];
183
- this.unitOptions.map(unit => {
218
+ this.unitOptions.map((unit) => {
184
219
  if (unit.toLowerCase().includes(filterValue)) {
185
- searchResults.push({ "type": "unit", "label": unit, "value": unit });
220
+ searchResults.push({ type: 'unit', label: unit, value: unit });
186
221
  }
187
222
  });
188
- this.customerOptions.map(unit => {
223
+ this.customerOptions.map((unit) => {
189
224
  if (unit.toLowerCase().includes(filterValue)) {
190
- searchResults.push({ "type": "customer", "label": unit, "value": unit });
225
+ searchResults.push({ type: 'customer', label: unit, value: unit });
191
226
  }
192
227
  });
193
- this.materialOptions.map(unit => {
228
+ this.materialOptions.map((unit) => {
194
229
  if (unit.toLowerCase().includes(filterValue)) {
195
- searchResults.push({ "type": "material", "label": unit, "value": unit });
230
+ searchResults.push({ type: 'material', label: unit, value: unit });
196
231
  }
197
232
  });
198
- this.pickupOptions.map(unit => {
233
+ this.pickupOptions.map((unit) => {
199
234
  if (unit.toLowerCase().includes(filterValue)) {
200
- searchResults.push({ "type": "pickup location", "label": unit, "value": unit });
235
+ searchResults.push({
236
+ type: 'pickup location',
237
+ label: unit,
238
+ value: unit,
239
+ });
201
240
  }
202
241
  });
203
- this.destOptions.map(unit => {
242
+ this.destOptions.map((unit) => {
204
243
  if (unit.toLowerCase().includes(filterValue)) {
205
- searchResults.push({ "type": "destination location", "label": unit, "value": unit });
244
+ searchResults.push({
245
+ type: 'destination location',
246
+ label: unit,
247
+ value: unit,
248
+ });
206
249
  }
207
250
  });
208
- this.jcodeOptions.map(unit => {
251
+ this.jcodeOptions.map((unit) => {
209
252
  if (unit.job_code.toLowerCase().includes(filterValue)) {
210
- searchResults.push({ "type": "job", "label": unit['job_code'], "value": unit });
253
+ searchResults.push({
254
+ type: 'job',
255
+ label: unit['job_code'],
256
+ value: unit,
257
+ });
211
258
  }
212
259
  });
213
- this.driverOption.map(unit => {
260
+ this.driverOption.map((unit) => {
214
261
  if (unit.toLowerCase().includes(filterValue)) {
215
- searchResults.push({ "type": "Driver", "label": unit, "value": unit });
262
+ searchResults.push({ type: 'Driver', label: unit, value: unit });
216
263
  }
217
264
  });
218
- this.truckingCompanayOption.map(unit => {
265
+ this.truckingCompanayOption.map((unit) => {
219
266
  if (unit.toLowerCase().includes(filterValue)) {
220
- searchResults.push({ "type": "Trucking Company", "label": unit, "value": unit });
267
+ searchResults.push({
268
+ type: 'Trucking Company',
269
+ label: unit,
270
+ value: unit,
271
+ });
221
272
  }
222
273
  });
223
- this.routeNameOptions.map(unit => {
274
+ this.routeNameOptions.map((unit) => {
224
275
  if (unit.toLowerCase().includes(filterValue)) {
225
- searchResults.push({ "type": "Route name", "label": unit, "value": unit });
276
+ searchResults.push({ type: 'Route name', label: unit, value: unit });
226
277
  }
227
278
  });
228
279
  const searchDict = {};
@@ -230,8 +281,9 @@ class UtilsService {
230
281
  searchDict[filter['name'] + filter['type']] = filter;
231
282
  });
232
283
  const furtherFilter = [];
233
- searchResults.map(search => {
234
- if ((search['label'] + search['type']) in searchDict) { }
284
+ searchResults.map((search) => {
285
+ if (search['label'] + search['type'] in searchDict) {
286
+ }
235
287
  else {
236
288
  furtherFilter.push(search);
237
289
  }
@@ -239,17 +291,19 @@ class UtilsService {
239
291
  return furtherFilter;
240
292
  }
241
293
  getSearchResults(list, filterval) {
242
- return list.filter(element => {
294
+ return list.filter((element) => {
243
295
  const result_list_boolean = [];
244
296
  if (filterval.length > 0) {
245
297
  if (filterval[0]['type'] === 'unit') {
246
- result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type']]);
298
+ result_list_boolean.push(filterval[0]['name'] ===
299
+ element[filterval[0]['type']]);
247
300
  }
248
301
  if (filterval[0]['type'] === 'customer') {
249
302
  result_list_boolean.push(filterval[0]['name'] === element['customer_name']);
250
303
  }
251
304
  if (filterval[0]['type'] === 'material') {
252
- result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type']]);
305
+ result_list_boolean.push(filterval[0]['name'] ===
306
+ element[filterval[0]['type']]);
253
307
  }
254
308
  if (filterval[0]['type'] === 'pickup location') {
255
309
  result_list_boolean.push(filterval[0]['name'] === element['pickup_location']);
@@ -264,12 +318,16 @@ class UtilsService {
264
318
  result_list_boolean.push(filterval[0]['name'] === element['route_name']);
265
319
  }
266
320
  if (filterval[0]['type'] === 'Driver') {
267
- const index = element.driver_list?.findIndex(ele => { return filterval[0]['name'] === ele['driver_name']; });
321
+ const index = element.driver_list?.findIndex((ele) => {
322
+ return filterval[0]['name'] === ele['driver_name'];
323
+ });
268
324
  if (index !== -1)
269
325
  result_list_boolean.push(true);
270
326
  }
271
327
  if (filterval[0]['type'] === 'Trucking Company') {
272
- const index = element.driver_list?.findIndex(ele => { return filterval[0]['name'] === ele['trucking_company']; });
328
+ const index = element.driver_list?.findIndex((ele) => {
329
+ return filterval[0]['name'] === ele['trucking_company'];
330
+ });
273
331
  if (index !== -1)
274
332
  result_list_boolean.push(true);
275
333
  }
@@ -300,7 +358,7 @@ class UtilsService {
300
358
  this.dict.delete(key);
301
359
  }
302
360
  conveySearchIcon(value) {
303
- if (value && typeof (value) !== 'object')
361
+ if (value && typeof value !== 'object')
304
362
  return true;
305
363
  return false;
306
364
  }
@@ -322,11 +380,11 @@ class UtilsService {
322
380
  fetchMaterialsList() {
323
381
  return new Promise((resolve, reject) => {
324
382
  if (!this.materialsList) {
325
- this.getData('material/list/view').subscribe(((res) => {
383
+ this.getData('material/list/view').subscribe((res) => {
326
384
  res.data.sort((a, b) => a.material.localeCompare(b.material));
327
385
  this.materialsList = res.data;
328
386
  resolve(this.materialsList);
329
- }));
387
+ });
330
388
  }
331
389
  else {
332
390
  resolve(this.materialsList);
@@ -336,7 +394,7 @@ class UtilsService {
336
394
  fetchMaterialsListForCustomer() {
337
395
  return new Promise((resolve, reject) => {
338
396
  if (!this.materialsListForCustomer) {
339
- this.getData('material/list/view').subscribe(((res) => {
397
+ this.getData('material/list/view').subscribe((res) => {
340
398
  let meterialListDetails = [];
341
399
  res.data.map((item) => {
342
400
  if (item.sub.length > 0) {
@@ -353,7 +411,7 @@ class UtilsService {
353
411
  meterialListDetails.sort((a, b) => a.label.localeCompare(b.label));
354
412
  this.materialsListForCustomer = meterialListDetails;
355
413
  resolve(this.materialsListForCustomer);
356
- }));
414
+ });
357
415
  }
358
416
  else {
359
417
  resolve(this.materialsListForCustomer);
@@ -375,10 +433,10 @@ class UtilsService {
375
433
  }
376
434
  });
377
435
  }
378
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: UtilsService, deps: [{ token: i1.HttpClient }, { token: i2.MatSnackBar }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
379
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: UtilsService, providedIn: 'root' });
436
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: UtilsService, deps: [{ token: i1.HttpClient }, { token: i2.MatSnackBar }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
437
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: UtilsService, providedIn: 'root' });
380
438
  }
381
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: UtilsService, decorators: [{
439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: UtilsService, decorators: [{
382
440
  type: Injectable,
383
441
  args: [{ providedIn: 'root' }]
384
442
  }], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.MatSnackBar }, { type: CoolmapConfigModel, decorators: [{
@@ -418,7 +476,10 @@ class CoolmapService {
418
476
  container: el,
419
477
  style: this.config.mapboxStyle,
420
478
  center: [-77.036873, 38.907192],
421
- zoom: 10, bearing: 0, pitch: 65, interactive: true,
479
+ zoom: 10,
480
+ bearing: 0,
481
+ pitch: 65,
482
+ interactive: true,
422
483
  });
423
484
  this.map.once('load', (res) => {
424
485
  resolve(res);
@@ -429,14 +490,18 @@ class CoolmapService {
429
490
  loadMapProperty(pinRouteGeojson, index, unit, route, bottom) {
430
491
  return new Promise((resolve, reject) => {
431
492
  let origin = pinRouteGeojson.features[0].geometry.coordinates[0];
432
- const linecolor = (unit === 'Ton') ? '#ff7272' : (unit === 'Load') ? '#a3c52e' : '#ae23d1';
493
+ const linecolor = unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1';
433
494
  let destination = pinRouteGeojson.features[0].geometry.coordinates[pinRouteGeojson.features[0].geometry.coordinates.length - 1];
434
495
  this.extendBound(pinRouteGeojson.features[0].geometry.coordinates, true).then((res) => {
435
496
  const point = {
436
- 'type': 'FeatureCollection',
437
- 'features': [
438
- { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'Point', 'coordinates': origin } }
439
- ]
497
+ type: 'FeatureCollection',
498
+ features: [
499
+ {
500
+ type: 'Feature',
501
+ properties: {},
502
+ geometry: { type: 'Point', coordinates: origin },
503
+ },
504
+ ],
440
505
  };
441
506
  const lineDistance = turf.length(pinRouteGeojson.features[0]);
442
507
  const arc = [];
@@ -448,11 +513,17 @@ class CoolmapService {
448
513
  pinRouteGeojson.features[0].geometry.coordinates = arc;
449
514
  const pinRoute = pinRouteGeojson.features[0].geometry.coordinates;
450
515
  const marker = new mapboxgl.Marker(document.createElement('div'))
451
- .setLngLat(pinRoute[0]).addTo(this.map).togglePopup();
516
+ .setLngLat(pinRoute[0])
517
+ .addTo(this.map)
518
+ .togglePopup();
452
519
  if (this.map.getSource(`line${index}`)) {
453
520
  this.removeRouteAndMarker(index).then(() => { });
454
521
  }
455
- this.map.addSource(`line${index}`, { type: 'geojson', lineMetrics: true, data: pinRouteGeojson });
522
+ this.map.addSource(`line${index}`, {
523
+ type: 'geojson',
524
+ lineMetrics: true,
525
+ data: pinRouteGeojson,
526
+ });
456
527
  this.map.addLayer({
457
528
  type: 'line',
458
529
  source: `line${index}`,
@@ -463,18 +534,38 @@ class CoolmapService {
463
534
  'interpolate',
464
535
  ['linear'],
465
536
  ['line-progress'],
466
- 0, unit === 'Ton' ? '#d7f7e4' : unit === 'Load' ? '#c9d8f5' : '#f5dcc1',
467
- 1, unit === 'Ton' ? '#ff7272' : unit === 'Load' ? '#a3c52e' : '#ae23d1',
468
- ]
537
+ 0,
538
+ unit === 'Ton'
539
+ ? '#d7f7e4'
540
+ : unit === 'Load'
541
+ ? '#c9d8f5'
542
+ : '#f5dcc1',
543
+ 1,
544
+ unit === 'Ton'
545
+ ? '#ff7272'
546
+ : unit === 'Load'
547
+ ? '#a3c52e'
548
+ : '#ae23d1',
549
+ ],
469
550
  },
470
- layout: { 'line-cap': 'round', 'line-join': 'round' }
551
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
471
552
  });
472
553
  const dataSetForMap = {
473
- counter: 0, pinRouteGeojson, steps,
474
- point, pointId: `point${index}`,
475
- marker, pinRoute, lineId: `line${index}`, index,
476
- origin, destination, lineDistance,
477
- linecolor, route, isViewRoute: true
554
+ counter: 0,
555
+ pinRouteGeojson,
556
+ steps,
557
+ point,
558
+ pointId: `point${index}`,
559
+ marker,
560
+ pinRoute,
561
+ lineId: `line${index}`,
562
+ index,
563
+ origin,
564
+ destination,
565
+ lineDistance,
566
+ linecolor,
567
+ route,
568
+ isViewRoute: true,
478
569
  };
479
570
  this.createMarker(dataSetForMap);
480
571
  this.map.on('mouseenter', `line${index}`, (e) => {
@@ -485,9 +576,13 @@ class CoolmapService {
485
576
  pickup: route.pickup_location ? route.pickup_location : '',
486
577
  drop: route.delivery_location ? route.delivery_location : '',
487
578
  routeType: route.project ? 'Project' : 'Route',
488
- title: route.project ? route.project : route.route_name ? route.route_name : '',
579
+ title: route.project
580
+ ? route.project
581
+ : route.route_name
582
+ ? route.route_name
583
+ : '',
489
584
  material: route.materialLabel ? route.materialLabel : '',
490
- type: route.unit ? route.unit : ''
585
+ type: route.unit ? route.unit : '',
491
586
  };
492
587
  this.createPopup(datasetForPopup);
493
588
  });
@@ -508,12 +603,20 @@ class CoolmapService {
508
603
  let linecolor;
509
604
  let origin = cordinates[0];
510
605
  let destination = cordinates[cordinates.length - 1];
511
- if (origin[0] && origin[1] && destination && destination[0] && destination[1]) {
606
+ if (origin[0] &&
607
+ origin[1] &&
608
+ destination &&
609
+ destination[0] &&
610
+ destination[1]) {
512
611
  linecolor = this.provideLineColor(route['unit'], routeType);
513
612
  if (enablefitbound) {
514
613
  const padding = {
515
- top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65)),
516
- left: this.padding.left, right: this.padding.right
614
+ top: this.padding.top + this.customTopForCustomer,
615
+ bottom: this.padding.bottom +
616
+ (this.windowActualHeightWidth.availHeight -
617
+ (window.innerHeight - 65)),
618
+ left: this.padding.left,
619
+ right: this.padding.right,
517
620
  };
518
621
  this.map.fitBounds([origin, destination], { padding, pitch: 65 }, { fitboundCompleteJob: true });
519
622
  }
@@ -521,16 +624,26 @@ class CoolmapService {
521
624
  this.removeRouteAndMarker(index).then(() => { });
522
625
  }
523
626
  this.map.addSource(`route-source-for-job-code${index}`, {
524
- 'type': 'geojson',
525
- 'data': { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'LineString', 'coordinates': cordinates } }
627
+ type: 'geojson',
628
+ data: {
629
+ type: 'Feature',
630
+ properties: {},
631
+ geometry: { type: 'LineString', coordinates: cordinates },
632
+ },
526
633
  });
527
634
  this.map.addLayer({
528
- 'id': `route-for-job-code${index}`, 'type': 'line', 'source': `route-source-for-job-code${index}`,
635
+ id: `route-for-job-code${index}`,
636
+ type: 'line',
637
+ source: `route-source-for-job-code${index}`,
529
638
  paint: { 'line-color': linecolor, 'line-width': 2 },
530
- layout: { 'line-cap': 'round', 'line-join': 'round' }
639
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
531
640
  });
532
641
  const dataSetForMap = {
533
- origin, destination, index, linecolor, route
642
+ origin,
643
+ destination,
644
+ index,
645
+ linecolor,
646
+ route,
534
647
  };
535
648
  this.createMarker(dataSetForMap);
536
649
  this.map.on('mouseenter', `route-for-job-code${index}`, (e) => {
@@ -546,9 +659,13 @@ class CoolmapService {
546
659
  jobCode: route.project ? route.order_number : null,
547
660
  customer: route.project ? route.customer_name : null,
548
661
  routeType: route.project ? 'Project' : 'Route',
549
- title: route.project ? route.project : route.route_name ? route.route_name : '',
662
+ title: route.project
663
+ ? route.project
664
+ : route.route_name
665
+ ? route.route_name
666
+ : '',
550
667
  material: route.materialLabel ? route.materialLabel : '',
551
- type: route.unit ? route.unit : ''
668
+ type: route.unit ? route.unit : '',
552
669
  };
553
670
  this.createPopup(datasetForPopup);
554
671
  });
@@ -561,16 +678,16 @@ class CoolmapService {
561
678
  }
562
679
  }
563
680
  provideLineColor(unitType, type) {
564
- let checkType = (type && !['jobrouteList', 'addroute'].includes(type)) ? true : false;
681
+ let checkType = type && !['jobrouteList', 'addroute'].includes(type) ? true : false;
565
682
  let color;
566
683
  switch (unitType) {
567
- case "Ton":
684
+ case 'Ton':
568
685
  color = checkType ? '#39c471' : '#ff7272';
569
686
  break;
570
- case "Load":
687
+ case 'Load':
571
688
  color = checkType ? '#326ad3' : '#a3c52e';
572
689
  break;
573
- case "Hourly":
690
+ case 'Hourly':
574
691
  color = checkType ? '#ffad56' : '#ae23d1';
575
692
  break;
576
693
  }
@@ -581,19 +698,38 @@ class CoolmapService {
581
698
  this.popup.remove();
582
699
  this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 2);
583
700
  }
584
- if (arcDetails.color && this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
701
+ if (arcDetails.color &&
702
+ this.map.getLayoutProperty(arcDetails.layer.id, 'visibility') !== 'none') {
585
703
  this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-width', 5);
586
704
  this.map.setPaintProperty(`${isViewRoute ? 'line' : 'route-for-job-code'}${arcDetails.layer.props.data.index}`, 'line-opacity', 1);
587
705
  const datasetForPopup = {
588
706
  coordinate: arcDetails.coordinate,
589
- pickup: arcDetails.layer.props.data.route.pickup_location ? arcDetails.layer.props.data.route.pickup_location : '',
590
- drop: arcDetails.layer.props.data.route.delivery_location ? arcDetails.layer.props.data.route.delivery_location : '',
591
- jobCode: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.order_number : '',
592
- customer: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.customer_name : '',
593
- routeType: arcDetails.layer.props.data.route.project ? 'Project' : 'Route',
594
- title: arcDetails.layer.props.data.route.project ? arcDetails.layer.props.data.route.project : arcDetails.layer.props.data.route.route_name ? arcDetails.layer.props.data.route.route_name : '',
595
- material: arcDetails.layer.props.data.route.materialLabel ? arcDetails.layer.props.data.route.materialLabel : '',
596
- type: arcDetails.layer.props.data.route.unit ? arcDetails.layer.props.data.route.unit : ''
707
+ pickup: arcDetails.layer.props.data.route.pickup_location
708
+ ? arcDetails.layer.props.data.route.pickup_location
709
+ : '',
710
+ drop: arcDetails.layer.props.data.route.delivery_location
711
+ ? arcDetails.layer.props.data.route.delivery_location
712
+ : '',
713
+ jobCode: arcDetails.layer.props.data.route.project
714
+ ? arcDetails.layer.props.data.route.order_number
715
+ : '',
716
+ customer: arcDetails.layer.props.data.route.project
717
+ ? arcDetails.layer.props.data.route.customer_name
718
+ : '',
719
+ routeType: arcDetails.layer.props.data.route.project
720
+ ? 'Project'
721
+ : 'Route',
722
+ title: arcDetails.layer.props.data.route.project
723
+ ? arcDetails.layer.props.data.route.project
724
+ : arcDetails.layer.props.data.route.route_name
725
+ ? arcDetails.layer.props.data.route.route_name
726
+ : '',
727
+ material: arcDetails.layer.props.data.route.materialLabel
728
+ ? arcDetails.layer.props.data.route.materialLabel
729
+ : '',
730
+ type: arcDetails.layer.props.data.route.unit
731
+ ? arcDetails.layer.props.data.route.unit
732
+ : '',
597
733
  };
598
734
  this.createPopup(datasetForPopup);
599
735
  }
@@ -603,17 +739,22 @@ class CoolmapService {
603
739
  closeButton: false,
604
740
  closeOnClick: false,
605
741
  closeOnMove: true,
606
- anchor: 'bottom-left'
742
+ anchor: 'bottom-left',
607
743
  });
608
- this.popup.setLngLat(datasetForPopup.coordinate)
744
+ this.popup
745
+ .setLngLat(datasetForPopup.coordinate)
609
746
  .setHTML(`
610
747
  <div class="destination">
611
748
  <div class="duration">
612
749
  <p class="pickprt"><b>Pickup Location:</b> ${datasetForPopup.pickup}</p>
613
750
  <p class="dropprt"><b>Drop Location:</b> ${datasetForPopup.drop}</p>
614
751
  </div>
615
- ${datasetForPopup.jobCode ? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>' : ''}
616
- ${datasetForPopup.customer ? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>' : ''}
752
+ ${datasetForPopup.jobCode
753
+ ? '<span><b>Job Code:</b> ' + datasetForPopup.jobCode + '</span>'
754
+ : ''}
755
+ ${datasetForPopup.customer
756
+ ? '<span><b>Customer:</b> ' + datasetForPopup.customer + '</span>'
757
+ : ''}
617
758
  <span><b>${datasetForPopup.routeType} Name:</b> ${datasetForPopup.title}</span>
618
759
  <span><b>Material:</b> ${datasetForPopup.material}</span>
619
760
  <span><b>Type:</b> ${datasetForPopup.type}</span>
@@ -622,28 +763,47 @@ class CoolmapService {
622
763
  .addTo(this.map);
623
764
  }
624
765
  hexToRGB(hex) {
625
- return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
626
- .substring(1).match(/.{2}/g)
627
- .map(x => parseInt(x, 16));
766
+ return hex
767
+ .replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => '#' + r + r + g + g + b + b)
768
+ .substring(1)
769
+ .match(/.{2}/g)
770
+ .map((x) => parseInt(x, 16));
628
771
  }
629
772
  createMarker(routeDetails) {
630
- if (routeDetails.origin[0] && routeDetails.origin[1] && routeDetails.destination[0] && routeDetails.destination[1]) {
773
+ if (routeDetails.origin[0] &&
774
+ routeDetails.origin[1] &&
775
+ routeDetails.destination[0] &&
776
+ routeDetails.destination[1]) {
631
777
  const popup = new mapboxgl.Popup({ closeButton: false }).setHTML('<b>Pickup: </b>' + routeDetails.route?.pickup_location);
632
- const popupForDestination = new mapboxgl.Popup({ closeButton: false })
633
- .setHTML('<b>Delivery: </b>' + routeDetails.route?.delivery_location);
778
+ const popupForDestination = new mapboxgl.Popup({
779
+ closeButton: false,
780
+ }).setHTML('<b>Delivery: </b>' + routeDetails.route?.delivery_location);
634
781
  const el = document.createElement('div');
635
782
  el.className = 'marker';
636
783
  el.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>P</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
637
784
  const originMarker = new mapboxgl.Marker(el)
638
- .setPopup(popup).setLngLat(routeDetails.origin).addTo(this.map);
639
- originMarker.getElement().addEventListener('mouseenter', () => originMarker.togglePopup());
640
- originMarker.getElement().addEventListener('mouseleave', () => originMarker.togglePopup());
785
+ .setPopup(popup)
786
+ .setLngLat(routeDetails.origin)
787
+ .addTo(this.map);
788
+ originMarker
789
+ .getElement()
790
+ .addEventListener('mouseenter', () => originMarker.togglePopup());
791
+ originMarker
792
+ .getElement()
793
+ .addEventListener('mouseleave', () => originMarker.togglePopup());
641
794
  const elementForDestination = document.createElement('div');
642
795
  elementForDestination.className = 'marker';
643
796
  elementForDestination.innerHTML = `<span class='markerPointer' style='background:${routeDetails.linecolor}'><b>D</b><span class='markerSpan' style='border-top: 10px solid ${routeDetails.linecolor}'></span></span>`;
644
- const destinationMarker = new mapboxgl.Marker(elementForDestination).setPopup(popupForDestination).setLngLat(routeDetails.destination).addTo(this.map);
645
- destinationMarker.getElement().addEventListener('mouseenter', () => destinationMarker.togglePopup());
646
- destinationMarker.getElement().addEventListener('mouseleave', () => destinationMarker.togglePopup());
797
+ const destinationMarker = new mapboxgl.Marker(elementForDestination)
798
+ .setPopup(popupForDestination)
799
+ .setLngLat(routeDetails.destination)
800
+ .addTo(this.map);
801
+ destinationMarker
802
+ .getElement()
803
+ .addEventListener('mouseenter', () => destinationMarker.togglePopup());
804
+ destinationMarker
805
+ .getElement()
806
+ .addEventListener('mouseleave', () => destinationMarker.togglePopup());
647
807
  this.markerOriginList[routeDetails.index] = originMarker;
648
808
  this.markerDestinationList[routeDetails.index] = destinationMarker;
649
809
  const colorArray = this.hexToRGB(routeDetails.linecolor);
@@ -664,20 +824,37 @@ class CoolmapService {
664
824
  }
665
825
  async removeRouteAndMarker(index) {
666
826
  if (this.map) {
667
- this.map.getLayer(`arc-layer${index}`) ? this.map.removeLayer(`arc-layer${index}`) : '';
668
- this.map.getLayer(`line${index}`) ? this.map.removeLayer(`line${index}`) : '';
669
- this.map.getLayer(`custom_layer${index}`) ? this.map.removeLayer(`custom_layer${index}`) : '';
670
- this.map.getSource(`line${index}`) ? this.map.removeSource(`line${index}`) : '';
671
- this.map.getLayer(`route-for-job-code${index}`) ? this.map.removeLayer(`route-for-job-code${index}`) : '';
672
- this.map.getSource(`route-source-for-job-code${index}`) ? this.map.removeSource(`route-source-for-job-code${index}`) : '';
827
+ this.map.getLayer(`arc-layer${index}`)
828
+ ? this.map.removeLayer(`arc-layer${index}`)
829
+ : '';
830
+ this.map.getLayer(`line${index}`)
831
+ ? this.map.removeLayer(`line${index}`)
832
+ : '';
833
+ this.map.getLayer(`custom_layer${index}`)
834
+ ? this.map.removeLayer(`custom_layer${index}`)
835
+ : '';
836
+ this.map.getSource(`line${index}`)
837
+ ? this.map.removeSource(`line${index}`)
838
+ : '';
839
+ this.map.getLayer(`route-for-job-code${index}`)
840
+ ? this.map.removeLayer(`route-for-job-code${index}`)
841
+ : '';
842
+ this.map.getSource(`route-source-for-job-code${index}`)
843
+ ? this.map.removeSource(`route-source-for-job-code${index}`)
844
+ : '';
673
845
  this.findMarkerBound(index);
674
846
  this.markerOriginList[index] ? this.markerOriginList[index].remove() : '';
675
- this.markerDestinationList[index] ? this.markerDestinationList[index].remove() : '';
847
+ this.markerDestinationList[index]
848
+ ? this.markerDestinationList[index].remove()
849
+ : '';
676
850
  await true;
677
851
  }
678
852
  }
679
853
  findMarkerBound(index) {
680
- const indexOfCordinates = this.originDestinationCordinates.findIndex((x) => (x[0][0].toFixed(6) == this.markerOriginList[index]?.getLngLat()?.lng.toFixed(6)) && (x[0][1].toFixed(6) == this.markerOriginList[index]?.getLngLat()?.lat.toFixed(6)));
854
+ const indexOfCordinates = this.originDestinationCordinates.findIndex((x) => x[0][0].toFixed(6) ==
855
+ this.markerOriginList[index]?.getLngLat()?.lng.toFixed(6) &&
856
+ x[0][1].toFixed(6) ==
857
+ this.markerOriginList[index]?.getLngLat()?.lat.toFixed(6));
681
858
  if (indexOfCordinates >= 0) {
682
859
  this.originDestinationCordinates.splice(indexOfCordinates, 1);
683
860
  }
@@ -687,9 +864,10 @@ class CoolmapService {
687
864
  if (this.map.getLayer(`route-for-job-code${ID}`)) {
688
865
  this.map.setLayoutProperty(`route-for-job-code${ID}`, 'visibility', visibility);
689
866
  const originM = this.markerOriginList[ID].getElement();
690
- originM.style.display = ((visibility === 'visible') ? 'block' : visibility);
867
+ originM.style.display = visibility === 'visible' ? 'block' : visibility;
691
868
  const destinationM = this.markerDestinationList[ID].getElement();
692
- destinationM.style.display = ((visibility === 'visible') ? 'block' : visibility);
869
+ destinationM.style.display =
870
+ visibility === 'visible' ? 'block' : visibility;
693
871
  if (visibility === 'none' && showAllFitbound) {
694
872
  this.findMarkerBound(ID);
695
873
  this.extendReBound();
@@ -706,12 +884,19 @@ class CoolmapService {
706
884
  if (route) {
707
885
  if (typeof route === 'string') {
708
886
  let path = route.split(';');
709
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
710
- path.forEach((ele, index) => { if (ele.length === 1)
711
- path.splice(index, 1); });
887
+ path = path.map((ele) => {
888
+ return (ele = this.formateLatLong(ele));
889
+ });
890
+ path.forEach((ele, index) => {
891
+ if (ele.length === 1)
892
+ path.splice(index, 1);
893
+ });
712
894
  route = path;
713
895
  }
714
- if (route[0][0] && route[0][1] && route[route.length - 1][0] && route[route.length - 1][1]) {
896
+ if (route[0][0] &&
897
+ route[0][1] &&
898
+ route[route.length - 1][0] &&
899
+ route[route.length - 1][1]) {
715
900
  this.originDestinationCordinates.push(route);
716
901
  route.map((item) => {
717
902
  this.bounds.extend(item);
@@ -719,14 +904,15 @@ class CoolmapService {
719
904
  }
720
905
  }
721
906
  if (showAllFitbound) {
722
- const padding = { top: this.padding.top + this.customTopForCustomer, bottom: (this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65))), left: this.padding.left, right: this.padding.right };
723
907
  setTimeout(() => {
724
- if (showAllFitbound && (Object.keys(this.bounds).length > 0))
725
- this.map.fitBounds(this.bounds, { padding, pitch: 65 }, { fitboundComplete: true });
908
+ if (showAllFitbound && Object.keys(this.bounds).length > 0)
909
+ this.map.fitBounds(this.bounds, { pitch: 65 }, { fitboundComplete: true });
726
910
  }, 100);
727
- this.map.once('moveend', (event) => { if (event.fitboundComplete) {
728
- resolve(true);
729
- } });
911
+ this.map.once('moveend', (event) => {
912
+ if (event.fitboundComplete) {
913
+ resolve(true);
914
+ }
915
+ });
730
916
  }
731
917
  });
732
918
  }
@@ -738,8 +924,15 @@ class CoolmapService {
738
924
  item.map((route) => {
739
925
  this.bounds.extend(route);
740
926
  });
741
- if (index === (this.originDestinationCordinates.length - 1)) {
742
- const padding = { top: this.padding.top + this.customTopForCustomer, bottom: (this.padding.bottom + (this.windowActualHeightWidth.availHeight - (window.innerHeight - 65))), left: this.padding.left, right: this.padding.right };
927
+ if (index === this.originDestinationCordinates.length - 1) {
928
+ const padding = {
929
+ top: this.padding.top + this.customTopForCustomer,
930
+ bottom: this.padding.bottom +
931
+ (this.windowActualHeightWidth.availHeight -
932
+ (window.innerHeight - 65)),
933
+ left: this.padding.left,
934
+ right: this.padding.right,
935
+ };
743
936
  setTimeout(() => {
744
937
  if (this.originDestinationCordinates.length > 0)
745
938
  this.map.fitBounds(this.bounds, { padding, pitch: 65 });
@@ -761,9 +954,13 @@ class CoolmapService {
761
954
  this.utils.postDataWithRestUrl('schedule/job/path', param).subscribe((res) => {
762
955
  if (res['data']['route']) {
763
956
  let path = res['data']['route'].split(';');
764
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
765
- path.forEach((ele, index) => { if (ele.length === 1)
766
- path.splice(index, 1); });
957
+ path = path.map((ele) => {
958
+ return (ele = this.formateLatLong(ele));
959
+ });
960
+ path.forEach((ele, index) => {
961
+ if (ele.length === 1)
962
+ path.splice(index, 1);
963
+ });
767
964
  route['path'] = path;
768
965
  this.extendBound(route['path'], showAllFitbound);
769
966
  if (route['path'] && route['path'].length > 0)
@@ -774,55 +971,88 @@ class CoolmapService {
774
971
  this.extendBound(null, showAllFitbound);
775
972
  }
776
973
  resolve(true);
777
- }, (err) => { if (err) {
778
- reject(false);
779
- } });
974
+ }, (err) => {
975
+ if (err) {
976
+ reject(false);
977
+ }
978
+ });
780
979
  }
781
980
  else if (['jobrouteList', 'addroute'].includes(type)) {
782
981
  if (route['path'] && route['path'].length > 0) {
783
982
  let path = route['path'].split(';');
784
- path = path.map((ele) => { return ele = this.formateLatLong(ele); });
785
- path.forEach((ele, index) => { if (ele.length === 1)
786
- path.splice(index, 1); });
983
+ path = path.map((ele) => {
984
+ return (ele = this.formateLatLong(ele));
985
+ });
986
+ path.forEach((ele, index) => {
987
+ if (ele.length === 1)
988
+ path.splice(index, 1);
989
+ });
787
990
  this.extendBound(path, showAllFitbound);
788
991
  this.drawLine(path, i, route, enablefitbound, type);
789
992
  }
790
- ;
791
993
  }
792
994
  });
793
995
  }
794
- clearBound() { this.bounds = new mapboxgl.LngLatBounds(); this.originDestinationCordinates = []; this.clearPadding(); }
795
- formateLatLong(latlong) { return latlong ? latlong.split(',').map(x => +x).reverse() : null; }
996
+ clearBound() {
997
+ this.bounds = new mapboxgl.LngLatBounds();
998
+ this.originDestinationCordinates = [];
999
+ this.clearPadding();
1000
+ }
1001
+ formateLatLong(latlong) {
1002
+ return latlong
1003
+ ? latlong
1004
+ .split(',')
1005
+ .map((x) => +x)
1006
+ .reverse()
1007
+ : null;
1008
+ }
796
1009
  clearBoundWithCordinates() {
797
1010
  this.bounds = new mapboxgl.LngLatBounds();
798
1011
  this.originDestinationCordinates = [];
799
1012
  }
800
1013
  onResize(event) {
801
1014
  if (!this.bounds.isEmpty()) {
802
- this.windowActualHeightWidth.availHeight = (window.innerHeight > window.screen.availHeight) ? window.innerHeight : window.screen.availHeight;
1015
+ this.windowActualHeightWidth.availHeight =
1016
+ window.innerHeight > window.screen.availHeight
1017
+ ? window.innerHeight
1018
+ : window.screen.availHeight;
803
1019
  setTimeout(() => {
804
- this.map.fitBounds(this.bounds, { padding: { top: this.padding.top + this.customTopForCustomer, bottom: this.padding.bottom + (this.windowActualHeightWidth.availHeight - (event.target.innerHeight - 65)), left: this.padding.left, right: this.padding.right }, pitch: 65 });
1020
+ this.map.fitBounds(this.bounds, {
1021
+ padding: {
1022
+ top: this.padding.top + this.customTopForCustomer,
1023
+ bottom: this.padding.bottom +
1024
+ (this.windowActualHeightWidth.availHeight -
1025
+ (event.target.innerHeight - 65)),
1026
+ left: this.padding.left,
1027
+ right: this.padding.right,
1028
+ },
1029
+ pitch: 65,
1030
+ });
805
1031
  }, 500);
806
1032
  }
807
1033
  }
808
1034
  setWindowHeight(screen) {
809
1035
  this.windowActualHeightWidth.availHeight = screen;
810
1036
  }
811
- setPadding(padding) { this.padding = padding; }
812
- clearPadding() { this.padding = null; }
1037
+ setPadding(padding) {
1038
+ this.padding = padding;
1039
+ }
1040
+ clearPadding() {
1041
+ this.padding = null;
1042
+ }
813
1043
  removeJobFromMap(data) {
814
1044
  data.map((ele, index) => {
815
- const id = (ele['job_id'] ? ele['job_id'] : ele['route_id']);
1045
+ const id = ele['job_id'] ? ele['job_id'] : ele['route_id'];
816
1046
  this.removeRouteAndMarker(id);
817
- if (index === (data.length - 1)) {
1047
+ if (index === data.length - 1) {
818
1048
  this.extendReBound();
819
1049
  }
820
1050
  });
821
1051
  }
822
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: CoolmapService, deps: [{ token: UtilsService }, { token: i2$1.EventManager }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
823
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: CoolmapService, providedIn: 'root' });
1052
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: CoolmapService, deps: [{ token: UtilsService }, { token: i2$1.EventManager }, { token: 'memberData' }], target: i0.ɵɵFactoryTarget.Injectable });
1053
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: CoolmapService, providedIn: 'root' });
824
1054
  }
825
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: CoolmapService, decorators: [{
1055
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: CoolmapService, decorators: [{
826
1056
  type: Injectable,
827
1057
  args: [{ providedIn: 'root' }]
828
1058
  }], ctorParameters: () => [{ type: UtilsService }, { type: i2$1.EventManager }, { type: CoolmapConfigModel, decorators: [{