Major update to Apps page. Add instance switcher.

This commit is contained in:
2025-10-22 22:28:02 +00:00
parent 1d2f0b7891
commit 35296b3bd2
11 changed files with 1882 additions and 45 deletions

View File

@@ -108,3 +108,58 @@ export function useAppBackups(instanceName: string | null | undefined, appName:
restoreResult: restoreMutation.data,
};
}
// Enhanced hooks for app details and runtime status
export function useAppEnhanced(instanceName: string | null | undefined, appName: string | null | undefined) {
return useQuery({
queryKey: ['instances', instanceName, 'apps', appName, 'enhanced'],
queryFn: () => appsApi.getEnhanced(instanceName!, appName!),
enabled: !!instanceName && !!appName,
refetchInterval: 10000, // Poll every 10 seconds
});
}
export function useAppRuntime(instanceName: string | null | undefined, appName: string | null | undefined) {
return useQuery({
queryKey: ['instances', instanceName, 'apps', appName, 'runtime'],
queryFn: () => appsApi.getRuntime(instanceName!, appName!),
enabled: !!instanceName && !!appName,
refetchInterval: 5000, // Poll every 5 seconds
});
}
export function useAppLogs(
instanceName: string | null | undefined,
appName: string | null | undefined,
params?: { tail?: number; sinceSeconds?: number; pod?: string }
) {
return useQuery({
queryKey: ['instances', instanceName, 'apps', appName, 'logs', params],
queryFn: () => appsApi.getLogs(instanceName!, appName!, params),
enabled: !!instanceName && !!appName,
refetchInterval: false, // Manual refresh only
});
}
export function useAppEvents(
instanceName: string | null | undefined,
appName: string | null | undefined,
limit?: number
) {
return useQuery({
queryKey: ['instances', instanceName, 'apps', appName, 'events', limit],
queryFn: () => appsApi.getEvents(instanceName!, appName!, limit),
enabled: !!instanceName && !!appName,
refetchInterval: 10000, // Poll every 10 seconds
});
}
export function useAppReadme(instanceName: string | null | undefined, appName: string | null | undefined) {
return useQuery({
queryKey: ['instances', instanceName, 'apps', appName, 'readme'],
queryFn: () => appsApi.getReadme(instanceName!, appName!),
enabled: !!instanceName && !!appName,
staleTime: 5 * 60 * 1000, // 5 minutes - READMEs don't change often
retry: false, // Don't retry if README not found (404)
});
}