@aggdirect/coolmap-services 1.3.2 → 1.3.4

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