@futo-org/backups-orchestrator-ui 1.8.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/backups/BackupItem.svelte +11 -0
- package/dist/components/backups/BackupStatus.svelte +23 -7
- package/dist/components/backups/BackupStatus.svelte.d.ts +2 -2
- package/dist/components/backups/BackupTaskMonitor.svelte +2 -2
- package/dist/components/backups/dialogs/CancelJobModal.svelte +59 -0
- package/dist/components/backups/dialogs/CancelJobModal.svelte.d.ts +8 -0
- package/dist/components/backups/dialogs/RemoveDeletedRepositoryModal.svelte +39 -0
- package/dist/components/backups/dialogs/RemoveDeletedRepositoryModal.svelte.d.ts +6 -0
- package/dist/components/backups/dialogs/RestoreSnapshotModal.svelte +2 -2
- package/dist/components/backups/dialogs/SelectRepositoryModal.svelte +35 -17
- package/dist/components/backups/dialogs/ViewStatusModal.svelte +63 -70
- package/dist/components/backups/dialogs/ViewStatusModal.svelte.d.ts +1 -1
- package/dist/components/backups/metrics-history/MetricsHistoryModal.svelte +2 -7
- package/dist/components/backups/run-history/RepositoryRunHistory.svelte +10 -10
- package/dist/components/backups/run-history/RepositoryRunHistoryItem.svelte +43 -18
- package/dist/components/backups/run-history/RepositoryRunHistoryItem.svelte.d.ts +2 -2
- package/dist/components/backups/run-history/RepositoryRunHistoryPage.svelte +17 -16
- package/dist/components/backups/snapshots-list/RepositorySnapshotsList.svelte +2 -2
- package/dist/components/backups/snapshots-list/RepositorySnapshotsPage.svelte +2 -2
- package/dist/components/integrations/immich/ImmichBackupSettingsPage.svelte +2 -0
- package/dist/components/integrations/immich/ImmichManageBackupOverview.svelte +7 -3
- package/dist/components/integrations/immich/settings/ImmichSettingsBackupContents.svelte +0 -1
- package/dist/components/integrations/immich/settings/ImmichSettingsSchedule.svelte +0 -1
- package/dist/components/jobs/JobProgressLabel.svelte +35 -0
- package/dist/components/jobs/JobProgressLabel.svelte.d.ts +6 -0
- package/dist/components/onboarding/restore-point-flow/RestorePointFlow3ConfirmRestore.svelte +4 -4
- package/dist/components/onboarding/restore-point-flow/RestorePointFlow4Restore.svelte +35 -20
- package/dist/components/onboarding/restore-point-flow/RestorePointFlow4Restore.svelte.d.ts +1 -2
- package/dist/components/schedules/dialogs/ConfigureScheduleModal.svelte +6 -1
- package/dist/components/schedules/dialogs/CreateScheduleModal.svelte +7 -2
- package/dist/components/settings/GlobalSettings.svelte +2 -0
- package/dist/components/settings/SettingsSupportMode.svelte +154 -0
- package/dist/components/settings/SettingsSupportMode.svelte.d.ts +3 -0
- package/dist/components/test/dashboard/Dashboard.svelte +0 -3
- package/dist/components/util/RelativeTime.svelte +12 -11
- package/dist/components/util/RelativeTime.svelte.d.ts +1 -0
- package/dist/fetch-client.d.ts +111 -59
- package/dist/fetch-client.js +70 -49
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/locales/en-XA.js +1 -1
- package/dist/locales/en-XA.po +222 -30
- package/dist/locales/en.js +1 -1
- package/dist/locales/en.po +223 -31
- package/dist/services/immich.integration.service.d.ts +6 -3
- package/dist/services/immich.integration.service.js +5 -4
- package/dist/services/job.service.d.ts +42 -0
- package/dist/services/job.service.js +159 -0
- package/dist/services/repository.service.d.ts +2 -2
- package/dist/services/repository.service.js +37 -2
- package/dist/services/snapshot.service.d.ts +5 -9
- package/dist/services/snapshot.service.js +2 -3
- package/dist/services/supportMode.service.d.ts +8 -0
- package/dist/services/supportMode.service.js +19 -0
- package/dist/utils/cron.d.ts +1 -0
- package/dist/utils/cron.js +18 -0
- package/dist/utils/now.d.ts +1 -0
- package/dist/utils/now.js +6 -0
- package/dist/utils/repository.d.ts +4 -0
- package/dist/utils/repository.js +15 -0
- package/dist/utils/supportMode.d.ts +2 -0
- package/dist/utils/supportMode.js +2 -0
- package/package.json +2 -2
- package/dist/components/test/dashboard/ActiveJobs.svelte +0 -393
- package/dist/components/test/dashboard/ActiveJobs.svelte.d.ts +0 -3
- package/dist/services/log.service.svelte.d.ts +0 -67
- package/dist/services/log.service.svelte.js +0 -123
- package/dist/services/runHistory.service.d.ts +0 -37
- package/dist/services/runHistory.service.js +0 -102
- package/dist/services/task.service.d.ts +0 -3
- package/dist/services/task.service.js +0 -21
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { BackupStatusType } from '../components/backups/BackupStatus.svelte';
|
|
2
|
+
import { SocketEvent } from '../events';
|
|
3
|
+
import { type JobDto, type YuccaJobName, type JobProgressDto, type YuccaJobStatus } from '../fetch-client';
|
|
4
|
+
import { type ActionItem } from '@immich/ui';
|
|
5
|
+
import { gt } from 'svelte-i18n-lingui';
|
|
6
|
+
export type JobCreateEvent = SocketEvent<{
|
|
7
|
+
job: JobDto;
|
|
8
|
+
}>;
|
|
9
|
+
export type JobUpdateEvent = SocketEvent<{
|
|
10
|
+
jobId: string;
|
|
11
|
+
repositoryId: string;
|
|
12
|
+
job: Partial<JobDto>;
|
|
13
|
+
}>;
|
|
14
|
+
export type JobTickEvent = SocketEvent<{
|
|
15
|
+
jobId: string;
|
|
16
|
+
repositoryId: string;
|
|
17
|
+
progress: JobProgressDto;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const jobKeys: {
|
|
20
|
+
byRepository: (id: string) => readonly ["jobs", string];
|
|
21
|
+
byId: (id: string) => readonly ["job", string];
|
|
22
|
+
};
|
|
23
|
+
export declare const jobKinds: Record<YuccaJobName, 'backup' | 'restore' | 'forget' | 'syncMetrics'>;
|
|
24
|
+
export declare const isJobFinished: (status?: YuccaJobStatus) => status is Exclude<YuccaJobStatus, "queued" | "running">;
|
|
25
|
+
export declare const getRemainingText: (progress: JobProgressDto | undefined, now: number) => string;
|
|
26
|
+
export declare const useJobs: (repositoryId: () => string | undefined, name?: YuccaJobName) => import("@tanstack/svelte-query").CreateQueryResult<JobDto[], Error>;
|
|
27
|
+
export declare const useJob: (jobId: string) => import("@tanstack/svelte-query").CreateQueryResult<JobDto, Error>;
|
|
28
|
+
export declare const useJobEventHandler: () => {
|
|
29
|
+
onJobCreate(event: JobCreateEvent): void;
|
|
30
|
+
onJobUpdate(event: JobUpdateEvent): void;
|
|
31
|
+
onJobTick(event: JobTickEvent): void;
|
|
32
|
+
};
|
|
33
|
+
export declare const useBackupJobMonitor: () => {
|
|
34
|
+
onJobCreate(event: JobCreateEvent): void;
|
|
35
|
+
onJobUpdate(event: JobUpdateEvent): void;
|
|
36
|
+
};
|
|
37
|
+
export declare const handleCancelJob: (jobId: string, type: BackupStatusType) => Promise<void>;
|
|
38
|
+
export declare const getJobActions: (job: JobDto, t: typeof gt) => {
|
|
39
|
+
ViewLog: ActionItem;
|
|
40
|
+
DownloadLog: ActionItem;
|
|
41
|
+
DownloadSupportLog: ActionItem;
|
|
42
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import CancelJobModal from '../components/backups/dialogs/CancelJobModal.svelte';
|
|
2
|
+
import ViewStatusModal from '../components/backups/dialogs/ViewStatusModal.svelte';
|
|
3
|
+
import { SocketEvent } from '../events';
|
|
4
|
+
import { cancelJob, getJob, getJobs, } from '../fetch-client';
|
|
5
|
+
import { getProvider } from '../providers';
|
|
6
|
+
import { queryClient } from '../query-client';
|
|
7
|
+
import { formatDuration } from '../utils/format';
|
|
8
|
+
import { handleError } from '../utils/handle-error';
|
|
9
|
+
import { modalManager, toastManager, } from '@immich/ui';
|
|
10
|
+
import { createQuery } from '@tanstack/svelte-query';
|
|
11
|
+
import { gt, msg } from 'svelte-i18n-lingui';
|
|
12
|
+
export const jobKeys = {
|
|
13
|
+
byRepository: (id) => ['jobs', id],
|
|
14
|
+
byId: (id) => ['job', id],
|
|
15
|
+
};
|
|
16
|
+
export const jobKinds = {
|
|
17
|
+
'repository-backup': 'backup',
|
|
18
|
+
'repository-prune': 'forget',
|
|
19
|
+
'repository-restore': 'restore',
|
|
20
|
+
'repository-restore-from-point': 'restore',
|
|
21
|
+
'repository-snapshot-forget': 'forget',
|
|
22
|
+
'repository-sync-metrics': 'syncMetrics',
|
|
23
|
+
};
|
|
24
|
+
export const isJobFinished = (status) => status !== undefined && status !== 'queued' && status !== 'running';
|
|
25
|
+
export const getRemainingText = (progress, now) => {
|
|
26
|
+
if (!progress) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
const { estimatedEndAt, bytesDone, totalBytes, percentDone, scanning } = progress;
|
|
30
|
+
if (scanning) {
|
|
31
|
+
return gt `Scanning files…`;
|
|
32
|
+
}
|
|
33
|
+
const finished = bytesDone && totalBytes ? bytesDone >= totalBytes : percentDone >= 1;
|
|
34
|
+
if (estimatedEndAt === undefined && !finished) {
|
|
35
|
+
return gt `Calculating time remaining…`;
|
|
36
|
+
}
|
|
37
|
+
const remaining = estimatedEndAt ? Date.parse(estimatedEndAt) - now : 0;
|
|
38
|
+
if (finished || remaining <= 0) {
|
|
39
|
+
return gt `Nearly done.`;
|
|
40
|
+
}
|
|
41
|
+
if (remaining < 60_000) {
|
|
42
|
+
return gt `Less than a minute remaining`;
|
|
43
|
+
}
|
|
44
|
+
return gt({
|
|
45
|
+
message: 'About {duration} remaining',
|
|
46
|
+
values: {
|
|
47
|
+
duration: formatDuration(Math.round(remaining / 60_000) * 60_000),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const useJobs = (repositoryId, name) => createQuery(() => ({
|
|
52
|
+
queryKey: jobKeys.byRepository(repositoryId() ?? ''),
|
|
53
|
+
queryFn: () => getJobs(repositoryId()).then(({ jobs }) => jobs),
|
|
54
|
+
select: (jobs) => name ? jobs.filter((job) => job.name === name) : jobs,
|
|
55
|
+
enabled: repositoryId() !== undefined,
|
|
56
|
+
}), () => queryClient);
|
|
57
|
+
export const useJob = (jobId) => createQuery(() => ({
|
|
58
|
+
queryKey: jobKeys.byId(jobId),
|
|
59
|
+
queryFn: () => getJob(jobId),
|
|
60
|
+
}), () => queryClient);
|
|
61
|
+
export const useJobEventHandler = () => {
|
|
62
|
+
return {
|
|
63
|
+
onJobCreate(event) {
|
|
64
|
+
queryClient.setQueryData(jobKeys.byId(event.data.job.id), event.data.job);
|
|
65
|
+
queryClient.setQueryData(jobKeys.byRepository(event.data.job.repositoryId), (data) => data
|
|
66
|
+
? [
|
|
67
|
+
event.data.job,
|
|
68
|
+
...data.filter(({ id }) => id !== event.data.job.id),
|
|
69
|
+
]
|
|
70
|
+
: void 0);
|
|
71
|
+
},
|
|
72
|
+
onJobUpdate(event) {
|
|
73
|
+
queryClient.setQueryData(jobKeys.byId(event.data.jobId), (data) => data ? { ...data, ...event.data.job } : void 0);
|
|
74
|
+
queryClient.setQueryData(jobKeys.byRepository(event.data.repositoryId), (data) => data
|
|
75
|
+
? data.map((entry) => entry.id === event.data.jobId
|
|
76
|
+
? { ...entry, ...event.data.job }
|
|
77
|
+
: entry)
|
|
78
|
+
: void 0);
|
|
79
|
+
},
|
|
80
|
+
onJobTick(event) {
|
|
81
|
+
queryClient.setQueryData(jobKeys.byId(event.data.jobId), (data) => data ? { ...data, progress: event.data.progress } : void 0);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export const useBackupJobMonitor = () => {
|
|
86
|
+
const watching = new Set();
|
|
87
|
+
return {
|
|
88
|
+
onJobCreate(event) {
|
|
89
|
+
if (event.data.job.name === 'repository-backup') {
|
|
90
|
+
watching.add(event.data.job.id);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onJobUpdate(event) {
|
|
94
|
+
const { jobId, job } = event.data;
|
|
95
|
+
if (!watching.has(jobId) || !isJobFinished(job.status)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
watching.delete(jobId);
|
|
99
|
+
const alerts = {
|
|
100
|
+
complete: {
|
|
101
|
+
color: 'success',
|
|
102
|
+
title: gt `Backup complete`,
|
|
103
|
+
description: gt `Library successfully backed up.`,
|
|
104
|
+
},
|
|
105
|
+
warn: {
|
|
106
|
+
color: 'warning',
|
|
107
|
+
title: gt `Backup completed with warnings`,
|
|
108
|
+
description: gt `Some files could not be backed up. Check the backup log for details.`,
|
|
109
|
+
},
|
|
110
|
+
failed: {
|
|
111
|
+
color: 'danger',
|
|
112
|
+
title: gt `Backup failed`,
|
|
113
|
+
description: gt `Could not finish backing up.`,
|
|
114
|
+
},
|
|
115
|
+
cancelled: {
|
|
116
|
+
color: 'secondary',
|
|
117
|
+
title: gt `Backup cancelled`,
|
|
118
|
+
description: gt `The backup was stopped before it finished.`,
|
|
119
|
+
},
|
|
120
|
+
incomplete: {
|
|
121
|
+
color: 'warning',
|
|
122
|
+
title: gt `Backup interrupted`,
|
|
123
|
+
description: gt `The backup stopped before it could finish.`,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
toastManager.show(alerts[job.status], { closable: true });
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export const handleCancelJob = async (jobId, type) => {
|
|
131
|
+
const confirmed = await modalManager.show(CancelJobModal, { type });
|
|
132
|
+
if (!confirmed) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
await cancelJob(jobId);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
handleError(error, gt `Failed to cancel task`);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export const getJobActions = (job, t) => {
|
|
144
|
+
const ViewLog = {
|
|
145
|
+
title: t(msg `View Log`),
|
|
146
|
+
onAction: () => void modalManager.open(ViewStatusModal, { jobId: job.id }),
|
|
147
|
+
$if: () => job.name !== 'repository-sync-metrics',
|
|
148
|
+
};
|
|
149
|
+
const DownloadLog = {
|
|
150
|
+
title: t(msg `Download Full Log`),
|
|
151
|
+
onAction: () => window.open(`${getProvider().baseUrl}/api/yucca/jobs/${job.id}/download`, '_blank'),
|
|
152
|
+
};
|
|
153
|
+
const DownloadSupportLog = {
|
|
154
|
+
title: t(msg `Download Support Log`),
|
|
155
|
+
onAction: () => window.open(`${getProvider().baseUrl}/api/yucca/jobs/${job.id}/support-log/download`, '_blank'),
|
|
156
|
+
$if: () => Boolean(job.outcome?.support),
|
|
157
|
+
};
|
|
158
|
+
return { ViewLog, DownloadLog, DownloadSupportLog };
|
|
159
|
+
};
|
|
@@ -37,8 +37,8 @@ export declare const useReconfigureRepositoryPrimaryBackend: () => import("@tans
|
|
|
37
37
|
id: string;
|
|
38
38
|
backendId: string;
|
|
39
39
|
}, unknown>;
|
|
40
|
-
export declare const handleCreateBackup: (id: string) => Promise<sdk.
|
|
41
|
-
export declare const handlePruneRepository: (id: string) => Promise<sdk.
|
|
40
|
+
export declare const handleCreateBackup: (id: string) => Promise<sdk.JobResponseDto>;
|
|
41
|
+
export declare const handlePruneRepository: (id: string) => Promise<sdk.JobResponseDto>;
|
|
42
42
|
export declare const handleDeleteRepository: (repositoryId: string, local?: boolean) => Promise<void>;
|
|
43
43
|
export declare const handleDisableWormRepository: (repositoryId: string, local?: boolean) => Promise<void>;
|
|
44
44
|
export declare const getRepositoryActions: (repository: LocalRepositoryDto, t: typeof gt, local?: boolean) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sdk } from '..';
|
|
2
2
|
import ConfigureRepositoryModal from '../components/backups/dialogs/ConfigureRepositoryModal.svelte';
|
|
3
3
|
import ImportRepositoryModal from '../components/backups/dialogs/ImportRepositoryModal.svelte';
|
|
4
|
+
import RemoveDeletedRepositoryModal from '../components/backups/dialogs/RemoveDeletedRepositoryModal.svelte';
|
|
4
5
|
import ViewStatusModal from '../components/backups/dialogs/ViewStatusModal.svelte';
|
|
5
6
|
import MetricsHistoryModal from '../components/backups/metrics-history/MetricsHistoryModal.svelte';
|
|
6
7
|
import RunHistoryModal from '../components/backups/run-history/RunHistoryModal.svelte';
|
|
@@ -87,7 +88,7 @@ export const handleCreateBackup = async (id) => {
|
|
|
87
88
|
toastManager.info(gt `Started backup`);
|
|
88
89
|
const response = await sdk.createBackup(id);
|
|
89
90
|
void modalManager.open(ViewStatusModal, {
|
|
90
|
-
|
|
91
|
+
jobId: response.jobId,
|
|
91
92
|
onRetry: () => void handleCreateBackup(id),
|
|
92
93
|
});
|
|
93
94
|
return response;
|
|
@@ -102,7 +103,7 @@ export const handlePruneRepository = async (id) => {
|
|
|
102
103
|
toastManager.info(gt `Cleaning up old backups`);
|
|
103
104
|
const response = await sdk.pruneRepository(id);
|
|
104
105
|
void modalManager.open(ViewStatusModal, {
|
|
105
|
-
|
|
106
|
+
jobId: response.jobId,
|
|
106
107
|
onRetry: () => void handlePruneRepository(id),
|
|
107
108
|
});
|
|
108
109
|
return response;
|
|
@@ -112,6 +113,33 @@ export const handlePruneRepository = async (id) => {
|
|
|
112
113
|
throw error;
|
|
113
114
|
}
|
|
114
115
|
};
|
|
116
|
+
const REMOTE_DELETION_SYNC_TIMEOUT_MS = 15 * 60 * 1000;
|
|
117
|
+
const isRepositoryGone = (error) => error.status === 410;
|
|
118
|
+
const syncRemoteDeletion = (repositoryId) => {
|
|
119
|
+
const stop = () => {
|
|
120
|
+
window.removeEventListener('focus', onFocus);
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
};
|
|
123
|
+
const onFocus = () => void sdk
|
|
124
|
+
.syncRepositoryDeletion(repositoryId)
|
|
125
|
+
.then(({ deleted }) => deleted && stop())
|
|
126
|
+
.catch(stop);
|
|
127
|
+
const timeout = setTimeout(stop, REMOTE_DELETION_SYNC_TIMEOUT_MS);
|
|
128
|
+
window.addEventListener('focus', onFocus);
|
|
129
|
+
};
|
|
130
|
+
const handleRemoveDeletedRepository = async (repositoryId) => {
|
|
131
|
+
const confirmed = await modalManager.show(RemoveDeletedRepositoryModal, {});
|
|
132
|
+
if (!confirmed) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
await sdk.deleteRepository(repositoryId);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
handleError(error, gt `Failed to remove repository`);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
115
143
|
export const handleDeleteRepository = async (repositoryId, local) => {
|
|
116
144
|
try {
|
|
117
145
|
const action = local ? sdk.createTicket : createTicket;
|
|
@@ -122,9 +150,16 @@ export const handleDeleteRepository = async (repositoryId, local) => {
|
|
|
122
150
|
window.open(redirectTo, '_blank');
|
|
123
151
|
}
|
|
124
152
|
catch (error) {
|
|
153
|
+
if (local && isRepositoryGone(error)) {
|
|
154
|
+
await handleRemoveDeletedRepository(repositoryId);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
125
157
|
handleError(error, gt `Failed to start deletion`);
|
|
126
158
|
throw error;
|
|
127
159
|
}
|
|
160
|
+
if (local) {
|
|
161
|
+
syncRemoteDeletion(repositoryId);
|
|
162
|
+
}
|
|
128
163
|
};
|
|
129
164
|
export const handleDisableWormRepository = async (repositoryId, local) => {
|
|
130
165
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sdk } from '..';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { type RepositorySnapshotRestoreFromPointRequestDto, type RepositorySnapshotRestoreRequestDto, type SnapshotDto } from '../fetch-client';
|
|
3
|
+
import type { JobUpdateEvent } from './job.service';
|
|
4
4
|
import { type ActionItem } from '@immich/ui';
|
|
5
5
|
import { gt } from 'svelte-i18n-lingui';
|
|
6
6
|
export declare const snapshotKeys: {
|
|
@@ -8,20 +8,16 @@ export declare const snapshotKeys: {
|
|
|
8
8
|
};
|
|
9
9
|
export declare const useSnapshots: (repositoryId: string) => import("@tanstack/svelte-query").CreateQueryResult<sdk.SnapshotDto[], Error>;
|
|
10
10
|
export declare const useSnapshotEventHandler: () => {
|
|
11
|
-
|
|
12
|
-
runId: string;
|
|
13
|
-
repositoryId: string;
|
|
14
|
-
run: Partial<RunDto>;
|
|
15
|
-
}>): void;
|
|
11
|
+
onJobUpdate(event: JobUpdateEvent): void;
|
|
16
12
|
};
|
|
17
13
|
export declare const useRemoveSnapshot: (repositoryId: string) => (snapshotId: string) => void;
|
|
18
14
|
export declare const handleGetSnapshots: (repositoryId: string) => Promise<sdk.ListSnapshotsResponseDto>;
|
|
19
|
-
export declare const useRestoreSnapshot: () => import("@tanstack/svelte-query").CreateMutationResult<sdk.
|
|
15
|
+
export declare const useRestoreSnapshot: () => import("@tanstack/svelte-query").CreateMutationResult<sdk.JobResponseDto, Error, {
|
|
20
16
|
repositoryId: string;
|
|
21
17
|
snapshotId: string;
|
|
22
18
|
options: RepositorySnapshotRestoreRequestDto;
|
|
23
19
|
}, unknown>;
|
|
24
|
-
export declare const handleRestoreFromPoint: (repositoryId: string, snapshotId: string, backendId: string, options: RepositorySnapshotRestoreFromPointRequestDto) => Promise<sdk.
|
|
20
|
+
export declare const handleRestoreFromPoint: (repositoryId: string, snapshotId: string, backendId: string, options: RepositorySnapshotRestoreFromPointRequestDto) => Promise<sdk.JobResponseDto>;
|
|
25
21
|
export declare const handleForgetSnapshot: (repositoryId: string, snapshotId: string) => Promise<void>;
|
|
26
22
|
export declare const useRollbackSnapshot: () => import("@tanstack/svelte-query").CreateMutationResult<never, Error, sdk.ImmichRollbackRequestDto, unknown>;
|
|
27
23
|
export declare const handleGetSnapshotListing: (id: string, snapshotId: string, path?: string) => Promise<sdk.FilesystemListingResponseDto>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { sdk } from '..';
|
|
2
2
|
import RestoreSnapshotModal from '../components/backups/dialogs/RestoreSnapshotModal.svelte';
|
|
3
3
|
import RollbackSnapshotModal from '../components/backups/dialogs/RollbackSnapshotModal.svelte';
|
|
4
|
-
import { SocketEvent } from '../events';
|
|
5
4
|
import { getSnapshots, } from '../fetch-client';
|
|
6
5
|
import { queryClient } from '../query-client';
|
|
7
6
|
import { handleError } from '../utils/handle-error';
|
|
@@ -18,8 +17,8 @@ export const useSnapshots = (repositoryId) => createQuery(() => ({
|
|
|
18
17
|
}), () => queryClient);
|
|
19
18
|
export const useSnapshotEventHandler = () => {
|
|
20
19
|
return {
|
|
21
|
-
|
|
22
|
-
if (event.data.
|
|
20
|
+
onJobUpdate(event) {
|
|
21
|
+
if (event.data.job.status === 'complete') {
|
|
23
22
|
void queryClient.invalidateQueries({
|
|
24
23
|
queryKey: snapshotKeys.byRepository(event.data.repositoryId),
|
|
25
24
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type SupportModeUpdateRequestDto } from '../fetch-client';
|
|
2
|
+
export declare const supportModeKeys: {
|
|
3
|
+
all: readonly ["support-mode"];
|
|
4
|
+
};
|
|
5
|
+
export declare const maxSupportModeRuns = 20;
|
|
6
|
+
export declare const useSupportMode: () => import("@tanstack/svelte-query").CreateQueryResult<import("../fetch-client").SupportModeResponseDto, Error>;
|
|
7
|
+
export declare const refreshSupportMode: () => undefined;
|
|
8
|
+
export declare const useUpdateSupportMode: () => import("@tanstack/svelte-query").CreateMutationResult<import("../fetch-client").SupportModeResponseDto, Error, SupportModeUpdateRequestDto, unknown>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getSupportMode, updateSupportMode, } from '../fetch-client';
|
|
2
|
+
import { queryClient } from '../query-client';
|
|
3
|
+
import { handleError } from '../utils/handle-error';
|
|
4
|
+
import { createMutation, createQuery } from '@tanstack/svelte-query';
|
|
5
|
+
import { gt } from 'svelte-i18n-lingui';
|
|
6
|
+
export const supportModeKeys = {
|
|
7
|
+
all: ['support-mode'],
|
|
8
|
+
};
|
|
9
|
+
export const maxSupportModeRuns = 20;
|
|
10
|
+
export const useSupportMode = () => createQuery(() => ({
|
|
11
|
+
queryKey: supportModeKeys.all,
|
|
12
|
+
queryFn: () => getSupportMode(),
|
|
13
|
+
}), () => queryClient);
|
|
14
|
+
export const refreshSupportMode = () => void queryClient.invalidateQueries({ queryKey: supportModeKeys.all });
|
|
15
|
+
export const useUpdateSupportMode = () => createMutation(() => ({
|
|
16
|
+
mutationFn: (dto) => updateSupportMode(dto),
|
|
17
|
+
onSuccess: (supportMode) => queryClient.setQueryData(supportModeKeys.all, supportMode),
|
|
18
|
+
onError: (error) => handleError(error, gt `Failed to save support mode`),
|
|
19
|
+
}), () => queryClient);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runsMoreThanHourly: (cron: string) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const MINUTES_PER_HOUR = 60;
|
|
2
|
+
const expandMinutes = (field) => {
|
|
3
|
+
const minutes = new Set();
|
|
4
|
+
for (const part of field.split(',')) {
|
|
5
|
+
const [range = '', step] = part.split('/');
|
|
6
|
+
const [from = Number.NaN, to] = range === '*' ? [0, MINUTES_PER_HOUR - 1] : range.split('-').map(Number);
|
|
7
|
+
const last = Math.min(to ?? (step === undefined ? from : MINUTES_PER_HOUR - 1), MINUTES_PER_HOUR - 1);
|
|
8
|
+
const increment = Math.max(1, Number(step ?? 1) || 1);
|
|
9
|
+
for (let minute = from; minute <= last; minute += increment) {
|
|
10
|
+
minutes.add(minute);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return minutes;
|
|
14
|
+
};
|
|
15
|
+
export const runsMoreThanHourly = (cron) => {
|
|
16
|
+
const [minute = ''] = cron.trim().split(/\s+/);
|
|
17
|
+
return expandMinutes(minute).size > 1;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const now: import("svelte/store").Readable<number>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InspectedLocalRepositoryDto, SnapshotDto } from '../fetch-client';
|
|
2
|
+
export declare const latestSnapshot: (snapshots?: SnapshotDto[]) => SnapshotDto | undefined;
|
|
3
|
+
export declare const isRestorable: ({ snapshots }: InspectedLocalRepositoryDto) => boolean;
|
|
4
|
+
export declare const sortRestoreCandidates: (repositories: InspectedLocalRepositoryDto[]) => InspectedLocalRepositoryDto[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const latestSnapshot = (snapshots = []) => snapshots.toSorted((a, b) => Date.parse(b.time) - Date.parse(a.time)).at(0);
|
|
2
|
+
export const isRestorable = ({ snapshots }) => !!snapshots?.length;
|
|
3
|
+
const restoreRank = (repository) => {
|
|
4
|
+
if (isRestorable(repository)) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
return repository.snapshots === undefined ? 1 : 2;
|
|
8
|
+
};
|
|
9
|
+
const latestBackupTime = ({ snapshots }) => {
|
|
10
|
+
const latest = latestSnapshot(snapshots);
|
|
11
|
+
return latest ? Date.parse(latest.time) : 0;
|
|
12
|
+
};
|
|
13
|
+
export const sortRestoreCandidates = (repositories) => repositories.toSorted((a, b) => restoreRank(a) - restoreRank(b) ||
|
|
14
|
+
Number(b.name.includes('Immich')) - Number(a.name.includes('Immich')) ||
|
|
15
|
+
latestBackupTime(b) - latestBackupTime(a));
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@futo-org/backups-orchestrator-ui",
|
|
3
3
|
"repository": "https://github.com/futo-org/backups",
|
|
4
4
|
"description": "Backups orchestrator (UI library)",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.10.0",
|
|
6
6
|
"license": "Source First License 1.1",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"lodash.debounce": "^4.0.8",
|
|
72
72
|
"luxon": "^3.7.2",
|
|
73
73
|
"socket.io-client": "^4.8.3",
|
|
74
|
-
"@futo-org/backups-api-client": "^1.
|
|
74
|
+
"@futo-org/backups-api-client": "^1.10.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"dev": "vite dev --port 5174",
|