@fleetbase/fleetops-engine 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/admin/visibility-controls.js +1 -0
- package/addon/components/layout/fleet-ops-sidebar.js +2 -1
- package/addon/components/live-map-drawer/driver-listing.hbs +6 -0
- package/addon/components/live-map-drawer/driver-listing.js +240 -0
- package/addon/components/live-map-drawer/place-listing.hbs +6 -0
- package/addon/components/live-map-drawer/place-listing.js +204 -0
- package/addon/components/live-map-drawer/vehicle-listing.hbs +6 -0
- package/addon/components/live-map-drawer/vehicle-listing.js +216 -0
- package/addon/components/live-map-drawer.hbs +17 -0
- package/addon/components/live-map-drawer.js +104 -0
- package/addon/components/live-map.hbs +5 -1
- package/addon/components/live-map.js +107 -15
- package/addon/components/map-container/toolbar.hbs +6 -0
- package/addon/components/modals/order-event.hbs +1 -1
- package/addon/components/order/schedule-card.hbs +4 -4
- package/addon/components/order/schedule-card.js +13 -6
- package/addon/components/place-panel/details.hbs +2 -2
- package/addon/controllers/operations/orders/index.js +29 -15
- package/addon/controllers/operations/scheduler/index.js +45 -30
- package/addon/routes/operations/scheduler/index.js +25 -0
- package/addon/styles/fleetops-engine.css +28 -0
- package/addon/templates/operations/orders/index.hbs +2 -2
- package/addon/templates/operations/scheduler/index.hbs +33 -9
- package/addon/utils/create-full-calendar-event-from-order.js +8 -0
- package/app/components/live-map-drawer/driver-listing.js +1 -0
- package/app/components/live-map-drawer/place-listing.js +1 -0
- package/app/components/live-map-drawer/vehicle-listing.js +1 -0
- package/app/components/live-map-drawer.js +1 -0
- package/app/utils/create-full-calendar-event-from-order.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +4 -4
- package/server/src/Models/FuelReport.php +1 -1
- package/server/src/Models/Order.php +22 -0
- package/server/src/Models/VehicleDevice.php +1 -1
- package/server/src/Models/VehicleDeviceEvent.php +1 -1
- package/server/src/Observers/FleetObserver.php +19 -0
- package/server/src/Providers/FleetOpsServiceProvider.php +1 -0
- package/addon/components/full-calendar/draggable.js +0 -1
- package/addon/components/full-calendar.js +0 -1
- package/app/components/full-calendar/draggable.js +0 -1
- package/app/components/full-calendar.js +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<Drawer @isMinimized={{true}} @notchEnabled={{true}} @onLoad={{this.setDrawerContext}}>
|
|
2
|
+
<div class="ui-tabs pt-4">
|
|
3
|
+
<nav>
|
|
4
|
+
{{#each this.tabs as |tab|}}
|
|
5
|
+
<a href="javascript:;" class="ui-tab {{if (eq this.tab.slug tab.slug) 'active' }}" {{on "click" (fn this.onTabChanged tab.slug)}}>
|
|
6
|
+
<FaIcon @icon={{tab.icon}} class="mr-1" />
|
|
7
|
+
<span>{{tab.title}}</span>
|
|
8
|
+
</a>
|
|
9
|
+
{{/each}}
|
|
10
|
+
</nav>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="tab-content tab-{{this.tab.slug}}">
|
|
13
|
+
{{#if this.drawer}}
|
|
14
|
+
{{component this.tab.component drivers=@drivers vehicles=@vehicles places=@places drawer=this.drawer liveMap=@liveMap tabOptions=this.tab options=this.tab.componentParams}}
|
|
15
|
+
{{/if}}
|
|
16
|
+
</div>
|
|
17
|
+
</Drawer>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { action } from '@ember/object';
|
|
4
|
+
import { inject as service } from '@ember/service';
|
|
5
|
+
import { isArray } from '@ember/array';
|
|
6
|
+
import contextComponentCallback from '../utils/context-component-callback';
|
|
7
|
+
import applyContextComponentArguments from '../utils/apply-context-component-arguments';
|
|
8
|
+
import LiveMapDrawerVehicleListingComponent from './live-map-drawer/vehicle-listing';
|
|
9
|
+
import LiveMapDrawerDriverListingComponent from './live-map-drawer/driver-listing';
|
|
10
|
+
import LiveMapDrawerPlaceListingComponent from './live-map-drawer/place-listing';
|
|
11
|
+
|
|
12
|
+
export default class LiveMapDrawerComponent extends Component {
|
|
13
|
+
/**
|
|
14
|
+
* Universe service for managing global data and settings.
|
|
15
|
+
*
|
|
16
|
+
* @type {Service}
|
|
17
|
+
*/
|
|
18
|
+
@service universe;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The current active tab.
|
|
22
|
+
*
|
|
23
|
+
* @type {Object}
|
|
24
|
+
* @tracked
|
|
25
|
+
*/
|
|
26
|
+
@tracked tab;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The drawer component context api.
|
|
30
|
+
*
|
|
31
|
+
* @type {Object}
|
|
32
|
+
* @tracked
|
|
33
|
+
*/
|
|
34
|
+
@tracked drawer;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the array of tabs available for the drawer.
|
|
38
|
+
*
|
|
39
|
+
* @type {Array}
|
|
40
|
+
*/
|
|
41
|
+
get tabs() {
|
|
42
|
+
const registeredTabs = this.universe.getMenuItemsFromRegistry('component:live-map-drawer');
|
|
43
|
+
const defaultTabs = [
|
|
44
|
+
this.universe._createMenuItem('Vehicles', null, { icon: 'car', component: LiveMapDrawerVehicleListingComponent }),
|
|
45
|
+
this.universe._createMenuItem('Drivers', null, { icon: 'id-card', component: LiveMapDrawerDriverListingComponent }),
|
|
46
|
+
this.universe._createMenuItem('Places', null, { icon: 'building', component: LiveMapDrawerPlaceListingComponent }),
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
if (isArray(registeredTabs)) {
|
|
50
|
+
return [...defaultTabs, ...registeredTabs];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return defaultTabs;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Initializes the vehicle panel component.
|
|
58
|
+
*/
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.tab = this.getTabUsingSlug(this.args.tab);
|
|
62
|
+
applyContextComponentArguments(this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Sets the drawer component context api.
|
|
67
|
+
*
|
|
68
|
+
* @param {Object} drawerApi
|
|
69
|
+
* @memberof LiveMapDrawerComponent
|
|
70
|
+
*/
|
|
71
|
+
@action setDrawerContext(drawerApi) {
|
|
72
|
+
this.drawer = drawerApi;
|
|
73
|
+
|
|
74
|
+
if (typeof this.args.onDrawerReady === 'function') {
|
|
75
|
+
this.args.onDrawerReady(...arguments);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Handles changing the active tab.
|
|
81
|
+
*
|
|
82
|
+
* @method
|
|
83
|
+
* @param {String} tab - The new tab to switch to.
|
|
84
|
+
* @action
|
|
85
|
+
*/
|
|
86
|
+
@action onTabChanged(tab) {
|
|
87
|
+
this.tab = this.getTabUsingSlug(tab);
|
|
88
|
+
contextComponentCallback(this, 'onTabChanged', tab);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Finds and returns a tab based on its slug.
|
|
93
|
+
*
|
|
94
|
+
* @param {String} tabSlug - The slug of the tab.
|
|
95
|
+
* @returns {Object|null} The found tab or null.
|
|
96
|
+
*/
|
|
97
|
+
getTabUsingSlug(tabSlug) {
|
|
98
|
+
if (tabSlug) {
|
|
99
|
+
return this.tabs.find(({ slug }) => slug === tabSlug);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return this.tabs[0];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -152,6 +152,13 @@ export default class LiveMapComponent extends Component {
|
|
|
152
152
|
*/
|
|
153
153
|
@tracked isReady = false;
|
|
154
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Indicates if all the data requested has completed loading.
|
|
157
|
+
* @type {boolean}
|
|
158
|
+
* @memberof LiveMapComponent
|
|
159
|
+
*/
|
|
160
|
+
@tracked isDataLoaded = false;
|
|
161
|
+
|
|
155
162
|
/**
|
|
156
163
|
* Controls for visibility.
|
|
157
164
|
* @type {Object}
|
|
@@ -188,6 +195,13 @@ export default class LiveMapComponent extends Component {
|
|
|
188
195
|
*/
|
|
189
196
|
@tracked leafletMap;
|
|
190
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The Drawer component context API.
|
|
200
|
+
* @type {Object}
|
|
201
|
+
* @memberof LiveMapComponent
|
|
202
|
+
*/
|
|
203
|
+
@tracked drawer;
|
|
204
|
+
|
|
191
205
|
/**
|
|
192
206
|
* The map's zoom level.
|
|
193
207
|
* @type {number}
|
|
@@ -288,21 +302,63 @@ export default class LiveMapComponent extends Component {
|
|
|
288
302
|
// set initial coordinates
|
|
289
303
|
this.setInitialCoordinates();
|
|
290
304
|
|
|
291
|
-
// load
|
|
292
|
-
this.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
// load data and complete setup
|
|
306
|
+
this.completeSetup([
|
|
307
|
+
this.fetchLiveData('routes'),
|
|
308
|
+
this.fetchLiveData('vehicles', {
|
|
309
|
+
onLoaded: (vehicles) => {
|
|
310
|
+
this.watchMovingObjects('vehicles', vehicles);
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
this.fetchLiveData('drivers', {
|
|
314
|
+
onLoaded: (drivers) => {
|
|
315
|
+
this.watchMovingObjects('drivers', drivers);
|
|
316
|
+
},
|
|
317
|
+
}),
|
|
318
|
+
this.fetchLiveData('places'),
|
|
319
|
+
]);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Completes the setup of the component by processing an array of live data promises.
|
|
324
|
+
* It waits for all the provided promises to settle and then sets a flag indicating
|
|
325
|
+
* that data fetching is complete. It ensures that any final listening and readiness
|
|
326
|
+
* processes are invoked at the end of the setup process.
|
|
327
|
+
*
|
|
328
|
+
* @param {Promise[]} liveDataPromises - An array of promises that fetch live data.
|
|
329
|
+
* @returns {Promise} A promise that resolves when all data-fetching promises have settled.
|
|
330
|
+
*/
|
|
331
|
+
completeSetup(liveDataPromises) {
|
|
332
|
+
return allSettled(liveDataPromises)
|
|
333
|
+
.then(() => {
|
|
334
|
+
this.isDataLoaded = true;
|
|
335
|
+
})
|
|
336
|
+
.finally(() => {
|
|
337
|
+
this.listen();
|
|
338
|
+
this.ready();
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Reloads the live map data.
|
|
344
|
+
*
|
|
345
|
+
* @memberof LiveMapComponent
|
|
346
|
+
*/
|
|
347
|
+
reload() {
|
|
348
|
+
this.completeSetup([
|
|
349
|
+
this.fetchLiveData('routes'),
|
|
350
|
+
this.fetchLiveData('vehicles', {
|
|
351
|
+
onLoaded: (vehicles) => {
|
|
352
|
+
this.watchMovingObjects('vehicles', vehicles);
|
|
353
|
+
},
|
|
354
|
+
}),
|
|
355
|
+
this.fetchLiveData('drivers', {
|
|
356
|
+
onLoaded: (drivers) => {
|
|
357
|
+
this.watchMovingObjects('drivers', drivers);
|
|
358
|
+
},
|
|
359
|
+
}),
|
|
360
|
+
this.fetchLiveData('places'),
|
|
361
|
+
]);
|
|
306
362
|
}
|
|
307
363
|
|
|
308
364
|
/**
|
|
@@ -463,6 +519,11 @@ export default class LiveMapComponent extends Component {
|
|
|
463
519
|
|
|
464
520
|
return data;
|
|
465
521
|
})
|
|
522
|
+
.catch((error) => {
|
|
523
|
+
if (typeof options.onFailure === 'function') {
|
|
524
|
+
options.onFailure(error);
|
|
525
|
+
}
|
|
526
|
+
})
|
|
466
527
|
.finally(() => {
|
|
467
528
|
this.isLoading = false;
|
|
468
529
|
});
|
|
@@ -838,6 +899,20 @@ export default class LiveMapComponent extends Component {
|
|
|
838
899
|
return null;
|
|
839
900
|
}
|
|
840
901
|
|
|
902
|
+
/**
|
|
903
|
+
* Sets the drawer component context api.
|
|
904
|
+
*
|
|
905
|
+
* @param {Object} drawerApi
|
|
906
|
+
* @memberof LiveMapComponent
|
|
907
|
+
*/
|
|
908
|
+
@action setDrawerContext(drawerApi) {
|
|
909
|
+
this.drawer = drawerApi;
|
|
910
|
+
|
|
911
|
+
if (typeof this.args.onDrawerReady === 'function') {
|
|
912
|
+
this.args.onDrawerReady(...arguments);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
841
916
|
/**
|
|
842
917
|
* Handle the 'drawstop' event.
|
|
843
918
|
*
|
|
@@ -1012,6 +1087,23 @@ export default class LiveMapComponent extends Component {
|
|
|
1012
1087
|
this.createVehicleContextMenu(vehicle, target);
|
|
1013
1088
|
}
|
|
1014
1089
|
|
|
1090
|
+
/**
|
|
1091
|
+
* Handle the addition of a place marker.
|
|
1092
|
+
*
|
|
1093
|
+
* @param {PlaceModel} place - The place object.
|
|
1094
|
+
* @param {Event} event - The event object associated with the addition.
|
|
1095
|
+
* @memberof LiveMapComponent
|
|
1096
|
+
*/
|
|
1097
|
+
@action onPlaceAdded(place, event) {
|
|
1098
|
+
const { target } = event;
|
|
1099
|
+
|
|
1100
|
+
set(target, 'record_id', place.id);
|
|
1101
|
+
set(target, 'record_type', 'place');
|
|
1102
|
+
|
|
1103
|
+
// set the marker instance to the vehicle model
|
|
1104
|
+
set(place, '_marker', target);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1015
1107
|
/**
|
|
1016
1108
|
* Handle the click event of a vehicle marker.
|
|
1017
1109
|
*
|
|
@@ -58,5 +58,11 @@
|
|
|
58
58
|
<MapContainer::Toolbar::VisibilityControlPanel @dd={{dd}} @liveMap={{@liveMap}} @map={{@map}} />
|
|
59
59
|
</dd.Content>
|
|
60
60
|
</BasicDropdown>
|
|
61
|
+
<button type="button" id="map-toolbar-live-map-drawer-button" class="toolbar-button is-action mb-0i" {{on "click" (fn this.onAction "onPressLiveMapDrawerToggle")}}>
|
|
62
|
+
<FaIcon @icon="binoculars" />
|
|
63
|
+
<Attach::Tooltip @class="clean" @animation="scale" @placement="right">
|
|
64
|
+
<InputInfo @text="Scope" @iconClass="hidden" class="py-1 px-2 bg-gray-900 -mt-1" />
|
|
65
|
+
</Attach::Tooltip>
|
|
66
|
+
</button>
|
|
61
67
|
</div>
|
|
62
68
|
</MapContainer::ToolbarContainer>
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
|
-
<ScheduleCard class="border border-night-905" @itemClass="bg-green-600" @contentClass="bg-transparent-i py-3" @titleClass="hidden-i" @order={{@options.order}} />
|
|
16
|
+
<Order::ScheduleCard class="border border-night-905" @itemClass="bg-green-600" @contentClass="bg-transparent-i py-3" @titleClass="hidden-i" @order={{@options.order}} />
|
|
17
17
|
</div>
|
|
18
18
|
</Modal::Default>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class="order-schedule-card border border-gray-200 dark:border-gray-700"
|
|
1
|
+
<div class="order-schedule-card border border-gray-200 dark:border-gray-700" ...attributes>
|
|
2
2
|
<a href="javascript:;" class="{{@titleClass}} card-title border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900" {{on "click" (fn this.onTitleClick @order)}}>
|
|
3
3
|
<span>{{@order.public_id}}</span>
|
|
4
4
|
<div>
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
<FaIcon @icon="calendar" class="mr-2" />
|
|
12
12
|
<span class="font-semibold">Date scheduled</span>
|
|
13
13
|
</div>
|
|
14
|
-
<span>{{@order.scheduledAt}}</span>
|
|
14
|
+
<span class={{unless @order.scheduled_at "dark:text-gray-600 text-gray-400"}}>{{n-a @order.scheduledAt "Not Scheduled"}}</span>
|
|
15
15
|
</div>
|
|
16
16
|
<div class="flex items-center justify-between">
|
|
17
17
|
<div>
|
|
18
18
|
<FaIcon @icon="calendar" class="mr-2" />
|
|
19
19
|
<span class="font-semibold">Date created</span>
|
|
20
20
|
</div>
|
|
21
|
-
<span>{{@order.createdAtWithTime}}</span>
|
|
21
|
+
<span>{{n-a @order.createdAtWithTime}}</span>
|
|
22
22
|
</div>
|
|
23
23
|
<div class="flex items-center justify-between">
|
|
24
24
|
<div>
|
|
25
25
|
<FaIcon @icon="calendar" class="mr-2" />
|
|
26
26
|
<span class="font-semibold">Driver Assigned</span>
|
|
27
27
|
</div>
|
|
28
|
-
<span>{{@order.driver_assigned.name "
|
|
28
|
+
<span class={{unless @order.driver_assigned "dark:text-gray-600 text-gray-400"}}>{{n-a @order.driver_assigned.name "No Driver Assigned"}}</span>
|
|
29
29
|
</div>
|
|
30
30
|
<div class="z-20 relative">
|
|
31
31
|
<RouteList @order={{@order}} />
|
|
@@ -2,16 +2,23 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
|
|
4
4
|
export default class OrderScheduleCardComponent extends Component {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
constructor(owner, { order }) {
|
|
6
|
+
super(...arguments);
|
|
7
7
|
|
|
8
|
-
order
|
|
9
|
-
|
|
8
|
+
if (order && typeof order.loadDriver === 'function') {
|
|
9
|
+
order.loadDriver();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (order && typeof order.loadPayload === 'function') {
|
|
13
|
+
order.loadPayload();
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
|
|
12
17
|
@action onTitleClick(order) {
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
const { onTitleClick } = this.args;
|
|
19
|
+
|
|
20
|
+
if (typeof onTitleClick === 'function') {
|
|
21
|
+
onTitleClick(order);
|
|
15
22
|
}
|
|
16
23
|
}
|
|
17
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div class="p-4 space-y-4">
|
|
2
|
-
<ContentPanel @title="Map" @open={{
|
|
3
|
-
<LeafletMap class="w-full h-48 rounded-b-md shadow-md" @lat={{@place.latitude}} @lng={{@place.longitude}} @zoom={{17}} as |layers|>
|
|
2
|
+
<ContentPanel @title="Map" @open={{false}}>
|
|
3
|
+
<LeafletMap class="w-full h-48 rounded-b-md shadow-md" @lat={{@place.latitude}} @lng={{@place.longitude}} @zoom={{17}} @zoomControl={{false}} as |layers|>
|
|
4
4
|
<layers.tile @url="https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png" />
|
|
5
5
|
<layers.marker @id={{@place.id}} @icon={{icon iconUrl="/engines-dist/images/building-marker.png" iconSize=(array 16 16)}} @location={{point-to-coordinates @place.location}} @riseOnHover={{true}} @title={{@place.address}} @alt={{@place.address}} as |marker|>
|
|
6
6
|
<marker.popup>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Controller
|
|
1
|
+
import Controller from '@ember/controller';
|
|
2
2
|
import { inject as service } from '@ember/service';
|
|
3
3
|
import { tracked } from '@glimmer/tracking';
|
|
4
4
|
import { action } from '@ember/object';
|
|
@@ -9,20 +9,6 @@ import { timeout } from 'ember-concurrency';
|
|
|
9
9
|
import { task } from 'ember-concurrency-decorators';
|
|
10
10
|
|
|
11
11
|
export default class OperationsOrdersIndexController extends Controller {
|
|
12
|
-
/**
|
|
13
|
-
* Injection of the `ManagementDriversIndexController` controller
|
|
14
|
-
*
|
|
15
|
-
* @memberof OperationsOrdersIndexController
|
|
16
|
-
*/
|
|
17
|
-
@controller('management.drivers.index') driversController;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Injection of the `ManagementFleetIndexController` controller
|
|
21
|
-
*
|
|
22
|
-
* @memberof OperationsOrdersIndexController
|
|
23
|
-
*/
|
|
24
|
-
@controller('management.fleets.index') fleetController;
|
|
25
|
-
|
|
26
12
|
/**
|
|
27
13
|
* Inject the `currentUser` service
|
|
28
14
|
*
|
|
@@ -266,6 +252,13 @@ export default class OperationsOrdersIndexController extends Controller {
|
|
|
266
252
|
*/
|
|
267
253
|
@tracked leafletMap;
|
|
268
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Reference to the drawer context API.
|
|
257
|
+
*
|
|
258
|
+
* @type {Object}
|
|
259
|
+
*/
|
|
260
|
+
@tracked drawer;
|
|
261
|
+
|
|
269
262
|
/**
|
|
270
263
|
* Current layout type (e.g., 'map', 'table', 'kanban', 'analytics')
|
|
271
264
|
*
|
|
@@ -722,6 +715,27 @@ export default class OperationsOrdersIndexController extends Controller {
|
|
|
722
715
|
this.liveMap = liveMap;
|
|
723
716
|
}
|
|
724
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Sets the drawer component context api.
|
|
720
|
+
*
|
|
721
|
+
* @param {Object} drawerApi
|
|
722
|
+
* @memberof OperationsOrdersIndexController
|
|
723
|
+
*/
|
|
724
|
+
@action setDrawerContext(drawerApi) {
|
|
725
|
+
this.drawer = drawerApi;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Toggles the LiveMap drawer component.
|
|
730
|
+
*
|
|
731
|
+
* @memberof OperationsOrdersIndexController
|
|
732
|
+
*/
|
|
733
|
+
@action onPressLiveMapDrawerToggle() {
|
|
734
|
+
if (this.drawer) {
|
|
735
|
+
this.drawer.toggleMinimize();
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
725
739
|
/**
|
|
726
740
|
* Exports all orders.
|
|
727
741
|
* @action
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
import Controller from '@ember/controller';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
2
3
|
import { inject as service } from '@ember/service';
|
|
3
|
-
import {
|
|
4
|
+
import { action } from '@ember/object';
|
|
4
5
|
import { format, isValid as isValidDate } from 'date-fns';
|
|
6
|
+
import createFullCalendarEventFromOrder from '../../../utils/create-full-calendar-event-from-order';
|
|
5
7
|
|
|
6
8
|
export default class OperationsSchedulerIndexController extends Controller {
|
|
7
9
|
@service modalsManager;
|
|
8
10
|
@service notifications;
|
|
9
|
-
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@computed('scheduledOrders.@each.scheduled_at') get events() {
|
|
19
|
-
return this.scheduledOrders.map((order) => ({
|
|
20
|
-
id: order.id,
|
|
21
|
-
title: `${order.scheduledAtTime} - ${order.public_id}`,
|
|
22
|
-
start: order.scheduled_at,
|
|
23
|
-
allDay: true,
|
|
24
|
-
}));
|
|
11
|
+
@service store;
|
|
12
|
+
@service hostRouter;
|
|
13
|
+
@tracked scheduledOrders = [];
|
|
14
|
+
@tracked unscheduledOrders = [];
|
|
15
|
+
@tracked events = [];
|
|
16
|
+
|
|
17
|
+
@action setCalendarApi(calendar) {
|
|
18
|
+
this.calendar = calendar;
|
|
25
19
|
}
|
|
26
20
|
|
|
27
|
-
@action viewEvent(order
|
|
28
|
-
|
|
21
|
+
@action viewEvent(order) {
|
|
22
|
+
// get the event from the calendar
|
|
23
|
+
let event = this.calendar.getEventById(order.id);
|
|
29
24
|
|
|
30
25
|
this.modalsManager.show('modals/order-event', {
|
|
31
26
|
title: `Scheduling for ${order.public_id}`,
|
|
@@ -34,7 +29,7 @@ export default class OperationsSchedulerIndexController extends Controller {
|
|
|
34
29
|
hideDeclineButton: true,
|
|
35
30
|
order,
|
|
36
31
|
reschedule: (date) => {
|
|
37
|
-
if (typeof date
|
|
32
|
+
if (date && typeof date.toDate === 'function') {
|
|
38
33
|
date = date.toDate();
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -51,15 +46,27 @@ export default class OperationsSchedulerIndexController extends Controller {
|
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
return order.save().then((order) => {
|
|
54
|
-
|
|
49
|
+
// remove event from calendar
|
|
50
|
+
if (event) {
|
|
51
|
+
event.remove();
|
|
52
|
+
}
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (order.scheduled_at) {
|
|
55
|
+
// notify order has been scheduled
|
|
56
|
+
this.notifications.success(`Order '${order.public_id}' has been scheduled at ${order.scheduledAt}.`);
|
|
57
|
+
// add event to calendar
|
|
58
|
+
event = this.calendar.addEvent(createFullCalendarEventFromOrder(order));
|
|
59
|
+
} else {
|
|
60
|
+
this.notifications.info(`Order '${order.public_id}' has been unscheduled.`);
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
//
|
|
60
|
-
if (
|
|
61
|
-
event.
|
|
63
|
+
// update event props
|
|
64
|
+
if (event && typeof event.setProp === 'function') {
|
|
65
|
+
event.setProp('title', order.eventTitle);
|
|
62
66
|
}
|
|
67
|
+
|
|
68
|
+
// refresh route
|
|
69
|
+
this.hostRouter.refresh();
|
|
63
70
|
});
|
|
64
71
|
},
|
|
65
72
|
});
|
|
@@ -80,7 +87,9 @@ export default class OperationsSchedulerIndexController extends Controller {
|
|
|
80
87
|
const order = this.store.peekRecord('order', data.id);
|
|
81
88
|
|
|
82
89
|
order.set('scheduled_at', date);
|
|
83
|
-
order.save()
|
|
90
|
+
return order.save().then(() => {
|
|
91
|
+
this.hostRouter.refresh();
|
|
92
|
+
});
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
@action receivedEvent(eventReceivedInfo) {
|
|
@@ -88,7 +97,9 @@ export default class OperationsSchedulerIndexController extends Controller {
|
|
|
88
97
|
const order = this.store.peekRecord('order', event.id);
|
|
89
98
|
|
|
90
99
|
// update event props
|
|
91
|
-
event
|
|
100
|
+
if (typeof event.setProp === 'function') {
|
|
101
|
+
event.setProp('title', order.eventTitle);
|
|
102
|
+
}
|
|
92
103
|
}
|
|
93
104
|
|
|
94
105
|
@action rescheduleEventFromDrag(eventDropInfo) {
|
|
@@ -102,9 +113,13 @@ export default class OperationsSchedulerIndexController extends Controller {
|
|
|
102
113
|
|
|
103
114
|
// set and save order props
|
|
104
115
|
order.set('scheduled_at', isValidDate(newDate) ? newDate : start);
|
|
105
|
-
order.save()
|
|
116
|
+
order.save().then(() => {
|
|
117
|
+
this.hostRouter.refresh();
|
|
118
|
+
});
|
|
106
119
|
|
|
107
120
|
// update event props
|
|
108
|
-
event
|
|
121
|
+
if (typeof event.setProp === 'function') {
|
|
122
|
+
event.setProp('title', order.eventTitle);
|
|
123
|
+
}
|
|
109
124
|
}
|
|
110
125
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import Route from '@ember/routing/route';
|
|
2
2
|
import { inject as service } from '@ember/service';
|
|
3
|
+
import { isValid as isValidDate } from 'date-fns';
|
|
4
|
+
import { isNone } from '@ember/utils';
|
|
5
|
+
import createFullCalendarEventFromOrder from '../../../utils/create-full-calendar-event-from-order';
|
|
6
|
+
|
|
7
|
+
const getUnscheduledOrder = (order) => {
|
|
8
|
+
return isNone(order.scheduled_at);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getScheduledOrder = (order) => {
|
|
12
|
+
return isValidDate(order.scheduled_at);
|
|
13
|
+
};
|
|
3
14
|
|
|
4
15
|
export default class OperationsSchedulerIndexRoute extends Route {
|
|
5
16
|
@service store;
|
|
@@ -7,4 +18,18 @@ export default class OperationsSchedulerIndexRoute extends Route {
|
|
|
7
18
|
model() {
|
|
8
19
|
return this.store.query('order', { status: 'created', with: ['payload'] });
|
|
9
20
|
}
|
|
21
|
+
|
|
22
|
+
setupController(controller, model) {
|
|
23
|
+
// get orders
|
|
24
|
+
const orders = model.toArray();
|
|
25
|
+
|
|
26
|
+
// set unscheduled orders
|
|
27
|
+
controller.unscheduledOrders = orders.filter(getUnscheduledOrder);
|
|
28
|
+
|
|
29
|
+
// set scheduled orders
|
|
30
|
+
controller.scheduledOrders = orders.filter(getScheduledOrder);
|
|
31
|
+
|
|
32
|
+
// create events from scheduledOrders
|
|
33
|
+
controller.events = controller.scheduledOrders.map(createFullCalendarEventFromOrder);
|
|
34
|
+
}
|
|
10
35
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.scheduler-left-sidebar {
|
|
2
|
+
border-right: 1px rgba(229, 231, 235, 1) solid;
|
|
3
|
+
height: 100vh;
|
|
4
|
+
overflow-y: scroll;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body[data-theme="dark"] .scheduler-left-sidebar {
|
|
8
|
+
border-right: 1px rgba(55, 65, 81, 1) solid;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.scheduler-left-sidebar > .next-content-panel-wrapper > .next-content-panel-container > .next-content-panel > .next-content-panel-header.next-content-panel-is-closed {
|
|
12
|
+
border-bottom-left-radius: 0;
|
|
13
|
+
border-bottom-right-radius: 0;
|
|
14
|
+
}
|
|
15
|
+
.scheduler-left-sidebar > .next-content-panel-wrapper > .next-content-panel-container > .next-content-panel > .next-content-panel-header {
|
|
16
|
+
border-top-left-radius: 0;
|
|
17
|
+
border-top-right-radius: 0;
|
|
18
|
+
border-top: 0;
|
|
19
|
+
border-left: 0;
|
|
20
|
+
border-right: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.scheduler-left-sidebar > .next-content-panel-wrapper > .next-content-panel-container > .next-content-panel > .next-content-panel-body {
|
|
24
|
+
border-left: 0;
|
|
25
|
+
border-right: 0;
|
|
26
|
+
border-bottom-left-radius: 0;
|
|
27
|
+
border-bottom-right-radius: 0;
|
|
28
|
+
}
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
{{#if this.isMapLayout}}
|
|
14
14
|
<MapContainer @layout={{this.layout}} @onReady={{this.onMapContainerReady}}>
|
|
15
15
|
<GlobalSearch @visible={{this.isSearchVisible}} @onPressOrder={{this.viewOrder}} />
|
|
16
|
-
<MapContainer::Toolbar @activeOrdersCount={{this.activeOrdersCount}} @liveMap={{this.liveMap}} @map={{this.leafletMap}} @onPressViewOrders={{this.toggleOrdersPanel}} @onPressSearch={{this.toggleSearch}} @onPressCreateOrder={{this.createOrder}} @
|
|
16
|
+
<MapContainer::Toolbar @activeOrdersCount={{this.activeOrdersCount}} @liveMap={{this.liveMap}} @map={{this.leafletMap}} @onPressViewOrders={{this.toggleOrdersPanel}} @onPressSearch={{this.toggleSearch}} @onPressCreateOrder={{this.createOrder}} @onPressLiveMapDrawerToggle={{this.onPressLiveMapDrawerToggle}} />
|
|
17
17
|
<OrderListOverlay @noBackdrop={{true}} @fullHeight={{true}} @outView={{not this.isOrdersPanelVisible}} @width={{if (media 'isMobile') "100%" "338px"}} @onPressCancel={{this.hideOrdersPanel}} @onPressCreateOrder={{this.createOrder}} @onPressViewOrder={{this.viewOrder}} @onPressCreateFleet={{this.fleetController.createFleet}} @onPressManageFleet={{this.fleetController.viewFleet}} @onPressCancelOrders={{this.bulkCancelOrders}} @onPressDeleteOrders={{this.bulkDeleteOrders}} />
|
|
18
|
-
<LiveMap id="leafletMap" class="next-leaflet-container-map" @lat={{1.3521}} @lng={{103.8198}} @zoom={{12}} @zoomControl={{false}} @onLoad={{this.setMapReference}} {{set-container-dimensions}} />
|
|
18
|
+
<LiveMap id="leafletMap" class="next-leaflet-container-map" @lat={{1.3521}} @lng={{103.8198}} @zoom={{12}} @zoomControl={{false}} @onLoad={{this.setMapReference}} @onDrawerReady={{this.setDrawerContext}} {{set-container-dimensions}} />
|
|
19
19
|
</MapContainer>
|
|
20
20
|
{{/if}}
|
|
21
21
|
|