@fleetbase/fleetops-engine 0.3.5 → 0.3.6
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.
- package/README.md +4 -4
- package/addon/components/admin/navigator-app.hbs +5 -0
- package/addon/components/admin/navigator-app.js +27 -0
- package/addon/components/driver-form-panel.js +13 -19
- package/addon/components/leaflet-draw-control.js +2 -3
- package/addon/components/live-map.js +7 -4
- package/addon/components/modals/driver-assign-order.hbs +2 -2
- package/addon/components/modals/order-import.hbs +5 -5
- package/addon/components/modals/order-new-activity.hbs +1 -1
- package/addon/components/order-config/entities-editor.js +3 -5
- package/addon/components/route-list.hbs +2 -2
- package/addon/components/vendor-form-panel.js +1 -1
- package/addon/controllers/application.js +2 -2
- package/addon/controllers/base-controller.js +31 -0
- package/addon/controllers/management/contacts/index/details.js +2 -2
- package/addon/controllers/management/contacts/index/edit.js +2 -2
- package/addon/controllers/management/contacts/index/new.js +2 -2
- package/addon/controllers/management/contacts/index.js +2 -2
- package/addon/controllers/management/drivers/index/details.js +2 -2
- package/addon/controllers/management/drivers/index/edit.js +28 -2
- package/addon/controllers/management/drivers/index/new.js +2 -2
- package/addon/controllers/management/drivers/index.js +11 -24
- package/addon/controllers/management/fleets/index/details.js +2 -2
- package/addon/controllers/management/fleets/index/edit.js +2 -2
- package/addon/controllers/management/fleets/index/new.js +2 -2
- package/addon/controllers/management/fleets/index.js +9 -9
- package/addon/controllers/management/fuel-reports/index/details.js +2 -2
- package/addon/controllers/management/fuel-reports/index/edit.js +2 -2
- package/addon/controllers/management/fuel-reports/index/new.js +2 -2
- package/addon/controllers/management/fuel-reports/index.js +2 -2
- package/addon/controllers/management/issues/index/details.js +2 -2
- package/addon/controllers/management/issues/index/edit.js +2 -2
- package/addon/controllers/management/issues/index/new.js +2 -2
- package/addon/controllers/management/issues/index.js +2 -9
- package/addon/controllers/management/places/index/details.js +2 -2
- package/addon/controllers/management/places/index/edit.js +2 -2
- package/addon/controllers/management/places/index/new.js +2 -2
- package/addon/controllers/management/places/index.js +2 -2
- package/addon/controllers/management/vehicles/index/details.js +2 -2
- package/addon/controllers/management/vehicles/index/edit.js +2 -2
- package/addon/controllers/management/vehicles/index/new.js +2 -2
- package/addon/controllers/management/vehicles/index.js +11 -12
- package/addon/controllers/management/vendors/index/details.js +2 -2
- package/addon/controllers/management/vendors/index/edit.js +2 -2
- package/addon/controllers/management/vendors/index/new.js +2 -2
- package/addon/controllers/management/vendors/index.js +2 -8
- package/addon/controllers/management.js +2 -2
- package/addon/controllers/operations/orders/index/config/types.js +2 -2
- package/addon/controllers/operations/orders/index/config.js +2 -2
- package/addon/controllers/operations/orders/index/new.js +64 -44
- package/addon/controllers/operations/orders/index/view.js +11 -4
- package/addon/controllers/operations/orders/index.js +2 -2
- package/addon/controllers/operations/scheduler/index.js +2 -2
- package/addon/controllers/operations/service-rates/index/edit.js +12 -18
- package/addon/controllers/operations/service-rates/index/new.js +16 -22
- package/addon/controllers/operations/service-rates/index.js +2 -2
- package/addon/engine.js +6 -0
- package/addon/helpers/waypoint-label.js +6 -1
- package/addon/routes/application.js +4 -15
- package/addon/routes/management/contacts/index.js +9 -5
- package/addon/routes/management/drivers/index.js +7 -3
- package/addon/routes/management/fleets/index.js +9 -5
- package/addon/routes/management/fuel-reports/index.js +9 -5
- package/addon/routes/management/issues/index.js +9 -5
- package/addon/routes/management/places/index.js +9 -5
- package/addon/routes/management/vehicles/index/details.js +2 -2
- package/addon/routes/management/vehicles/index.js +9 -0
- package/addon/routes/management/vendors/index.js +9 -6
- package/addon/routes/operations/orders/index/view.js +6 -2
- package/addon/routes/operations/orders/index.js +7 -1
- package/addon/routes/operations/orders.js +0 -1
- package/addon/routes/operations/service-rates/index.js +9 -27
- package/addon/routes/operations/service-rates.js +1 -8
- package/addon/styles/fleetops-engine.css +14 -7
- package/addon/templates/operations/orders/index/new.hbs +7 -7
- package/addon/templates/operations/orders/index/view.hbs +17 -16
- package/addon/utils/waypoint-label.js +3 -0
- package/app/controllers/{operations/zones/index.js → base-controller.js} +1 -1
- package/app/utils/waypoint-label.js +1 -0
- package/composer.json +1 -1
- package/config/environment.js +11 -1
- package/extension.json +1 -1
- package/index.js +1 -0
- package/package.json +47 -41
- package/server/migrations/2023_11_28_074244_add_supplier_uuid_column_to_entities_table.php +33 -0
- package/server/migrations/2023_12_14_100209_add_meta_column_on_driver_table.php +30 -0
- package/server/src/Http/Controllers/Api/v1/DriverController.php +7 -4
- package/server/src/Http/Controllers/Api/v1/OrderController.php +118 -42
- package/server/src/Http/Controllers/Api/v1/PayloadController.php +41 -43
- package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +43 -2
- package/server/src/Http/Controllers/Internal/v1/MorphController.php +48 -16
- package/server/src/Http/Controllers/Internal/v1/NavigatorController.php +41 -0
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +3 -2
- package/server/src/Http/Controllers/Internal/v1/PlaceController.php +2 -2
- package/server/src/Http/Requests/CreateDriverRequest.php +2 -0
- package/server/src/Http/Requests/CreateOrderRequest.php +18 -4
- package/server/src/Http/Requests/CreatePayloadRequest.php +23 -7
- package/server/src/Http/Requests/CreatePlaceRequest.php +9 -5
- package/server/src/Http/Requests/CreateTrackingStatusRequest.php +69 -12
- package/server/src/Http/Requests/CreateVehicleRequest.php +5 -3
- package/server/src/Http/Resources/v1/Entity.php +3 -0
- package/server/src/Http/Resources/v1/Order.php +3 -2
- package/server/src/Models/Driver.php +5 -2
- package/server/src/Models/Entity.php +1 -1
- package/server/src/Models/Order.php +2 -2
- package/server/src/Models/Payload.php +27 -9
- package/server/src/Models/Place.php +28 -5
- package/server/src/Models/TrackingStatus.php +9 -3
- package/server/src/Models/VehicleDevice.php +28 -0
- package/server/src/Models/Vendor.php +16 -0
- package/server/src/Observers/DriverObserver.php +1 -1
- package/server/src/routes.php +8 -0
- package/tsconfig.declarations.json +10 -0
- package/addon/components/file-icon.js +0 -1
- package/addon/controllers/operations/zones/index.js +0 -475
- package/addon/routes/operations/dispatch.js +0 -3
- package/addon/routes/operations/zones/index.js +0 -25
- package/addon/routes/operations/zones.js +0 -7
- package/addon/templates/operations/dispatch.hbs +0 -1
- package/addon/templates/operations/zones/index.hbs +0 -72
- package/addon/templates/operations/zones.hbs +0 -1
- package/app/components/file-icon.js +0 -1
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
import Controller from '@ember/controller';
|
|
2
|
-
import { inject as service } from '@ember/service';
|
|
3
|
-
import { tracked } from '@glimmer/tracking';
|
|
4
|
-
import { action } from '@ember/object';
|
|
5
|
-
import { later } from '@ember/runloop';
|
|
6
|
-
import GeoJson from '@fleetbase/fleetops-data/utils/geojson/geo-json';
|
|
7
|
-
import FeatureCollection from '@fleetbase/fleetops-data/utils/geojson/feature-collection';
|
|
8
|
-
import last from '@fleetbase/ember-core/utils/last';
|
|
9
|
-
|
|
10
|
-
export default class OperationsZonesIndexController extends Controller {
|
|
11
|
-
/**
|
|
12
|
-
* Inject the `currentUser` service
|
|
13
|
-
*
|
|
14
|
-
* @var {Service}
|
|
15
|
-
*/
|
|
16
|
-
@service store;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Inject the `currentUser` service
|
|
20
|
-
*
|
|
21
|
-
* @var {Service}
|
|
22
|
-
*/
|
|
23
|
-
@service currentUser;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Inject the `modalsManager` service
|
|
27
|
-
*
|
|
28
|
-
* @var {Service}
|
|
29
|
-
*/
|
|
30
|
-
@service modalsManager;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Inject the `notifications` service
|
|
34
|
-
*
|
|
35
|
-
* @var {Service}
|
|
36
|
-
*/
|
|
37
|
-
@service notifications;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Inject the `hostRouter` service
|
|
41
|
-
*
|
|
42
|
-
* @var {Service}
|
|
43
|
-
*/
|
|
44
|
-
@service hostRouter;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Inject the `crud` service
|
|
48
|
-
*
|
|
49
|
-
* @var {Service}
|
|
50
|
-
*/
|
|
51
|
-
@service crud;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* True if the viewing an orders route preview.
|
|
55
|
-
*
|
|
56
|
-
* @var {L.Map}
|
|
57
|
-
*/
|
|
58
|
-
@tracked leafletMap;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The ActiveFeatureGroup
|
|
62
|
-
*
|
|
63
|
-
* @var {ActiveFeatureGroup}
|
|
64
|
-
*/
|
|
65
|
-
@tracked activeFeatureGroup;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* All active editable zone layers
|
|
69
|
-
*
|
|
70
|
-
* @var {Array}
|
|
71
|
-
*/
|
|
72
|
-
@tracked editableZones = [];
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* True to display draw controls on map.
|
|
76
|
-
*
|
|
77
|
-
* @var {Boolean}
|
|
78
|
-
*/
|
|
79
|
-
@tracked showDrawControl;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The active service area to focus.
|
|
83
|
-
*
|
|
84
|
-
* @var {ServiceAreaModel}
|
|
85
|
-
*/
|
|
86
|
-
@tracked activeServiceArea;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The users latitude based on whois lookup.
|
|
90
|
-
*
|
|
91
|
-
* @var {String}
|
|
92
|
-
*/
|
|
93
|
-
get userLatitude() {
|
|
94
|
-
const whois = this.currentUser.getOption('whois');
|
|
95
|
-
|
|
96
|
-
return whois.latitude || null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The users longitude based on whois lookup.
|
|
101
|
-
*
|
|
102
|
-
* @var {String}
|
|
103
|
-
*/
|
|
104
|
-
get userLongitude() {
|
|
105
|
-
const whois = this.currentUser.getOption('whois');
|
|
106
|
-
|
|
107
|
-
return whois.longitude || null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Sets a reference to the leaflet map onload
|
|
112
|
-
*
|
|
113
|
-
* @void
|
|
114
|
-
*/
|
|
115
|
-
@action
|
|
116
|
-
setMapReference(event) {
|
|
117
|
-
if (!event || !event.target) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
this.leafletMap = event.target;
|
|
122
|
-
|
|
123
|
-
// handle resize event now
|
|
124
|
-
later(
|
|
125
|
-
this,
|
|
126
|
-
() => {
|
|
127
|
-
this.leafletMap.invalidateSize();
|
|
128
|
-
},
|
|
129
|
-
100
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Set the active feature group
|
|
135
|
-
*
|
|
136
|
-
* @param {ActiveFeatureGroup} activeFeatureGroup
|
|
137
|
-
* @param {LeafletMap} map
|
|
138
|
-
* @void
|
|
139
|
-
*/
|
|
140
|
-
@action
|
|
141
|
-
setFeatureGroup(activeFeatureGroup, map) {
|
|
142
|
-
this.activeFeatureGroup = activeFeatureGroup;
|
|
143
|
-
this.leafletMap = map;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Enable zone editing for the passed ServiceArea.
|
|
148
|
-
*
|
|
149
|
-
* @param {ServiceAreaModel} serviceArea
|
|
150
|
-
*/
|
|
151
|
-
@action
|
|
152
|
-
startZoneEditing(serviceArea) {
|
|
153
|
-
this.activeServiceArea = serviceArea;
|
|
154
|
-
this.showDrawControl = true;
|
|
155
|
-
|
|
156
|
-
let bounds = serviceArea.bounds;
|
|
157
|
-
|
|
158
|
-
this.leafletMap.setMaxBounds(bounds);
|
|
159
|
-
this.leafletMap.flyToBounds(bounds);
|
|
160
|
-
this.notifications.info('Use the draw controls to the left to define, edit, or delete zones within your service area, your zone is not limited to the bounds of your service area.');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Adds a new layer to the ActiveFeatureGroup
|
|
165
|
-
*
|
|
166
|
-
* @param {ZoneModel} zone
|
|
167
|
-
* @void
|
|
168
|
-
*/
|
|
169
|
-
@action
|
|
170
|
-
makeZoneEditable(zone, { target }) {
|
|
171
|
-
if (this.editableZones.includes(target) || !this.activeFeatureGroup || this.activeFeatureGroup.hasLayer(target)) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
target._zone_id = zone.id || 'new_zone';
|
|
176
|
-
|
|
177
|
-
this.editableZones.pushObject(target);
|
|
178
|
-
this.activeFeatureGroup.addLayer(target);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Save changes made to zone coordinates.
|
|
183
|
-
*
|
|
184
|
-
* @param {Event} event
|
|
185
|
-
* @void
|
|
186
|
-
*/
|
|
187
|
-
@action
|
|
188
|
-
saveZoneCoordinateChanges(event, _layer) {
|
|
189
|
-
const serviceArea = this.activeServiceArea;
|
|
190
|
-
|
|
191
|
-
if (!serviceArea) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// get all layers
|
|
196
|
-
const layers = Object.values(_layer._layers);
|
|
197
|
-
|
|
198
|
-
// iterate and get zone model
|
|
199
|
-
for (let i = 0; i < layers.length; i++) {
|
|
200
|
-
const layer = layers[i];
|
|
201
|
-
|
|
202
|
-
if (!layer._boundary_id) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// peek boundary to destroy
|
|
207
|
-
const zone = this.store.peekRecord('zone', layer._zone_id);
|
|
208
|
-
|
|
209
|
-
if (zone) {
|
|
210
|
-
const geoJson = layer.toGeoJSON();
|
|
211
|
-
const border = new GeoJson(geoJson.geometry);
|
|
212
|
-
|
|
213
|
-
zone.border = border;
|
|
214
|
-
zone.save();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Delete boundaries selected in layers
|
|
221
|
-
*
|
|
222
|
-
* @param {Event} event
|
|
223
|
-
* @void
|
|
224
|
-
*/
|
|
225
|
-
@action
|
|
226
|
-
deleteZoneBorders({ layers }) {
|
|
227
|
-
const serviceArea = this.activeServiceArea;
|
|
228
|
-
|
|
229
|
-
if (!serviceArea) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// get current zones for service area
|
|
234
|
-
const zones = serviceArea.zones || [];
|
|
235
|
-
|
|
236
|
-
// get array of layers to delete
|
|
237
|
-
layers = Array.from(layers.getLayers());
|
|
238
|
-
|
|
239
|
-
// iterate and get zone model
|
|
240
|
-
for (let i = 0; i < layers.length; i++) {
|
|
241
|
-
const layer = layers[i];
|
|
242
|
-
|
|
243
|
-
if (!layer._zone_id) {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// peek zone to destroy
|
|
248
|
-
const zone = this.store.peekRecord('boundary', layer._zone_id);
|
|
249
|
-
|
|
250
|
-
if (zone) {
|
|
251
|
-
zones.removeObject(zone);
|
|
252
|
-
zone.destroyRecord();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
@action
|
|
258
|
-
createZoneFromLayer(event, layer) {
|
|
259
|
-
const serviceArea = this.activeServiceArea;
|
|
260
|
-
|
|
261
|
-
if (!serviceArea) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const leafletLayerGeoJson = layer.toGeoJSON();
|
|
266
|
-
const featureCollection = new FeatureCollection(leafletLayerGeoJson);
|
|
267
|
-
const feature = last(featureCollection.features);
|
|
268
|
-
const border = new GeoJson(feature.geometry);
|
|
269
|
-
|
|
270
|
-
return this.createZone({
|
|
271
|
-
service_area_uuid: serviceArea.id,
|
|
272
|
-
border,
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Create a new `zone` in modal
|
|
278
|
-
*
|
|
279
|
-
* @param {Object} options
|
|
280
|
-
* @void
|
|
281
|
-
*/
|
|
282
|
-
@action
|
|
283
|
-
createZone(attrs = {}) {
|
|
284
|
-
const zone = this.store.createRecord('zone', attrs);
|
|
285
|
-
|
|
286
|
-
return this.editZone(zone, {
|
|
287
|
-
title: 'New Zone',
|
|
288
|
-
acceptButtonText: 'Confirm & Create',
|
|
289
|
-
successNotification: (zone) => `New zone (${zone.name}) successfully created.`,
|
|
290
|
-
onConfirm: () => {
|
|
291
|
-
// make sure to push zone to serviceArea model
|
|
292
|
-
let serviceArea = this.store.peekRecord('service-area', zone.service_area_uuid);
|
|
293
|
-
|
|
294
|
-
if (serviceArea) {
|
|
295
|
-
serviceArea.zones.pushObject(zone);
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Edit a `zone` details
|
|
303
|
-
*
|
|
304
|
-
* @param {ZoneModel} zone
|
|
305
|
-
* @param {Object} options
|
|
306
|
-
* @void
|
|
307
|
-
*/
|
|
308
|
-
@action
|
|
309
|
-
editZone(zone, options = {}) {
|
|
310
|
-
this.modalsManager.show('modals/zone-form', {
|
|
311
|
-
title: 'Edit Zone',
|
|
312
|
-
acceptButtonText: 'Save Changes',
|
|
313
|
-
zone,
|
|
314
|
-
confirm: (modal) => {
|
|
315
|
-
modal.startLoading();
|
|
316
|
-
|
|
317
|
-
return zone.save().then((zone) => {
|
|
318
|
-
if (typeof options.successNotification === 'function') {
|
|
319
|
-
this.notifications.success(options.successNotification(zone));
|
|
320
|
-
} else {
|
|
321
|
-
this.notifications.success(options.successNotification || `${zone.name} details updated.`);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
},
|
|
325
|
-
...options,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Delete a `zone` via confirm prompt
|
|
331
|
-
*
|
|
332
|
-
* @param {ZoneModel} zone
|
|
333
|
-
* @param {Object} options
|
|
334
|
-
* @void
|
|
335
|
-
*/
|
|
336
|
-
@action
|
|
337
|
-
deleteZone(zone, options = {}) {
|
|
338
|
-
this.crud.delete(zone, {
|
|
339
|
-
...options,
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Edit a `zone` border coordinates.
|
|
345
|
-
*
|
|
346
|
-
* @param {ZoneModel} zone
|
|
347
|
-
* @param {Object} options
|
|
348
|
-
* @void
|
|
349
|
-
*/
|
|
350
|
-
@action
|
|
351
|
-
editZoneBorder() {}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Create a new `serviceArea` in modal
|
|
355
|
-
*
|
|
356
|
-
* @param {Object} options
|
|
357
|
-
* @void
|
|
358
|
-
*/
|
|
359
|
-
@action
|
|
360
|
-
createServiceArea() {
|
|
361
|
-
const serviceArea = this.store.createRecord('service-area', {
|
|
362
|
-
status: 'active',
|
|
363
|
-
type: 'country',
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
return this.editServiceArea(serviceArea, {
|
|
367
|
-
title: 'New Service Area',
|
|
368
|
-
acceptButtonText: 'Confirm & Create',
|
|
369
|
-
successNotification: (serviceArea) => `New service area (${serviceArea.name}) created.`,
|
|
370
|
-
onConfirm: () => {
|
|
371
|
-
this.hostRouter.refresh();
|
|
372
|
-
},
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Edit a `serviceArea` details
|
|
378
|
-
*
|
|
379
|
-
* @param {ServiceAreaModel} serviceArea
|
|
380
|
-
* @param {Object} options
|
|
381
|
-
* @void
|
|
382
|
-
*/
|
|
383
|
-
@action
|
|
384
|
-
editServiceArea(serviceArea, options = {}) {
|
|
385
|
-
this.modalsManager.show('modals/service-area-form', {
|
|
386
|
-
title: 'Edit Service Area',
|
|
387
|
-
acceptButtonText: 'Save Changes',
|
|
388
|
-
serviceArea,
|
|
389
|
-
confirm: (modal) => {
|
|
390
|
-
modal.startLoading();
|
|
391
|
-
|
|
392
|
-
return serviceArea.save().then((serviceArea) => {
|
|
393
|
-
if (typeof options.successNotification === 'function') {
|
|
394
|
-
this.notifications.success(options.successNotification(serviceArea));
|
|
395
|
-
} else {
|
|
396
|
-
this.notifications.success(options.successNotification || `${serviceArea.name} details updated.`);
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
},
|
|
400
|
-
...options,
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Rename a `serviceArea` details
|
|
406
|
-
*
|
|
407
|
-
* @param {ServiceAreaModel} serviceArea
|
|
408
|
-
* @param {Object} options
|
|
409
|
-
* @void
|
|
410
|
-
*/
|
|
411
|
-
@action
|
|
412
|
-
renameServiceArea(serviceArea, options = {}) {
|
|
413
|
-
this.modalsManager.show('modals/service-area-form', {
|
|
414
|
-
title: 'Rename Service Area',
|
|
415
|
-
acceptButtonText: 'Save Changes',
|
|
416
|
-
rename: true,
|
|
417
|
-
serviceArea,
|
|
418
|
-
confirm: (modal) => {
|
|
419
|
-
modal.startLoading();
|
|
420
|
-
|
|
421
|
-
return serviceArea.save().then((serviceArea) => {
|
|
422
|
-
if (typeof options.successNotification === 'function') {
|
|
423
|
-
this.notifications.success(options.successNotification(serviceArea));
|
|
424
|
-
} else {
|
|
425
|
-
this.notifications.success(options.successNotification || `${serviceArea.name} renamed.`);
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
},
|
|
429
|
-
...options,
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Delete a `serviceArea` via confirm prompt
|
|
435
|
-
*
|
|
436
|
-
* @param {ServiceAreaModel} serviceArea
|
|
437
|
-
* @param {Object} options
|
|
438
|
-
* @void
|
|
439
|
-
*/
|
|
440
|
-
@action
|
|
441
|
-
deleteServiceArea(serviceArea, options = {}) {
|
|
442
|
-
// if the service area being deleted is active untoggle
|
|
443
|
-
if (serviceArea === this.activeServiceArea) {
|
|
444
|
-
this.activeServiceArea = null;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
this.crud.delete(serviceArea, {
|
|
448
|
-
...options,
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
@action moveToCurrentLocation() {
|
|
453
|
-
// eslint-disable-next-line no-undef
|
|
454
|
-
if (window.navigator && window.navigator.geolocation) {
|
|
455
|
-
// eslint-disable-next-line no-undef
|
|
456
|
-
return navigator.geolocation.getCurrentPosition(
|
|
457
|
-
({ coords }) => {
|
|
458
|
-
const { latitude, longitude } = coords;
|
|
459
|
-
|
|
460
|
-
this.leafletMap.flyTo([latitude, longitude]);
|
|
461
|
-
},
|
|
462
|
-
() => {
|
|
463
|
-
this.notifications.error('Unable to move to current location.');
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
@action handleMapResize(options = {}, container) {
|
|
470
|
-
const element = this.leafletMap._container;
|
|
471
|
-
|
|
472
|
-
element.style.width = `${container.offsetWidth - (options.horizontalLeftPadding || 0) - (options.horizontalRightPadding || 0)}px`;
|
|
473
|
-
element.style.height = `${container.offsetHeight - (options.verticalTopPadding || 0) - (options.verticalBottomPadding || 0)}px`;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Route from '@ember/routing/route';
|
|
2
|
-
import { inject as service } from '@ember/service';
|
|
3
|
-
import { action } from '@ember/object';
|
|
4
|
-
|
|
5
|
-
export default class OperationsZonesIndexRoute extends Route {
|
|
6
|
-
/**
|
|
7
|
-
* Inject the `loader` service.
|
|
8
|
-
*
|
|
9
|
-
* @var {Service}
|
|
10
|
-
*/
|
|
11
|
-
@service loader;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Loading event handler for route.
|
|
15
|
-
*
|
|
16
|
-
* @param {Transition} transition
|
|
17
|
-
*/
|
|
18
|
-
@action loading(transition) {
|
|
19
|
-
this.loader.showOnInitialTransition(transition, 'section.next-view-section', { loadingMessage: 'Loading zones...' });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
model() {
|
|
23
|
-
return this.store.query('service-area', { with: ['zones'] });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{outlet}}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
<div class="relative shadow-inner h-full" {{did-resize (fn this.handleMapResize (hash verticalTopPadding=65))}}>
|
|
2
|
-
<LeafletMap {{set-container-dimensions (hash verticalTopPadding=65)}} class="z-0 zones-leaflet" @lat={{this.userLatitude}} @lng={{this.userLongitude}} @zoom={{14}} @onLoad={{this.setMapReference}} as |layers|>
|
|
3
|
-
<layers.tile @url="https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png" />
|
|
4
|
-
|
|
5
|
-
{{#each @model as |serviceArea|}}
|
|
6
|
-
{{#each serviceArea.zones as |zone|}}
|
|
7
|
-
<layers.polygon @id={{zone.id}} @locations={{zone.locations}} @color={{or zone.stroke_color "#48BB78"}} @onAdd={{fn
|
|
8
|
-
this.makeZoneEditable zone}} />
|
|
9
|
-
{{/each}}
|
|
10
|
-
{{/each}}
|
|
11
|
-
|
|
12
|
-
{{#if this.showDrawControl}}
|
|
13
|
-
<LeafletDrawControl @draw={{hash marker=false circlemarker=false circle=false polyline=false}} @onDrawDrawstop={{this.createZoneFromLayer}} @onDrawDeleted={{this.deleteZoneBorders}} @onDrawEditstop={{this.saveZoneCoordinateChanges}} @onDrawFeatureGroupCreated={{this.setFeatureGroup}} />
|
|
14
|
-
{{/if}}
|
|
15
|
-
|
|
16
|
-
{{#if this.activeServiceArea}}
|
|
17
|
-
<layers.polygon @locations={{this.activeServiceArea.bounds}} @color="#48BB78" />
|
|
18
|
-
{{/if}}
|
|
19
|
-
</LeafletMap>
|
|
20
|
-
|
|
21
|
-
<div class="z-20 absolute right-0 top-0">
|
|
22
|
-
<div class="zones-panel">
|
|
23
|
-
<div class="content-panel">
|
|
24
|
-
<div class="content-panel-header items-center flex">
|
|
25
|
-
<h3 class="text-lg font-semibold dark:text-gray-100">
|
|
26
|
-
Zones
|
|
27
|
-
</h3>
|
|
28
|
-
|
|
29
|
-
<div class="flex items-center">
|
|
30
|
-
<Button @size="sm" @icon="crosshairs" @onClick={{this.moveToCurrentLocation}} class="mr-2" />
|
|
31
|
-
<Button @type="primary" @size="sm" @text="New Service Area" @onClick={{this.createServiceArea}} />
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
<div class="content-panel-body no-padding sidebar-panels not-service-nav w-full">
|
|
35
|
-
<ContentPanel @title={{this.activeServiceArea.name}} @open={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
|
|
36
|
-
<div class="px-2 mb-2">
|
|
37
|
-
<div class="flex items-center justify-end">
|
|
38
|
-
<Button class="mr-2" @icon="eye" @type="magic" @text="Focus" @onClick={{fn this.startZoneEditing this.activeServiceArea}} @helpText="Moves map focus to {{this.activeServiceArea.name}}. Once focused you will then be able to edit, delete, and define zone bounds for the service area." />
|
|
39
|
-
<DropdownButton @icon="cog" @contentClass="dropdown-menu" @size="xs" @horizontalPosition="right" @helpText="Service Area options.">
|
|
40
|
-
<div class="dropdown-menu-content context-menu">
|
|
41
|
-
<a href="javascript:;" class="dropdown-menu-item" {{on "click" (fn this.renameServiceArea this.activeServiceArea)}}>Rename Service Area</a>
|
|
42
|
-
<a href="javascript:;" class="dropdown-menu-item" {{on "click" (fn this.deleteServiceArea this.activeServiceArea)}}>Delete Service Area</a>
|
|
43
|
-
</div>
|
|
44
|
-
</DropdownButton>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
<div class="px-0 py-1">
|
|
48
|
-
{{#each this.activeServiceArea.zones as |zone|}}
|
|
49
|
-
<div class="flex items-center justify-between border-t w-full border-gray-900 py-3 px-5 dark:text-gray-100">
|
|
50
|
-
<div>
|
|
51
|
-
<div class="font-semibold mb-1">
|
|
52
|
-
<FaIcon @icon="map-marker" class="mr-1" />
|
|
53
|
-
{{zone.name}}
|
|
54
|
-
</div>
|
|
55
|
-
<div>Created At: {{zone.createdAt}}</div>
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<div>
|
|
59
|
-
<Button @icon="edit" @size="xs" @helpText="Edit the zone boundary." />
|
|
60
|
-
<Button @icon="drafting-compass" @size="xs" @helpText="View zone details." @onClick={{fn this.editZone zone}} />
|
|
61
|
-
<Button @icon="trash" @size="xs" @helpText="Delete this zone." @onClick={{fn this.deleteZone zone}} />
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
{{/each}}
|
|
65
|
-
</div>
|
|
66
|
-
</ContentPanel>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
{{outlet}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{outlet}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@fleetbase/fleetops-engine/components/file-icon';
|