thêm giao diện cảnh báo
This commit is contained in:
15
controller/AlarmController.ts
Normal file
15
controller/AlarmController.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { api } from "@/config";
|
||||
import { API_GET_ALARM, API_MANAGER_ALARM } from "@/constants";
|
||||
|
||||
export async function queryAlarms(payload: Model.AlarmPayload) {
|
||||
return await api.get<Model.AlarmResponse>(API_GET_ALARM, {
|
||||
params: payload,
|
||||
});
|
||||
}
|
||||
|
||||
export async function queryConfirmAlarm(body: Model.AlarmConfirmRequest) {
|
||||
return await api.post(API_MANAGER_ALARM, body);
|
||||
}
|
||||
export async function queryrUnconfirmAlarm(body: Model.AlarmConfirmRequest) {
|
||||
return await api.delete(API_MANAGER_ALARM, { data: body });
|
||||
}
|
||||
@@ -1,43 +1,9 @@
|
||||
import { api } from "@/config";
|
||||
import {
|
||||
API_GET_ALARMS,
|
||||
API_GET_GPS,
|
||||
API_GET_SHIP_GROUPS,
|
||||
API_GET_SHIP_TYPES,
|
||||
API_PATH_ENTITIES,
|
||||
API_PATH_SEARCH_THINGS,
|
||||
API_PATH_SHIP_TRACK_POINTS,
|
||||
API_SOS,
|
||||
} from "@/constants";
|
||||
import { transformEntityResponse } from "@/utils/tranform";
|
||||
|
||||
export async function queryGpsData() {
|
||||
return api.get<Model.GPSResponse>(API_GET_GPS);
|
||||
}
|
||||
|
||||
export async function queryAlarm() {
|
||||
return api.get<Model.AlarmResponse>(API_GET_ALARMS);
|
||||
}
|
||||
|
||||
export async function queryTrackPoints() {
|
||||
return api.get<Model.ShipTrackPoint[]>(API_PATH_SHIP_TRACK_POINTS);
|
||||
}
|
||||
|
||||
export async function queryEntities(): Promise<Model.TransformedEntity[]> {
|
||||
const response = await api.get<Model.EntityResponse[]>(API_PATH_ENTITIES);
|
||||
return response.data.map(transformEntityResponse);
|
||||
}
|
||||
|
||||
export async function queryGetSos() {
|
||||
return await api.get<Model.SosResponse>(API_SOS);
|
||||
}
|
||||
export async function queryDeleteSos() {
|
||||
return await api.delete<Model.SosResponse>(API_SOS);
|
||||
}
|
||||
|
||||
export async function querySendSosMessage(message: string) {
|
||||
return await api.put<Model.SosRequest>(API_SOS, { message });
|
||||
}
|
||||
|
||||
export async function querySearchThings(body: Model.SearchThingBody) {
|
||||
return await api.post<Model.ThingsResponse>(API_PATH_SEARCH_THINGS, body);
|
||||
|
||||
74
controller/typings.d.ts
vendored
74
controller/typings.d.ts
vendored
@@ -17,41 +17,6 @@ declare namespace Model {
|
||||
fishing: boolean;
|
||||
t: number;
|
||||
}
|
||||
interface Alarm {
|
||||
name: string;
|
||||
t: number; // timestamp (epoch seconds)
|
||||
level: number;
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface AlarmResponse {
|
||||
alarms: Alarm[];
|
||||
level: number;
|
||||
}
|
||||
|
||||
interface ShipTrackPoint {
|
||||
time: number;
|
||||
lon: number;
|
||||
lat: number;
|
||||
s: number;
|
||||
h: number;
|
||||
}
|
||||
interface EntityResponse {
|
||||
id: string;
|
||||
v: number;
|
||||
vs: string;
|
||||
t: number;
|
||||
type: string;
|
||||
}
|
||||
interface TransformedEntity {
|
||||
id: string;
|
||||
value: number;
|
||||
valueString: string;
|
||||
time: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
// Banzones
|
||||
// Banzone
|
||||
interface Zone {
|
||||
id?: string;
|
||||
@@ -332,4 +297,43 @@ declare namespace Model {
|
||||
owner_id?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface AlarmPayload {
|
||||
offset: number;
|
||||
limit: number;
|
||||
order?: string;
|
||||
dir?: "asc" | "desc";
|
||||
name?: string;
|
||||
level?: number;
|
||||
confirmed?: boolean;
|
||||
}
|
||||
|
||||
interface AlarmResponse {
|
||||
total?: number;
|
||||
limit?: number;
|
||||
order?: string;
|
||||
dir?: string;
|
||||
alarms?: Alarm[];
|
||||
}
|
||||
|
||||
interface Alarm {
|
||||
name?: string;
|
||||
time?: number;
|
||||
level?: number;
|
||||
id?: string;
|
||||
confirmed?: boolean;
|
||||
confirmed_email?: string;
|
||||
confirmed_time?: number;
|
||||
confirmed_desc?: string;
|
||||
thing_id?: string;
|
||||
thing_name?: string;
|
||||
thing_type?: ThingType;
|
||||
}
|
||||
|
||||
interface AlarmConfirmRequest {
|
||||
id: string;
|
||||
description?: string;
|
||||
thing_id: string;
|
||||
time: number;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user