mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-29 23:41:31 +02:00
add resource info to side panel
This commit is contained in:
@@ -54,8 +54,12 @@ import type {
|
||||
ListLauncherSitesResponse,
|
||||
ListLauncherViewsResponse,
|
||||
LauncherListQuery,
|
||||
LauncherResource,
|
||||
LauncherViewConfig
|
||||
} from "@server/routers/launcher/types";
|
||||
import type { GetResourceResponse } from "@server/routers/resource/getResource";
|
||||
import type { GetResourceAuthInfoResponse } from "@server/routers/resource/getResourceAuthInfo";
|
||||
import type { GetSiteResourceResponse } from "@server/routers/siteResource/getSiteResource";
|
||||
import type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
||||
import { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
||||
|
||||
@@ -1313,5 +1317,48 @@ export const launcherQueries = {
|
||||
>(`/org/${orgId}/launcher/scale?${sp.toString()}`, { signal });
|
||||
return res.data.data.scale;
|
||||
}
|
||||
}),
|
||||
resourceDetail: (orgId: string, resource: LauncherResource | null) =>
|
||||
queryOptions({
|
||||
queryKey: [
|
||||
"ORG",
|
||||
orgId,
|
||||
"LAUNCHER",
|
||||
"RESOURCE_DETAIL",
|
||||
resource?.launcherResourceKey ?? null
|
||||
] as const,
|
||||
enabled: resource != null,
|
||||
queryFn: async ({ signal, meta }) => {
|
||||
if (!resource) {
|
||||
throw new Error("Resource is required");
|
||||
}
|
||||
|
||||
if (resource.resourceType === "public") {
|
||||
const res = await meta!.api.get<
|
||||
AxiosResponse<GetResourceResponse>
|
||||
>(`/org/${orgId}/resource/${resource.niceId}`, { signal });
|
||||
const resourceData = res.data.data;
|
||||
const authRes = await meta!.api.get<
|
||||
AxiosResponse<GetResourceAuthInfoResponse>
|
||||
>(`/resource/${resourceData.resourceGuid}/auth`, {
|
||||
signal
|
||||
});
|
||||
return {
|
||||
resourceType: "public" as const,
|
||||
data: resourceData,
|
||||
authInfo: authRes.data.data
|
||||
};
|
||||
}
|
||||
|
||||
const siteResourceId =
|
||||
resource.siteResourceId ?? resource.resourceId;
|
||||
const res = await meta!.api.get<
|
||||
AxiosResponse<GetSiteResourceResponse>
|
||||
>(`/org/${orgId}/site-resource/${siteResourceId}`, { signal });
|
||||
return {
|
||||
resourceType: "site" as const,
|
||||
data: res.data.data
|
||||
};
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user