@fleetbase/fleetops-engine 0.6.51 → 0.6.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/addon/components/cell/telematic-provider.hbs +16 -0
- package/addon/components/cell/telematic-provider.js +36 -0
- package/addon/components/cell/telematic-status.hbs +1 -0
- package/addon/components/cell/telematic-status.js +39 -0
- package/addon/components/device/manager.hbs +5 -6
- package/addon/components/device/manager.js +12 -15
- package/addon/components/driver/details.hbs +1 -1
- package/addon/components/fleet/vehicle-listing.js +1 -0
- package/addon/components/fuel-integration/form.hbs +200 -0
- package/addon/components/fuel-integration/form.js +242 -0
- package/addon/components/fuel-integration/hub.hbs +154 -0
- package/addon/components/fuel-integration/hub.js +165 -0
- package/addon/components/fuel-integration/matching-priority.hbs +76 -0
- package/addon/components/fuel-integration/matching-priority.js +145 -0
- package/addon/components/fuel-report/details.hbs +13 -1
- package/addon/components/issue/details.hbs +3 -57
- package/addon/components/issue/details.js +0 -96
- package/addon/components/layout/fleet-ops-sidebar/operations-monitor.hbs +201 -0
- package/addon/components/layout/fleet-ops-sidebar/operations-monitor.js +589 -0
- package/addon/components/layout/fleet-ops-sidebar.hbs +19 -233
- package/addon/components/layout/fleet-ops-sidebar.js +287 -376
- package/addon/components/maintenance-schedule/form.js +1 -0
- package/addon/components/map/drawer/device-event-listing.hbs +12 -2
- package/addon/components/map/drawer/driver-listing.hbs +14 -1
- package/addon/components/map/drawer/place-listing.hbs +14 -1
- package/addon/components/map/drawer/position-listing.hbs +12 -2
- package/addon/components/map/drawer/vehicle-listing.hbs +14 -1
- package/addon/components/modals/assigned-orders.hbs +40 -0
- package/addon/components/modals/attach-device.hbs +4 -3
- package/addon/components/modals/attach-telematic-device.hbs +25 -0
- package/addon/components/modals/attach-telematic-device.js +3 -0
- package/addon/components/modals/driver-assign-order.hbs +7 -58
- package/addon/components/modals/driver-assign-vehicle.hbs +10 -2
- package/addon/components/modals/fleet-assign-driver.hbs +18 -0
- package/addon/components/modals/fleet-assign-driver.js +3 -0
- package/addon/components/modals/fleet-assign-vehicle.hbs +18 -0
- package/addon/components/modals/fleet-assign-vehicle.js +3 -0
- package/addon/components/modals/telematic-connection-diagnostics.hbs +75 -0
- package/addon/components/modals/telematic-connection-diagnostics.js +287 -0
- package/addon/components/modals/vehicle-details.hbs +6 -1
- package/addon/components/modals/vehicle-form.hbs +8 -1
- package/addon/components/order/card.hbs +106 -0
- package/addon/components/order/card.js +257 -0
- package/addon/components/order/form/payload.js +3 -1
- package/addon/components/order/form/service-rate.hbs +2 -0
- package/addon/components/service-rate/form.hbs +3 -2
- package/addon/components/telematic/details.hbs +98 -87
- package/addon/components/telematic/details.js +230 -1
- package/addon/components/telematic/form.hbs +303 -72
- package/addon/components/telematic/form.js +519 -3
- package/addon/components/telematic/hub.hbs +149 -0
- package/addon/components/telematic/hub.js +142 -0
- package/addon/components/telematic/settings.hbs +152 -0
- package/addon/components/telematic/settings.js +45 -0
- package/addon/components/telematic/tab-empty-state.hbs +29 -0
- package/addon/components/telematic/tab-empty-state.js +33 -0
- package/addon/components/vehicle/details.hbs +6 -1
- package/addon/components/vehicle/form.hbs +2 -1
- package/addon/components/widget/fuel-providers.hbs +43 -0
- package/addon/components/widget/fuel-providers.js +27 -0
- package/addon/controllers/connectivity/devices/index/details.js +27 -1
- package/addon/controllers/connectivity/devices/index.js +18 -1
- package/addon/controllers/connectivity/fuel-providers/details/sync.js +18 -0
- package/addon/controllers/connectivity/fuel-providers/details/transactions.js +24 -0
- package/addon/controllers/connectivity/fuel-providers/details.js +69 -0
- package/addon/controllers/connectivity/fuel-providers/edit.js +24 -0
- package/addon/controllers/connectivity/fuel-providers/index.js +177 -0
- package/addon/controllers/connectivity/fuel-providers/new.js +37 -0
- package/addon/controllers/connectivity/telematics/details/attachments.js +247 -0
- package/addon/controllers/connectivity/telematics/details/devices.js +368 -0
- package/addon/controllers/connectivity/telematics/details/events.js +244 -0
- package/addon/controllers/connectivity/telematics/details/index.js +3 -0
- package/addon/controllers/connectivity/telematics/details/logs.js +43 -0
- package/addon/controllers/connectivity/telematics/details/sensors.js +270 -0
- package/addon/controllers/connectivity/telematics/details.js +149 -0
- package/addon/controllers/connectivity/telematics/{index/edit.js → edit.js} +15 -4
- package/addon/controllers/connectivity/telematics/index.js +25 -5
- package/addon/controllers/connectivity/telematics/{index/new.js → new.js} +8 -2
- package/addon/controllers/maintenance/index.js +100 -0
- package/addon/controllers/management/drivers/index/details.js +78 -1
- package/addon/controllers/management/drivers/index.js +39 -0
- package/addon/controllers/management/fleets/index/details.js +23 -1
- package/addon/controllers/management/fleets/index.js +6 -1
- package/addon/controllers/management/fuel-reports/index.js +37 -1
- package/addon/controllers/management/fuel-transactions/index/details.js +70 -0
- package/addon/controllers/management/fuel-transactions/index.js +240 -0
- package/addon/controllers/management/index.js +88 -0
- package/addon/controllers/management/vehicles/index/details.js +32 -0
- package/addon/controllers/management/vehicles/index.js +26 -0
- package/addon/controllers/operations/orders/index.js +4 -0
- package/addon/controllers/settings/index.js +142 -0
- package/addon/controllers/settings/payments/index.js +5 -0
- package/addon/extension.js +31 -0
- package/addon/routes/analytics/index.js +3 -0
- package/addon/routes/connectivity/devices/index.js +3 -0
- package/addon/routes/connectivity/fuel-providers/details/index.js +7 -0
- package/addon/routes/connectivity/fuel-providers/details/matching.js +7 -0
- package/addon/routes/connectivity/fuel-providers/details/settings.js +7 -0
- package/addon/routes/connectivity/fuel-providers/details/sync.js +18 -0
- package/addon/routes/connectivity/fuel-providers/details/transactions.js +14 -0
- package/addon/routes/connectivity/fuel-providers/details.js +18 -0
- package/addon/routes/connectivity/fuel-providers/edit.js +18 -0
- package/addon/routes/connectivity/fuel-providers/index.js +20 -0
- package/addon/routes/connectivity/fuel-providers/new.js +3 -0
- package/addon/routes/connectivity/fuel-providers.js +3 -0
- package/addon/routes/connectivity/telematics/details/attachments.js +28 -0
- package/addon/routes/connectivity/telematics/details/devices.js +30 -0
- package/addon/routes/connectivity/telematics/details/events.js +33 -0
- package/addon/routes/connectivity/telematics/details/index.js +3 -0
- package/addon/routes/connectivity/telematics/details/logs.js +17 -0
- package/addon/routes/connectivity/telematics/details/sensors.js +29 -0
- package/addon/routes/connectivity/telematics/{index/details.js → details.js} +1 -1
- package/addon/routes/connectivity/telematics/{index/edit.js → edit.js} +1 -1
- package/addon/routes/connectivity/telematics/new.js +3 -0
- package/addon/routes/maintenance/index.js +3 -0
- package/addon/routes/maintenance/work-orders/index.js +2 -0
- package/addon/routes/management/drivers/index/details/activity.js +3 -0
- package/addon/routes/management/fuel-reports/index.js +2 -0
- package/addon/routes/management/fuel-transactions/index/details.js +18 -0
- package/addon/routes/management/fuel-transactions/index.js +21 -0
- package/addon/routes/management/fuel-transactions.js +3 -0
- package/addon/routes/settings/index.js +3 -0
- package/addon/routes.js +28 -9
- package/addon/services/device-actions.js +64 -1
- package/addon/services/device-event-actions.js +12 -1
- package/addon/services/driver-actions.js +147 -11
- package/addon/services/fleet-actions.js +66 -1
- package/addon/services/fuel-integration-actions.js +31 -0
- package/addon/services/issue-actions.js +1 -1
- package/addon/services/telematic-actions.js +9 -3
- package/addon/services/vehicle-actions.js +125 -0
- package/addon/styles/fleetops-engine.css +2237 -162
- package/addon/templates/analytics/index.hbs +14 -0
- package/addon/templates/analytics/reports/index.hbs +19 -1
- package/addon/templates/connectivity/devices/index.hbs +19 -1
- package/addon/templates/connectivity/events/index.hbs +16 -1
- package/addon/templates/connectivity/fuel-providers/details/index.hbs +38 -0
- package/addon/templates/connectivity/fuel-providers/details/matching.hbs +13 -0
- package/addon/templates/connectivity/fuel-providers/details/settings.hbs +11 -0
- package/addon/templates/connectivity/fuel-providers/details/sync.hbs +48 -0
- package/addon/templates/connectivity/fuel-providers/details/transactions.hbs +21 -0
- package/addon/templates/connectivity/fuel-providers/details.hbs +51 -0
- package/addon/templates/connectivity/fuel-providers/edit.hbs +24 -0
- package/addon/templates/connectivity/fuel-providers/index.hbs +12 -0
- package/addon/templates/connectivity/fuel-providers/new.hbs +22 -0
- package/addon/templates/connectivity/fuel-providers.hbs +1 -0
- package/addon/templates/connectivity/sensors/index.hbs +19 -1
- package/addon/templates/connectivity/telematics/details/attachments.hbs +163 -0
- package/addon/templates/connectivity/telematics/details/devices.hbs +88 -0
- package/addon/templates/connectivity/telematics/details/events.hbs +101 -0
- package/addon/templates/connectivity/telematics/{index/details → details}/index.hbs +0 -1
- package/addon/templates/connectivity/telematics/details/logs.hbs +69 -0
- package/addon/templates/connectivity/telematics/details/sensors.hbs +88 -0
- package/addon/templates/connectivity/telematics/details.hbs +53 -0
- package/addon/templates/connectivity/telematics/edit.hbs +27 -0
- package/addon/templates/connectivity/telematics/index.hbs +6 -8
- package/addon/templates/connectivity/telematics/new.hbs +24 -0
- package/addon/templates/maintenance/equipment/index.hbs +19 -1
- package/addon/templates/maintenance/index.hbs +113 -0
- package/addon/templates/maintenance/maintenances/index.hbs +15 -1
- package/addon/templates/maintenance/parts/index.hbs +19 -1
- package/addon/templates/maintenance/schedules/index.hbs +19 -1
- package/addon/templates/maintenance/work-orders/index.hbs +19 -1
- package/addon/templates/management/contacts/customers.hbs +15 -1
- package/addon/templates/management/contacts/index.hbs +19 -1
- package/addon/templates/management/drivers/index/details/activity.hbs +1 -0
- package/addon/templates/management/drivers/index.hbs +19 -1
- package/addon/templates/management/fleets/index.hbs +19 -1
- package/addon/templates/management/fuel-reports/index.hbs +19 -1
- package/addon/templates/management/fuel-transactions/index/details.hbs +73 -0
- package/addon/templates/management/fuel-transactions/index.hbs +58 -0
- package/addon/templates/management/fuel-transactions.hbs +1 -0
- package/addon/templates/management/index.hbs +109 -73
- package/addon/templates/management/issues/index.hbs +19 -1
- package/addon/templates/management/places/index.hbs +19 -1
- package/addon/templates/management/vehicles/index.hbs +19 -1
- package/addon/templates/management/vendors/index.hbs +19 -1
- package/addon/templates/management/vendors/integrated.hbs +13 -1
- package/addon/templates/operations/orders/index.hbs +19 -1
- package/addon/templates/operations/service-rates/index.hbs +19 -1
- package/addon/templates/settings/index.hbs +83 -0
- package/addon/templates/settings/payments/index.hbs +15 -1
- package/addon/templates/settings/routing.hbs +2 -2
- package/addon/utils/fleet-ops-options.js +3 -0
- package/app/components/cell/telematic-provider.js +1 -0
- package/app/components/cell/telematic-status.js +1 -0
- package/app/components/fuel-integration/form.js +1 -0
- package/app/components/fuel-integration/hub.js +1 -0
- package/app/components/fuel-integration/matching-priority.js +1 -0
- package/app/components/modals/assigned-orders.js +1 -0
- package/app/components/modals/attach-telematic-device.js +1 -0
- package/app/components/modals/fleet-assign-driver.js +1 -0
- package/app/components/modals/fleet-assign-vehicle.js +1 -0
- package/app/components/modals/telematic-connection-diagnostics.js +1 -0
- package/app/components/order/card.js +1 -0
- package/app/components/telematic/hub.js +1 -0
- package/app/components/telematic/settings.js +1 -0
- package/app/components/telematic/tab-empty-state.js +1 -0
- package/app/components/widget/fuel-providers.js +1 -0
- package/app/controllers/connectivity/fuel-providers/details/sync.js +1 -0
- package/app/controllers/connectivity/{telematics/index/details/devices.js → fuel-providers/details/transactions.js} +1 -1
- package/app/controllers/connectivity/{telematics/index → fuel-providers}/details.js +1 -1
- package/app/controllers/connectivity/{telematics/index → fuel-providers}/edit.js +1 -1
- package/app/controllers/connectivity/{telematics/index/details → fuel-providers}/index.js +1 -1
- package/app/controllers/connectivity/{telematics/index → fuel-providers}/new.js +1 -1
- package/app/controllers/connectivity/telematics/details/attachments.js +1 -0
- package/app/controllers/connectivity/telematics/details/devices.js +1 -0
- package/app/controllers/connectivity/telematics/details/events.js +1 -0
- package/app/controllers/connectivity/telematics/details/index.js +1 -0
- package/app/controllers/connectivity/telematics/details/logs.js +1 -0
- package/app/controllers/connectivity/telematics/details/sensors.js +1 -0
- package/app/controllers/connectivity/telematics/details.js +1 -0
- package/app/controllers/connectivity/telematics/edit.js +1 -0
- package/app/controllers/connectivity/telematics/new.js +1 -0
- package/app/controllers/maintenance/index.js +1 -0
- package/app/controllers/management/fuel-transactions/index/details.js +1 -0
- package/app/controllers/management/fuel-transactions/index.js +1 -0
- package/app/controllers/management/index.js +1 -0
- package/app/controllers/settings/index.js +1 -0
- package/app/routes/analytics/index.js +1 -0
- package/app/routes/connectivity/{telematics/index → fuel-providers}/details/index.js +1 -1
- package/app/routes/connectivity/{telematics/index/details/events.js → fuel-providers/details/matching.js} +1 -1
- package/app/routes/connectivity/fuel-providers/details/settings.js +1 -0
- package/app/routes/connectivity/fuel-providers/details/sync.js +1 -0
- package/app/routes/connectivity/{telematics/index/details/devices.js → fuel-providers/details/transactions.js} +1 -1
- package/app/routes/connectivity/{telematics/index → fuel-providers}/details.js +1 -1
- package/app/routes/connectivity/{telematics/index → fuel-providers}/edit.js +1 -1
- package/app/routes/connectivity/fuel-providers/index.js +1 -0
- package/app/routes/connectivity/{telematics/index → fuel-providers}/new.js +1 -1
- package/app/routes/connectivity/fuel-providers.js +1 -0
- package/app/routes/connectivity/telematics/details/attachments.js +1 -0
- package/app/routes/connectivity/telematics/details/devices.js +1 -0
- package/app/routes/connectivity/telematics/details/events.js +1 -0
- package/app/routes/connectivity/telematics/details/index.js +1 -0
- package/app/routes/connectivity/telematics/details/logs.js +1 -0
- package/app/routes/connectivity/telematics/details/sensors.js +1 -0
- package/app/routes/connectivity/telematics/details.js +1 -0
- package/app/routes/connectivity/telematics/edit.js +1 -0
- package/app/routes/connectivity/telematics/new.js +1 -0
- package/app/routes/maintenance/index.js +1 -0
- package/app/routes/management/drivers/index/details/activity.js +1 -0
- package/app/routes/management/fuel-transactions/index/details.js +1 -0
- package/app/routes/management/fuel-transactions/index.js +1 -0
- package/app/routes/management/fuel-transactions.js +1 -0
- package/app/routes/settings/index.js +1 -0
- package/app/services/fuel-integration-actions.js +1 -0
- package/app/templates/analytics/index.js +1 -0
- package/app/templates/connectivity/{telematics/index → fuel-providers}/details/index.js +1 -1
- package/app/templates/connectivity/{telematics/index/details/events.js → fuel-providers/details/matching.js} +1 -1
- package/app/templates/connectivity/fuel-providers/details/settings.js +1 -0
- package/app/templates/connectivity/fuel-providers/details/sync.js +1 -0
- package/app/templates/connectivity/{telematics/index/details/devices.js → fuel-providers/details/transactions.js} +1 -1
- package/app/templates/connectivity/{telematics/index → fuel-providers}/details.js +1 -1
- package/app/templates/connectivity/{telematics/index → fuel-providers}/edit.js +1 -1
- package/app/templates/connectivity/fuel-providers/index.js +1 -0
- package/app/templates/connectivity/{telematics/index → fuel-providers}/new.js +1 -1
- package/app/templates/connectivity/fuel-providers.js +1 -0
- package/app/templates/connectivity/telematics/details/attachments.js +1 -0
- package/app/templates/connectivity/telematics/details/devices.js +1 -0
- package/app/templates/connectivity/telematics/details/events.js +1 -0
- package/app/templates/connectivity/telematics/details/index.js +1 -0
- package/app/templates/connectivity/telematics/details/logs.js +1 -0
- package/app/templates/connectivity/telematics/details/sensors.js +1 -0
- package/app/templates/connectivity/telematics/details.js +1 -0
- package/app/templates/connectivity/telematics/edit.js +1 -0
- package/app/templates/connectivity/telematics/new.js +1 -0
- package/app/templates/maintenance/index.js +1 -0
- package/app/templates/management/drivers/index/details/activity.js +1 -0
- package/app/templates/management/fuel-transactions/index/details.js +1 -0
- package/app/templates/management/fuel-transactions/index.js +1 -0
- package/app/templates/management/fuel-transactions.js +1 -0
- package/app/templates/management/index.js +1 -0
- package/app/templates/settings/index.js +1 -0
- package/assets/images/telematics/providers/afaqy.webp +0 -0
- package/assets/images/telematics/providers/default.webp +0 -0
- package/assets/images/telematics/providers/flespi.webp +0 -0
- package/assets/images/telematics/providers/geotab.webp +0 -0
- package/assets/images/telematics/providers/safee.webp +0 -0
- package/assets/images/telematics/providers/samsara.webp +0 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +4 -4
- package/server/config/fuel-providers.php +42 -0
- package/server/config/telematics.php +139 -130
- package/server/migrations/2026_06_06_000001_harden_device_events_telematics_contract.php +59 -0
- package/server/migrations/2026_06_08_000001_create_fuel_provider_connections_table.php +37 -0
- package/server/migrations/2026_06_08_000002_create_fuel_provider_transactions_table.php +53 -0
- package/server/migrations/2026_06_08_000003_create_fuel_provider_sync_runs_table.php +40 -0
- package/server/migrations/2026_06_10_000001_add_fuel_card_number_to_vehicles_table.php +25 -0
- package/server/migrations/2026_06_10_000002_add_vehicle_identity_columns_to_fuel_provider_transactions_table.php +39 -0
- package/server/migrations/2026_06_15_000001_normalize_device_attachable_vehicle_morph_types.php +30 -0
- package/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php +1 -0
- package/server/src/Contracts/FuelProvider.php +30 -0
- package/server/src/Contracts/TelematicProviderDescriptor.php +3 -1
- package/server/src/Events/FuelProviderTransactionImported.php +17 -0
- package/server/src/Events/FuelProviderTransactionMatched.php +17 -0
- package/server/src/Events/FuelProviderTransactionUnmatched.php +17 -0
- package/server/src/Events/FuelReportCreatedFromProvider.php +18 -0
- package/server/src/Http/Controllers/Internal/v1/AnalyticsController.php +6 -0
- package/server/src/Http/Controllers/Internal/v1/DeviceController.php +140 -2
- package/server/src/Http/Controllers/Internal/v1/DeviceEventController.php +44 -0
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +158 -7
- package/server/src/Http/Controllers/Internal/v1/FuelProviderConnectionController.php +124 -0
- package/server/src/Http/Controllers/Internal/v1/FuelProviderSyncRunController.php +10 -0
- package/server/src/Http/Controllers/Internal/v1/FuelProviderTransactionController.php +76 -0
- package/server/src/Http/Controllers/Internal/v1/HubController.php +300 -0
- package/server/src/Http/Controllers/Internal/v1/SearchController.php +506 -0
- package/server/src/Http/Controllers/Internal/v1/SensorController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/TelematicController.php +179 -16
- package/server/src/Http/Controllers/Internal/v1/VehicleController.php +249 -0
- package/server/src/Http/Controllers/TelematicWebhookController.php +103 -19
- package/server/src/Http/Filter/DeviceFilter.php +74 -0
- package/server/src/Http/Filter/DriverFilter.php +6 -0
- package/server/src/Http/Filter/FuelProviderConnectionFilter.php +33 -0
- package/server/src/Http/Filter/FuelProviderSyncRunFilter.php +28 -0
- package/server/src/Http/Filter/FuelProviderTransactionFilter.php +59 -0
- package/server/src/Http/Filter/FuelReportFilter.php +10 -0
- package/server/src/Http/Filter/VehicleFilter.php +6 -0
- package/server/src/Http/Resources/v1/Driver.php +15 -0
- package/server/src/Http/Resources/v1/FuelProviderConnection.php +30 -0
- package/server/src/Http/Resources/v1/FuelProviderSyncRun.php +36 -0
- package/server/src/Http/Resources/v1/FuelProviderTransaction.php +54 -0
- package/server/src/Http/Resources/v1/FuelReport.php +28 -22
- package/server/src/Http/Resources/v1/Index/Driver.php +26 -20
- package/server/src/Http/Resources/v1/Index/Vehicle.php +29 -22
- package/server/src/Http/Resources/v1/Vehicle.php +17 -0
- package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +2 -0
- package/server/src/Jobs/SyncFuelProviderTransactionsJob.php +57 -0
- package/server/src/Jobs/SyncTelematicDevicesJob.php +105 -17
- package/server/src/Jobs/TestTelematicConnectionJob.php +9 -22
- package/server/src/Models/Asset.php +2 -1
- package/server/src/Models/Contact.php +2 -1
- package/server/src/Models/Device.php +27 -4
- package/server/src/Models/DeviceEvent.php +40 -3
- package/server/src/Models/Driver.php +3 -2
- package/server/src/Models/Equipment.php +2 -1
- package/server/src/Models/Fleet.php +2 -1
- package/server/src/Models/FuelProviderConnection.php +60 -0
- package/server/src/Models/FuelProviderSyncRun.php +58 -0
- package/server/src/Models/FuelProviderTransaction.php +119 -0
- package/server/src/Models/FuelReport.php +16 -1
- package/server/src/Models/Part.php +2 -1
- package/server/src/Models/Sensor.php +21 -4
- package/server/src/Models/ServiceRate.php +39 -2
- package/server/src/Models/Vehicle.php +14 -2
- package/server/src/Models/Vendor.php +2 -1
- package/server/src/Providers/FleetOpsServiceProvider.php +20 -0
- package/server/src/Support/Analytics/FuelProviderSummary.php +42 -0
- package/server/src/Support/FuelProviders/FuelProviderDescriptor.php +55 -0
- package/server/src/Support/FuelProviders/FuelProviderRegistry.php +75 -0
- package/server/src/Support/FuelProviders/FuelProviderService.php +447 -0
- package/server/src/Support/FuelProviders/Providers/AbstractFuelProvider.php +98 -0
- package/server/src/Support/FuelProviders/Providers/PetroAppFuelProvider.php +167 -0
- package/server/src/Support/Telematics/Providers/AbstractProvider.php +27 -6
- package/server/src/Support/Telematics/Providers/AfaqyProvider.php +105 -38
- package/server/src/Support/Telematics/Providers/FlespiProvider.php +1 -0
- package/server/src/Support/Telematics/Providers/GeotabProvider.php +1 -0
- package/server/src/Support/Telematics/Providers/SafeeProvider.php +32 -22
- package/server/src/Support/Telematics/Providers/SamsaraProvider.php +3 -1
- package/server/src/Support/Telematics/TelematicService.php +340 -21
- package/server/src/routes.php +50 -4
- package/server/tests/FuelProviderRegistryTest.php +416 -0
- package/server/tests/HubRoutesTest.php +62 -0
- package/server/tests/ServiceRateAlgorithmWeightVariablesTest.php +44 -0
- package/server/tests/TelematicsHardeningTest.php +359 -0
- package/server/tests/VehicleDriverAssignmentTest.php +51 -0
- package/translations/ar-ae.yml +23 -1
- package/translations/bg-bg.yaml +72 -0
- package/translations/en-us.yaml +83 -0
- package/translations/es-pa.yaml +72 -0
- package/translations/fr-fr.yaml +72 -0
- package/translations/mn-mn.yaml +72 -0
- package/translations/pt-br.yaml +72 -0
- package/translations/ru-ru.yaml +72 -0
- package/translations/vi-vn.yaml +98 -1
- package/addon/controllers/connectivity/telematics/index/details/devices.js +0 -3
- package/addon/controllers/connectivity/telematics/index/details/events.js +0 -3
- package/addon/controllers/connectivity/telematics/index/details/index.js +0 -3
- package/addon/controllers/connectivity/telematics/index/details/sensors.js +0 -3
- package/addon/controllers/connectivity/telematics/index/details.js +0 -24
- package/addon/routes/connectivity/telematics/index/details/devices.js +0 -3
- package/addon/routes/connectivity/telematics/index/details/events.js +0 -3
- package/addon/routes/connectivity/telematics/index/details/index.js +0 -3
- package/addon/routes/connectivity/telematics/index/details/sensors.js +0 -3
- package/addon/routes/connectivity/telematics/index/new.js +0 -3
- package/addon/templates/connectivity/telematics/index/details/devices.hbs +0 -1
- package/addon/templates/connectivity/telematics/index/details/events.hbs +0 -1
- package/addon/templates/connectivity/telematics/index/details/sensors.hbs +0 -1
- package/addon/templates/connectivity/telematics/index/details.hbs +0 -14
- package/addon/templates/connectivity/telematics/index/edit.hbs +0 -12
- package/addon/templates/connectivity/telematics/index/new.hbs +0 -12
- package/app/controllers/connectivity/telematics/index/details/events.js +0 -1
- package/app/controllers/connectivity/telematics/index/details/sensors.js +0 -1
- package/app/routes/connectivity/telematics/index/details/sensors.js +0 -1
- package/app/templates/connectivity/telematics/index/details/sensors.js +0 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { inject as service } from '@ember/service';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import { task } from 'ember-concurrency';
|
|
6
|
+
import copyToClipboard from '@fleetbase/ember-core/utils/copy-to-clipboard';
|
|
7
|
+
|
|
8
|
+
const SENSITIVE_METADATA_KEYS = ['password', 'secret', 'session', 'token'];
|
|
9
|
+
|
|
10
|
+
export default class ModalsTelematicConnectionDiagnosticsComponent extends Component {
|
|
11
|
+
@service fetch;
|
|
12
|
+
@service modalsManager;
|
|
13
|
+
@service notifications;
|
|
14
|
+
|
|
15
|
+
@tracked result;
|
|
16
|
+
@tracked startedAt;
|
|
17
|
+
@tracked completedAt;
|
|
18
|
+
|
|
19
|
+
constructor(owner, { options = {} }) {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.setupOptions();
|
|
23
|
+
this.runTest.perform();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get telematic() {
|
|
27
|
+
return this.options.telematic;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get providerLabel() {
|
|
31
|
+
return this.telematic?.provider_descriptor?.label ?? this.telematic?.provider ?? 'Provider';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get providerKey() {
|
|
35
|
+
return this.telematic?.provider;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get connectionState() {
|
|
39
|
+
if (this.runTest.isRunning) {
|
|
40
|
+
return 'testing';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!this.result) {
|
|
44
|
+
return 'idle';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return this.result.success ? 'success' : 'failed';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get connectionStateTitle() {
|
|
51
|
+
if (this.connectionState === 'testing') {
|
|
52
|
+
return 'Testing provider connection...';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.connectionState === 'success') {
|
|
56
|
+
return 'Connection verified';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (this.connectionState === 'failed') {
|
|
60
|
+
return 'Connection failed';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return 'Ready to test';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get connectionStateMessage() {
|
|
67
|
+
if (this.connectionState === 'testing') {
|
|
68
|
+
return 'Waiting for the provider to accept the saved credentials.';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (this.connectionState === 'idle') {
|
|
72
|
+
return 'Run a connection test to verify the saved provider credentials.';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (this.isDuplicateConnectionMessage) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return this.result?.message;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get isDuplicateConnectionMessage() {
|
|
83
|
+
const message = this.result?.message;
|
|
84
|
+
|
|
85
|
+
if (!message) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return ['connection successful', 'connection verified'].includes(message.trim().toLowerCase());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get connectionMetadataEntries() {
|
|
93
|
+
const metadata = this.result?.metadata ?? {};
|
|
94
|
+
|
|
95
|
+
return Object.entries(metadata)
|
|
96
|
+
.filter(([key, value]) => {
|
|
97
|
+
if (value === null || value === undefined || value === '') {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return !this.isSensitiveMetadataKey(key);
|
|
102
|
+
})
|
|
103
|
+
.map(([key, value]) => ({
|
|
104
|
+
label: this.formatMetadataLabel(key),
|
|
105
|
+
value: this.formatDiagnosticValue(value),
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
get hasConnectionMetadata() {
|
|
110
|
+
return this.connectionMetadataEntries.length > 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get connectionDiagnosticEntries() {
|
|
114
|
+
const entries = [];
|
|
115
|
+
const startedAt = this.startedAt;
|
|
116
|
+
const completedAt = this.completedAt;
|
|
117
|
+
|
|
118
|
+
entries.push({
|
|
119
|
+
time: this.formatDiagnosticTime(startedAt),
|
|
120
|
+
tone: 'muted',
|
|
121
|
+
text: `Provider selected: ${this.providerLabel}${this.providerKey ? ` (${this.providerKey})` : ''}`,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
entries.push({
|
|
125
|
+
time: this.formatDiagnosticTime(startedAt),
|
|
126
|
+
tone: 'info',
|
|
127
|
+
text: 'Sending saved provider connection test request',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (this.connectionState === 'testing') {
|
|
131
|
+
entries.push({
|
|
132
|
+
time: this.formatDiagnosticTime(),
|
|
133
|
+
tone: 'info',
|
|
134
|
+
text: 'Awaiting provider response',
|
|
135
|
+
});
|
|
136
|
+
return entries;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.connectionState === 'idle') {
|
|
140
|
+
entries.push({
|
|
141
|
+
time: this.formatDiagnosticTime(),
|
|
142
|
+
tone: 'muted',
|
|
143
|
+
text: 'Connection test has not been run yet',
|
|
144
|
+
});
|
|
145
|
+
return entries;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
entries.push({
|
|
149
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
150
|
+
tone: 'info',
|
|
151
|
+
text: 'Provider response received',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (this.hasConnectionMetadata) {
|
|
155
|
+
entries.push({
|
|
156
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
157
|
+
tone: 'muted',
|
|
158
|
+
text: `Provider metadata: ${this.connectionMetadataEntries.map((entry) => `${entry.label}=${entry.value}`).join(', ')}`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.connectionState === 'success') {
|
|
163
|
+
entries.push({
|
|
164
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
165
|
+
tone: 'success',
|
|
166
|
+
text: 'Connection verified',
|
|
167
|
+
});
|
|
168
|
+
return entries;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
entries.push({
|
|
172
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
173
|
+
tone: 'danger',
|
|
174
|
+
text: `Connection failed${this.result?.message ? `: ${this.formatDiagnosticValue(this.result.message)}` : ''}`,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
return entries;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
get connectionDiagnosticText() {
|
|
181
|
+
return this.connectionDiagnosticEntries.map((entry) => `[${entry.time}] ${entry.text}`).join('\n');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setupOptions() {
|
|
185
|
+
this.options.title = this.options.title ?? 'Test Connection';
|
|
186
|
+
this.options.acceptButtonText = 'Run Test';
|
|
187
|
+
this.options.acceptButtonIcon = 'plug';
|
|
188
|
+
this.options.declineButtonText = this.options.declineButtonText ?? 'Close';
|
|
189
|
+
this.options.confirm = async (modal) => {
|
|
190
|
+
modal.startLoading();
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
await this.runTest.perform();
|
|
194
|
+
} finally {
|
|
195
|
+
modal.stopLoading();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@task *runTest() {
|
|
201
|
+
if (!this.telematic?.id) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.startedAt = new Date();
|
|
206
|
+
this.completedAt = null;
|
|
207
|
+
this.modalsManager.setOption('acceptButtonDisabled', true);
|
|
208
|
+
this.modalsManager.setOption('acceptButtonText', 'Testing...');
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const result = yield this.fetch.post(`telematics/${this.telematic.id}/test-connection`);
|
|
212
|
+
this.result = result;
|
|
213
|
+
this.completedAt = new Date();
|
|
214
|
+
yield this.options.onTested?.(result);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
this.completedAt = new Date();
|
|
217
|
+
this.result = {
|
|
218
|
+
success: false,
|
|
219
|
+
message: error.message || 'Connection test failed',
|
|
220
|
+
};
|
|
221
|
+
} finally {
|
|
222
|
+
this.modalsManager.setOption('acceptButtonDisabled', false);
|
|
223
|
+
this.modalsManager.setOption('acceptButtonText', this.result ? 'Test Again' : 'Run Test');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@action
|
|
228
|
+
copyConnectionDiagnostics() {
|
|
229
|
+
copyToClipboard(this.connectionDiagnosticText)
|
|
230
|
+
.then(() => {
|
|
231
|
+
this.notifications.success('Connection diagnostics copied.');
|
|
232
|
+
})
|
|
233
|
+
.catch(() => {
|
|
234
|
+
this.notifications.error('Unable to copy connection diagnostics.');
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
formatMetadataLabel(key) {
|
|
239
|
+
return key.replace(/_/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase());
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
formatDiagnosticValue(value) {
|
|
243
|
+
const sanitizedValue = this.sanitizeDiagnosticValue(value);
|
|
244
|
+
|
|
245
|
+
if (typeof sanitizedValue === 'object') {
|
|
246
|
+
return JSON.stringify(sanitizedValue);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return String(sanitizedValue);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
sanitizeDiagnosticValue(value, seen = new WeakSet()) {
|
|
253
|
+
if (!value || typeof value !== 'object') {
|
|
254
|
+
return value;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (seen.has(value)) {
|
|
258
|
+
return '[circular]';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
seen.add(value);
|
|
262
|
+
|
|
263
|
+
if (Array.isArray(value)) {
|
|
264
|
+
return value.map((item) => this.sanitizeDiagnosticValue(item, seen));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return Object.entries(value).reduce((acc, [key, item]) => {
|
|
268
|
+
if (!this.isSensitiveMetadataKey(key)) {
|
|
269
|
+
acc[key] = this.sanitizeDiagnosticValue(item, seen);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return acc;
|
|
273
|
+
}, {});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
formatDiagnosticTime(date = new Date()) {
|
|
277
|
+
if (!(date instanceof Date)) {
|
|
278
|
+
return '--:--:--';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
isSensitiveMetadataKey(key) {
|
|
285
|
+
return SENSITIVE_METADATA_KEYS.some((sensitiveKey) => key.toLowerCase().includes(sensitiveKey));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
<div class="field-value">{{n-a @options.vehicle.vin}}</div>
|
|
30
30
|
</div>
|
|
31
31
|
|
|
32
|
+
<div class="field-info-container">
|
|
33
|
+
<div class="field-name">Fuel Card Number</div>
|
|
34
|
+
<div class="field-value">{{n-a @options.vehicle.fuel_card_number}}</div>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
32
37
|
<div class="field-info-container">
|
|
33
38
|
<div class="field-name">{{t "modals.vehicle-details.make"}}</div>
|
|
34
39
|
<div class="field-value">{{n-a @options.vehicle.name}}</div>
|
|
@@ -224,4 +229,4 @@
|
|
|
224
229
|
</div>
|
|
225
230
|
</div>
|
|
226
231
|
{{yield}}
|
|
227
|
-
</Modal::Default>
|
|
232
|
+
</Modal::Default>
|
|
@@ -36,6 +36,13 @@
|
|
|
36
36
|
<Input @value={{@options.vehicle.vin}} @type="text" class="w-full form-input" placeholder={{t "common.vin-number"}} />
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
|
+
<div class="input-group mb-2">
|
|
40
|
+
<label>
|
|
41
|
+
Fuel Card Number
|
|
42
|
+
</label>
|
|
43
|
+
<Input @value={{@options.vehicle.fuel_card_number}} @type="text" class="w-full form-input" placeholder="Fuel Card Number" />
|
|
44
|
+
</div>
|
|
45
|
+
|
|
39
46
|
<div class="input-group mb-2">
|
|
40
47
|
<label>
|
|
41
48
|
{{t "modals.vehicle-details.make"}}
|
|
@@ -303,4 +310,4 @@
|
|
|
303
310
|
</div>
|
|
304
311
|
</div>
|
|
305
312
|
</div>
|
|
306
|
-
</Modal::Default>
|
|
313
|
+
</Modal::Default>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{{! template-lint-disable no-positive-tabindex }}
|
|
2
|
+
<div
|
|
3
|
+
class={{this.classNames}}
|
|
4
|
+
role={{this.role}}
|
|
5
|
+
tabindex={{this.tabIndex}}
|
|
6
|
+
{{on "click" this.handleClick}}
|
|
7
|
+
{{on "keydown" this.handleKeyDown}}
|
|
8
|
+
...attributes
|
|
9
|
+
>
|
|
10
|
+
<div class="order-card-topline">
|
|
11
|
+
{{#if @selectable}}
|
|
12
|
+
<Input
|
|
13
|
+
@type="checkbox"
|
|
14
|
+
class="order-card-checkbox form-checkbox"
|
|
15
|
+
@checked={{@selected}}
|
|
16
|
+
disabled={{@disabled}}
|
|
17
|
+
{{on "click" this.handleSelect}}
|
|
18
|
+
/>
|
|
19
|
+
{{/if}}
|
|
20
|
+
<div class="order-card-title-block">
|
|
21
|
+
<div class="order-card-title">{{n-a this.orderLabel (t "order.card.unknown-order")}}</div>
|
|
22
|
+
{{#if this.showType}}
|
|
23
|
+
<div class="order-card-subtitle">{{n-a (smart-humanize this.orderTypeLabel) (t "order.card.no-type")}}</div>
|
|
24
|
+
{{/if}}
|
|
25
|
+
</div>
|
|
26
|
+
{{#if (has-block "headerActions")}}
|
|
27
|
+
<div class="order-card-header-actions">
|
|
28
|
+
{{yield this.order to="headerActions"}}
|
|
29
|
+
</div>
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if this.showStatus}}
|
|
32
|
+
<Badge @status={{this.order.status}} />
|
|
33
|
+
{{/if}}
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
{{#if this.showProgress}}
|
|
37
|
+
<div class="order-card-progress {{this.orderProgressClass}}">
|
|
38
|
+
<span></span>
|
|
39
|
+
</div>
|
|
40
|
+
{{/if}}
|
|
41
|
+
|
|
42
|
+
{{#if this.showRoute}}
|
|
43
|
+
{{#if this.hasOrderStops}}
|
|
44
|
+
<div class="order-card-route">
|
|
45
|
+
<div class="order-card-stop">
|
|
46
|
+
<div class="order-card-stop-marker pickup">1</div>
|
|
47
|
+
<div class="min-w-0">
|
|
48
|
+
<div class="order-card-stop-label">{{t "order.card.pickup"}}</div>
|
|
49
|
+
<div class="order-card-stop-address">{{n-a this.orderOriginAddress (t "order.card.no-pickup-address")}}</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
{{#if this.isMultiStopOrder}}
|
|
53
|
+
<div class="order-card-stop compact">
|
|
54
|
+
<div class="order-card-stop-marker middle">+</div>
|
|
55
|
+
<div class="min-w-0">
|
|
56
|
+
<div class="order-card-stop-label">{{t "order.card.waypoints"}}</div>
|
|
57
|
+
<div class="order-card-stop-address">
|
|
58
|
+
{{this.middleStopCount}}
|
|
59
|
+
{{if (eq this.middleStopCount 1) (t "order.card.additional-stop") (t "order.card.additional-stops")}}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
{{/if}}
|
|
64
|
+
<div class="order-card-stop">
|
|
65
|
+
<div class="order-card-stop-marker dropoff">{{this.orderStopCount}}</div>
|
|
66
|
+
<div class="min-w-0">
|
|
67
|
+
<div class="order-card-stop-label">{{t this.destinationLabelKey}}</div>
|
|
68
|
+
<div class="order-card-stop-address">{{n-a this.orderDestinationAddress (t "order.card.no-dropoff-address")}}</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
{{else}}
|
|
73
|
+
{{#if (has-block "emptyRoute")}}
|
|
74
|
+
{{yield this.order to="emptyRoute"}}
|
|
75
|
+
{{else}}
|
|
76
|
+
<div class="order-card-empty-route">
|
|
77
|
+
<FaIcon @icon="route" />
|
|
78
|
+
<span>{{t "order.card.no-route-details"}}</span>
|
|
79
|
+
</div>
|
|
80
|
+
{{/if}}
|
|
81
|
+
{{/if}}
|
|
82
|
+
{{/if}}
|
|
83
|
+
|
|
84
|
+
{{#if this.showMeta}}
|
|
85
|
+
{{#if (has-block "meta")}}
|
|
86
|
+
{{yield this.order to="meta"}}
|
|
87
|
+
{{else if this.hasMeta}}
|
|
88
|
+
<div class="order-card-meta">
|
|
89
|
+
{{#each this.metaItems as |item|}}
|
|
90
|
+
<span>
|
|
91
|
+
<FaIcon @icon={{item.icon}} />
|
|
92
|
+
{{#if item.isDate}}
|
|
93
|
+
{{format-date-fns item.value "MMM d, HH:mm"}}
|
|
94
|
+
{{else}}
|
|
95
|
+
{{item.value}}
|
|
96
|
+
{{/if}}
|
|
97
|
+
</span>
|
|
98
|
+
{{/each}}
|
|
99
|
+
</div>
|
|
100
|
+
{{/if}}
|
|
101
|
+
{{/if}}
|
|
102
|
+
|
|
103
|
+
{{#if (has-block "footer")}}
|
|
104
|
+
{{yield this.order to="footer"}}
|
|
105
|
+
{{/if}}
|
|
106
|
+
</div>
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
|
|
4
|
+
const COMPLETE_ORDER_STATUSES = ['completed', 'delivered'];
|
|
5
|
+
const ACTIVE_ORDER_STATUSES = ['dispatched', 'started', 'in_progress', 'driver_enroute', 'driver_nearby'];
|
|
6
|
+
|
|
7
|
+
export default class OrderCardComponent extends Component {
|
|
8
|
+
get order() {
|
|
9
|
+
return this.args.order ?? this.args.resource;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get variant() {
|
|
13
|
+
return this.args.variant ?? 'default';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get isCompact() {
|
|
17
|
+
return this.variant === 'compact';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get isSelection() {
|
|
21
|
+
return this.variant === 'selection';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get isInteractive() {
|
|
25
|
+
return Boolean(this.args.interactive && !this.args.disabled);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get classNames() {
|
|
29
|
+
return [
|
|
30
|
+
'order-card',
|
|
31
|
+
`order-card-${this.variant}`,
|
|
32
|
+
this.args.selected ? 'is-selected' : null,
|
|
33
|
+
this.args.disabled ? 'is-disabled' : null,
|
|
34
|
+
this.args.selectable ? 'is-selectable' : null,
|
|
35
|
+
this.isInteractive ? 'is-interactive' : null,
|
|
36
|
+
]
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.join(' ');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get orderLabel() {
|
|
42
|
+
const trackingNumber = this.order?.tracking_number;
|
|
43
|
+
|
|
44
|
+
return trackingNumber?.tracking_number ?? trackingNumber ?? this.order?.tracking ?? this.order?.public_id ?? this.order?.id;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get orderTypeLabel() {
|
|
48
|
+
return this.order?.type;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get orderStops() {
|
|
52
|
+
const payload = this.order?.payload ?? {};
|
|
53
|
+
const stops = [];
|
|
54
|
+
|
|
55
|
+
if (payload.pickup) {
|
|
56
|
+
stops.push({ type: 'pickup', place: payload.pickup });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
(payload.waypoints ?? []).forEach((waypoint, index) => {
|
|
60
|
+
stops.push({
|
|
61
|
+
type: waypoint.type ?? 'waypoint',
|
|
62
|
+
place: waypoint.place ?? waypoint,
|
|
63
|
+
index: index + 1,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (payload.dropoff) {
|
|
68
|
+
stops.push({ type: 'dropoff', place: payload.dropoff });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (payload.return) {
|
|
72
|
+
stops.push({ type: 'return', place: payload.return });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return stops.filter((stop) => this.addressForPlace(stop.place));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get orderOrigin() {
|
|
79
|
+
return this.orderStops[0];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get orderDestination() {
|
|
83
|
+
return this.orderStops[this.orderStops.length - 1];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get orderOriginAddress() {
|
|
87
|
+
return this.addressForPlace(this.orderOrigin?.place);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get orderDestinationAddress() {
|
|
91
|
+
return this.addressForPlace(this.orderDestination?.place);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get orderStopCount() {
|
|
95
|
+
return this.orderStops.length;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get middleStopCount() {
|
|
99
|
+
return Math.max(this.orderStopCount - 2, 0);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get isMultiStopOrder() {
|
|
103
|
+
return this.orderStopCount > 2;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get hasOrderStops() {
|
|
107
|
+
return this.orderStopCount > 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get destinationLabelKey() {
|
|
111
|
+
return this.orderDestination?.type === 'return' ? 'order.card.return' : 'order.card.dropoff';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get orderProgressClass() {
|
|
115
|
+
const status = this.order?.status;
|
|
116
|
+
|
|
117
|
+
if (COMPLETE_ORDER_STATUSES.includes(status)) {
|
|
118
|
+
return 'is-complete';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (ACTIVE_ORDER_STATUSES.includes(status)) {
|
|
122
|
+
return 'is-active';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return 'is-pending';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
get scheduledAt() {
|
|
129
|
+
return this.order?.scheduled_at ?? this.order?.scheduledAt;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get createdAt() {
|
|
133
|
+
return this.order?.created_at ?? this.order?.createdAt;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get orderDriverLabel() {
|
|
137
|
+
return this.order?.driver_assigned?.name ?? this.order?.driver_name ?? this.order?.driver?.name;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get orderVehicleLabel() {
|
|
141
|
+
return this.order?.vehicle_assigned?.displayName ?? this.order?.vehicle_assigned?.display_name ?? this.order?.vehicle_name ?? this.order?.vehicle?.displayName;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get orderCustomerLabel() {
|
|
145
|
+
return this.order?.customer?.name ?? this.order?.customer_name;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get showStatus() {
|
|
149
|
+
return this.argOrDefault('showStatus', true);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get showType() {
|
|
153
|
+
return this.argOrDefault('showType', !this.isCompact);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get showRoute() {
|
|
157
|
+
return this.argOrDefault('showRoute', !this.isCompact);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get showProgress() {
|
|
161
|
+
return this.argOrDefault('showProgress', !this.isCompact && !this.isSelection);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get showMeta() {
|
|
165
|
+
return this.argOrDefault('showMeta', true);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
get showDriver() {
|
|
169
|
+
return this.argOrDefault('showDriver', true);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get showVehicle() {
|
|
173
|
+
return this.argOrDefault('showVehicle', true);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
get showCustomer() {
|
|
177
|
+
return this.argOrDefault('showCustomer', false);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
get showScheduledAt() {
|
|
181
|
+
return this.argOrDefault('showScheduledAt', true);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
get metaItems() {
|
|
185
|
+
const items = [];
|
|
186
|
+
|
|
187
|
+
if (this.showScheduledAt && (this.scheduledAt || this.createdAt)) {
|
|
188
|
+
items.push({
|
|
189
|
+
key: 'scheduled',
|
|
190
|
+
icon: 'calendar',
|
|
191
|
+
value: this.scheduledAt ?? this.createdAt,
|
|
192
|
+
isDate: true,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (this.showDriver && this.orderDriverLabel) {
|
|
197
|
+
items.push({ key: 'driver', icon: 'id-card', value: this.orderDriverLabel });
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (this.showVehicle && this.orderVehicleLabel) {
|
|
201
|
+
items.push({ key: 'vehicle', icon: 'truck', value: this.orderVehicleLabel });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (this.showCustomer && this.orderCustomerLabel) {
|
|
205
|
+
items.push({ key: 'customer', icon: 'user', value: this.orderCustomerLabel });
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return items;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
get hasMeta() {
|
|
212
|
+
return this.metaItems.length > 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
get tabIndex() {
|
|
216
|
+
return this.isInteractive ? '0' : null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get role() {
|
|
220
|
+
return this.isInteractive ? 'button' : null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
argOrDefault(argName, defaultValue) {
|
|
224
|
+
return typeof this.args[argName] === 'boolean' ? this.args[argName] : defaultValue;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
addressForPlace(place) {
|
|
228
|
+
return place?.address ?? place?.address_html ?? place?.street1 ?? place?.name;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@action handleClick() {
|
|
232
|
+
if (!this.isInteractive || typeof this.args.onClick !== 'function') {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this.args.onClick(this.order);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@action handleKeyDown(event) {
|
|
240
|
+
if (!this.isInteractive || !['Enter', ' '].includes(event.key)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
this.handleClick();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@action handleSelect(event) {
|
|
249
|
+
event?.stopPropagation();
|
|
250
|
+
|
|
251
|
+
if (this.args.disabled || typeof this.args.onSelect !== 'function') {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
this.args.onSelect(this.order);
|
|
256
|
+
}
|
|
257
|
+
}
|