@fleetbase/fleetops-engine 0.6.8 → 0.6.10
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/activity-event-selector.js +4 -0
- package/addon/components/admin/navigator-app.js +1 -1
- package/addon/components/custom-field-form-panel.js +1 -1
- package/addon/components/display-place.hbs +27 -3
- package/addon/components/driver-onboard-settings.js +1 -1
- package/addon/components/driver-panel/orders.js +1 -1
- package/addon/components/edit-order-route-panel.js +1 -1
- package/addon/components/entity-field-editing-settings.js +1 -1
- package/addon/components/fleet-driver-listing.js +1 -2
- package/addon/components/fleet-panel/driver-listing.js +1 -2
- package/addon/components/fleet-panel/vehicle-listing.js +1 -2
- package/addon/components/fleet-vehicle-listing.js +1 -2
- package/addon/components/layout/fleet-ops-sidebar/driver-listing.js +1 -1
- package/addon/components/layout/fleet-ops-sidebar/fleet-listing.js +1 -1
- package/addon/components/live-map.js +1 -1
- package/addon/components/map-container/toolbar/zones-panel.js +1 -1
- package/addon/components/order-config-manager/activity-flow.js +1 -1
- package/addon/components/order-config-manager/custom-fields.js +1 -1
- package/addon/components/order-config-manager/entities.js +1 -1
- package/addon/components/order-config-manager.js +1 -1
- package/addon/components/route-list.hbs +3 -3
- package/addon/components/vendor-panel/drivers.js +1 -2
- package/addon/components/widget/fleet-ops-key-metrics.js +1 -1
- package/addon/controllers/management/contacts/index.js +1 -2
- package/addon/controllers/management/drivers/index.js +1 -2
- package/addon/controllers/management/fleets/index.js +1 -2
- package/addon/controllers/management/fuel-reports/index.js +1 -2
- package/addon/controllers/management/issues/index.js +1 -2
- package/addon/controllers/management/vehicles/index.js +1 -2
- package/addon/controllers/management/vendors/index.js +1 -2
- package/addon/controllers/operations/orders/index/new.js +40 -48
- package/addon/controllers/operations/orders/index/view.js +1 -1
- package/addon/controllers/operations/orders/index.js +1 -6
- package/addon/controllers/operations/service-rates/index.js +1 -2
- package/addon/routes/operations/orders/index/view.js +18 -1
- package/addon/services/movement-tracker.js +1 -1
- package/addon/services/order-creation.js +1 -1
- package/addon/styles/fleetops-engine.css +7 -0
- package/addon/templates/operations/orders/index/new.hbs +2 -2
- package/addon/templates/operations/orders/index/view.hbs +5 -1
- package/addon/templates/operations/orders/index.hbs +6 -1
- package/addon/templates/settings/notifications.hbs +9 -1
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +2 -3
- package/server/src/Console/Commands/TrackOrderDistanceAndTime.php +2 -2
- package/server/src/Events/OrderCanceled.php +6 -0
- package/server/src/Events/OrderCompleted.php +6 -0
- package/server/src/Events/OrderDispatched.php +6 -0
- package/server/src/Events/OrderFailed.php +6 -0
- package/server/src/Events/WaypointActivityChanged.php +119 -0
- package/server/src/Events/WaypointCompleted.php +119 -0
- package/server/src/Flow/Activity.php +28 -10
- package/server/src/Flow/Event.php +26 -2
- package/server/src/Http/Controllers/Api/v1/DriverController.php +19 -2
- package/server/src/Http/Controllers/Api/v1/OrderController.php +274 -164
- package/server/src/Http/Controllers/Internal/v1/OrderController.php +15 -8
- package/server/src/Http/Filter/OrderFilter.php +4 -4
- package/server/src/Http/Resources/v1/Payload.php +1 -1
- package/server/src/Listeners/HandleOrderCanceled.php +0 -10
- package/server/src/Listeners/NotifyOrderEvent.php +4 -4
- package/server/src/Models/OrderConfig.php +50 -35
- package/server/src/Models/Payload.php +26 -7
- package/server/src/Models/Waypoint.php +10 -0
- package/server/src/Notifications/OrderAssigned.php +3 -5
- package/server/src/Notifications/OrderCanceled.php +32 -12
- package/server/src/Notifications/OrderCompleted.php +31 -11
- package/server/src/Notifications/OrderDispatchFailed.php +3 -5
- package/server/src/Notifications/OrderDispatched.php +31 -11
- package/server/src/Notifications/OrderFailed.php +32 -12
- package/server/src/Notifications/OrderPing.php +2 -6
- package/server/src/Notifications/OrderSplit.php +1 -1
- package/server/src/Notifications/WaypointCompleted.php +157 -0
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
</div>
|
|
406
406
|
<div>
|
|
407
407
|
<div class="flex flex-row items-center space-x-4 text-sm mt-2">
|
|
408
|
-
<div class={{if (eq waypoint.type "dropoff")
|
|
408
|
+
<div class={{if (eq waypoint.type "dropoff") "is-checked"}}>
|
|
409
409
|
<div class="flex flex-row items-center">
|
|
410
410
|
<RadioButton
|
|
411
411
|
@radioClass="focus:ring-blue-500 h-4 w-4 text-blue-500"
|
|
@@ -418,7 +418,7 @@
|
|
|
418
418
|
<label for={{concat "waypoint_" index "_dropoff"}} class="ml-2">Dropoff</label>
|
|
419
419
|
</div>
|
|
420
420
|
</div>
|
|
421
|
-
<div class={{if (eq waypoint.type "pickup")
|
|
421
|
+
<div class={{if (eq waypoint.type "pickup") "is-checked"}}>
|
|
422
422
|
<div class="flex flex-row items-center">
|
|
423
423
|
<RadioButton
|
|
424
424
|
@radioClass="focus:ring-blue-500 h-4 w-4 text-blue-500"
|
|
@@ -579,7 +579,11 @@
|
|
|
579
579
|
>
|
|
580
580
|
{{#if @model.payload.isMultiDrop}}
|
|
581
581
|
<div>
|
|
582
|
-
<RouteList
|
|
582
|
+
<RouteList
|
|
583
|
+
@order={{@model}}
|
|
584
|
+
@eta={{@model.eta}}
|
|
585
|
+
@waypointActions={{hash viewWaypointLabel=(hash label=(t "fleet-ops.operations.orders.index.view.get-label") fn=this.viewWaypointLabel)}}
|
|
586
|
+
/>
|
|
583
587
|
</div>
|
|
584
588
|
{{else}}
|
|
585
589
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4 lg:gap-2">
|
|
@@ -72,7 +72,12 @@
|
|
|
72
72
|
<h4>Bulk Search</h4>
|
|
73
73
|
</div>
|
|
74
74
|
<div class="filters-dropdown-body">
|
|
75
|
-
<Textarea
|
|
75
|
+
<Textarea
|
|
76
|
+
@value={{this.bulkSearchValue}}
|
|
77
|
+
class="form-input w-full"
|
|
78
|
+
rows="8"
|
|
79
|
+
placeholder="Input comma delimited order ID's or tracking numbers to perform a bulk search"
|
|
80
|
+
/>
|
|
76
81
|
</div>
|
|
77
82
|
<div class="filters-dropdown-footer space-x-2">
|
|
78
83
|
<Button @text="Clear" @icon="trash" @size="xs" @onClick={{dropdown-fn dd this.removeBulkQuery}} />
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
<Layout::Section::Header @title={{t "fleet-ops.settings.notifications.fleet-ops-notification-settings"}}>
|
|
2
|
-
|
|
2
|
+
<Button
|
|
3
|
+
@type="primary"
|
|
4
|
+
@size="sm"
|
|
5
|
+
@icon="save"
|
|
6
|
+
@text={{t "common.save-button-text"}}
|
|
7
|
+
@onClick={{perform this.saveSettings}}
|
|
8
|
+
@disabled={{this.saveSettings.isRunning}}
|
|
9
|
+
@isLoading={{or this.saveSettings.isRunning this.getSettings.isRunning}}
|
|
10
|
+
/>
|
|
3
11
|
</Layout::Section::Header>
|
|
4
12
|
|
|
5
13
|
<Layout::Section::Body class="overflow-y-scroll h-full">
|
package/composer.json
CHANGED
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/fleetops-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"fleetbase": {
|
|
6
6
|
"route": "fleet-ops"
|
|
@@ -87,8 +87,7 @@
|
|
|
87
87
|
"ember-cli-sri": "^2.1.1",
|
|
88
88
|
"ember-cli-terser": "^4.0.2",
|
|
89
89
|
"ember-composable-helpers": "^5.0.0",
|
|
90
|
-
"ember-concurrency": "^
|
|
91
|
-
"ember-concurrency-decorators": "^2.0.3",
|
|
90
|
+
"ember-concurrency": "^4.0.4",
|
|
92
91
|
"ember-data": "^4.12.5",
|
|
93
92
|
"ember-engines": "^0.9.0",
|
|
94
93
|
"ember-load-initializers": "^2.1.2",
|
|
@@ -69,7 +69,7 @@ class TrackOrderDistanceAndTime extends Command
|
|
|
69
69
|
* - Not in 'completed' or 'canceled' status.
|
|
70
70
|
* - Not marked as deleted (`deleted_at` is null).
|
|
71
71
|
* - Associated with a company (`company_uuid` is not null).
|
|
72
|
-
* - The order process has started (`
|
|
72
|
+
* - The order process has started (`started_at` is not null).
|
|
73
73
|
* - Contains a payload (`payload` relationship exists).
|
|
74
74
|
* - Created within the past month.
|
|
75
75
|
*
|
|
@@ -85,7 +85,7 @@ class TrackOrderDistanceAndTime extends Command
|
|
|
85
85
|
return Order::whereNotIn('status', ['completed', 'canceled'])
|
|
86
86
|
->whereNull('deleted_at')
|
|
87
87
|
->whereNotNull('company_uuid')
|
|
88
|
-
->whereNotNull('
|
|
88
|
+
->whereNotNull('started_at')
|
|
89
89
|
->where('created_at', '>=', $oneMonthAgo)
|
|
90
90
|
->whereHas('payload')
|
|
91
91
|
->with(['payload', 'payload.waypoints', 'payload.pickup', 'payload.dropoff'])
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Events;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Events\ResourceLifecycleEvent;
|
|
6
6
|
use Fleetbase\FleetOps\Flow\Activity;
|
|
7
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
7
8
|
|
|
8
9
|
class OrderCanceled extends ResourceLifecycleEvent
|
|
9
10
|
{
|
|
@@ -18,4 +19,9 @@ class OrderCanceled extends ResourceLifecycleEvent
|
|
|
18
19
|
* Assosciated activity which triggered the event.
|
|
19
20
|
*/
|
|
20
21
|
public ?Activity $activity;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Assosciated order waypoint which event is for.
|
|
25
|
+
*/
|
|
26
|
+
public ?Waypoint $waypoint;
|
|
21
27
|
}
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Events;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Events\ResourceLifecycleEvent;
|
|
6
6
|
use Fleetbase\FleetOps\Flow\Activity;
|
|
7
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
7
8
|
|
|
8
9
|
class OrderCompleted extends ResourceLifecycleEvent
|
|
9
10
|
{
|
|
@@ -18,4 +19,9 @@ class OrderCompleted extends ResourceLifecycleEvent
|
|
|
18
19
|
* Assosciated activity which triggered the event.
|
|
19
20
|
*/
|
|
20
21
|
public ?Activity $activity;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Assosciated order waypoint which event is for.
|
|
25
|
+
*/
|
|
26
|
+
public ?Waypoint $waypoint;
|
|
21
27
|
}
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Events;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Events\ResourceLifecycleEvent;
|
|
6
6
|
use Fleetbase\FleetOps\Flow\Activity;
|
|
7
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
7
8
|
|
|
8
9
|
class OrderDispatched extends ResourceLifecycleEvent
|
|
9
10
|
{
|
|
@@ -18,4 +19,9 @@ class OrderDispatched extends ResourceLifecycleEvent
|
|
|
18
19
|
* Assosciated activity which triggered the event.
|
|
19
20
|
*/
|
|
20
21
|
public ?Activity $activity;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Assosciated order waypoint which event is for.
|
|
25
|
+
*/
|
|
26
|
+
public ?Waypoint $waypoint;
|
|
21
27
|
}
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Events;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\Events\ResourceLifecycleEvent;
|
|
6
6
|
use Fleetbase\FleetOps\Flow\Activity;
|
|
7
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
7
8
|
|
|
8
9
|
class OrderFailed extends ResourceLifecycleEvent
|
|
9
10
|
{
|
|
@@ -18,4 +19,9 @@ class OrderFailed extends ResourceLifecycleEvent
|
|
|
18
19
|
* Assosciated activity which triggered the event.
|
|
19
20
|
*/
|
|
20
21
|
public ?Activity $activity;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Assosciated order waypoint which event is for.
|
|
25
|
+
*/
|
|
26
|
+
public ?Waypoint $waypoint;
|
|
21
27
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Events;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Flow\Activity;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Order;
|
|
7
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
8
|
+
use Illuminate\Broadcasting\Channel;
|
|
9
|
+
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
10
|
+
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
11
|
+
use Illuminate\Foundation\Events\Dispatchable;
|
|
12
|
+
use Illuminate\Queue\SerializesModels;
|
|
13
|
+
use Illuminate\Support\Carbon;
|
|
14
|
+
|
|
15
|
+
class WaypointActivityChanged implements ShouldBroadcast
|
|
16
|
+
{
|
|
17
|
+
use Dispatchable;
|
|
18
|
+
use InteractsWithSockets;
|
|
19
|
+
use SerializesModels;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The waypoint which is completed.
|
|
23
|
+
*/
|
|
24
|
+
public Waypoint $waypoint;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The activity which triggered the waypoint completed.
|
|
28
|
+
*/
|
|
29
|
+
public Activity $activity;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The event id.
|
|
33
|
+
*
|
|
34
|
+
* @var string
|
|
35
|
+
*/
|
|
36
|
+
public $eventId;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The datetime instance the broadcast ws triggered.
|
|
40
|
+
*
|
|
41
|
+
* @var string
|
|
42
|
+
*/
|
|
43
|
+
public $sentAt;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a new event instance.
|
|
47
|
+
*
|
|
48
|
+
* @return void
|
|
49
|
+
*/
|
|
50
|
+
public function __construct(Waypoint $waypoint, Activity $activity)
|
|
51
|
+
{
|
|
52
|
+
$this->waypoint = $waypoint;
|
|
53
|
+
$this->activity = $activity;
|
|
54
|
+
$this->eventId = uniqid('event_');
|
|
55
|
+
$this->sentAt = Carbon::now()->toDateTimeString();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get the channels the event should broadcast on.
|
|
60
|
+
*
|
|
61
|
+
* @return Channel|array
|
|
62
|
+
*/
|
|
63
|
+
public function broadcastOn()
|
|
64
|
+
{
|
|
65
|
+
$channels = [
|
|
66
|
+
new Channel('api.' . session('api_credential')),
|
|
67
|
+
new Channel('waypoint.' . $this->waypoint->public_id),
|
|
68
|
+
new Channel('waypoint.' . $this->waypoint->uuid),
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
$order = $this->getModelRecord();
|
|
72
|
+
if ($order) {
|
|
73
|
+
$channels[] = new Channel('company.' . session('company', data_get($order, 'company.uuid')));
|
|
74
|
+
$channels[] = new Channel('company.' . data_get($order, 'company.public_id'));
|
|
75
|
+
$channels[] = new Channel('order.' . $order->uuid);
|
|
76
|
+
$channels[] = new Channel('order.' . $order->public_id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return $channels;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The event's broadcast name.
|
|
84
|
+
*
|
|
85
|
+
* @return string
|
|
86
|
+
*/
|
|
87
|
+
public function broadcastAs()
|
|
88
|
+
{
|
|
89
|
+
return 'waypoint.activity';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get the data to broadcast.
|
|
94
|
+
*
|
|
95
|
+
* @return array
|
|
96
|
+
*/
|
|
97
|
+
public function broadcastWith()
|
|
98
|
+
{
|
|
99
|
+
return [
|
|
100
|
+
'id' => $this->eventId,
|
|
101
|
+
'api_version' => config('api.version'),
|
|
102
|
+
'event' => $this->broadcastAs(),
|
|
103
|
+
'created_at' => $this->sentAt,
|
|
104
|
+
'data' => [
|
|
105
|
+
'waypoint' => $this->waypoint->public_id,
|
|
106
|
+
'place' => data_get($this->waypoint, 'place.public_id'),
|
|
107
|
+
'activity' => $this->activity->toArray(),
|
|
108
|
+
],
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the assosciated order model record for this waypoint.
|
|
114
|
+
*/
|
|
115
|
+
public function getModelRecord(): ?Order
|
|
116
|
+
{
|
|
117
|
+
return Order::where('payload_uuid', $this->waypoint->payload_uuid)->first();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Events;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Flow\Activity;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Order;
|
|
7
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
8
|
+
use Illuminate\Broadcasting\Channel;
|
|
9
|
+
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
10
|
+
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
11
|
+
use Illuminate\Foundation\Events\Dispatchable;
|
|
12
|
+
use Illuminate\Queue\SerializesModels;
|
|
13
|
+
use Illuminate\Support\Carbon;
|
|
14
|
+
|
|
15
|
+
class WaypointCompleted implements ShouldBroadcast
|
|
16
|
+
{
|
|
17
|
+
use Dispatchable;
|
|
18
|
+
use InteractsWithSockets;
|
|
19
|
+
use SerializesModels;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The waypoint which is completed.
|
|
23
|
+
*/
|
|
24
|
+
public Waypoint $waypoint;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The activity which triggered the waypoint completed.
|
|
28
|
+
*/
|
|
29
|
+
public Activity $activity;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The event id.
|
|
33
|
+
*
|
|
34
|
+
* @var string
|
|
35
|
+
*/
|
|
36
|
+
public $eventId;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The datetime instance the broadcast ws triggered.
|
|
40
|
+
*
|
|
41
|
+
* @var string
|
|
42
|
+
*/
|
|
43
|
+
public $sentAt;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a new event instance.
|
|
47
|
+
*
|
|
48
|
+
* @return void
|
|
49
|
+
*/
|
|
50
|
+
public function __construct(Waypoint $waypoint, Activity $activity)
|
|
51
|
+
{
|
|
52
|
+
$this->waypoint = $waypoint;
|
|
53
|
+
$this->activity = $activity;
|
|
54
|
+
$this->eventId = uniqid('event_');
|
|
55
|
+
$this->sentAt = Carbon::now()->toDateTimeString();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get the channels the event should broadcast on.
|
|
60
|
+
*
|
|
61
|
+
* @return Channel|array
|
|
62
|
+
*/
|
|
63
|
+
public function broadcastOn()
|
|
64
|
+
{
|
|
65
|
+
$channels = [
|
|
66
|
+
new Channel('api.' . session('api_credential')),
|
|
67
|
+
new Channel('waypoint.' . $this->waypoint->public_id),
|
|
68
|
+
new Channel('waypoint.' . $this->waypoint->uuid),
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
$order = $this->getModelRecord();
|
|
72
|
+
if ($order) {
|
|
73
|
+
$channels[] = new Channel('company.' . session('company', data_get($order, 'company.uuid')));
|
|
74
|
+
$channels[] = new Channel('company.' . data_get($order, 'company.public_id'));
|
|
75
|
+
$channels[] = new Channel('order.' . $order->uuid);
|
|
76
|
+
$channels[] = new Channel('order.' . $order->public_id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return $channels;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The event's broadcast name.
|
|
84
|
+
*
|
|
85
|
+
* @return string
|
|
86
|
+
*/
|
|
87
|
+
public function broadcastAs()
|
|
88
|
+
{
|
|
89
|
+
return 'waypoint.completed';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get the data to broadcast.
|
|
94
|
+
*
|
|
95
|
+
* @return array
|
|
96
|
+
*/
|
|
97
|
+
public function broadcastWith()
|
|
98
|
+
{
|
|
99
|
+
return [
|
|
100
|
+
'id' => $this->eventId,
|
|
101
|
+
'api_version' => config('api.version'),
|
|
102
|
+
'event' => $this->broadcastAs(),
|
|
103
|
+
'created_at' => $this->sentAt,
|
|
104
|
+
'data' => [
|
|
105
|
+
'waypoint' => $this->waypoint->public_id,
|
|
106
|
+
'place' => data_get($this->waypoint, 'place.public_id'),
|
|
107
|
+
'activity' => $this->activity->toArray(),
|
|
108
|
+
],
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get the assosciated order model record for this waypoint.
|
|
114
|
+
*/
|
|
115
|
+
public function getModelRecord(): ?Order
|
|
116
|
+
{
|
|
117
|
+
return Order::where('payload_uuid', $this->waypoint->payload_uuid)->first();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Flow;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Models\Order;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
6
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
7
8
|
|
|
8
9
|
class Activity extends FlowResource
|
|
@@ -100,10 +101,10 @@ class Activity extends FlowResource
|
|
|
100
101
|
*
|
|
101
102
|
* @param Order $order the order object to be passed to each event
|
|
102
103
|
*/
|
|
103
|
-
public function fireEvents(Order $order)
|
|
104
|
+
public function fireEvents(Order $order, ?Waypoint $waypoint = null)
|
|
104
105
|
{
|
|
105
106
|
foreach ($this->events as $event) {
|
|
106
|
-
$event->fire($order, $this);
|
|
107
|
+
$event->fire($order, $this, $waypoint);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -112,12 +113,22 @@ class Activity extends FlowResource
|
|
|
112
113
|
*
|
|
113
114
|
* @return \Illuminate\Support\Collection a collection of child activities
|
|
114
115
|
*/
|
|
115
|
-
public function getChildActivities()
|
|
116
|
+
public function getChildActivities(Order|Waypoint|null $context = null)
|
|
116
117
|
{
|
|
117
|
-
$children
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
$children = collect();
|
|
119
|
+
$activities = $this->activities;
|
|
120
|
+
|
|
121
|
+
// if waypoint provided
|
|
122
|
+
$waypointContext = $context instanceof Waypoint;
|
|
123
|
+
|
|
124
|
+
if (is_array($activities)) {
|
|
125
|
+
foreach ($activities as $childActivityCode) {
|
|
120
126
|
$childActivity = $this->flow->getActivity($childActivityCode);
|
|
127
|
+
// if waypoint context skip `created` - `started` - `dispatched`
|
|
128
|
+
if ($waypointContext && in_array($childActivity->code, ['created', 'started', 'dispatched'])) {
|
|
129
|
+
return $childActivity->getChildActivities($context);
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
if ($childActivity) {
|
|
122
133
|
$children->push($childActivity);
|
|
123
134
|
}
|
|
@@ -158,15 +169,19 @@ class Activity extends FlowResource
|
|
|
158
169
|
/**
|
|
159
170
|
* Determines the next set of activities based on the provided Order.
|
|
160
171
|
*
|
|
161
|
-
* @param Order $order the order to determine the next activities for
|
|
162
|
-
*
|
|
163
172
|
* @return \Illuminate\Support\Collection a collection of the next activities
|
|
164
173
|
*/
|
|
165
|
-
public function getNext(Order $
|
|
174
|
+
public function getNext(Order|Waypoint $context)
|
|
166
175
|
{
|
|
167
|
-
$children = $this->getChildActivities();
|
|
176
|
+
$children = $this->getChildActivities($context);
|
|
168
177
|
$nextActivities = collect();
|
|
169
178
|
|
|
179
|
+
// if context is a waypoint get the waypoint order
|
|
180
|
+
$order = $context;
|
|
181
|
+
if ($context instanceof Waypoint) {
|
|
182
|
+
$order = Order::where('payload_uuid', $context->payload_uuid)->first();
|
|
183
|
+
}
|
|
184
|
+
|
|
170
185
|
foreach ($children as $childActivity) {
|
|
171
186
|
if ($childActivity->passes($order)) {
|
|
172
187
|
$nextActivities->push($childActivity);
|
|
@@ -237,6 +252,9 @@ class Activity extends FlowResource
|
|
|
237
252
|
return $this->complete();
|
|
238
253
|
}
|
|
239
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Checks if this activiy has been completed within the order already.
|
|
257
|
+
*/
|
|
240
258
|
public function isCompleted(Order $order): bool
|
|
241
259
|
{
|
|
242
260
|
return $order->hasCompletedActivity($this);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Flow;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Models\Order;
|
|
6
|
+
use Fleetbase\FleetOps\Models\Waypoint;
|
|
6
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
7
8
|
use Illuminate\Support\Str;
|
|
8
9
|
|
|
@@ -18,6 +19,11 @@ class Event
|
|
|
18
19
|
*/
|
|
19
20
|
public ?Order $order = null;
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The waypoint associated with the event, if any.
|
|
24
|
+
*/
|
|
25
|
+
public ?Waypoint $waypoint = null;
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* The activity for the order event.
|
|
23
29
|
*/
|
|
@@ -29,11 +35,12 @@ class Event
|
|
|
29
35
|
* @param string $name the name of the event
|
|
30
36
|
* @param ?Order $order the associated order, if any
|
|
31
37
|
*/
|
|
32
|
-
public function __construct(string $name, ?Order $order = null, ?Activity $activity = null)
|
|
38
|
+
public function __construct(string $name, ?Order $order = null, ?Activity $activity = null, ?Waypoint $waypoint = null)
|
|
33
39
|
{
|
|
34
40
|
$this->name = $name;
|
|
35
41
|
$this->order = $order;
|
|
36
42
|
$this->activity = $activity;
|
|
43
|
+
$this->waypoint = $waypoint;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
/**
|
|
@@ -60,6 +67,18 @@ class Event
|
|
|
60
67
|
return $this;
|
|
61
68
|
}
|
|
62
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Sets the waypoint for the order event.
|
|
72
|
+
*
|
|
73
|
+
* @param Waypoint $waypoint the waypoint assosciated to this event
|
|
74
|
+
*/
|
|
75
|
+
public function setWaypoint(Waypoint $waypoint)
|
|
76
|
+
{
|
|
77
|
+
$this->waypoint = $waypoint;
|
|
78
|
+
|
|
79
|
+
return $this;
|
|
80
|
+
}
|
|
81
|
+
|
|
63
82
|
/**
|
|
64
83
|
* Triggers the event, optionally setting the order if not already set.
|
|
65
84
|
*
|
|
@@ -69,7 +88,7 @@ class Event
|
|
|
69
88
|
* @param ?Order $order optional order to associate with the event
|
|
70
89
|
* @param ?Activity $activity optional activity which triggered the event
|
|
71
90
|
*/
|
|
72
|
-
public function fire(?Order $order = null, ?Activity $activity = null)
|
|
91
|
+
public function fire(?Order $order = null, ?Activity $activity = null, ?Waypoint $waypoint = null)
|
|
73
92
|
{
|
|
74
93
|
if (!$this->order && $order instanceof Order) {
|
|
75
94
|
$this->setOrder($order);
|
|
@@ -79,10 +98,15 @@ class Event
|
|
|
79
98
|
$this->setActivity($activity);
|
|
80
99
|
}
|
|
81
100
|
|
|
101
|
+
if ($waypoint) {
|
|
102
|
+
$this->setWaypoint($waypoint);
|
|
103
|
+
}
|
|
104
|
+
|
|
82
105
|
$eventClass = $this->resolve();
|
|
83
106
|
if ($eventClass) {
|
|
84
107
|
$event = new $eventClass($this->order);
|
|
85
108
|
$event->activity = $activity;
|
|
109
|
+
$event->waypoint = $waypoint;
|
|
86
110
|
event($event);
|
|
87
111
|
}
|
|
88
112
|
}
|
|
@@ -535,15 +535,32 @@ class DriverController extends Controller
|
|
|
535
535
|
return 'Your ' . data_get($company, 'name', config('app.name')) . ' verification code is ' . $verification->code;
|
|
536
536
|
},
|
|
537
537
|
]);
|
|
538
|
+
|
|
539
|
+
return response()->json(['status' => 'OK', 'method' => 'sms']);
|
|
538
540
|
} catch (\Throwable $e) {
|
|
539
541
|
if (app()->bound('sentry')) {
|
|
540
542
|
app('sentry')->captureException($e);
|
|
541
543
|
}
|
|
542
544
|
|
|
543
|
-
|
|
545
|
+
// SEND VERIFICATION CODE BY EMAIL IF DRIVER HAS EMAIL ADDRESS
|
|
546
|
+
if ($user->email) {
|
|
547
|
+
try {
|
|
548
|
+
VerificationCode::generateEmailVerificationFor($user, 'driver_login', [
|
|
549
|
+
'messageCallback' => function ($verification) use ($company) {
|
|
550
|
+
return 'Your ' . data_get($company, 'name', config('app.name')) . ' verification code is ' . $verification->code;
|
|
551
|
+
},
|
|
552
|
+
]);
|
|
553
|
+
|
|
554
|
+
return response()->json(['status' => 'OK', 'method' => 'email']);
|
|
555
|
+
} catch (\Throwable $e) {
|
|
556
|
+
if (app()->bound('sentry')) {
|
|
557
|
+
app('sentry')->captureException($e);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
544
561
|
}
|
|
545
562
|
|
|
546
|
-
return response()->
|
|
563
|
+
return response()->apiError('Unable to send SMS Verification code.');
|
|
547
564
|
}
|
|
548
565
|
|
|
549
566
|
/**
|