Add Sensor Hub functionality with components for managing sensors, including a service for API calls, a modal for selection, and a form for adding new sensors. Updated layout to integrate SensorHub component.
This commit is contained in:
@@ -14,4 +14,5 @@ export * from './services/kanbanService'
|
||||
export * from './services/todoService'
|
||||
export * from './services/userManagementService'
|
||||
export * from './services/rolesPermissionsService'
|
||||
export * from './services/sensorHubService'
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Sensor Hub Service
|
||||
* Handles sensor hub API calls
|
||||
*/
|
||||
|
||||
import { apiClient } from '../client'
|
||||
|
||||
export interface Sensor {
|
||||
name: string
|
||||
uuid_sensor: string
|
||||
last_updated: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface ListSensorsResponse {
|
||||
status?: string
|
||||
data: Sensor | Sensor[]
|
||||
}
|
||||
|
||||
export const sensorHubService = {
|
||||
/**
|
||||
* Get list of sensors
|
||||
*/
|
||||
async listSensors(): Promise<Sensor[]> {
|
||||
const response = await apiClient.get<ListSensorsResponse>('/api/sensor-hub/')
|
||||
const data = response?.data
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
return data
|
||||
}
|
||||
|
||||
if (data && typeof data === 'object') {
|
||||
return [data as Sensor]
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user