@aggdirect/coolmap-services 0.0.5 → 0.0.7

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.
@@ -1,198 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { Injectable } from '@angular/core';
3
- import { MatSnackBar } from '@angular/material/snack-bar';
4
- import { BehaviorSubject } from 'rxjs';
5
- import { Route } from './data-model';
6
-
7
- @Injectable({ providedIn: 'root' })
8
- export class UtilsService {
9
- analyticsRESTURL = '';
10
- RESTURLPrefix = '';
11
- pickupOptions: any[] = [];
12
- destOptions: any[] = [];
13
- ownerOptions: any[] = [];
14
- customerOptions: any[] = [];
15
- unitOptions: any[] = [];
16
- materialOptions: any[] = [];
17
- jcodeOptions: any[] = [];
18
- driverOption: any[] = [];
19
- truckingCompanayOption: any[] = [];
20
- routeNameOptions: any[] = [];
21
- public preventnavChange = new BehaviorSubject(false);
22
- navChangeObserve = this.preventnavChange.asObservable();
23
- clearViewRouteforJobCode = new BehaviorSubject(false);
24
- clearViewRouteforJobCodeObserve = this.clearViewRouteforJobCode.asObservable();
25
- preVentJobdetailclose = new BehaviorSubject(false);
26
- getpreVentJobdetailclose = this.preVentJobdetailclose.asObservable();
27
- routeDetailsUtility = new BehaviorSubject({});
28
- getrouteDetailsUtility = this.routeDetailsUtility.asObservable();
29
- removeMapEntity = new BehaviorSubject({});
30
- removeMapEntityUtility = this.removeMapEntity.asObservable();
31
- dict = new Map<string, string>();
32
- constructor(private http: HttpClient,private snackBar: MatSnackBar) {
33
- this.analyticsRESTURL = 'https://test-analytics.aggdirect.com/REST/';
34
- this.RESTURLPrefix = 'https://test-server.aggdirect.com/REST/';
35
- }
36
- getDateFormat(strVal: Date | null, seprater?: string) {
37
- seprater = seprater ? seprater : '-';
38
- const mydate = strVal;
39
- return mydate?.getFullYear() + seprater + ((mydate ? mydate.getMonth() : 0) + 1) + seprater + mydate?.getDate();
40
- }
41
- getData(path: string) { return this.http.get(`${this.analyticsRESTURL}${path}`) }
42
- postdata(path: string, data: any) { return this.http.post(`${this.analyticsRESTURL}${path}`, data) }
43
- postDataWithRestUrl(path: string, data: any) { return this.http.post(`${this.RESTURLPrefix}${path}`, data) }
44
- fetchAutoCompleteLocations(keyword: string) {
45
- return this.http.get(`https://api.mapbox.com/geocoding/v5/mapbox.places/${keyword}.json?access_token=pk.eyJ1Ijoic2FudGFudS1vZ21hIiwiYSI6ImNsOGQ0cDVrNjAweTMzb3RmdG9ieTU5ZDkifQ.I6ZS7mViZYSvBo4zz-mGQQ&country=US`)
46
- }
47
- openSnackBar(message: string, className?: string) {
48
- this.snackBar.open(message, '', {
49
- duration: 5000, verticalPosition: 'top', horizontalPosition: 'center', panelClass: [className ? className : 'default']
50
- });
51
- }
52
-
53
- makeOptions(item: Route) {
54
- if (item.order_number) {
55
- (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;
56
- if (item.driver_list && item.driver_list?.length > 0) {
57
- item.driver_list.forEach((driver) => {
58
- this.driverOption.findIndex(elem => elem === driver['driver_name']) === -1 ? this.driverOption.push(driver['driver_name']) : null;
59
- this.truckingCompanayOption.findIndex(elem => elem === driver['trucking_company']) === -1 ? this.truckingCompanayOption.push(driver['trucking_company']) : null;
60
- });
61
- }
62
- }
63
- ((this.pickupOptions.findIndex((elem) => elem === item.pickup_location)) === -1) ? this.pickupOptions.push(item.pickup_location) : null;
64
- ((this.destOptions.findIndex((elem) => elem === item.delivery_location)) === -1) ? this.destOptions.push(item.delivery_location) : null;
65
- (this.customerOptions.findIndex((customer) => customer === item.customer_name) === -1) ? this.customerOptions.push(item.customer_name) : null;
66
- (this.unitOptions.findIndex((elem) => elem === item.unit) === -1) ? this.unitOptions.push(item.unit) : null;
67
- (this.materialOptions.findIndex((elem) => elem === item.material) === -1) ? this.materialOptions.push(item.material) : null;
68
- if (item.route_name) this.routeNameOptions.findIndex(elem => elem === item.route_name) === -1 ? this.routeNameOptions.push(item.route_name) : null;
69
- }
70
-
71
- filter(value: string, filters: any) {
72
- if (typeof value !== 'string') { return [] }
73
- const filterValue = value.toLowerCase();
74
- if (filterValue === '') { return [] }
75
- const searchResults: any[] = [];
76
- this.unitOptions.map(unit => {
77
- if (unit.toLowerCase().includes(filterValue)) {
78
- searchResults.push({ "type": "unit", "label": unit, "value": unit })
79
- }
80
- });
81
- this.customerOptions.map(unit => {
82
- if (unit.toLowerCase().includes(filterValue)) {
83
- searchResults.push({ "type": "customer", "label": unit, "value": unit })
84
- }
85
- });
86
- this.materialOptions.map(unit => {
87
- if (unit.toLowerCase().includes(filterValue)) {
88
- searchResults.push({ "type": "material", "label": unit, "value": unit })
89
- }
90
- });
91
- this.pickupOptions.map(unit => {
92
- if (unit.toLowerCase().includes(filterValue)) {
93
- searchResults.push({ "type": "pickup location", "label": unit, "value": unit })
94
- }
95
- });
96
- this.destOptions.map(unit => {
97
- if (unit.toLowerCase().includes(filterValue)) {
98
- searchResults.push({ "type": "destination location", "label": unit, "value": unit })
99
- }
100
- });
101
- this.jcodeOptions.map(unit => {
102
- if (unit.job_code.toLowerCase().includes(filterValue)) {
103
- searchResults.push({ "type": "job", "label": unit['job_code'], "value": unit })
104
- }
105
- });
106
- this.driverOption.map(unit => {
107
- if (unit.toLowerCase().includes(filterValue)) {
108
- searchResults.push({ "type": "Driver", "label": unit, "value": unit })
109
- }
110
- });
111
-
112
- this.truckingCompanayOption.map(unit => {
113
- if (unit.toLowerCase().includes(filterValue)) {
114
- searchResults.push({ "type": "Trucking Company", "label": unit, "value": unit })
115
- }
116
- });
117
- this.routeNameOptions.map(unit => {
118
- if (unit.toLowerCase().includes(filterValue)) {
119
- searchResults.push({ "type": "Route name", "label": unit, "value": unit })
120
- }
121
- });
122
- const searchDict: any = {}
123
- filters.map((filter: { [x: string]: any; }) => {
124
- searchDict[filter['name'] + filter['type']] = filter;
125
- })
126
- const furtherFilter: any[] = [];
127
- searchResults.map(search => {
128
- if ((search['label'] + search['type']) in searchDict) { }
129
- else { furtherFilter.push(search) }
130
- });
131
- return furtherFilter;
132
- }
133
-
134
- getSearchResults(list: Route[], filterval: any): any {
135
- return list.filter(element => {
136
- const result_list_boolean = []
137
- if (filterval.length > 0) {
138
- if (filterval[0]['type'] === 'unit') {
139
- result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type'] as keyof Route]);
140
- }
141
- if (filterval[0]['type'] === 'customer') {
142
- result_list_boolean.push(filterval[0]['name'] === element['customer_name']);
143
- }
144
- if (filterval[0]['type'] === 'material') {
145
- result_list_boolean.push(filterval[0]['name'] === element[filterval[0]['type'] as keyof Route]);
146
- }
147
- if (filterval[0]['type'] === 'pickup location') {
148
- result_list_boolean.push(filterval[0]['name'] === element['pickup_location']);
149
- }
150
- if (filterval[0]['type'] === 'destination location') {
151
- result_list_boolean.push(filterval[0]['name'] === element['delivery_location']);
152
- }
153
- if (filterval[0]['type'] === 'job') {
154
- result_list_boolean.push(filterval[0]['name'] === element['order_number']);
155
- }
156
- if (filterval[0]['type'] === 'Route name') {
157
- result_list_boolean.push(filterval[0]['name'] === element['route_name']);
158
- }
159
- if (filterval[0]['type'] === 'Driver') {
160
- const index = element.driver_list?.findIndex(ele => { return filterval[0]['name'] === ele['driver_name'] });
161
- if (index !== -1) result_list_boolean.push(true);
162
- }
163
- if (filterval[0]['type'] === 'Trucking Company') {
164
- const index = element.driver_list?.findIndex(ele => { return filterval[0]['name'] === ele['trucking_company'] });
165
- if (index !== -1) result_list_boolean.push(true);
166
- }
167
- }
168
- if (result_list_boolean.length > 0) {
169
- return result_list_boolean.reduce((prev, curr) => prev && curr);
170
- }
171
- return false;
172
- });
173
- }
174
-
175
- clearOptions() {
176
- this.pickupOptions = [];
177
- this.destOptions = [];
178
- this.ownerOptions = [];
179
- this.customerOptions = [];
180
- this.unitOptions = [];
181
- this.materialOptions = [];
182
- this.jcodeOptions = [];
183
- this.routeNameOptions = [];
184
- }
185
- setdictValue(key: string, value: string) {
186
- this.dict.set(key, value);
187
- }
188
- getdictValue(key: string) {
189
- return JSON.parse(this.dict.get(key));
190
- }
191
- removedictValue(key: string) {
192
- this.dict.delete(key);
193
- }
194
- conveySearchIcon(value: any): boolean{
195
- if(value && typeof(value) !== 'object') return true;
196
- return false
197
- }
198
- }
package/src/public-api.ts DELETED
@@ -1,13 +0,0 @@
1
- /*
2
- * Public API Surface of coolmap-services
3
- */
4
-
5
- export * from './lib/coolmap-services.service';
6
- export * from './lib/coolmap-services.component';
7
- export * from './lib/coolmap-services.module';
8
- export * from './lib/service/coolmap.service';
9
- export * from './lib/service/utils.service';
10
- export * from './lib/service/data-model';
11
-
12
-
13
-
package/src/test.ts DELETED
@@ -1,27 +0,0 @@
1
- // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
-
3
- import 'zone.js';
4
- import 'zone.js/testing';
5
- import { getTestBed } from '@angular/core/testing';
6
- import {
7
- BrowserDynamicTestingModule,
8
- platformBrowserDynamicTesting
9
- } from '@angular/platform-browser-dynamic/testing';
10
-
11
- declare const require: {
12
- context(path: string, deep?: boolean, filter?: RegExp): {
13
- <T>(id: string): T;
14
- keys(): string[];
15
- };
16
- };
17
-
18
- // First, initialize the Angular testing environment.
19
- getTestBed().initTestEnvironment(
20
- BrowserDynamicTestingModule,
21
- platformBrowserDynamicTesting(),
22
- );
23
-
24
- // Then we find all the tests.
25
- const context = require.context('./', true, /\.spec\.ts$/);
26
- // And load the modules.
27
- context.keys().forEach(context);
package/tsconfig.lib.json DELETED
@@ -1,15 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/lib",
6
- "declaration": true,
7
- "declarationMap": true,
8
- "inlineSources": true,
9
- "types": []
10
- },
11
- "exclude": [
12
- "src/test.ts",
13
- "**/*.spec.ts"
14
- ]
15
- }
@@ -1,10 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.lib.json",
4
- "compilerOptions": {
5
- "declarationMap": false
6
- },
7
- "angularCompilerOptions": {
8
- "compilationMode": "partial"
9
- }
10
- }
@@ -1,17 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../out-tsc/spec",
6
- "types": [
7
- "jasmine"
8
- ]
9
- },
10
- "files": [
11
- "src/test.ts"
12
- ],
13
- "include": [
14
- "**/*.spec.ts",
15
- "**/*.d.ts"
16
- ]
17
- }