thêm zustand để cấu hình global state, hook để lấy platform, thêm polyline và polygon b vào map

This commit is contained in:
Tran Anh Tuan
2025-10-31 19:54:16 +07:00
parent 2fac0b8093
commit 5801992eae
19 changed files with 1202 additions and 89 deletions

View File

@@ -2,8 +2,10 @@ import { api } from "@/config";
import {
API_GET_ALARMS,
API_GET_GPS,
API_PATH_ENTITIES,
API_PATH_SHIP_TRACK_POINTS,
} from "@/constants";
import { transformEntityResponse } from "@/utils/tranform";
export async function queryGpsData() {
return api.get<Model.GPSResonse>(API_GET_GPS);
@@ -16,3 +18,8 @@ export async function queryAlarm() {
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);
}

View File

@@ -0,0 +1,6 @@
import { api } from "@/config";
import { API_GET_ALL_BANZONES } from "@/constants";
export async function queryBanzones() {
return api.get<Model.Zone[]>(API_GET_ALL_BANZONES);
}

View File

@@ -1,3 +1,4 @@
import * as AuthController from "./AuthController";
export { AuthController };
import * as DeviceController from "./DeviceController";
import * as MapController from "./MapController";
export { AuthController, DeviceController, MapController };

View File

@@ -33,4 +33,51 @@ declare namespace Model {
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
export interface Zone {
id?: string;
name?: string;
type?: number;
conditions?: Condition[];
enabled?: boolean;
updated_at?: Date;
geom?: Geom;
}
export interface Condition {
max?: number;
min?: number;
type?: Type;
to?: number;
from?: number;
}
export enum Type {
LengthLimit = "length_limit",
MonthRange = "month_range",
}
export interface Geom {
geom_type?: number;
geom_poly?: string;
geom_lines?: string;
geom_point?: string;
geom_radius?: number;
}
}