| 12345678910111213141516171819202122232425262728293031323334353637 |
- import { http } from './http'
- export interface PksSeries {
- device_code: string
- start: string
- end: string
- count: number
- times: string[]
- oil: (number | null)[]
- coupling: (number | null)[]
- chain: (number | null)[]
- }
- export async function fetchPksSeries(
- deviceCode: string,
- start: string,
- end: string,
- onProgress?: (percent: number) => void,
- ): Promise<PksSeries> {
- const res = await http.get<PksSeries>('/api/pks-series', {
- params: { device_code: deviceCode, start, end },
- onDownloadProgress: (event) => {
- if (onProgress && event.total) {
- onProgress(Math.round((event.loaded / event.total) * 100))
- }
- },
- })
- onProgress?.(100)
- return res.data
- }
- export async function fetchRecentSeries(deviceCode: string, hours = 6): Promise<PksSeries> {
- const res = await http.get<PksSeries>('/api/recent-series', {
- params: { device_code: deviceCode, hours },
- })
- return res.data
- }
|