fixes and improvements

This commit is contained in:
2026-05-06 16:33:02 +02:00
parent d8d80867ce
commit 5277f21577
20 changed files with 577 additions and 222 deletions
+9 -9
View File
@@ -6,26 +6,26 @@ import {
fetchMonitoringOverview,
} from "../api/client";
export function useCounts() {
export function useCounts(machineId?: string) {
return useQuery({
queryKey: ["dashboard", "counts"],
queryFn: fetchCounts,
queryKey: ["dashboard", "counts", machineId ?? "default"],
queryFn: () => fetchCounts(machineId),
staleTime: 5 * 60 * 1000,
});
}
export function useLibraries() {
export function useLibraries(machineId?: string) {
return useQuery({
queryKey: ["dashboard", "libraries"],
queryFn: fetchLibraries,
queryKey: ["dashboard", "libraries", machineId ?? "default"],
queryFn: () => fetchLibraries(machineId),
staleTime: 5 * 60 * 1000,
});
}
export function useActivity() {
export function useActivity(machineId?: string) {
return useQuery({
queryKey: ["dashboard", "activity"],
queryFn: fetchActivity,
queryKey: ["dashboard", "activity", machineId ?? "default"],
queryFn: () => fetchActivity(machineId),
refetchInterval: 15_000,
});
}
+11 -11
View File
@@ -7,28 +7,28 @@ import {
runJob,
} from "../api/client";
export function useDirectoryListing(path: string) {
export function useDirectoryListing(path: string, machineId?: string) {
return useQuery({
queryKey: ["files", "list", path],
queryFn: () => fetchDirectoryListing(path),
queryKey: ["files", "list", path, machineId ?? "default"],
queryFn: () => fetchDirectoryListing(path, machineId),
enabled: !!path,
staleTime: 30_000,
});
}
export function useFfprobe(path: string, enabled = false) {
export function useFfprobe(path: string, enabled = false, machineId?: string) {
return useQuery({
queryKey: ["files", "ffprobe", path],
queryFn: () => fetchFfprobe(path),
queryKey: ["files", "ffprobe", path, machineId ?? "default"],
queryFn: () => fetchFfprobe(path, machineId),
enabled: enabled && !!path,
staleTime: 5 * 60_000,
});
}
export function useStat(path: string, enabled = false) {
export function useStat(path: string, enabled = false, machineId?: string) {
return useQuery({
queryKey: ["files", "stat", path],
queryFn: () => fetchStat(path),
queryKey: ["files", "stat", path, machineId ?? "default"],
queryFn: () => fetchStat(path, machineId),
enabled: enabled && !!path,
});
}
@@ -41,9 +41,9 @@ export function useJobTemplates() {
});
}
export function useRunJob() {
export function useRunJob(machineId?: string) {
return useMutation({
mutationFn: ({ jobKey, path }: { jobKey: string; path: string }) =>
runJob(jobKey, path),
runJob(jobKey, path, machineId),
});
}
+10 -10
View File
@@ -7,10 +7,10 @@ import {
forceStopMediaIndexBuild,
} from "../api/client";
export function useMediaStatus() {
export function useMediaStatus(machineId?: string) {
return useQuery({
queryKey: ["media", "status"],
queryFn: fetchMediaStatus,
queryKey: ["media", "status", machineId ?? "default"],
queryFn: () => fetchMediaStatus(machineId),
staleTime: 5_000,
refetchInterval: (query) =>
query.state.data?.build_running ? 1000 : false,
@@ -27,11 +27,11 @@ export function useMediaQuery(params: {
sort_order?: string;
limit?: number;
offset?: number;
machineId?: string;
enabled?: boolean;
}) {
const { enabled = true, ...queryParams } = params;
// Feature: Sync file browser with selected media path
return useQuery({
queryKey: ["media", "query", queryParams],
queryFn: () => queryMedia(queryParams),
@@ -44,30 +44,30 @@ function invalidateMedia(queryClient: ReturnType<typeof useQueryClient>) {
queryClient.invalidateQueries({ queryKey: ["media"] });
}
export function useBuildIndex() {
export function useBuildIndex(machineId?: string) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: buildMediaIndex,
mutationFn: () => buildMediaIndex(machineId),
onSuccess: () => {
invalidateMedia(queryClient);
},
});
}
export function useStopBuildIndex() {
export function useStopBuildIndex(machineId?: string) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: stopMediaIndexBuild,
mutationFn: () => stopMediaIndexBuild(machineId),
onSuccess: () => {
invalidateMedia(queryClient);
},
});
}
export function useForceStopBuildIndex() {
export function useForceStopBuildIndex(machineId?: string) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: forceStopMediaIndexBuild,
mutationFn: () => forceStopMediaIndexBuild(machineId),
onSuccess: () => {
invalidateMedia(queryClient);
},
+5 -4
View File
@@ -1,10 +1,11 @@
import { useQuery } from "@tanstack/react-query";
import { fetchUsers } from "../api/client";
import type { UserDirectoryResponse } from "../types";
export function useUsers() {
return useQuery({
queryKey: ["users"],
queryFn: fetchUsers,
export function useUsers(machineId?: string) {
return useQuery<UserDirectoryResponse>({
queryKey: ["users", machineId ?? "default"],
queryFn: () => fetchUsers(machineId),
staleTime: 30_000,
});
}