@fleetbase/fleetops-engine 0.6.51 → 0.6.52
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.js +20 -2
- 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/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 +14 -0
- 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/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/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/payments/index.js +5 -0
- package/addon/extension.js +10 -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/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.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 +310 -34
- 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/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/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/payments/index.hbs +15 -1
- 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/management/fuel-transactions/index/details.js +1 -0
- package/app/controllers/management/fuel-transactions/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/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/services/fuel-integration-actions.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/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/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/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 +76 -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/SensorController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/TelematicController.php +178 -15
- package/server/src/Http/Controllers/Internal/v1/VehicleController.php +165 -0
- package/server/src/Http/Controllers/TelematicWebhookController.php +103 -19
- 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/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 +36 -6
- 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 +2 -1
- 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 +10 -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 +55 -26
- 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 +41 -4
- package/server/tests/FuelProviderRegistryTest.php +416 -0
- package/server/tests/ServiceRateAlgorithmWeightVariablesTest.php +44 -0
- package/server/tests/TelematicsHardeningTest.php +268 -0
- package/server/tests/VehicleDriverAssignmentTest.php +51 -0
- package/translations/ar-ae.yml +22 -0
- 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 +97 -0
- 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
|
@@ -3,6 +3,9 @@ import { tracked } from '@glimmer/tracking';
|
|
|
3
3
|
import { inject as service } from '@ember/service';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
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'];
|
|
6
9
|
|
|
7
10
|
export default class TelematicFormComponent extends Component {
|
|
8
11
|
@service fetch;
|
|
@@ -10,6 +13,369 @@ export default class TelematicFormComponent extends Component {
|
|
|
10
13
|
@tracked providers = [];
|
|
11
14
|
@tracked selectedProvider = this.args.resource?.provider_descriptor ?? null;
|
|
12
15
|
@tracked connectionTestResult;
|
|
16
|
+
@tracked showConnectionDiagnostics = false;
|
|
17
|
+
@tracked lastConnectionTestStartedAt;
|
|
18
|
+
@tracked lastConnectionTestCompletedAt;
|
|
19
|
+
@tracked activeStep = 0;
|
|
20
|
+
@tracked initialProviderApplied = false;
|
|
21
|
+
|
|
22
|
+
get setupSteps() {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
icon: 'plug',
|
|
26
|
+
label: 'Provider',
|
|
27
|
+
complete: this.activeStep > 0 && this.isProviderStepValid,
|
|
28
|
+
active: this.activeStep === 0,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
icon: 'key',
|
|
32
|
+
label: 'Credentials',
|
|
33
|
+
complete: this.activeStep > 1 && this.areCredentialsValid,
|
|
34
|
+
active: this.activeStep === 1,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
icon: 'circle-check',
|
|
38
|
+
label: 'Test',
|
|
39
|
+
complete: this.activeStep > 2 && this.isTestStepValid,
|
|
40
|
+
active: this.activeStep === 2,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
icon: 'link',
|
|
44
|
+
label: 'Webhook',
|
|
45
|
+
complete: this.activeStep > 3 && this.isIntegrationStepValid,
|
|
46
|
+
active: this.activeStep === 3,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
icon: 'clipboard-check',
|
|
50
|
+
label: 'Review',
|
|
51
|
+
complete: false,
|
|
52
|
+
active: this.activeStep === 4,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get providerCards() {
|
|
58
|
+
return this.providers.map((provider) => ({
|
|
59
|
+
...provider,
|
|
60
|
+
selected: this.selectedProvider?.key === provider.key,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get hasCredentialValues() {
|
|
65
|
+
const credentials = this.args.resource?.credentials ?? {};
|
|
66
|
+
return Object.values(credentials).some((value) => value !== null && value !== undefined && value !== '');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get requiredCredentialFields() {
|
|
70
|
+
return (this.selectedProvider?.required_fields ?? []).filter((field) => field.required);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get credentialFields() {
|
|
74
|
+
return (this.selectedProvider?.required_fields ?? []).filter((field) => !field.advanced && !field.is_endpoint);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get advancedCredentialFields() {
|
|
78
|
+
return (this.selectedProvider?.required_fields ?? []).filter((field) => field.advanced || field.is_endpoint);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get hasAdvancedCredentialFields() {
|
|
82
|
+
return this.advancedCredentialFields.length > 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get missingCredentialFields() {
|
|
86
|
+
const credentials = this.args.resource?.credentials ?? {};
|
|
87
|
+
|
|
88
|
+
return this.requiredCredentialFields.filter((field) => {
|
|
89
|
+
const value = credentials[field.name];
|
|
90
|
+
return value === null || value === undefined || value === '';
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get isProviderStepValid() {
|
|
95
|
+
return Boolean(this.selectedProvider);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get areCredentialsValid() {
|
|
99
|
+
return this.isProviderStepValid && this.missingCredentialFields.length === 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get isTestStepValid() {
|
|
103
|
+
return this.areCredentialsValid;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get isIntegrationStepValid() {
|
|
107
|
+
return Boolean(this.args.resource?.name);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get isReviewStepValid() {
|
|
111
|
+
return this.isProviderStepValid && this.areCredentialsValid && this.isIntegrationStepValid;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get isLastStep() {
|
|
115
|
+
return this.activeStep === this.setupSteps.length - 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get canGoBack() {
|
|
119
|
+
return this.activeStep > 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get primaryFooterLabel() {
|
|
123
|
+
if (this.isLastStep) {
|
|
124
|
+
return this.args.isSaving ? this.args.savingLabel : this.args.saveLabel;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return 'Continue';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get primaryFooterIcon() {
|
|
131
|
+
return this.isLastStep ? 'check' : 'arrow-right';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get canUsePrimaryAction() {
|
|
135
|
+
if (this.args.isSaving) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.isLastStep) {
|
|
140
|
+
return this.isReviewStepValid;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return this.canLeaveStep(this.activeStep);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
get webhookUrl() {
|
|
147
|
+
const url = this.selectedProvider?.webhook_url;
|
|
148
|
+
const id = this.args.resource?.public_id;
|
|
149
|
+
|
|
150
|
+
if (!url || !id) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const separator = url.includes('?') ? '&' : '?';
|
|
155
|
+
return `${url}${separator}telematic=${id}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get connectionState() {
|
|
159
|
+
if (this.testConnection.isRunning) {
|
|
160
|
+
return 'testing';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!this.connectionTestResult) {
|
|
164
|
+
return 'idle';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return this.connectionTestResult.success ? 'success' : 'failed';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
get connectionStateTitle() {
|
|
171
|
+
if (this.connectionState === 'testing') {
|
|
172
|
+
return 'Testing provider credentials...';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this.connectionState === 'success') {
|
|
176
|
+
return 'Connection verified';
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.connectionState === 'failed') {
|
|
180
|
+
return 'Connection failed';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return 'Ready to test';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
get connectionStateMessage() {
|
|
187
|
+
if (this.connectionState === 'testing') {
|
|
188
|
+
return 'Sending the configured credentials to the provider and waiting for a response.';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (this.connectionState === 'idle') {
|
|
192
|
+
return 'Run a connection test to verify credentials before saving. You can still continue if the provider does not support live credential testing.';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (this.isDuplicateConnectionMessage) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return this.connectionTestResult?.message;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
get isDuplicateConnectionMessage() {
|
|
203
|
+
const message = this.connectionTestResult?.message;
|
|
204
|
+
|
|
205
|
+
if (!message) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return ['connection successful', 'connection verified'].includes(message.trim().toLowerCase());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
get connectionMetadataEntries() {
|
|
213
|
+
const metadata = this.connectionTestResult?.metadata ?? {};
|
|
214
|
+
|
|
215
|
+
return Object.entries(metadata)
|
|
216
|
+
.filter(([key, value]) => {
|
|
217
|
+
if (value === null || value === undefined || value === '') {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return !this.isSensitiveMetadataKey(key);
|
|
222
|
+
})
|
|
223
|
+
.map(([key, value]) => ({
|
|
224
|
+
label: this.formatMetadataLabel(key),
|
|
225
|
+
value: this.formatDiagnosticValue(value),
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
get hasConnectionMetadata() {
|
|
230
|
+
return this.connectionMetadataEntries.length > 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
get connectionDiagnosticEntries() {
|
|
234
|
+
const entries = [];
|
|
235
|
+
const providerLabel = this.selectedProvider?.label ?? 'No provider selected';
|
|
236
|
+
const providerKey = this.selectedProvider?.key;
|
|
237
|
+
const startedAt = this.lastConnectionTestStartedAt;
|
|
238
|
+
const completedAt = this.lastConnectionTestCompletedAt;
|
|
239
|
+
|
|
240
|
+
entries.push({
|
|
241
|
+
time: this.formatDiagnosticTime(startedAt),
|
|
242
|
+
tone: 'muted',
|
|
243
|
+
text: `Provider selected: ${providerLabel}${providerKey ? ` (${providerKey})` : ''}`,
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if (this.areCredentialsValid) {
|
|
247
|
+
entries.push({
|
|
248
|
+
time: this.formatDiagnosticTime(startedAt),
|
|
249
|
+
tone: 'muted',
|
|
250
|
+
text: `Credentials prepared: ${this.requiredCredentialFields.length} required fields present`,
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
entries.push({
|
|
254
|
+
time: this.formatDiagnosticTime(startedAt),
|
|
255
|
+
tone: 'warning',
|
|
256
|
+
text: `Credentials incomplete: ${this.missingCredentialFields.length} required fields missing`,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (this.connectionState === 'idle') {
|
|
261
|
+
entries.push({
|
|
262
|
+
time: this.formatDiagnosticTime(),
|
|
263
|
+
tone: 'muted',
|
|
264
|
+
text: 'Credential test has not been run yet',
|
|
265
|
+
});
|
|
266
|
+
return entries;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
entries.push({
|
|
270
|
+
time: this.formatDiagnosticTime(startedAt),
|
|
271
|
+
tone: 'info',
|
|
272
|
+
text: 'Sending provider credential test request',
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
if (this.connectionState === 'testing') {
|
|
276
|
+
entries.push({
|
|
277
|
+
time: this.formatDiagnosticTime(),
|
|
278
|
+
tone: 'info',
|
|
279
|
+
text: 'Awaiting provider response',
|
|
280
|
+
});
|
|
281
|
+
return entries;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
entries.push({
|
|
285
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
286
|
+
tone: 'info',
|
|
287
|
+
text: 'Provider response received',
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
if (this.hasConnectionMetadata) {
|
|
291
|
+
entries.push({
|
|
292
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
293
|
+
tone: 'muted',
|
|
294
|
+
text: `Provider metadata: ${this.connectionMetadataEntries.map((entry) => `${entry.label}=${entry.value}`).join(', ')}`,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (this.connectionState === 'success') {
|
|
299
|
+
entries.push({
|
|
300
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
301
|
+
tone: 'success',
|
|
302
|
+
text: 'Connection verified',
|
|
303
|
+
});
|
|
304
|
+
return entries;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
entries.push({
|
|
308
|
+
time: this.formatDiagnosticTime(completedAt),
|
|
309
|
+
tone: 'danger',
|
|
310
|
+
text: `Connection failed${this.connectionTestResult?.message ? `: ${this.formatDiagnosticValue(this.connectionTestResult.message)}` : ''}`,
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
return entries;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
get hasConnectionDiagnostics() {
|
|
317
|
+
return this.connectionDiagnosticEntries.length > 0;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
get connectionDiagnosticText() {
|
|
321
|
+
return this.connectionDiagnosticEntries.map((entry) => `[${entry.time}] ${entry.text}`).join('\n');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
formatMetadataLabel(key) {
|
|
325
|
+
return key.replace(/_/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase());
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
formatDiagnosticValue(value) {
|
|
329
|
+
const sanitizedValue = this.sanitizeDiagnosticValue(value);
|
|
330
|
+
|
|
331
|
+
if (typeof sanitizedValue === 'object') {
|
|
332
|
+
return JSON.stringify(sanitizedValue);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return String(sanitizedValue);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
sanitizeDiagnosticValue(value, seen = new WeakSet()) {
|
|
339
|
+
if (!value || typeof value !== 'object') {
|
|
340
|
+
return value;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (seen.has(value)) {
|
|
344
|
+
return '[circular]';
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
seen.add(value);
|
|
348
|
+
|
|
349
|
+
if (Array.isArray(value)) {
|
|
350
|
+
return value.map((item) => this.sanitizeDiagnosticValue(item, seen));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return Object.entries(value).reduce((acc, [key, item]) => {
|
|
354
|
+
if (!this.isSensitiveMetadataKey(key)) {
|
|
355
|
+
acc[key] = this.sanitizeDiagnosticValue(item, seen);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return acc;
|
|
359
|
+
}, {});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
formatDiagnosticTime(date = new Date()) {
|
|
363
|
+
if (!(date instanceof Date)) {
|
|
364
|
+
return '--:--:--';
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false });
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
isSensitiveMetadataKey(key) {
|
|
371
|
+
return SENSITIVE_METADATA_KEYS.some((sensitiveKey) => key.toLowerCase().includes(sensitiveKey));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
resetConnectionTest() {
|
|
375
|
+
this.connectionTestResult = null;
|
|
376
|
+
this.lastConnectionTestStartedAt = null;
|
|
377
|
+
this.lastConnectionTestCompletedAt = null;
|
|
378
|
+
}
|
|
13
379
|
|
|
14
380
|
get credentialsActionButtons() {
|
|
15
381
|
return [
|
|
@@ -25,6 +391,7 @@ export default class TelematicFormComponent extends Component {
|
|
|
25
391
|
|
|
26
392
|
constructor() {
|
|
27
393
|
super(...arguments);
|
|
394
|
+
this.activeStep = this.selectedProvider ? 1 : 0;
|
|
28
395
|
this.loadProviders.perform();
|
|
29
396
|
}
|
|
30
397
|
|
|
@@ -34,32 +401,165 @@ export default class TelematicFormComponent extends Component {
|
|
|
34
401
|
...credentials,
|
|
35
402
|
[field.name]: value,
|
|
36
403
|
});
|
|
404
|
+
this.resetConnectionTest();
|
|
37
405
|
}
|
|
38
406
|
|
|
39
407
|
@action selectProvider(provider) {
|
|
408
|
+
this.applyProvider(provider);
|
|
409
|
+
this.activeStep = 1;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
applyProvider(provider) {
|
|
40
413
|
this.selectedProvider = provider;
|
|
414
|
+
this.resetConnectionTest();
|
|
41
415
|
this.args.resource.setProperties({
|
|
416
|
+
name: this.args.resource.name ?? provider.label,
|
|
42
417
|
provider: provider.key,
|
|
43
|
-
credentials: (provider.required_fields ??
|
|
44
|
-
acc[item.name] = null;
|
|
418
|
+
credentials: (provider.required_fields ?? []).reduce((acc, item) => {
|
|
419
|
+
acc[item.name] = item.advanced || item.is_endpoint ? null : (item.default_value ?? null);
|
|
45
420
|
return acc;
|
|
46
421
|
}, {}),
|
|
47
422
|
});
|
|
48
423
|
}
|
|
49
424
|
|
|
425
|
+
@action goToStep(index) {
|
|
426
|
+
if (!this.canReachStep(index)) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
this.activeStep = index;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@action nextStep() {
|
|
434
|
+
if (!this.validateStep(this.activeStep)) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
this.activeStep = Math.min(this.activeStep + 1, this.setupSteps.length - 1);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
@action previousStep() {
|
|
442
|
+
this.activeStep = Math.max(this.activeStep - 1, 0);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@action primaryFooterAction() {
|
|
446
|
+
if (this.isLastStep) {
|
|
447
|
+
if (!this.validateStep(this.activeStep) || !this.isReviewStepValid) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return this.args.onSave?.();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return this.nextStep();
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
@action toggleConnectionDiagnostics() {
|
|
458
|
+
this.showConnectionDiagnostics = !this.showConnectionDiagnostics;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@action copyConnectionDiagnostics() {
|
|
462
|
+
copyToClipboard(this.connectionDiagnosticText)
|
|
463
|
+
.then(() => {
|
|
464
|
+
this.notifications.success('Connection diagnostics copied.');
|
|
465
|
+
})
|
|
466
|
+
.catch(() => {
|
|
467
|
+
this.notifications.error('Unable to copy connection diagnostics.');
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
canReachStep(index) {
|
|
472
|
+
if (index <= this.activeStep) {
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
for (let step = 0; step < index; step++) {
|
|
477
|
+
if (!this.canLeaveStep(step)) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
canLeaveStep(index) {
|
|
486
|
+
if (index === 0) {
|
|
487
|
+
return this.isProviderStepValid;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (index === 1) {
|
|
491
|
+
return this.areCredentialsValid;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (index === 3) {
|
|
495
|
+
return this.isIntegrationStepValid;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
validateStep(index) {
|
|
502
|
+
if (index === 0 && !this.isProviderStepValid) {
|
|
503
|
+
this.notifications.warning('Choose a provider to continue.');
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (index === 1 && !this.areCredentialsValid) {
|
|
508
|
+
this.notifications.warning('Enter the required provider credentials to continue.');
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
if (index === 3 && !this.isIntegrationStepValid) {
|
|
513
|
+
this.notifications.warning('Enter an integration name to continue.');
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (index === 4 && !this.isReviewStepValid) {
|
|
518
|
+
this.notifications.warning('Complete the required setup steps before saving.');
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
applyInitialProvider() {
|
|
526
|
+
if (this.initialProviderApplied || !this.args.initialProviderKey || this.selectedProvider) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const provider = this.providers.find((candidate) => candidate.key === this.args.initialProviderKey);
|
|
531
|
+
|
|
532
|
+
if (!provider) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
this.initialProviderApplied = true;
|
|
537
|
+
this.applyProvider(provider);
|
|
538
|
+
this.activeStep = 1;
|
|
539
|
+
}
|
|
540
|
+
|
|
50
541
|
@task *loadProviders() {
|
|
51
542
|
try {
|
|
52
543
|
const providers = yield this.fetch.get('telematics/providers');
|
|
53
544
|
this.providers = providers;
|
|
545
|
+
this.applyInitialProvider();
|
|
54
546
|
} catch (err) {
|
|
55
547
|
this.notifications.serverError(err);
|
|
56
548
|
}
|
|
57
549
|
}
|
|
58
550
|
|
|
59
551
|
@task *testConnection() {
|
|
552
|
+
this.lastConnectionTestStartedAt = new Date();
|
|
553
|
+
this.lastConnectionTestCompletedAt = null;
|
|
554
|
+
|
|
60
555
|
try {
|
|
61
|
-
const result = yield this.fetch.post(`telematics/${this.selectedProvider.key}/test-credentials`, {
|
|
556
|
+
const result = yield this.fetch.post(`telematics/${this.selectedProvider.key}/test-credentials`, {
|
|
557
|
+
credentials: this.args.resource.credentials,
|
|
558
|
+
telematic_id: this.args.resource?.id,
|
|
559
|
+
});
|
|
62
560
|
this.connectionTestResult = result;
|
|
561
|
+
this.lastConnectionTestCompletedAt = new Date();
|
|
562
|
+
this.updateResourceConnectionTestMeta(result);
|
|
63
563
|
|
|
64
564
|
if (result.success) {
|
|
65
565
|
this.notifications.success('Connection successful!');
|
|
@@ -67,11 +567,27 @@ export default class TelematicFormComponent extends Component {
|
|
|
67
567
|
this.notifications.error(result.message);
|
|
68
568
|
}
|
|
69
569
|
} catch (error) {
|
|
570
|
+
this.lastConnectionTestCompletedAt = new Date();
|
|
70
571
|
this.connectionTestResult = {
|
|
71
572
|
success: false,
|
|
72
573
|
message: error.message || 'Connection test failed',
|
|
73
574
|
};
|
|
575
|
+
this.updateResourceConnectionTestMeta(this.connectionTestResult);
|
|
74
576
|
this.notifications.error('Connection test failed');
|
|
75
577
|
}
|
|
76
578
|
}
|
|
579
|
+
|
|
580
|
+
updateResourceConnectionTestMeta(result) {
|
|
581
|
+
const meta = this.args.resource?.meta ?? {};
|
|
582
|
+
const testedAt = this.lastConnectionTestCompletedAt ?? new Date();
|
|
583
|
+
|
|
584
|
+
this.args.resource?.set('status', result?.success ? 'connected' : 'error');
|
|
585
|
+
this.args.resource?.set('meta', {
|
|
586
|
+
...meta,
|
|
587
|
+
last_connection_test: testedAt.toISOString(),
|
|
588
|
+
last_test_result: result?.success ? 'success' : 'failed',
|
|
589
|
+
last_error: result?.success ? null : (result?.message ?? 'Connection test failed'),
|
|
590
|
+
last_test_metadata: result?.metadata ?? {},
|
|
591
|
+
});
|
|
592
|
+
}
|
|
77
593
|
}
|