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

37 lines
1.2 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,
DashboardUpdateRequest
} 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);
};
export const dashboardsGetDashboard = async (id: string) => {
return await mainApi.get<BusterDashboardResponse>(`/dashboards/${id}`).then((res) => res.data);
};
export const dashboardsCreateDashboard = async (params: DashboardCreateRequest) => {
return await mainApi
.post<BusterDashboardResponse>('/dashboards', { params })
.then((res) => res.data);
};
export const dashboardsUpdateDashboard = async (params: DashboardUpdateRequest) => {
return await mainApi
.put<BusterDashboardResponse>(`/dashboards/${params.id}`, { params })
.then((res) => res.data);
};
export const dashboardsDeleteDashboard = async ({ ids }: { ids: string[] }) => {
return await mainApi.delete<null>(`/dashboards`, { data: { ids } }).then((res) => res.data);
};