033082954a
- Rename Go module from onixbyte.com/message-converter-manifest to onixbyte.com/pipely - Replace shadcn UI with Material UI components across all pages - Add axios-based API client in shared/web-client with credentials management - Organise API calls into feature modules: auth, devices, deployments, artefacts, users - Add .env.example with VITE_API_BASE_URL pointing to pipely.onixbyte.com - Fix deprecated FormEvent → MouseEvent in dialog submit handlers
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import WebClient from "@/shared/web-client"
|
|
|
|
export interface Device {
|
|
id: string
|
|
deviceId: string
|
|
status: "online" | "offline" | "upgrading"
|
|
lastHeartbeat: string
|
|
currentVersion?: string
|
|
targetVersion?: string
|
|
groupId?: string
|
|
createdAt: string
|
|
updatedAt: string
|
|
}
|
|
|
|
export interface DevicesResponse {
|
|
data: Device[]
|
|
total: number
|
|
page: number
|
|
pageSize: number
|
|
}
|
|
|
|
export interface DevicesQuery {
|
|
page?: number
|
|
pageSize?: number
|
|
status?: string
|
|
groupId?: string
|
|
search?: string
|
|
}
|
|
|
|
export async function getDevices(query?: DevicesQuery): Promise<DevicesResponse> {
|
|
const params = new URLSearchParams()
|
|
if (query?.page) params.append("page", query.page.toString())
|
|
if (query?.pageSize) params.append("pageSize", query.pageSize.toString())
|
|
if (query?.status) params.append("status", query.status)
|
|
if (query?.groupId) params.append("groupId", query.groupId)
|
|
if (query?.search) params.append("search", query.search)
|
|
|
|
const queryString = params.toString()
|
|
const { data } = await WebClient.get<DevicesResponse>(`/devices${queryString ? `?${queryString}` : ""}`)
|
|
return data
|
|
}
|