feat: multi-instance provider support
- provider_configs: add id TEXT PK; migrate existing rows (provider_type becomes id)
- local_files_index: add provider_id column + index; scope all queries per instance
- ProviderConfigRow: add id field; add get_by_id to trait
- LocalIndex:🆕 add provider_id param; all SQL scoped by provider_id
- factory: thread provider_id through build_local_files_bundle
- AppState.local_index: Option<Arc<LocalIndex>> → HashMap<String, Arc<LocalIndex>>
- admin_providers: restructured routes (POST /admin/providers create, PUT/DELETE /{id}, POST /test)
- admin_providers: use row.id as registry key for jellyfin and local_files
- files.rescan: optional ?provider=<id> query param
- frontend: add id to ProviderConfig, update api/hooks, new multi-instance panel UX
This commit is contained in:
@@ -13,17 +13,31 @@ export function useProviderConfigs() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateProvider() {
|
||||
const { token } = useAuthContext();
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (payload: {
|
||||
id: string;
|
||||
provider_type: string;
|
||||
config_json: Record<string, string>;
|
||||
enabled: boolean;
|
||||
}) => api.admin.providers.createProvider(token!, payload),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["admin", "providers"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateProvider() {
|
||||
const { token } = useAuthContext();
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
type,
|
||||
id,
|
||||
payload,
|
||||
}: {
|
||||
type: string;
|
||||
id: string;
|
||||
payload: { config_json: Record<string, string>; enabled: boolean };
|
||||
}) => api.admin.providers.updateProvider(token!, type, payload),
|
||||
}) => api.admin.providers.updateProvider(token!, id, payload),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["admin", "providers"] }),
|
||||
});
|
||||
}
|
||||
@@ -32,8 +46,8 @@ export function useDeleteProvider() {
|
||||
const { token } = useAuthContext();
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (type: string) =>
|
||||
api.admin.providers.deleteProvider(token!, type),
|
||||
mutationFn: (id: string) =>
|
||||
api.admin.providers.deleteProvider(token!, id),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["admin", "providers"] }),
|
||||
});
|
||||
}
|
||||
@@ -41,12 +55,9 @@ export function useDeleteProvider() {
|
||||
export function useTestProvider() {
|
||||
const { token } = useAuthContext();
|
||||
return useMutation({
|
||||
mutationFn: ({
|
||||
type,
|
||||
payload,
|
||||
}: {
|
||||
type: string;
|
||||
payload: { config_json: Record<string, string>; enabled: boolean };
|
||||
}) => api.admin.providers.testProvider(token!, type, payload),
|
||||
mutationFn: (payload: {
|
||||
provider_type: string;
|
||||
config_json: Record<string, string>;
|
||||
}) => api.admin.providers.testProvider(token!, payload),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user