@fleetbase/fleetops-engine 0.3.7 → 0.3.9
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/addon/components/contact-form-panel.hbs +4 -1
- package/addon/components/contact-panel.hbs +1 -1
- package/addon/components/driver-form-panel.hbs +5 -12
- package/addon/components/driver-panel.hbs +4 -1
- package/addon/components/fleet-form-panel.hbs +4 -1
- package/addon/components/fleet-listing-panel.hbs +2 -2
- package/addon/components/fleet-panel.hbs +1 -1
- package/addon/components/fuel-report-form-panel.hbs +4 -1
- package/addon/components/fuel-report-panel.hbs +4 -1
- package/addon/components/issue-form-panel.hbs +4 -1
- package/addon/components/issue-panel.hbs +4 -1
- package/addon/components/layout/fleet-ops-sidebar/driver-listing.hbs +5 -0
- package/addon/components/layout/fleet-ops-sidebar/driver-listing.js +122 -0
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.hbs +5 -1
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +118 -1
- package/addon/components/layout/fleet-ops-sidebar.hbs +5 -1
- package/addon/components/layout/fleet-ops-sidebar.js +4 -2
- package/addon/components/live-map.hbs +90 -9
- package/addon/components/live-map.js +28 -11
- package/addon/components/map-container/toolbar/zones-panel.js +16 -13
- package/addon/components/place-form-panel.hbs +4 -1
- package/addon/components/place-panel.hbs +4 -1
- package/addon/components/settings-window.hbs +1 -1
- package/addon/components/vehicle-form-panel.hbs +4 -1
- package/addon/components/vehicle-panel.hbs +4 -1
- package/addon/components/vendor-form-panel.hbs +4 -1
- package/addon/components/vendor-panel.hbs +4 -1
- package/addon/controllers/management/drivers/index.js +10 -90
- package/addon/controllers/management/vehicles/index.js +11 -21
- package/addon/controllers/operations/orders/index/new.js +5 -5
- package/addon/controllers/operations/orders/index/view.js +9 -13
- package/addon/helpers/format-point.js +5 -2
- package/addon/helpers/point-to-coordinates.js +6 -2
- package/addon/services/context-panel.js +23 -18
- package/addon/services/driver-actions.js +107 -0
- package/addon/services/vehicle-actions.js +42 -0
- package/addon/styles/fleetops-engine.css +27 -0
- package/addon/templates/operations/orders/index/new.hbs +3 -3
- package/addon/templates/operations/service-rates/index/new.hbs +1 -1
- package/addon/utils/fly-to-leaflet-layer.js +7 -0
- package/app/components/layout/fleet-ops-sidebar/driver-listing.js +1 -0
- package/app/services/driver-actions.js +1 -0
- package/app/services/vehicle-actions.js +1 -0
- package/composer.json +2 -2
- package/extension.json +1 -1
- package/package.json +4 -4
- package/server/src/Casts/MultiPolygon.php +14 -3
- package/server/src/Casts/Point.php +12 -2
- package/server/src/Casts/Polygon.php +19 -4
- package/server/src/Exceptions/IntegratedVendorException.php +45 -1
- package/server/src/Http/Controllers/Api/v1/DriverController.php +29 -14
- package/server/src/Http/Controllers/Api/v1/EntityController.php +36 -1
- package/server/src/Http/Controllers/Api/v1/LabelController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/OrderController.php +139 -59
- package/server/src/Http/Controllers/Api/v1/PayloadController.php +20 -12
- package/server/src/Http/Controllers/Api/v1/PlaceController.php +25 -3
- package/server/src/Http/Controllers/Api/v1/PurchaseRateController.php +1 -1
- package/server/src/Http/Controllers/Api/v1/ServiceAreaController.php +71 -3
- package/server/src/Http/Controllers/Api/v1/ServiceQuoteController.php +1 -1
- package/server/src/Http/Controllers/Api/v1/ServiceRateController.php +3 -2
- package/server/src/Http/Controllers/Api/v1/TrackingNumberController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +2 -2
- package/server/src/Http/Controllers/Api/v1/VehicleController.php +22 -2
- package/server/src/Http/Controllers/Api/v1/ZoneController.php +59 -3
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +25 -4
- package/server/src/Http/Controllers/Internal/v1/LiveController.php +3 -10
- package/server/src/Http/Controllers/Internal/v1/NavigatorController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +11 -1
- package/server/src/Http/Filter/TrackingStatusFilter.php +10 -0
- package/server/src/Http/Requests/CancelOrderRequest.php +1 -2
- package/server/src/Http/Requests/CreateContactRequest.php +5 -4
- package/server/src/Http/Requests/CreateDriverRequest.php +13 -11
- package/server/src/Http/Requests/CreateEntityRequest.php +7 -4
- package/server/src/Http/Requests/CreateOrderRequest.php +2 -2
- package/server/src/Http/Requests/CreatePayloadRequest.php +1 -1
- package/server/src/Http/Requests/CreatePlaceRequest.php +46 -4
- package/server/src/Http/Requests/CreatePurchaseRateRequest.php +3 -2
- package/server/src/Http/Requests/CreateServiceAreaRequest.php +24 -4
- package/server/src/Http/Requests/CreateServiceRateRequest.php +22 -21
- package/server/src/Http/Requests/CreateTrackingStatusRequest.php +9 -8
- package/server/src/Http/Requests/CreateVehicleRequest.php +6 -4
- package/server/src/Http/Requests/CreateZoneRequest.php +24 -5
- package/server/src/Http/Requests/QueryServiceQuotesRequest.php +11 -10
- package/server/src/Http/Requests/ScheduleOrderRequest.php +32 -0
- package/server/src/Http/Requests/UpdateContactRequest.php +0 -13
- package/server/src/Http/Requests/UpdateServiceAreaRequest.php +1 -23
- package/server/src/Http/Requests/UpdateServiceQuoteRequest.php +1 -23
- package/server/src/Http/Requests/UpdateServiceRateRequest.php +1 -23
- package/server/src/Http/Requests/UpdateTrackingStatusRequest.php +1 -26
- package/server/src/Http/Resources/v1/DeletedResource.php +2 -9
- package/server/src/Http/Resources/v1/Entity.php +47 -44
- package/server/src/Http/Resources/v1/Order.php +1 -1
- package/server/src/Http/Resources/v1/ServiceArea.php +2 -2
- package/server/src/Http/Resources/v1/Vehicle.php +1 -3
- package/server/src/Http/Resources/v1/Zone.php +2 -4
- package/server/src/Models/Entity.php +99 -3
- package/server/src/Models/Order.php +75 -7
- package/server/src/Models/Payload.php +104 -33
- package/server/src/Models/Place.php +56 -17
- package/server/src/Models/ServiceArea.php +285 -18
- package/server/src/Models/ServiceRate.php +10 -6
- package/server/src/Models/TrackingNumber.php +18 -24
- package/server/src/Models/TrackingStatus.php +2 -6
- package/server/src/Models/Vehicle.php +2 -2
- package/server/src/Models/Waypoint.php +0 -10
- package/server/src/Models/Zone.php +132 -5
- package/server/src/Support/Flow.php +17 -3
- package/server/src/Support/Utils.php +143 -9
- package/server/src/routes.php +4 -3
- package/addon/helpers/extract-coordinates.js +0 -6
- package/addon/utils/extract-coordinates.js +0 -1
- package/app/helpers/extract-coordinates.js +0 -1
- package/app/utils/extract-coordinates.js +0 -1
|
@@ -297,7 +297,7 @@ export default class LiveMapComponent extends Component {
|
|
|
297
297
|
*/
|
|
298
298
|
@action setupComponent() {
|
|
299
299
|
// trigger that initial coordinates have been set
|
|
300
|
-
this.universe.trigger('
|
|
300
|
+
this.universe.trigger('fleet-ops.live-map.loaded', this);
|
|
301
301
|
|
|
302
302
|
// set initial coordinates
|
|
303
303
|
this.setInitialCoordinates();
|
|
@@ -363,7 +363,7 @@ export default class LiveMapComponent extends Component {
|
|
|
363
363
|
|
|
364
364
|
/**
|
|
365
365
|
* Marks the LiveMapComponent as ready by setting the "isReady" property and triggering
|
|
366
|
-
* the "onReady" action and a "fleetops.
|
|
366
|
+
* the "onReady" action and a "fleetops.live-map.ready" event.
|
|
367
367
|
*
|
|
368
368
|
* @memberof LiveMapComponent
|
|
369
369
|
* @function
|
|
@@ -371,7 +371,7 @@ export default class LiveMapComponent extends Component {
|
|
|
371
371
|
ready() {
|
|
372
372
|
this.isReady = true;
|
|
373
373
|
this.triggerAction('onReady');
|
|
374
|
-
this.universe.trigger('
|
|
374
|
+
this.universe.trigger('fleet-ops.live-map.ready', this);
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
/**
|
|
@@ -396,7 +396,7 @@ export default class LiveMapComponent extends Component {
|
|
|
396
396
|
this.isReady = true;
|
|
397
397
|
|
|
398
398
|
// trigger that initial coordinates is set to livemap component
|
|
399
|
-
this.universe.trigger('
|
|
399
|
+
this.universe.trigger('fleet-ops.live-map.has_coordinates', { latitude: this.latitude, longitude: this.longitude });
|
|
400
400
|
|
|
401
401
|
return [this.latitude, this.longitude];
|
|
402
402
|
}
|
|
@@ -413,7 +413,7 @@ export default class LiveMapComponent extends Component {
|
|
|
413
413
|
this.isReady = true;
|
|
414
414
|
|
|
415
415
|
// trigger that initial coordinates is set to livemap component
|
|
416
|
-
this.universe.trigger('
|
|
416
|
+
this.universe.trigger('fleet-ops.live-map.has_coordinates', { latitude: this.latitude, longitude: this.longitude });
|
|
417
417
|
|
|
418
418
|
return [this.latitude, this.longitude];
|
|
419
419
|
}
|
|
@@ -425,7 +425,7 @@ export default class LiveMapComponent extends Component {
|
|
|
425
425
|
* Sets up the LiveMap component and the Leaflet map instance.
|
|
426
426
|
*
|
|
427
427
|
* This function initializes the LiveMap component, associates it with the Leaflet map instance,
|
|
428
|
-
* triggers the "fleetops.
|
|
428
|
+
* triggers the "fleetops.live-map.leaflet_ready" event, and performs additional setup tasks like
|
|
429
429
|
* configuring context menus, hiding draw controls, and associating the map with the "serviceAreas"
|
|
430
430
|
* service. It also triggers the "onLoad" action with the provided event and target.
|
|
431
431
|
*
|
|
@@ -443,13 +443,13 @@ export default class LiveMapComponent extends Component {
|
|
|
443
443
|
this.leafletMap = target;
|
|
444
444
|
|
|
445
445
|
// trigger liveMap ready through universe
|
|
446
|
-
this.universe.trigger('
|
|
446
|
+
this.universe.trigger('fleet-ops.live-map.leaflet_ready', event, target);
|
|
447
447
|
|
|
448
448
|
// make fleetops map globally available on the window
|
|
449
449
|
window.FleetOpsLeafletMap = target;
|
|
450
450
|
|
|
451
451
|
// store this component to universe
|
|
452
|
-
this.universe.set('
|
|
452
|
+
this.universe.set('component:fleet-ops:live-map', this);
|
|
453
453
|
|
|
454
454
|
// setup context menu
|
|
455
455
|
this.createMapContextMenu(target);
|
|
@@ -1065,7 +1065,16 @@ export default class LiveMapComponent extends Component {
|
|
|
1065
1065
|
*/
|
|
1066
1066
|
@action onDriverClicked(driver) {
|
|
1067
1067
|
this.contextPanel.clear();
|
|
1068
|
-
this.contextPanel.focus(driver
|
|
1068
|
+
this.contextPanel.focus(driver, 'viewing', {
|
|
1069
|
+
args: {
|
|
1070
|
+
width: '450px',
|
|
1071
|
+
onOpen: () => {
|
|
1072
|
+
this.leafletMap.once('moveend', () => {
|
|
1073
|
+
this.leafletMap.panBy([200, 0]);
|
|
1074
|
+
});
|
|
1075
|
+
},
|
|
1076
|
+
},
|
|
1077
|
+
});
|
|
1069
1078
|
}
|
|
1070
1079
|
|
|
1071
1080
|
/**
|
|
@@ -1113,7 +1122,16 @@ export default class LiveMapComponent extends Component {
|
|
|
1113
1122
|
*/
|
|
1114
1123
|
@action onVehicleClicked(vehicle) {
|
|
1115
1124
|
this.contextPanel.clear();
|
|
1116
|
-
this.contextPanel.focus(vehicle
|
|
1125
|
+
this.contextPanel.focus(vehicle, 'viewing', {
|
|
1126
|
+
args: {
|
|
1127
|
+
width: '450px',
|
|
1128
|
+
onOpen: () => {
|
|
1129
|
+
this.leafletMap.once('moveend', () => {
|
|
1130
|
+
this.leafletMap.panBy([200, 0]);
|
|
1131
|
+
});
|
|
1132
|
+
},
|
|
1133
|
+
},
|
|
1134
|
+
});
|
|
1117
1135
|
}
|
|
1118
1136
|
|
|
1119
1137
|
/**
|
|
@@ -1910,7 +1928,6 @@ export default class LiveMapComponent extends Component {
|
|
|
1910
1928
|
}
|
|
1911
1929
|
|
|
1912
1930
|
// from the `get-active-order-coordinates` the responded coordinates will always be [longitude, latitude]
|
|
1913
|
-
// const [latitude, longitude] = extractCoordinates(coordinates.firstObject.coordinates);
|
|
1914
1931
|
const validCoordinates = coordinates.filter((point) => point.cordinates[0] !== 0);
|
|
1915
1932
|
const [longitude, latitude] = getWithDefault(validCoordinates, '0.coordiantes', [0, 0]);
|
|
1916
1933
|
|
|
@@ -2,8 +2,10 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { inject as service } from '@ember/service';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
|
+
import { later } from '@ember/runloop';
|
|
5
6
|
import { classify } from '@ember/string';
|
|
6
7
|
import { calculateInPlacePosition } from 'ember-basic-dropdown/utils/calculate-position';
|
|
8
|
+
import { task } from 'ember-concurrency-decorators';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* @class MapContainerToolbarZonesPanelComponent
|
|
@@ -66,10 +68,18 @@ export default class MapContainerToolbarZonesPanelComponent extends Component {
|
|
|
66
68
|
*/
|
|
67
69
|
constructor() {
|
|
68
70
|
super(...arguments);
|
|
71
|
+
|
|
69
72
|
this.map = this.args.map;
|
|
70
73
|
this.liveMap = this.args.liveMap;
|
|
71
|
-
this.fetchServiceAreas();
|
|
72
74
|
this.serviceAreas.setMapInstance(this.args.map);
|
|
75
|
+
|
|
76
|
+
later(
|
|
77
|
+
this,
|
|
78
|
+
() => {
|
|
79
|
+
this.fetchServiceAreas.perform();
|
|
80
|
+
},
|
|
81
|
+
100
|
|
82
|
+
);
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
/**
|
|
@@ -115,21 +125,14 @@ export default class MapContainerToolbarZonesPanelComponent extends Component {
|
|
|
115
125
|
* Fetch service areas and update state.
|
|
116
126
|
* @memberof MapContainerToolbarZonesPanelComponent
|
|
117
127
|
*/
|
|
118
|
-
fetchServiceAreas() {
|
|
119
|
-
this.isLoading = true;
|
|
120
|
-
|
|
128
|
+
@task *fetchServiceAreas() {
|
|
121
129
|
if (this.appCache.has('serviceAreas')) {
|
|
122
130
|
this.serviceAreaRecords = this.appCache.getEmberData('serviceAreas', 'service-area');
|
|
123
131
|
}
|
|
124
132
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.appCache.setEmberData('serviceAreas', serviceAreaRecords);
|
|
130
|
-
})
|
|
131
|
-
.finally(() => {
|
|
132
|
-
this.isLoading = false;
|
|
133
|
-
});
|
|
133
|
+
const serviceAreas = yield this.store.query('service-area', { with: ['zones'] });
|
|
134
|
+
|
|
135
|
+
this.serviceAreaRecords = serviceAreas;
|
|
136
|
+
this.appCache.setEmberData('serviceAreas', serviceAreas);
|
|
134
137
|
}
|
|
135
138
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<Overlay
|
|
2
2
|
@onLoad={{this.setOverlayContext}}
|
|
3
|
+
@onOpen={{this.onOpen}}
|
|
4
|
+
@onClose={{this.onClose}}
|
|
5
|
+
@onToggle={{this.onToggle}}
|
|
3
6
|
@position="right"
|
|
4
7
|
@noBackdrop={{true}}
|
|
5
8
|
@fullHeight={{true}}
|
|
6
9
|
@isResizeble={{or this.isResizable @isResizable}}
|
|
7
|
-
@width={{or this.width @width "
|
|
10
|
+
@width={{or this.width @width "570px"}}
|
|
8
11
|
>
|
|
9
12
|
<Overlay::Header
|
|
10
13
|
@title={{if this.place.public_id this.place.name "New Place"}}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<Overlay
|
|
2
2
|
@onLoad={{this.setOverlayContext}}
|
|
3
|
+
@onOpen={{this.onOpen}}
|
|
4
|
+
@onClose={{this.onClose}}
|
|
5
|
+
@onToggle={{this.onToggle}}
|
|
3
6
|
@position="right"
|
|
4
7
|
@noBackdrop={{true}}
|
|
5
8
|
@fullHeight={{true}}
|
|
6
9
|
@isResizable={{or this.isResizable @isResizable}}
|
|
7
|
-
@width={{or this.width @width "
|
|
10
|
+
@width={{or this.width @width "570px"}}
|
|
8
11
|
>
|
|
9
12
|
<Overlay::Header @title={{this.place.name}} @status={{this.place.public_id}} @hideStatusDot={{true}} @createdAt={{this.place.createdAt}}>
|
|
10
13
|
<Button @type="default" @icon="pen" @helpText="Edit place" @onClick={{this.onEdit}} @wrapperClass="mr-2" />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<Overlay @onLoad={{this.onLoad}} @isOpen={{@isOpen}} @position="right" @noBackdrop={{true}} @fullHeight={{true}} @isResizable={{true}} @isMaximizable={{true}} @isMinimizable={{true}} @width="
|
|
1
|
+
<Overlay @onLoad={{this.onLoad}} @isOpen={{@isOpen}} @position="right" @noBackdrop={{true}} @fullHeight={{true}} @isResizable={{true}} @isMaximizable={{true}} @isMinimizable={{true}} @width="570px" as |overlay|>
|
|
2
2
|
<Overlay::Header @overlay={{overlay}} @title="FleetOps Settings" @onPressCancel={{@onPressCancel}}>
|
|
3
3
|
<Button @icon="save" @type="primary" @text={{if (media 'isMobile') "" "Save Changes"}} @onClick={{this.saveSettings}} @isLoading={{this.isSaving}} @disabled={{or this.isLoading this.isSaving}} />
|
|
4
4
|
</Overlay::Header>
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<Overlay
|
|
2
2
|
@onLoad={{this.setOverlayContext}}
|
|
3
|
+
@onOpen={{this.onOpen}}
|
|
4
|
+
@onClose={{this.onClose}}
|
|
5
|
+
@onToggle={{this.onToggle}}
|
|
3
6
|
@position="right"
|
|
4
7
|
@noBackdrop={{true}}
|
|
5
8
|
@fullHeight={{true}}
|
|
6
9
|
@isResizeble={{or this.isResizable @isResizable}}
|
|
7
|
-
@width={{or this.width @width "
|
|
10
|
+
@width={{or this.width @width "570px"}}
|
|
8
11
|
>
|
|
9
12
|
<Overlay::Header @hideLeftSection={{true}} @actionsWrapperClass="flex-1 flex-col py-3" class="h-auto-i min-h-[127px]">
|
|
10
13
|
<div class="flex flex-row items-center justify-between w-full mb-4">
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<Overlay
|
|
2
2
|
@onLoad={{this.setOverlayContext}}
|
|
3
|
+
@onOpen={{this.onOpen}}
|
|
4
|
+
@onClose={{this.onClose}}
|
|
5
|
+
@onToggle={{this.onToggle}}
|
|
3
6
|
@position="right"
|
|
4
7
|
@noBackdrop={{true}}
|
|
5
8
|
@fullHeight={{true}}
|
|
6
9
|
@isResizable={{or this.isResizable @isResizable}}
|
|
7
|
-
@width={{or this.width @width "
|
|
10
|
+
@width={{or this.width @width "570px"}}
|
|
8
11
|
>
|
|
9
12
|
<Overlay::Header @hideLeftSection={{true}} @actionsWrapperClass="flex-1 flex-col py-3" class="h-auto-i min-h-[127px]">
|
|
10
13
|
<div class="flex flex-row items-center justify-between w-full mb-4">
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<Overlay
|
|
2
2
|
@onLoad={{this.setOverlayContext}}
|
|
3
|
+
@onOpen={{this.onOpen}}
|
|
4
|
+
@onClose={{this.onClose}}
|
|
5
|
+
@onToggle={{this.onToggle}}
|
|
3
6
|
@position="right"
|
|
4
7
|
@noBackdrop={{true}}
|
|
5
8
|
@fullHeight={{true}}
|
|
6
9
|
@isResizeble={{or this.isResizable @isResizable}}
|
|
7
|
-
@width={{or this.width @width "
|
|
10
|
+
@width={{or this.width @width "570px"}}
|
|
8
11
|
>
|
|
9
12
|
<Overlay::Header @hideLeftSection={{true}} @actionsWrapperClass="flex-1 flex-col py-3" class="h-auto-i">
|
|
10
13
|
<div class="flex flex-row items-center justify-between w-full mb-4">
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<Overlay
|
|
2
2
|
@onLoad={{this.setOverlayContext}}
|
|
3
|
+
@onOpen={{this.onOpen}}
|
|
4
|
+
@onClose={{this.onClose}}
|
|
5
|
+
@onToggle={{this.onToggle}}
|
|
3
6
|
@position="right"
|
|
4
7
|
@noBackdrop={{true}}
|
|
5
8
|
@fullHeight={{true}}
|
|
6
9
|
@isResizable={{or this.isResizable @isResizable}}
|
|
7
|
-
@width={{or this.width @width "
|
|
10
|
+
@width={{or this.width @width "570px"}}
|
|
8
11
|
>
|
|
9
12
|
<Overlay::Header @hideLeftSection={{true}} @actionsWrapperClass="flex-1 flex-col py-3" class="h-auto-i">
|
|
10
13
|
<div class="flex flex-row items-center justify-between w-full mb-4">
|
|
@@ -6,8 +6,6 @@ import { isBlank } from '@ember/utils';
|
|
|
6
6
|
import { equal } from '@ember/object/computed';
|
|
7
7
|
import { timeout } from 'ember-concurrency';
|
|
8
8
|
import { task } from 'ember-concurrency-decorators';
|
|
9
|
-
import extractCoordinates from '@fleetbase/ember-core/utils/extract-coordinates';
|
|
10
|
-
import leafletIcon from '@fleetbase/ember-core/utils/leaflet-icon';
|
|
11
9
|
|
|
12
10
|
export default class ManagementDriversIndexController extends BaseController {
|
|
13
11
|
/**
|
|
@@ -18,18 +16,18 @@ export default class ManagementDriversIndexController extends BaseController {
|
|
|
18
16
|
@service notifications;
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
|
-
* Inject the `
|
|
19
|
+
* Inject the `crud` service
|
|
22
20
|
*
|
|
23
21
|
* @var {Service}
|
|
24
22
|
*/
|
|
25
|
-
@service
|
|
23
|
+
@service crud;
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
|
-
* Inject the `
|
|
26
|
+
* Inject the `driverActions` service
|
|
29
27
|
*
|
|
30
28
|
* @var {Service}
|
|
31
29
|
*/
|
|
32
|
-
@service
|
|
30
|
+
@service driverActions;
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Inject the `store` service
|
|
@@ -412,7 +410,7 @@ export default class ManagementDriversIndexController extends BaseController {
|
|
|
412
410
|
},
|
|
413
411
|
{
|
|
414
412
|
label: 'Locate driver on map...',
|
|
415
|
-
fn: this.
|
|
413
|
+
fn: this.locateDriver,
|
|
416
414
|
},
|
|
417
415
|
{
|
|
418
416
|
separator: true,
|
|
@@ -539,7 +537,7 @@ export default class ManagementDriversIndexController extends BaseController {
|
|
|
539
537
|
* @void
|
|
540
538
|
*/
|
|
541
539
|
@action deleteDriver(driver, options = {}) {
|
|
542
|
-
this.
|
|
540
|
+
this.driverActions.delete(driver, {
|
|
543
541
|
onSuccess: () => {
|
|
544
542
|
return this.hostRouter.refresh();
|
|
545
543
|
},
|
|
@@ -555,44 +553,7 @@ export default class ManagementDriversIndexController extends BaseController {
|
|
|
555
553
|
* @void
|
|
556
554
|
*/
|
|
557
555
|
@action assignOrder(driver, options = {}) {
|
|
558
|
-
this.
|
|
559
|
-
title: `Assign Order to this Driver`,
|
|
560
|
-
acceptButtonText: 'Assign Order',
|
|
561
|
-
acceptButtonIcon: 'check',
|
|
562
|
-
acceptButtonIconPrefix: 'fas',
|
|
563
|
-
acceptButtonDisabled: true,
|
|
564
|
-
hideDeclineButton: true,
|
|
565
|
-
selectedOrder: null,
|
|
566
|
-
selectOrder: (order) => {
|
|
567
|
-
this.modalsManager.setOption('selectedOrder', order);
|
|
568
|
-
this.modalsManager.setOption('acceptButtonDisabled', false);
|
|
569
|
-
},
|
|
570
|
-
driver,
|
|
571
|
-
confirm: (modal) => {
|
|
572
|
-
const selectedOrder = modal.getOption('selectedOrder');
|
|
573
|
-
|
|
574
|
-
if (!selectedOrder) {
|
|
575
|
-
this.notifications.warning('No order selected!');
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
modal.startLoading();
|
|
580
|
-
|
|
581
|
-
driver.set('current_job_uuid', selectedOrder.id);
|
|
582
|
-
|
|
583
|
-
return driver
|
|
584
|
-
.save()
|
|
585
|
-
.then(() => {
|
|
586
|
-
this.notifications.success(`${driver.name} assigned to order.`);
|
|
587
|
-
})
|
|
588
|
-
.catch((error) => {
|
|
589
|
-
driver.rollbackAttributes();
|
|
590
|
-
modal.stopLoading();
|
|
591
|
-
this.notifications.serverError(error);
|
|
592
|
-
});
|
|
593
|
-
},
|
|
594
|
-
...options,
|
|
595
|
-
});
|
|
556
|
+
this.driverActions.assignOrder(driver, options);
|
|
596
557
|
}
|
|
597
558
|
|
|
598
559
|
/**
|
|
@@ -603,29 +564,7 @@ export default class ManagementDriversIndexController extends BaseController {
|
|
|
603
564
|
* @void
|
|
604
565
|
*/
|
|
605
566
|
@action assignVehicle(driver, options = {}) {
|
|
606
|
-
this.
|
|
607
|
-
title: `Assign Vehicle to this Driver`,
|
|
608
|
-
acceptButtonText: 'Confirm & Create',
|
|
609
|
-
acceptButtonIcon: 'check',
|
|
610
|
-
acceptButtonIconPrefix: 'fas',
|
|
611
|
-
hideDeclineButton: true,
|
|
612
|
-
driver,
|
|
613
|
-
confirm: (modal) => {
|
|
614
|
-
modal.startLoading();
|
|
615
|
-
|
|
616
|
-
return driver
|
|
617
|
-
.save()
|
|
618
|
-
.then((driver) => {
|
|
619
|
-
this.notifications.success(`${driver.name} assigned to vehicle.`);
|
|
620
|
-
})
|
|
621
|
-
.catch((error) => {
|
|
622
|
-
driver.rollbackAttributes();
|
|
623
|
-
modal.stopLoading();
|
|
624
|
-
this.notifications.serverError(error);
|
|
625
|
-
});
|
|
626
|
-
},
|
|
627
|
-
...options,
|
|
628
|
-
});
|
|
567
|
+
this.driverActions.assignVehicle(driver, options);
|
|
629
568
|
}
|
|
630
569
|
|
|
631
570
|
/**
|
|
@@ -634,26 +573,7 @@ export default class ManagementDriversIndexController extends BaseController {
|
|
|
634
573
|
* @param {DriverModel} driver
|
|
635
574
|
* @void
|
|
636
575
|
*/
|
|
637
|
-
@action
|
|
638
|
-
|
|
639
|
-
const [latitude, longitude] = extractCoordinates(location.coordinates);
|
|
640
|
-
|
|
641
|
-
this.modalsManager.show('modals/point-map', {
|
|
642
|
-
title: `Location of ${driver.name}`,
|
|
643
|
-
acceptButtonText: 'Done',
|
|
644
|
-
acceptButtonIcon: 'check',
|
|
645
|
-
acceptButtonIconPrefix: 'fas',
|
|
646
|
-
modalClass: 'modal-lg',
|
|
647
|
-
hideDeclineButton: true,
|
|
648
|
-
latitude,
|
|
649
|
-
longitude,
|
|
650
|
-
location,
|
|
651
|
-
popupText: `${driver.name} (${driver.public_id})`,
|
|
652
|
-
icon: leafletIcon({
|
|
653
|
-
iconUrl: driver?.vehicle_avatar,
|
|
654
|
-
iconSize: [40, 40],
|
|
655
|
-
}),
|
|
656
|
-
...options,
|
|
657
|
-
});
|
|
576
|
+
@action locateDriver(driver, options = {}) {
|
|
577
|
+
this.driverActions.locate(driver, options);
|
|
658
578
|
}
|
|
659
579
|
}
|
|
@@ -22,11 +22,11 @@ export default class ManagementVehiclesIndexController extends BaseController {
|
|
|
22
22
|
@service notifications;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Inject the `
|
|
25
|
+
* Inject the `vehicleActions` service
|
|
26
26
|
*
|
|
27
27
|
* @var {Service}
|
|
28
28
|
*/
|
|
29
|
-
@service
|
|
29
|
+
@service vehicleActions;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Inject the `store` service
|
|
@@ -386,13 +386,13 @@ export default class ManagementVehiclesIndexController extends BaseController {
|
|
|
386
386
|
label: 'Edit vehicle...',
|
|
387
387
|
fn: this.editVehicle,
|
|
388
388
|
},
|
|
389
|
+
{
|
|
390
|
+
label: 'Locate vehicle...',
|
|
391
|
+
fn: this.locateVehicle,
|
|
392
|
+
},
|
|
389
393
|
{
|
|
390
394
|
separator: true,
|
|
391
395
|
},
|
|
392
|
-
// {
|
|
393
|
-
// label: 'Assign driver to vehicle...',
|
|
394
|
-
// fn: this.assignDriver,
|
|
395
|
-
// },
|
|
396
396
|
{
|
|
397
397
|
label: 'Delete vehicle...',
|
|
398
398
|
fn: this.deleteVehicle,
|
|
@@ -503,7 +503,7 @@ export default class ManagementVehiclesIndexController extends BaseController {
|
|
|
503
503
|
* @void
|
|
504
504
|
*/
|
|
505
505
|
@action deleteVehicle(vehicle, options = {}) {
|
|
506
|
-
this.
|
|
506
|
+
this.vehicleActions.delete(vehicle, {
|
|
507
507
|
onSuccess: () => {
|
|
508
508
|
return this.hostRouter.refresh();
|
|
509
509
|
},
|
|
@@ -522,23 +522,13 @@ export default class ManagementVehiclesIndexController extends BaseController {
|
|
|
522
522
|
@action assignDriver() {}
|
|
523
523
|
|
|
524
524
|
/**
|
|
525
|
-
* View a
|
|
525
|
+
* View a vehicle location on map
|
|
526
526
|
*
|
|
527
|
-
* @param {
|
|
527
|
+
* @param {VehicleModel} vehicle
|
|
528
528
|
* @param {Object} options
|
|
529
529
|
* @void
|
|
530
530
|
*/
|
|
531
|
-
@action
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
this.modalsManager.show('modals/point-map', {
|
|
535
|
-
title: `Location of ${place.name}`,
|
|
536
|
-
acceptButtonText: 'Done',
|
|
537
|
-
hideDeclineButton: true,
|
|
538
|
-
latitude,
|
|
539
|
-
longitude,
|
|
540
|
-
location: [latitude, longitude],
|
|
541
|
-
...options,
|
|
542
|
-
});
|
|
531
|
+
@action locateVehicle(vehicle, options = {}) {
|
|
532
|
+
this.vehicleActions.locate(vehicle, options);
|
|
543
533
|
}
|
|
544
534
|
}
|
|
@@ -13,7 +13,6 @@ import findClosestWaypoint from '@fleetbase/ember-core/utils/find-closest-waypoi
|
|
|
13
13
|
import isNotEmpty from '@fleetbase/ember-core/utils/is-not-empty';
|
|
14
14
|
import getRoutingHost from '@fleetbase/ember-core/utils/get-routing-host';
|
|
15
15
|
import groupBy from '@fleetbase/ember-core/utils/macros/group-by';
|
|
16
|
-
import extractCoordinates from '@fleetbase/ember-core/utils/extract-coordinates';
|
|
17
16
|
import getWithDefault from '@fleetbase/ember-core/utils/get-with-default';
|
|
18
17
|
|
|
19
18
|
L.Bounds.prototype.intersects = function (bounds) {
|
|
@@ -213,7 +212,7 @@ export default class OperationsOrdersIndexNewController extends BaseController {
|
|
|
213
212
|
return (
|
|
214
213
|
this.routePreviewArray
|
|
215
214
|
// .filter((place) => place.get('hasValidCoordinates'))
|
|
216
|
-
.map((place) => place.get('
|
|
215
|
+
.map((place) => place.get('latlng'))
|
|
217
216
|
);
|
|
218
217
|
}
|
|
219
218
|
|
|
@@ -580,7 +579,7 @@ export default class OperationsOrdersIndexNewController extends BaseController {
|
|
|
580
579
|
});
|
|
581
580
|
} else {
|
|
582
581
|
// setup interface when livemap is ready
|
|
583
|
-
this.universe.on('
|
|
582
|
+
this.universe.on('fleet-ops.live-map.ready', () => {
|
|
584
583
|
this.setupInterface();
|
|
585
584
|
});
|
|
586
585
|
}
|
|
@@ -749,7 +748,7 @@ export default class OperationsOrdersIndexNewController extends BaseController {
|
|
|
749
748
|
}
|
|
750
749
|
|
|
751
750
|
@action createCoordinatesFromRoutePlaceArray(array) {
|
|
752
|
-
return array.filter((place) => place.get('hasValidCoordinates')).map((place) => place.get('
|
|
751
|
+
return array.filter((place) => place.get('hasValidCoordinates')).map((place) => place.get('latlng'));
|
|
753
752
|
}
|
|
754
753
|
|
|
755
754
|
@action previewDraftOrderRoute(payload, waypoints, isMultipleDropoffOrder = false) {
|
|
@@ -875,7 +874,8 @@ export default class OperationsOrdersIndexNewController extends BaseController {
|
|
|
875
874
|
const waypointModel = findClosestWaypoint(optimizedWaypointLatitude, optimizedWaypointLongitude, this.waypoints);
|
|
876
875
|
// eslint-disable-next-line no-undef
|
|
877
876
|
// const optimizedWaypointMarker = new L.Marker(optimizedWaypoint.location.reverse()).addTo(leafletMap);
|
|
878
|
-
const
|
|
877
|
+
const [longitude, latitude] = getWithDefault(optimizedWaypoint.location, 'coordiantes', [0, 0]);
|
|
878
|
+
const optimizedWaypointMarker = new L.Marker([latitude, longitude]).addTo(leafletMap);
|
|
879
879
|
|
|
880
880
|
sortedWaypoints.pushObject(waypointModel);
|
|
881
881
|
optimizedRouteMarkers.pushObject(optimizedWaypointMarker);
|
|
@@ -19,13 +19,6 @@ export default class OperationsOrdersIndexViewController extends BaseController
|
|
|
19
19
|
*/
|
|
20
20
|
@controller('operations.orders.index') ordersController;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Inject the `operations.orders.index` controller
|
|
24
|
-
*
|
|
25
|
-
* @var {Controller}
|
|
26
|
-
*/
|
|
27
|
-
@controller('management.places.index') placesController;
|
|
28
|
-
|
|
29
22
|
/**
|
|
30
23
|
* Inject the `management.contacts.index` controller
|
|
31
24
|
*
|
|
@@ -248,14 +241,14 @@ export default class OperationsOrdersIndexViewController extends BaseController
|
|
|
248
241
|
};
|
|
249
242
|
|
|
250
243
|
// re-display order routes when livemap has coordinates
|
|
251
|
-
this.universe.on('
|
|
244
|
+
this.universe.on('fleet-ops.live-map.has_coordinates', this, displayOrderRoute);
|
|
252
245
|
|
|
253
246
|
// when transitioning away kill event listener
|
|
254
247
|
this.hostRouter.on('routeWillChange', () => {
|
|
255
|
-
const isListening = this.universe.has('
|
|
248
|
+
const isListening = this.universe.has('fleet-ops.live-map.has_coordinates');
|
|
256
249
|
|
|
257
250
|
if (isListening) {
|
|
258
|
-
this.universe.off('
|
|
251
|
+
this.universe.off('fleet-ops.live-map.has_coordinates', this, displayOrderRoute);
|
|
259
252
|
}
|
|
260
253
|
});
|
|
261
254
|
|
|
@@ -472,9 +465,12 @@ export default class OperationsOrdersIndexViewController extends BaseController
|
|
|
472
465
|
isOptimizingRoute: false,
|
|
473
466
|
editPlace: async (place) => {
|
|
474
467
|
await this.modalsManager.done();
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
468
|
+
|
|
469
|
+
this.contextPanel.focus(place, 'editing', {
|
|
470
|
+
args: {
|
|
471
|
+
onClose: () => {
|
|
472
|
+
this.editOrderRoute(order);
|
|
473
|
+
},
|
|
478
474
|
},
|
|
479
475
|
});
|
|
480
476
|
},
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { helper } from '@ember/component/helper';
|
|
2
2
|
import { isArray } from '@ember/array';
|
|
3
|
-
import extractCoordinates from '../utils/extract-coordinates';
|
|
4
3
|
|
|
5
4
|
export default helper(function formatPoint([point]) {
|
|
5
|
+
// array assumes [latitude, longitude]
|
|
6
6
|
if (isArray(point)) {
|
|
7
7
|
return `(${point[0]}, ${point[1]})`;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
let [longitude, latitude] = [0, 0];
|
|
11
|
+
if (point && isArray(point.coordinates)) {
|
|
12
|
+
[longitude, latitude] = point.coordinates;
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
return `(${latitude}, ${longitude})`;
|
|
13
16
|
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { helper } from '@ember/component/helper';
|
|
2
|
-
import
|
|
2
|
+
import { isArray } from '@ember/array';
|
|
3
3
|
|
|
4
4
|
export default helper(function pointToCoordinates([point, format = 'array']) {
|
|
5
|
-
|
|
5
|
+
let [longitude, latitude] = [0, 0];
|
|
6
|
+
|
|
7
|
+
if (point && isArray(point.coordinates)) {
|
|
8
|
+
[longitude, latitude] = point.coordinates;
|
|
9
|
+
}
|
|
6
10
|
|
|
7
11
|
if (format === 'array') {
|
|
8
12
|
return [latitude, longitude];
|