draw path | draw area | localstorage layer state | add entities property parallel | timeline bar
This commit is contained in:
@@ -6,6 +6,7 @@ export const API_BASE_URL =
|
||||
export const API_ENDPOINTS = {
|
||||
geometries: `${API_BASE_URL}/geometries`,
|
||||
geometriesBatch: `${API_BASE_URL}/geometries/batch`,
|
||||
entities: `${API_BASE_URL}/entities`,
|
||||
vectorTiles: `${API_BASE_URL}/tiles/{z}/{x}/{y}`,
|
||||
rasterTiles: `${API_BASE_URL}/raster-tiles/{z}/{x}/{y}`,
|
||||
vectorTilesMetadata: `${API_BASE_URL}/tiles/metadata/info`,
|
||||
|
||||
48
api/entities.ts
Normal file
48
api/entities.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { API_ENDPOINTS } from "@/api/config";
|
||||
import { requestJson } from "@/api/http";
|
||||
|
||||
export type Entity = {
|
||||
id: string;
|
||||
name: string;
|
||||
slug?: string | null;
|
||||
description?: string | null;
|
||||
type_id?: string | null;
|
||||
status?: number | null;
|
||||
geometry_count?: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
};
|
||||
|
||||
export type CreateEntityPayload = {
|
||||
name: string;
|
||||
slug?: string | null;
|
||||
description?: string | null;
|
||||
type_id?: string | null;
|
||||
status?: number | null;
|
||||
};
|
||||
|
||||
export async function fetchEntities(query?: { q?: string }): Promise<Entity[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (query?.q) {
|
||||
params.set("q", query.q);
|
||||
}
|
||||
const suffix = params.toString();
|
||||
const url = suffix ? `${API_ENDPOINTS.entities}?${suffix}` : API_ENDPOINTS.entities;
|
||||
return requestJson<Entity[]>(url);
|
||||
}
|
||||
|
||||
export async function createEntity(payload: CreateEntityPayload): Promise<Entity> {
|
||||
return requestJson<Entity>(API_ENDPOINTS.entities, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateEntity(id: string, payload: CreateEntityPayload): Promise<Entity> {
|
||||
return requestJson<Entity>(`${API_ENDPOINTS.entities}/${id}`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
@@ -8,19 +8,23 @@ export type GeometriesBBoxQuery = {
|
||||
maxLng: number;
|
||||
maxLat: number;
|
||||
time?: number;
|
||||
entity_id?: string;
|
||||
};
|
||||
|
||||
export type GeometryCreatePayload = {
|
||||
geometry: Geometry;
|
||||
time_start?: number | null;
|
||||
time_end?: number | null;
|
||||
kind?: string | null;
|
||||
entity_id?: string | null;
|
||||
entity_ids?: string[];
|
||||
};
|
||||
|
||||
export type GeometryUpdatePayload = {
|
||||
geometry: Geometry;
|
||||
time_start?: number | null;
|
||||
time_end?: number | null;
|
||||
entity_id?: string | null;
|
||||
entity_ids?: string[];
|
||||
};
|
||||
|
||||
export type GeometryCreateResponse = {
|
||||
@@ -44,6 +48,10 @@ function buildBBoxQueryString(params: GeometriesBBoxQuery): string {
|
||||
query.set("time", String(params.time));
|
||||
}
|
||||
|
||||
if (params.entity_id) {
|
||||
query.set("entity_id", params.entity_id);
|
||||
}
|
||||
|
||||
return query.toString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user