Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions addon/components/activity-event-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export default class ActivityEventSelectorComponent extends Component {
name: 'order.canceled',
description: 'Triggers when an order is canceled by a user, driver, or system process.',
},
'order.completed': {
name: 'order.completed',
description: 'Triggers when an order is completed by a driver, or system process.',
},
};

/**
Expand Down
30 changes: 27 additions & 3 deletions addon/components/display-place.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,33 @@
</span>
</div>
{{else}}
{{#if @eta}}
<Badge @status="warning" @hideStatusDot={{true}} class="my-1"><span class="font-bold">ETA:</span> {{format-duration @eta}}</Badge>
{{/if}}
<div class="flex flex-row item-center space-x-2 {{if (or place.status_code @eta) 'mb-2'}}">
{{#if place.status_code}}
<Badge @status={{place.status_code}} />
{{/if}}
{{#if @eta}}
<Badge @status="warning" @hideStatusDot={{true}}><span class="font-bold">ETA:</span> {{format-duration @eta}}</Badge>
{{/if}}
{{#if @waypointActions}}
<DropdownButton @iconClass="icon-text-height" @size="xs" @buttonClass="fleetops-btn-xxs" @icon="ellipsis-h" @iconPrefix="fas" @contentClass="dropdown-menu" as |dd|>
<div class="next-dd-menu mt-1 mx-0" aria-labelledby="user-menu">
<div class="px-1">
<div class="text-sm flex flex-row items-center px-3 py-1 rounded-md my-1 text-gray-300">
{{t "fleet-ops.operations.orders.index.view.waypoint-actions"}}
</div>
</div>
<div class="next-dd-menu-seperator"></div>
{{#each-in @waypointActions as |actionId action|}}
<div class="px-1">
<a href="javascript:;" class="next-dd-item" disabled={{cannot "fleet-ops view order"}} {{on "click" (fn action.fn place dd)}}>
{{action.label}}
</a>
</div>
{{/each-in}}
</div>
</DropdownButton>
{{/if}}
</div>
<address class={{@addressClass}}>
{{#if place.name}}
{{place.name}}<br />
Expand Down
6 changes: 3 additions & 3 deletions addon/components/route-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="index-count">1</div>
</div>
<div class="order-route-location {{@routeLocationClass}} dark:text-gray-100">
<DisplayPlace @place={{@order.payload.firstWaypoint}} @eta={{get @eta @order.payload.firstWaypoint.id}} />
<DisplayPlace @place={{@order.payload.firstWaypoint}} @eta={{get @eta @order.payload.firstWaypoint.id}} @waypointActions={{@waypointActions}} />
</div>
</div>
{{/if}}
Expand All @@ -28,7 +28,7 @@
<div class="index-count">{{add index 2}}</div>
</div>
<div class="order-route-location {{@routeLocationClass}} dark:text-gray-100">
<DisplayPlace @place={{waypoint}} @eta={{get @eta waypoint.id}} />
<DisplayPlace @place={{waypoint}} @eta={{get @eta waypoint.id}} @waypointActions={{@waypointActions}} />
</div>
</div>
{{/each}}
Expand All @@ -41,7 +41,7 @@
<div class="index-count">{{add @order.payload.middleWaypoints.length 2}}</div>
</div>
<div class="order-route-location {{@routeLocationClass}} dark:text-gray-100">
<DisplayPlace @place={{@order.payload.lastWaypoint}} @eta={{get @eta @order.payload.lastWaypoint.id}} />
<DisplayPlace @place={{@order.payload.lastWaypoint}} @eta={{get @eta @order.payload.lastWaypoint.id}} @waypointActions={{@waypointActions}} />
</div>
</div>
{{/if}}
Expand Down
4 changes: 0 additions & 4 deletions addon/controllers/operations/orders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,6 @@ export default class OperationsOrdersIndexController extends BaseController {
selected = selected.length > 0 ? selected : this.table.selectedRows;

this.crud.bulkDelete(selected, {
modelNamePath: `public_id`,
acceptButtonText: 'Delete Orders',
resolveModelName: (model) => `${model.get('tracking_number.tracking_number')} - ${model.get('public_id')}`,
onSuccess: async () => {
Expand Down Expand Up @@ -1075,7 +1074,6 @@ export default class OperationsOrdersIndexController extends BaseController {
acceptButtonText: 'Cancel Orders',
acceptButtonScheme: 'danger',
acceptButtonIcon: 'ban',
modelNamePath: `public_id`,
actionPath: `orders/bulk-cancel`,
actionMethod: `PATCH`,
resolveModelName: (model) => `${model.get('tracking_number.tracking_number')} - ${model.get('public_id')}`,
Expand Down Expand Up @@ -1109,7 +1107,6 @@ export default class OperationsOrdersIndexController extends BaseController {
acceptButtonText: 'Dispatch Orders',
acceptButtonScheme: 'magic',
acceptButtonIcon: 'rocket',
modelNamePath: 'public_id',
actionPath: 'orders/bulk-dispatch',
actionMethod: 'POST',
resolveModelName: (model) => `${model.get('tracking_number.tracking_number')} - ${model.get('public_id')}`,
Expand Down Expand Up @@ -1152,7 +1149,6 @@ export default class OperationsOrdersIndexController extends BaseController {
acceptButtonScheme: 'magic',
acceptButtonIcon: 'user-plus',
acceptButtonDisabled: true,
modelNamePath: 'public_id',
actionPath: 'orders/bulk-assign-driver',
actionMethod: 'PATCH',
driverAssigned: null,
Expand Down
19 changes: 18 additions & 1 deletion addon/routes/operations/orders/index/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { debug } from '@ember/debug';

export default class OperationsOrdersIndexViewRoute extends Route {
@service currentUser;
Expand Down Expand Up @@ -66,7 +67,23 @@ export default class OperationsOrdersIndexViewRoute extends Route {
// Listen for channel subscription
(async () => {
for await (let output of channel) {
this.refresh();
const { event, data } = output;

// debug output
debug(`Socket Event : ${event} : ${JSON.stringify(output)}`);

// Only reload if the order has a status change stemming from an updated event OR
// if a waypoint has been completed which will trigger `order.completed`
const statusChanged = event === 'order.updated' && data.status !== model.status;
const shouldReload = ['order.completed', 'waypoint.activity', 'order.created'].includes(event);
if (statusChanged || shouldReload) {
this.refresh();

// reload the controller stuff as well
if (this.controller) {
this.controller.loadOrderRelations.perform(model);
}
}

if (typeof this.onOrderEvent === 'function') {
this.onOrderEvent(output);
Expand Down
2 changes: 1 addition & 1 deletion addon/services/movement-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class MovementTrackerService extends Service {

if (event === `${type}.location_changed` || event === `${type}.simulated_location_changed`) {
eventBuffer.add(output);
debug(`Incoming socket event added to buffer: ${event}`);
debug(`Socket Event : ${event} : Added to EventBuffer : ${JSON.stringify(output)}`);
}
}
})();
Expand Down
7 changes: 7 additions & 0 deletions addon/styles/fleetops-engine.css
Original file line number Diff line number Diff line change
Expand Up @@ -1623,3 +1623,10 @@ body[data-theme='dark']
.justify-end-i {
justify-content: end !important;
}

button.fleetops-btn-xxs.btn,
button.fleetops-btn-xxs,
.fleetops-btn-xxs {
padding-top: 0.2rem !important;
padding-bottom: 0.2rem !important;
}
7 changes: 6 additions & 1 deletion addon/templates/operations/orders/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@
<h4>Bulk Search</h4>
</div>
<div class="filters-dropdown-body">
<Textarea @value={{this.bulkSearchValue}} class="form-input w-full" rows="8" placeholder="Input comma delimited order ID's or tracking numbers to perform a bulk search" />
<Textarea
@value={{this.bulkSearchValue}}
class="form-input w-full"
rows="8"
placeholder="Input comma delimited order ID's or tracking numbers to perform a bulk search"
/>
</div>
<div class="filters-dropdown-footer space-x-2">
<Button @text="Clear" @icon="trash" @size="xs" @onClick={{dropdown-fn dd this.removeBulkQuery}} />
Expand Down
4 changes: 2 additions & 2 deletions addon/templates/operations/orders/index/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@
</div>
<div>
<div class="flex flex-row items-center space-x-4 text-sm mt-2">
<div class={{if (eq waypoint.type "dropoff") 'is-checked'}}>
<div class={{if (eq waypoint.type "dropoff") "is-checked"}}>
<div class="flex flex-row items-center">
<RadioButton
@radioClass="focus:ring-blue-500 h-4 w-4 text-blue-500"
Expand All @@ -418,7 +418,7 @@
<label for={{concat "waypoint_" index "_dropoff"}} class="ml-2">Dropoff</label>
</div>
</div>
<div class={{if (eq waypoint.type "pickup") 'is-checked'}}>
<div class={{if (eq waypoint.type "pickup") "is-checked"}}>
<div class="flex flex-row items-center">
<RadioButton
@radioClass="focus:ring-blue-500 h-4 w-4 text-blue-500"
Expand Down
6 changes: 5 additions & 1 deletion addon/templates/operations/orders/index/view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,11 @@
>
{{#if @model.payload.isMultiDrop}}
<div>
<RouteList @order={{@model}} @eta={{@model.eta}} />
<RouteList
@order={{@model}}
@eta={{@model.eta}}
@waypointActions={{hash viewWaypointLabel=(hash label=(t "fleet-ops.operations.orders.index.view.get-label") fn=this.viewWaypointLabel)}}
/>
</div>
{{else}}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4 lg:gap-2">
Expand Down
10 changes: 9 additions & 1 deletion addon/templates/settings/notifications.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<Layout::Section::Header @title={{t "fleet-ops.settings.notifications.fleet-ops-notification-settings"}}>
<Button @type="primary" @size="sm" @icon="save" @text={{t "common.save-button-text"}} @onClick={{perform this.saveSettings}} @disabled={{this.saveSettings.isRunning}} @isLoading={{or this.saveSettings.isRunning this.getSettings.isRunning}} />
<Button
@type="primary"
@size="sm"
@icon="save"
@text={{t "common.save-button-text"}}
@onClick={{perform this.saveSettings}}
@disabled={{this.saveSettings.isRunning}}
@isLoading={{or this.saveSettings.isRunning this.getSettings.isRunning}}
/>
</Layout::Section::Header>

<Layout::Section::Body class="overflow-y-scroll h-full">
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/fleetops-api",
"version": "0.6.8",
"version": "0.6.9",
"description": "Fleet & Transport Management Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Fleet-Ops",
"version": "0.6.8",
"version": "0.6.9",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "AGPL-3.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-engine",
"version": "0.6.8",
"version": "0.6.9",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
Expand Down
4 changes: 2 additions & 2 deletions server/src/Console/Commands/TrackOrderDistanceAndTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function handle()
* - Not in 'completed' or 'canceled' status.
* - Not marked as deleted (`deleted_at` is null).
* - Associated with a company (`company_uuid` is not null).
* - The order process has started (`started` is not null).
* - The order process has started (`started_at` is not null).
* - Contains a payload (`payload` relationship exists).
* - Created within the past month.
*
Expand All @@ -85,7 +85,7 @@ protected function getActiveOrders()
return Order::whereNotIn('status', ['completed', 'canceled'])
->whereNull('deleted_at')
->whereNotNull('company_uuid')
->whereNotNull('started')
->whereNotNull('started_at')
->where('created_at', '>=', $oneMonthAgo)
->whereHas('payload')
->with(['payload', 'payload.waypoints', 'payload.pickup', 'payload.dropoff'])
Expand Down
6 changes: 6 additions & 0 deletions server/src/Events/OrderCanceled.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Fleetbase\Events\ResourceLifecycleEvent;
use Fleetbase\FleetOps\Flow\Activity;
use Fleetbase\FleetOps\Models\Waypoint;

class OrderCanceled extends ResourceLifecycleEvent
{
Expand All @@ -18,4 +19,9 @@ class OrderCanceled extends ResourceLifecycleEvent
* Assosciated activity which triggered the event.
*/
public ?Activity $activity;

/**
* Assosciated order waypoint which event is for.
*/
public ?Waypoint $waypoint;
}
6 changes: 6 additions & 0 deletions server/src/Events/OrderCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Fleetbase\Events\ResourceLifecycleEvent;
use Fleetbase\FleetOps\Flow\Activity;
use Fleetbase\FleetOps\Models\Waypoint;

class OrderCompleted extends ResourceLifecycleEvent
{
Expand All @@ -18,4 +19,9 @@ class OrderCompleted extends ResourceLifecycleEvent
* Assosciated activity which triggered the event.
*/
public ?Activity $activity;

/**
* Assosciated order waypoint which event is for.
*/
public ?Waypoint $waypoint;
}
6 changes: 6 additions & 0 deletions server/src/Events/OrderDispatched.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Fleetbase\Events\ResourceLifecycleEvent;
use Fleetbase\FleetOps\Flow\Activity;
use Fleetbase\FleetOps\Models\Waypoint;

class OrderDispatched extends ResourceLifecycleEvent
{
Expand All @@ -18,4 +19,9 @@ class OrderDispatched extends ResourceLifecycleEvent
* Assosciated activity which triggered the event.
*/
public ?Activity $activity;

/**
* Assosciated order waypoint which event is for.
*/
public ?Waypoint $waypoint;
}
6 changes: 6 additions & 0 deletions server/src/Events/OrderFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Fleetbase\Events\ResourceLifecycleEvent;
use Fleetbase\FleetOps\Flow\Activity;
use Fleetbase\FleetOps\Models\Waypoint;

class OrderFailed extends ResourceLifecycleEvent
{
Expand All @@ -18,4 +19,9 @@ class OrderFailed extends ResourceLifecycleEvent
* Assosciated activity which triggered the event.
*/
public ?Activity $activity;

/**
* Assosciated order waypoint which event is for.
*/
public ?Waypoint $waypoint;
}
Loading
Loading