From ce21ecd7624bc46dd44d0f48da6e8bc8ebff58d8 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 7 Apr 2025 16:11:33 -0600 Subject: [PATCH] start moving to new asset layout --- web/src/api/buster_rest/dashboards/requests.ts | 12 ++++++++++++ .../api/buster_rest/metrics/queryReqestsServer.ts | 1 + web/src/api/createServerInstance.ts | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/src/api/buster_rest/dashboards/requests.ts b/web/src/api/buster_rest/dashboards/requests.ts index c329a582a..f29f76897 100644 --- a/web/src/api/buster_rest/dashboards/requests.ts +++ b/web/src/api/buster_rest/dashboards/requests.ts @@ -9,6 +9,7 @@ import { SharePostRequest, ShareUpdateRequest } from '@/api/asset_interfaces/shared_interfaces'; +import { serverFetch } from '@/api/createServerInstance'; export const dashboardsGetList = async (params: { /** The page number to fetch */ @@ -42,6 +43,17 @@ export const dashboardsGetDashboard = async ({ .then((res) => res.data); }; +export const getDashboard_server = async ({ + id, + password, + version_number +}: Parameters[0]) => { + return serverFetch(`/dashboards/${id}`, { + method: 'GET', + params: { password, version_number } + }); +}; + export const dashboardsCreateDashboard = async (params: { /** The name of the dashboard */ name?: string; diff --git a/web/src/api/buster_rest/metrics/queryReqestsServer.ts b/web/src/api/buster_rest/metrics/queryReqestsServer.ts index fe2b1c5a1..b509d80dc 100644 --- a/web/src/api/buster_rest/metrics/queryReqestsServer.ts +++ b/web/src/api/buster_rest/metrics/queryReqestsServer.ts @@ -11,6 +11,7 @@ export const prefetchGetMetric = async ( queryClientProp?: QueryClient ) => { const queryClient = queryClientProp || new QueryClient(); + await queryClient.prefetchQuery({ ...metricsQueryKeys.metricsGetMetric(params.id, params.version_number), queryFn: async () => { diff --git a/web/src/api/createServerInstance.ts b/web/src/api/createServerInstance.ts index 09c58d3f2..64b9ba99d 100644 --- a/web/src/api/createServerInstance.ts +++ b/web/src/api/createServerInstance.ts @@ -41,9 +41,11 @@ export const serverFetch = async (url: string, config: FetchConfig = {}): Pro }); if (!response.ok) { + const errorText = await response.text(); + throw { status: response.status, - message: response.statusText + message: errorText || response.statusText } satisfies RustApiError; }