buster/web/src/api/buster_rest/dashboards/requests.ts

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-03-11 06:17:24 +08:00
import mainApi from '@/api/buster_rest/instances';
import type {
DashboardsListRequest,
DashboardCreateRequest,
2025-03-13 12:55:49 +08:00
DashboardUpdateRequest,
DashboardSubscribeRequest
2025-03-11 06:17:24 +08:00
} from '@/api/request_interfaces/dashboards/interfaces';
import type {
BusterDashboardListItem,
BusterDashboardResponse
} from '@/api/asset_interfaces/dashboard';
export const dashboardsGetList = async (params: DashboardsListRequest) => {
return await mainApi
.get<BusterDashboardListItem[]>('/dashboards', { params })
.then((res) => res.data);
};
2025-03-13 12:55:49 +08:00
export const dashboardsGetDashboard = async ({ id, password }: DashboardSubscribeRequest) => {
2025-03-18 12:40:09 +08:00
return await mainApi
.get<BusterDashboardResponse>(`/dashboards/${id}`, { params: { password } })
.then((res) => res.data);
2025-03-11 06:17:24 +08:00
};
export const dashboardsCreateDashboard = async (params: DashboardCreateRequest) => {
2025-03-19 12:29:46 +08:00
return await mainApi.post<BusterDashboardResponse>('/dashboards', params).then((res) => res.data);
2025-03-11 06:17:24 +08:00
};
export const dashboardsUpdateDashboard = async (params: DashboardUpdateRequest) => {
return await mainApi
2025-03-19 12:29:46 +08:00
.put<BusterDashboardResponse>(`/dashboards/${params.id}`, params)
2025-03-11 06:17:24 +08:00
.then((res) => res.data);
};
export const dashboardsDeleteDashboard = async ({ ids }: { ids: string[] }) => {
return await mainApi.delete<null>(`/dashboards`, { data: { ids } }).then((res) => res.data);
};