Frontend requests log on backend
This commit is contained in:
29
central_frontend/src/api/LogsAPI.ts
Normal file
29
central_frontend/src/api/LogsAPI.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Dayjs } from "dayjs";
|
||||
import { APIClient } from "./ApiClient";
|
||||
|
||||
export type LogSeverity = "Debug" | "Info" | "Warn" | "Error";
|
||||
|
||||
export interface LogEntry {
|
||||
device_id: string;
|
||||
time: number;
|
||||
severity: LogSeverity;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export class LogsAPI {
|
||||
/**
|
||||
* Request the logs from the server
|
||||
*
|
||||
* @param date The date that contains the requested date
|
||||
*/
|
||||
static async GetLogs(date: Dayjs): Promise<LogEntry[]> {
|
||||
const day = Math.floor(date.unix() / (3600 * 24));
|
||||
|
||||
const res = await APIClient.exec({
|
||||
uri: `/logging/logs?day=${day}`,
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
return res.data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user