@fleetbase/fleetops-engine 0.6.55 → 0.6.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/components/admin/map-settings.hbs +1 -1
- package/addon/components/ai/create-order-preview.hbs +297 -0
- package/addon/components/ai/create-order-preview.js +362 -0
- package/addon/components/ai/route-preview-map.hbs +79 -0
- package/addon/components/ai/route-preview-map.js +527 -0
- package/addon/components/device/details.js +1 -1
- package/addon/components/device-event/details.hbs +192 -0
- package/addon/components/device-event/details.js +151 -0
- package/addon/components/driver/schedule.js +1 -1
- package/addon/components/fleet/details.hbs +21 -8
- package/addon/components/fleet/details.js +55 -1
- package/addon/components/fleet/hierarchy-tree.hbs +137 -0
- package/addon/components/fleet/hierarchy-tree.js +528 -0
- package/addon/components/layout/fleet-ops-sidebar.js +15 -9
- package/addon/components/map/drawer/device-event-listing.js +1 -0
- package/addon/components/map/drawer/driver-listing.js +1 -0
- package/addon/components/map/drawer/place-listing.js +1 -0
- package/addon/components/map/drawer/vehicle-listing.js +1 -0
- package/addon/components/order/details.hbs +34 -1
- package/addon/components/order/form/details.hbs +4 -0
- package/addon/components/order/form.hbs +9 -1
- package/addon/components/telematic/details.hbs +1 -1
- package/addon/components/telematic/form.hbs +2 -2
- package/addon/components/telematic/settings.hbs +1 -1
- package/addon/components/vehicle/card.hbs +14 -2
- package/addon/components/vehicle/form.hbs +13 -1
- package/addon/controllers/connectivity/devices/index/details/events.js +1 -1
- package/addon/controllers/connectivity/devices/index/details/vehicle.js +2 -2
- package/addon/controllers/connectivity/events/details.js +68 -1
- package/addon/controllers/connectivity/sensors/index.js +4 -0
- package/addon/controllers/connectivity/telematics/details/events.js +1 -1
- package/addon/controllers/connectivity/telematics/details/sensors.js +4 -0
- package/addon/controllers/settings/map.js +19 -0
- package/addon/extension.js +14 -0
- package/addon/instance-initializers/register-vroom-allocation.js +1 -1
- package/addon/routes/connectivity/events/details.js +26 -1
- package/addon/routes/management/fleets/index/details.js +1 -1
- package/addon/routes/management/vehicles/index/details.js +3 -1
- package/addon/services/map-adapter/google.js +66 -1
- package/addon/services/map-adapter/leaflet.js +1 -1
- package/addon/services/map-adapter-interface.js +1 -1
- package/addon/services/map-manager.js +16 -1
- package/addon/services/map-settings.js +15 -0
- package/addon/styles/fleetops-engine.css +487 -1
- package/addon/templates/connectivity/devices/index/details/vehicle.hbs +2 -1
- package/addon/templates/connectivity/events/details.hbs +40 -1
- package/addon/templates/settings/map.hbs +38 -9
- package/addon/utils/leaflet-plugin-loader.js +5 -5
- package/addon/utils/map-drawer-dropdown-position.js +11 -13
- package/addon/utils/route-colors.js +1 -1
- package/app/components/ai/create-order-preview.js +1 -0
- package/app/components/ai/route-preview-map.js +1 -0
- package/app/components/device-event/details.hbs +192 -0
- package/app/components/device-event/details.js +1 -0
- package/app/components/fleet/hierarchy-tree.js +1 -0
- package/app/services/route-engine.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +6 -4
- package/scripts/normalize-rgba-alpha.js +90 -0
- package/server/migrations/2026_06_23_000001_delete_bad_afaqy_telematics_sensors.php +34 -0
- package/server/src/Exports/ContactExport.php +12 -5
- package/server/src/Exports/DeviceExport.php +92 -0
- package/server/src/Exports/DriverExport.php +28 -3
- package/server/src/Exports/EquipmentExport.php +94 -0
- package/server/src/Exports/FleetExport.php +22 -7
- package/server/src/Exports/FuelReportExport.php +16 -1
- package/server/src/Exports/IssueExport.php +25 -3
- package/server/src/Exports/MaintenanceExport.php +106 -0
- package/server/src/Exports/MaintenanceScheduleExport.php +99 -0
- package/server/src/Exports/OrderExport.php +24 -5
- package/server/src/Exports/PartExport.php +99 -0
- package/server/src/Exports/PlaceExport.php +33 -7
- package/server/src/Exports/SensorExport.php +94 -0
- package/server/src/Exports/ServiceAreaExport.php +31 -7
- package/server/src/Exports/ServiceRateExport.php +41 -1
- package/server/src/Exports/TelematicExport.php +90 -0
- package/server/src/Exports/VehicleExport.php +274 -8
- package/server/src/Exports/VendorExport.php +15 -2
- package/server/src/Exports/WorkOrderExport.php +92 -0
- package/server/src/Http/Controllers/Api/v1/Concerns/ResolvesFleetOpsApiResources.php +176 -0
- package/server/src/Http/Controllers/Api/v1/DeviceController.php +225 -0
- package/server/src/Http/Controllers/Api/v1/EquipmentController.php +114 -0
- package/server/src/Http/Controllers/Api/v1/FuelTransactionController.php +185 -0
- package/server/src/Http/Controllers/Api/v1/PartController.php +120 -0
- package/server/src/Http/Controllers/Api/v1/SensorController.php +132 -0
- package/server/src/Http/Controllers/Api/v1/WorkOrderController.php +161 -0
- package/server/src/Http/Controllers/Internal/v1/DeviceController.php +18 -0
- package/server/src/Http/Controllers/Internal/v1/EquipmentController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/MaintenanceController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/MaintenanceScheduleController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/PartController.php +17 -0
- package/server/src/Http/Controllers/Internal/v1/SensorController.php +18 -0
- package/server/src/Http/Controllers/Internal/v1/SettingController.php +29 -5
- package/server/src/Http/Controllers/Internal/v1/TelematicController.php +18 -0
- package/server/src/Http/Controllers/Internal/v1/WorkOrderController.php +17 -0
- package/server/src/Http/Filter/DeviceFilter.php +33 -10
- package/server/src/Http/Filter/EquipmentFilter.php +23 -0
- package/server/src/Http/Filter/FuelProviderTransactionFilter.php +57 -2
- package/server/src/Http/Filter/PartFilter.php +47 -0
- package/server/src/Http/Filter/SensorFilter.php +34 -6
- package/server/src/Http/Filter/WorkOrderFilter.php +23 -0
- package/server/src/Http/Requests/CreateDeviceRequest.php +51 -0
- package/server/src/Http/Requests/CreateEquipmentRequest.php +35 -0
- package/server/src/Http/Requests/CreateFuelTransactionRequest.php +50 -0
- package/server/src/Http/Requests/CreatePartRequest.php +40 -0
- package/server/src/Http/Requests/CreateSensorRequest.php +47 -0
- package/server/src/Http/Requests/CreateWorkOrderRequest.php +42 -0
- package/server/src/Http/Requests/UpdateDeviceRequest.php +7 -0
- package/server/src/Http/Requests/UpdateEquipmentRequest.php +7 -0
- package/server/src/Http/Requests/UpdateFuelTransactionRequest.php +7 -0
- package/server/src/Http/Requests/UpdatePartRequest.php +7 -0
- package/server/src/Http/Requests/UpdateSensorRequest.php +7 -0
- package/server/src/Http/Requests/UpdateWorkOrderRequest.php +7 -0
- package/server/src/Http/Resources/v1/Device.php +72 -0
- package/server/src/Http/Resources/v1/Equipment.php +57 -0
- package/server/src/Http/Resources/v1/Fleet.php +8 -2
- package/server/src/Http/Resources/v1/FuelTransaction.php +69 -0
- package/server/src/Http/Resources/v1/Part.php +64 -0
- package/server/src/Http/Resources/v1/Sensor.php +68 -0
- package/server/src/Jobs/SyncTelematicDevicesJob.php +194 -38
- package/server/src/Models/Driver.php +6 -0
- package/server/src/Models/Order.php +20 -7
- package/server/src/Models/Place.php +11 -3
- package/server/src/Observers/PurchaseRateObserver.php +2 -1
- package/server/src/Providers/FleetOpsServiceProvider.php +26 -0
- package/server/src/Support/Ai/Capabilities/AbstractFleetOpsAICapability.php +88 -0
- package/server/src/Support/Ai/Capabilities/AssetStatusCapability.php +108 -0
- package/server/src/Support/Ai/Capabilities/ConsoleNavigationCapability.php +55 -0
- package/server/src/Support/Ai/Capabilities/CreateOrderPreviewCapability.php +508 -0
- package/server/src/Support/Ai/Capabilities/DocsHelpCapability.php +49 -0
- package/server/src/Support/Ai/Capabilities/ImportOrdersPreviewCapability.php +66 -0
- package/server/src/Support/Ai/Capabilities/OperationalQueryCapability.php +319 -0
- package/server/src/Support/Ai/Capabilities/OptimizeOrderRouteCapability.php +240 -0
- package/server/src/Support/Ai/Capabilities/OrderInsightsCapability.php +95 -0
- package/server/src/Support/Ai/Capabilities/SearchResourcesCapability.php +195 -0
- package/server/src/Support/Ai/FleetOpsAiQueryResources.php +150 -0
- package/server/src/Support/Analytics/RevenueTrend.php +3 -8
- package/server/src/Support/Metrics/ActiveRevenueQuery.php +121 -0
- package/server/src/Support/Metrics/AvgOrderValueMetric.php +1 -7
- package/server/src/Support/Metrics/EarningsMetric.php +1 -10
- package/server/src/Support/Telematics/Providers/AfaqyProvider.php +104 -5
- package/server/src/Support/Telematics/Providers/SafeeProvider.php +550 -54
- package/server/src/Support/Telematics/TelematicService.php +28 -9
- package/server/src/Support/Utils.php +52 -0
- package/server/src/routes.php +67 -14
- package/server/tests/AiCreateOrderPreviewCapabilityTest.php +131 -0
- package/server/tests/AiOperationalQueryCapabilityTest.php +75 -0
- package/server/tests/ExportCoverageTest.php +79 -0
- package/server/tests/FleetHierarchyResourceTest.php +12 -0
- package/server/tests/MetricsRegistryTest.php +45 -5
- package/server/tests/OrderPayloadPlaceResolutionTest.php +53 -0
- package/server/tests/PointResolutionTest.php +63 -0
- package/server/tests/PublicFleetOpsRestEndpointsTest.php +191 -0
- package/server/tests/TelematicsHardeningTest.php +636 -1
- package/addon/components/table/cell/dropdown/action-item.hbs +0 -31
- package/addon/components/table/cell/dropdown/action-item.js +0 -62
- package/addon/components/table/cell/dropdown.hbs +0 -28
- package/addon/components/table/cell/dropdown.js +0 -91
- package/app/components/table/cell/dropdown/action-item.js +0 -1
- package/app/components/table/cell/dropdown.js +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Device extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
public function toArray($request)
|
|
13
|
+
{
|
|
14
|
+
return $this->withCustomFields([
|
|
15
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
16
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
17
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
18
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
19
|
+
'telematic_uuid' => $this->when(Http::isInternalRequest(), $this->telematic_uuid),
|
|
20
|
+
'attachable_uuid' => $this->when(Http::isInternalRequest(), $this->attachable_uuid),
|
|
21
|
+
'attachable_type' => $this->when(Http::isInternalRequest(), $this->attachable_type ? Utils::toEmberResourceType($this->attachable_type) : null),
|
|
22
|
+
'warranty_uuid' => $this->when(Http::isInternalRequest(), $this->warranty_uuid),
|
|
23
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
24
|
+
'telematic' => $this->whenLoaded('telematic', fn () => $this->resolveLoadedRelation($this->telematic)),
|
|
25
|
+
'attachable' => $this->whenLoaded('attachable', fn () => $this->resolveLoadedRelation($this->attachable)),
|
|
26
|
+
'warranty' => $this->whenLoaded('warranty', fn () => $this->resolveLoadedRelation($this->warranty)),
|
|
27
|
+
'photo' => $this->whenLoaded('photo', fn () => $this->resolveLoadedRelation($this->photo)),
|
|
28
|
+
'type' => $this->type,
|
|
29
|
+
'device_id' => $this->device_id,
|
|
30
|
+
'internal_id' => $this->internal_id,
|
|
31
|
+
'imei' => $this->imei,
|
|
32
|
+
'imsi' => $this->imsi,
|
|
33
|
+
'firmware_version' => $this->firmware_version,
|
|
34
|
+
'provider' => $this->provider,
|
|
35
|
+
'name' => $this->name,
|
|
36
|
+
'model' => $this->model,
|
|
37
|
+
'location' => $this->location,
|
|
38
|
+
'manufacturer' => $this->manufacturer,
|
|
39
|
+
'serial_number' => $this->serial_number,
|
|
40
|
+
'last_position' => $this->last_position,
|
|
41
|
+
'installation_date' => $this->installation_date,
|
|
42
|
+
'last_maintenance_date' => $this->last_maintenance_date,
|
|
43
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
44
|
+
'data' => data_get($this, 'data', Utils::createObject()),
|
|
45
|
+
'options' => data_get($this, 'options', Utils::createObject()),
|
|
46
|
+
'online' => $this->online,
|
|
47
|
+
'status' => $this->status,
|
|
48
|
+
'data_frequency' => $this->data_frequency,
|
|
49
|
+
'notes' => $this->notes,
|
|
50
|
+
'last_online_at' => $this->last_online_at,
|
|
51
|
+
'warranty_name' => $this->warranty_name,
|
|
52
|
+
'telematic_name' => $this->telematic_name,
|
|
53
|
+
'is_online' => $this->is_online,
|
|
54
|
+
'attached_to_name' => $this->attached_to_name,
|
|
55
|
+
'connection_status' => $this->connection_status,
|
|
56
|
+
'photo_url' => $this->photo_url,
|
|
57
|
+
'sensors_count' => $this->when(isset($this->sensors_count), $this->sensors_count),
|
|
58
|
+
'slug' => $this->slug,
|
|
59
|
+
'updated_at' => $this->updated_at,
|
|
60
|
+
'created_at' => $this->created_at,
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected function resolveLoadedRelation($model)
|
|
65
|
+
{
|
|
66
|
+
if (!$model) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Equipment extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
public function toArray($request)
|
|
13
|
+
{
|
|
14
|
+
return $this->withCustomFields([
|
|
15
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
16
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
17
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
18
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
19
|
+
'warranty_uuid' => $this->when(Http::isInternalRequest(), $this->warranty_uuid),
|
|
20
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
21
|
+
'equipable_uuid' => $this->when(Http::isInternalRequest(), $this->equipable_uuid),
|
|
22
|
+
'equipable_type' => $this->when(Http::isInternalRequest(), $this->equipable_type ? Utils::toEmberResourceType($this->equipable_type) : null),
|
|
23
|
+
'warranty' => $this->whenLoaded('warranty', fn () => $this->resolveLoadedRelation($this->warranty)),
|
|
24
|
+
'photo' => $this->whenLoaded('photo', fn () => $this->resolveLoadedRelation($this->photo)),
|
|
25
|
+
'equipable' => $this->whenLoaded('equipable', fn () => $this->resolveLoadedRelation($this->equipable)),
|
|
26
|
+
'name' => $this->name,
|
|
27
|
+
'code' => $this->code,
|
|
28
|
+
'type' => $this->type,
|
|
29
|
+
'status' => $this->status,
|
|
30
|
+
'serial_number' => $this->serial_number,
|
|
31
|
+
'manufacturer' => $this->manufacturer,
|
|
32
|
+
'model' => $this->model,
|
|
33
|
+
'purchased_at' => $this->purchased_at,
|
|
34
|
+
'purchase_price' => $this->purchase_price,
|
|
35
|
+
'currency' => $this->currency,
|
|
36
|
+
'warranty_name' => $this->warranty_name,
|
|
37
|
+
'photo_url' => $this->photo_url,
|
|
38
|
+
'equipped_to_name' => $this->equipped_to_name,
|
|
39
|
+
'is_equipped' => $this->is_equipped,
|
|
40
|
+
'age_in_days' => $this->age_in_days,
|
|
41
|
+
'depreciated_value' => $this->depreciated_value,
|
|
42
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
43
|
+
'slug' => $this->slug,
|
|
44
|
+
'updated_at' => $this->updated_at,
|
|
45
|
+
'created_at' => $this->created_at,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected function resolveLoadedRelation($model)
|
|
50
|
+
{
|
|
51
|
+
if (!$model) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -24,8 +24,14 @@ class Fleet extends FleetbaseResource
|
|
|
24
24
|
|
|
25
25
|
$this->load($with);
|
|
26
26
|
|
|
27
|
-
if (in_array('subfleets', $with, true)
|
|
28
|
-
|
|
27
|
+
if (in_array('subfleets', $with, true)) {
|
|
28
|
+
if (in_array('drivers', $with, true)) {
|
|
29
|
+
$this->loadMissing('subFleets.drivers');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (in_array('vehicles', $with, true)) {
|
|
33
|
+
$this->loadMissing('subFleets.vehicles');
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
|
+
use Fleetbase\Support\Http;
|
|
7
|
+
use Fleetbase\Support\Resolve;
|
|
8
|
+
|
|
9
|
+
class FuelTransaction extends FleetbaseResource
|
|
10
|
+
{
|
|
11
|
+
public function toArray($request)
|
|
12
|
+
{
|
|
13
|
+
return [
|
|
14
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
15
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
16
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
17
|
+
'fuel_provider_connection_uuid' => $this->when(Http::isInternalRequest(), $this->fuel_provider_connection_uuid),
|
|
18
|
+
'fuel_report_uuid' => $this->when(Http::isInternalRequest(), $this->fuel_report_uuid),
|
|
19
|
+
'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
|
|
20
|
+
'driver_uuid' => $this->when(Http::isInternalRequest(), $this->driver_uuid),
|
|
21
|
+
'order_uuid' => $this->when(Http::isInternalRequest(), $this->order_uuid),
|
|
22
|
+
'connection' => $this->whenLoaded('connection', fn () => $this->resolveLoadedRelation($this->connection)),
|
|
23
|
+
'fuel_report' => $this->whenLoaded('fuelReport', fn () => $this->resolveLoadedRelation($this->fuelReport)),
|
|
24
|
+
'vehicle' => $this->whenLoaded('vehicle', fn () => $this->resolveLoadedRelation($this->vehicle)),
|
|
25
|
+
'driver' => $this->whenLoaded('driver', fn () => $this->resolveLoadedRelation($this->driver)),
|
|
26
|
+
'order' => $this->whenLoaded('order', fn () => $this->resolveLoadedRelation($this->order)),
|
|
27
|
+
'provider' => $this->provider,
|
|
28
|
+
'provider_transaction_id' => $this->provider_transaction_id,
|
|
29
|
+
'provider_vehicle_id' => $this->provider_vehicle_id,
|
|
30
|
+
'vehicle_card_id' => $this->vehicle_card_id,
|
|
31
|
+
'internal_number' => $this->internal_number,
|
|
32
|
+
'structure_number' => $this->structure_number,
|
|
33
|
+
'plate_number' => $this->plate_number,
|
|
34
|
+
'vin' => $this->vin,
|
|
35
|
+
'serial_number' => $this->serial_number,
|
|
36
|
+
'call_sign' => $this->call_sign,
|
|
37
|
+
'trip_number' => $this->trip_number,
|
|
38
|
+
'station_name' => $this->station_name,
|
|
39
|
+
'station_latitude' => $this->station_latitude,
|
|
40
|
+
'station_longitude' => $this->station_longitude,
|
|
41
|
+
'station_location' => $this->station_location,
|
|
42
|
+
'transaction_at' => $this->transaction_at,
|
|
43
|
+
'volume' => $this->volume,
|
|
44
|
+
'metric_unit' => $this->metric_unit,
|
|
45
|
+
'amount' => $this->amount,
|
|
46
|
+
'currency' => $this->currency,
|
|
47
|
+
'odometer' => $this->odometer,
|
|
48
|
+
'sync_status' => $this->sync_status,
|
|
49
|
+
'matched_at' => $this->matched_at,
|
|
50
|
+
'vehicle_name' => $this->vehicle_name,
|
|
51
|
+
'driver_name' => $this->driver_name,
|
|
52
|
+
'fuel_report_id' => $this->fuel_report_id,
|
|
53
|
+
'normalized_payload' => $this->when(Http::isInternalRequest(), $this->normalized_payload),
|
|
54
|
+
'raw_payload' => $this->when(Http::isInternalRequest(), $this->raw_payload),
|
|
55
|
+
'meta' => $this->when(Http::isInternalRequest(), $this->meta),
|
|
56
|
+
'updated_at' => $this->updated_at,
|
|
57
|
+
'created_at' => $this->created_at,
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected function resolveLoadedRelation($model)
|
|
62
|
+
{
|
|
63
|
+
if (!$model) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Part extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
public function toArray($request)
|
|
13
|
+
{
|
|
14
|
+
return [
|
|
15
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
16
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
17
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
18
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
19
|
+
'vendor_uuid' => $this->when(Http::isInternalRequest(), $this->vendor_uuid),
|
|
20
|
+
'warranty_uuid' => $this->when(Http::isInternalRequest(), $this->warranty_uuid),
|
|
21
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
22
|
+
'asset_uuid' => $this->when(Http::isInternalRequest(), $this->asset_uuid),
|
|
23
|
+
'asset_type' => $this->when(Http::isInternalRequest(), $this->asset_type ? Utils::toEmberResourceType($this->asset_type) : null),
|
|
24
|
+
'vendor' => $this->whenLoaded('vendor', fn () => $this->resolveLoadedRelation($this->vendor)),
|
|
25
|
+
'warranty' => $this->whenLoaded('warranty', fn () => $this->resolveLoadedRelation($this->warranty)),
|
|
26
|
+
'photo' => $this->whenLoaded('photo', fn () => $this->resolveLoadedRelation($this->photo)),
|
|
27
|
+
'asset' => $this->whenLoaded('asset', fn () => $this->resolveLoadedRelation($this->asset)),
|
|
28
|
+
'sku' => $this->sku,
|
|
29
|
+
'name' => $this->name,
|
|
30
|
+
'manufacturer' => $this->manufacturer,
|
|
31
|
+
'model' => $this->model,
|
|
32
|
+
'serial_number' => $this->serial_number,
|
|
33
|
+
'barcode' => $this->barcode,
|
|
34
|
+
'description' => $this->description,
|
|
35
|
+
'quantity_on_hand' => $this->quantity_on_hand,
|
|
36
|
+
'unit_cost' => $this->unit_cost,
|
|
37
|
+
'msrp' => $this->msrp,
|
|
38
|
+
'currency' => $this->currency,
|
|
39
|
+
'type' => $this->type,
|
|
40
|
+
'status' => $this->status,
|
|
41
|
+
'specs' => data_get($this, 'specs', Utils::createObject()),
|
|
42
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
43
|
+
'vendor_name' => $this->vendor_name,
|
|
44
|
+
'warranty_name' => $this->warranty_name,
|
|
45
|
+
'photo_url' => $this->photo_url,
|
|
46
|
+
'total_value' => $this->total_value,
|
|
47
|
+
'is_in_stock' => $this->is_in_stock,
|
|
48
|
+
'is_low_stock' => $this->is_low_stock,
|
|
49
|
+
'asset_name' => $this->asset_name,
|
|
50
|
+
'slug' => $this->slug,
|
|
51
|
+
'updated_at' => $this->updated_at,
|
|
52
|
+
'created_at' => $this->created_at,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected function resolveLoadedRelation($model)
|
|
57
|
+
{
|
|
58
|
+
if (!$model) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Http\Resources\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Support\Utils;
|
|
6
|
+
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
7
|
+
use Fleetbase\Support\Http;
|
|
8
|
+
use Fleetbase\Support\Resolve;
|
|
9
|
+
|
|
10
|
+
class Sensor extends FleetbaseResource
|
|
11
|
+
{
|
|
12
|
+
public function toArray($request)
|
|
13
|
+
{
|
|
14
|
+
return $this->withCustomFields([
|
|
15
|
+
'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
|
|
16
|
+
'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
|
|
17
|
+
'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
|
|
18
|
+
'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
|
|
19
|
+
'device_uuid' => $this->when(Http::isInternalRequest(), $this->device_uuid),
|
|
20
|
+
'warranty_uuid' => $this->when(Http::isInternalRequest(), $this->warranty_uuid),
|
|
21
|
+
'telematic_uuid' => $this->when(Http::isInternalRequest(), $this->telematic_uuid),
|
|
22
|
+
'photo_uuid' => $this->when(Http::isInternalRequest(), $this->photo_uuid),
|
|
23
|
+
'sensorable_uuid' => $this->when(Http::isInternalRequest(), $this->sensorable_uuid),
|
|
24
|
+
'sensorable_type' => $this->when(Http::isInternalRequest(), $this->sensorable_type ? Utils::toEmberResourceType($this->sensorable_type) : null),
|
|
25
|
+
'device' => $this->whenLoaded('device', fn () => $this->resolveLoadedRelation($this->device)),
|
|
26
|
+
'warranty' => $this->whenLoaded('warranty', fn () => $this->resolveLoadedRelation($this->warranty)),
|
|
27
|
+
'telematic' => $this->whenLoaded('telematic', fn () => $this->resolveLoadedRelation($this->telematic)),
|
|
28
|
+
'photo' => $this->whenLoaded('photo', fn () => $this->resolveLoadedRelation($this->photo)),
|
|
29
|
+
'sensorable' => $this->whenLoaded('sensorable', fn () => $this->resolveLoadedRelation($this->sensorable)),
|
|
30
|
+
'name' => $this->name,
|
|
31
|
+
'type' => $this->type,
|
|
32
|
+
'internal_id' => $this->internal_id,
|
|
33
|
+
'imei' => $this->imei,
|
|
34
|
+
'imsi' => $this->imsi,
|
|
35
|
+
'firmware_version' => $this->firmware_version,
|
|
36
|
+
'serial_number' => $this->serial_number,
|
|
37
|
+
'last_position' => $this->last_position,
|
|
38
|
+
'unit' => $this->unit,
|
|
39
|
+
'min_threshold' => $this->min_threshold,
|
|
40
|
+
'max_threshold' => $this->max_threshold,
|
|
41
|
+
'threshold_inclusive' => $this->threshold_inclusive,
|
|
42
|
+
'last_reading_at' => $this->last_reading_at,
|
|
43
|
+
'last_value' => $this->last_value,
|
|
44
|
+
'calibration' => data_get($this, 'calibration', Utils::createObject()),
|
|
45
|
+
'report_frequency_sec' => $this->report_frequency_sec,
|
|
46
|
+
'status' => $this->status,
|
|
47
|
+
'meta' => data_get($this, 'meta', Utils::createObject()),
|
|
48
|
+
'is_active' => $this->is_active,
|
|
49
|
+
'threshold_status' => $this->threshold_status,
|
|
50
|
+
'photo_url' => $this->photo_url,
|
|
51
|
+
'device_name' => $this->device_name,
|
|
52
|
+
'warranty_name' => $this->warranty_name,
|
|
53
|
+
'attached_to_name' => $this->attached_to_name,
|
|
54
|
+
'slug' => $this->slug,
|
|
55
|
+
'updated_at' => $this->updated_at,
|
|
56
|
+
'created_at' => $this->created_at,
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected function resolveLoadedRelation($model)
|
|
61
|
+
{
|
|
62
|
+
if (!$model) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return Http::isInternalRequest() ? Resolve::httpResourceForModel($model) : $model->public_id;
|
|
67
|
+
}
|
|
68
|
+
}
|