feat(frontend): rclone repositories config

This commit is contained in:
Nicolas Meienberger
2025-11-11 21:31:10 +01:00
parent 8f9873148a
commit 36b0282d18
10 changed files with 265 additions and 43 deletions

View File

@@ -29,6 +29,7 @@ import {
listSnapshotFiles,
restoreSnapshot,
doctorRepository,
listRcloneRemotes,
listBackupSchedules,
createBackupSchedule,
deleteBackupSchedule,
@@ -84,6 +85,7 @@ import type {
RestoreSnapshotResponse,
DoctorRepositoryData,
DoctorRepositoryResponse,
ListRcloneRemotesData,
ListBackupSchedulesData,
CreateBackupScheduleData,
CreateBackupScheduleResponse,
@@ -918,6 +920,27 @@ export const doctorRepositoryMutation = (
return mutationOptions;
};
export const listRcloneRemotesQueryKey = (options?: Options<ListRcloneRemotesData>) =>
createQueryKey("listRcloneRemotes", options);
/**
* List all configured rclone remotes on the host system
*/
export const listRcloneRemotesOptions = (options?: Options<ListRcloneRemotesData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
const { data } = await listRcloneRemotes({
...options,
...queryKey[0],
signal,
throwOnError: true,
});
return data;
},
queryKey: listRcloneRemotesQueryKey(options),
});
};
export const listBackupSchedulesQueryKey = (options?: Options<ListBackupSchedulesData>) =>
createQueryKey("listBackupSchedules", options);

View File

@@ -60,6 +60,8 @@ import type {
RestoreSnapshotResponses,
DoctorRepositoryData,
DoctorRepositoryResponses,
ListRcloneRemotesData,
ListRcloneRemotesResponses,
ListBackupSchedulesData,
ListBackupSchedulesResponses,
CreateBackupScheduleData,
@@ -443,6 +445,18 @@ export const doctorRepository = <ThrowOnError extends boolean = false>(
});
};
/**
* List all configured rclone remotes on the host system
*/
export const listRcloneRemotes = <ThrowOnError extends boolean = false>(
options?: Options<ListRcloneRemotesData, ThrowOnError>,
) => {
return (options?.client ?? _heyApiClient).get<ListRcloneRemotesResponses, unknown, ThrowOnError>({
url: "/api/v1/repositories/rclone-remotes",
...options,
});
};
/**
* List all backup schedules
*/

View File

@@ -754,6 +754,11 @@ export type ListRepositoriesResponses = {
| {
backend: "local";
name: string;
}
| {
backend: "rclone";
path: string;
remote: string;
};
createdAt: number;
id: string;
@@ -761,7 +766,7 @@ export type ListRepositoriesResponses = {
lastError: string | null;
name: string;
status: "error" | "healthy" | "unknown" | null;
type: "azure" | "gcs" | "local" | "s3";
type: "azure" | "gcs" | "local" | "rclone" | "s3";
updatedAt: number;
}>;
};
@@ -794,6 +799,11 @@ export type CreateRepositoryData = {
| {
backend: "local";
name: string;
}
| {
backend: "rclone";
path: string;
remote: string;
};
name: string;
compressionMode?: "auto" | "better" | "fastest" | "max" | "off";
@@ -877,6 +887,11 @@ export type GetRepositoryResponses = {
| {
backend: "local";
name: string;
}
| {
backend: "rclone";
path: string;
remote: string;
};
createdAt: number;
id: string;
@@ -884,7 +899,7 @@ export type GetRepositoryResponses = {
lastError: string | null;
name: string;
status: "error" | "healthy" | "unknown" | null;
type: "azure" | "gcs" | "local" | "s3";
type: "azure" | "gcs" | "local" | "rclone" | "s3";
updatedAt: number;
};
};
@@ -1037,6 +1052,25 @@ export type DoctorRepositoryResponses = {
export type DoctorRepositoryResponse = DoctorRepositoryResponses[keyof DoctorRepositoryResponses];
export type ListRcloneRemotesData = {
body?: never;
path?: never;
query?: never;
url: "/api/v1/repositories/rclone-remotes";
};
export type ListRcloneRemotesResponses = {
/**
* List of rclone remotes
*/
200: Array<{
name: string;
type: string;
}>;
};
export type ListRcloneRemotesResponse = ListRcloneRemotesResponses[keyof ListRcloneRemotesResponses];
export type ListBackupSchedulesData = {
body?: never;
path?: never;
@@ -1085,6 +1119,11 @@ export type ListBackupSchedulesResponses = {
| {
backend: "local";
name: string;
}
| {
backend: "rclone";
path: string;
remote: string;
};
createdAt: number;
id: string;
@@ -1092,7 +1131,7 @@ export type ListBackupSchedulesResponses = {
lastError: string | null;
name: string;
status: "error" | "healthy" | "unknown" | null;
type: "azure" | "gcs" | "local" | "s3";
type: "azure" | "gcs" | "local" | "rclone" | "s3";
updatedAt: number;
};
repositoryId: string;
@@ -1284,6 +1323,11 @@ export type GetBackupScheduleResponses = {
| {
backend: "local";
name: string;
}
| {
backend: "rclone";
path: string;
remote: string;
};
createdAt: number;
id: string;
@@ -1291,7 +1335,7 @@ export type GetBackupScheduleResponses = {
lastError: string | null;
name: string;
status: "error" | "healthy" | "unknown" | null;
type: "azure" | "gcs" | "local" | "s3";
type: "azure" | "gcs" | "local" | "rclone" | "s3";
updatedAt: number;
};
repositoryId: string;
@@ -1464,6 +1508,11 @@ export type GetBackupScheduleForVolumeResponses = {
| {
backend: "local";
name: string;
}
| {
backend: "rclone";
path: string;
remote: string;
};
createdAt: number;
id: string;
@@ -1471,7 +1520,7 @@ export type GetBackupScheduleForVolumeResponses = {
lastError: string | null;
name: string;
status: "error" | "healthy" | "unknown" | null;
type: "azure" | "gcs" | "local" | "s3";
type: "azure" | "gcs" | "local" | "rclone" | "s3";
updatedAt: number;
};
repositoryId: string;