@futo-org/backups-orchestrator-ui 1.16.0 → 1.18.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.
Files changed (29) hide show
  1. package/dist/components/backups/dialogs/CancelJobModal.svelte +1 -1
  2. package/dist/components/backups/metrics-history/MetricsHistoryModal.svelte +8 -0
  3. package/dist/components/integrations/immich/ImmichManageBackupOverview.svelte +9 -6
  4. package/dist/components/integrations/immich/ImmichOnboardingSetupFlow.svelte +22 -12
  5. package/dist/components/integrations/immich/settings/ImmichSettingsBackupContents.svelte +1 -1
  6. package/dist/components/integrations/immich/settings/ImmichSettingsSchedule.svelte +14 -85
  7. package/dist/components/integrations/immich/settings/ImmichSettingsStorage.svelte +1 -1
  8. package/dist/components/onboarding/steps/OnboardingStep4FirstBackup.svelte +42 -2
  9. package/dist/components/onboarding/steps/OnboardingStep4FirstBackup.svelte.d.ts +4 -1
  10. package/dist/components/onboarding/steps/OnboardingStepBetaDisclaimer.svelte +1 -1
  11. package/dist/components/schedules/ScheduleEditor.svelte +326 -0
  12. package/dist/components/schedules/ScheduleEditor.svelte.d.ts +7 -0
  13. package/dist/components/schedules/ScheduleList.svelte +1 -1
  14. package/dist/components/schedules/dialogs/ConfigureScheduleModal.svelte +5 -22
  15. package/dist/components/schedules/dialogs/CreateScheduleModal.svelte +6 -23
  16. package/dist/fetch-client.d.ts +8 -0
  17. package/dist/locales/en-XA.js +1 -1
  18. package/dist/locales/en-XA.po +148 -24
  19. package/dist/locales/en.js +1 -1
  20. package/dist/locales/en.po +149 -25
  21. package/dist/services/immich.integration.service.js +2 -1
  22. package/dist/services/integrations.service.d.ts +1 -1
  23. package/dist/services/integrations.service.js +1 -1
  24. package/dist/services/schedule.service.d.ts +1 -1
  25. package/dist/services/schedule.service.js +14 -6
  26. package/dist/services/snapshot.service.js +2 -2
  27. package/dist/utils/cron.d.ts +15 -0
  28. package/dist/utils/cron.js +42 -0
  29. package/package.json +3 -3
@@ -24,7 +24,7 @@
24
24
  };
25
25
 
26
26
  const prompts: Record<BackupStatusType, string> = {
27
- backup: msg`Progress since the last snapshot will be lost.`,
27
+ backup: msg`Anything already uploaded will be kept and the next backup will resume from where this one stopped. No snapshot will be made until a complete backup is finished.`,
28
28
  restore: msg`The restore will stop and will need to be started again.`,
29
29
  forget: msg`Pruning will stop and will need to be started again.`,
30
30
  };
@@ -18,6 +18,7 @@
18
18
  mdiCloudAlertOutline,
19
19
  mdiCloudCancelOutline,
20
20
  mdiCloudCheckOutline,
21
+ mdiCloudClockOutline,
21
22
  mdiCloudUploadOutline,
22
23
  mdiDatabaseOutline,
23
24
  mdiTimerOutline,
@@ -82,6 +83,13 @@
82
83
  color: "warning",
83
84
  } as const;
84
85
  }
86
+ case "skipped": {
87
+ return {
88
+ title: $t`Backup skipped`,
89
+ icon: mdiCloudClockOutline,
90
+ color: "warning",
91
+ } as const;
92
+ }
85
93
  }
86
94
 
87
95
  if (entry.backup != null) {
@@ -7,7 +7,11 @@
7
7
  import type { ImmichBackupStatus } from "../../../services/immich.integration.service";
8
8
  import { handleCancelJob } from "../../../services/job.service";
9
9
  import { handleCreateBackup } from "../../../services/repository.service";
10
- import { handleResumeSchedule } from "../../../services/schedule.service";
10
+ import {
11
+ handleResumeSchedule,
12
+ useSchedules,
13
+ } from "../../../services/schedule.service";
14
+ import { describeSchedule } from "../../../utils/cron";
11
15
  import { Button, FormatBytes, Icon } from "@immich/ui";
12
16
  import {
13
17
  mdiAlert,
@@ -18,7 +22,6 @@
18
22
  mdiProgressUpload,
19
23
  mdiStopCircleOutline,
20
24
  } from "@mdi/js";
21
- import cronstrue from "cronstrue";
22
25
  import { T, t } from "svelte-i18n-lingui";
23
26
 
24
27
  type Props = {
@@ -30,6 +33,8 @@
30
33
 
31
34
  const { repository, schedule, status, resticMissing = false }: Props = $props();
32
35
 
36
+ const schedules = useSchedules();
37
+
33
38
  const appearance = $derived.by(() => {
34
39
  switch (status.kind) {
35
40
  case "running": {
@@ -71,10 +76,8 @@
71
76
  {/if} &middot;
72
77
  {#if status.kind === "paused"}
73
78
  {$t`Backups paused`}
74
- {:else}
75
- <span class="lowercase">
76
- {cronstrue.toString(schedule.cron, { verbose: true })}
77
- </span>
79
+ {:else if schedules.data}
80
+ {describeSchedule(schedule.cron, schedules.data.defaults, schedules.data.tz)}
78
81
  {/if}
79
82
 
80
83
  {#snippet trailing()}
@@ -21,8 +21,8 @@
21
21
  handleOnboardingStatus,
22
22
  } from "../../../services/onboarding.service";
23
23
  import { handleCreateBackup } from "../../../services/repository.service";
24
+ import { useSchedules } from "../../../services/schedule.service";
24
25
  import { LoadingSpinner } from "@immich/ui";
25
- import cronstrue from "cronstrue";
26
26
  import { onMount, type Snippet } from "svelte";
27
27
  import { t } from "svelte-i18n-lingui";
28
28
 
@@ -49,10 +49,11 @@
49
49
  let status: OnboardingStatusResponseDto | undefined = $state();
50
50
  let stage: Stage = $state("idle");
51
51
  let confirming = $state(false);
52
+ let repositoryId = $state("");
52
53
 
53
54
  const defaults = useConfigureAndStartImmichIntegration();
54
55
 
55
- const schedule = cronstrue.toString(IMMICH_DEFAULT_CRON, { verbose: true });
56
+ const schedules = useSchedules();
56
57
 
57
58
  onMount(() => {
58
59
  handleOnboardingStatus().then(async (data) => {
@@ -83,7 +84,7 @@
83
84
  status?.hasOnboardedKey && status.hasBackup ? "finished" : "storage");
84
85
 
85
86
  const onBackendReady = () =>
86
- (stage = status?.hasOnboardedKey ? "backup" : "key");
87
+ (stage = status?.hasOnboardedKey ? "disclaimer" : "key");
87
88
 
88
89
  const onConnect = () => {
89
90
  handleStartYuccaLogin(onBackendReady);
@@ -94,18 +95,25 @@
94
95
 
95
96
  try {
96
97
  await handleConfirmRecoveryKey();
97
- stage = "backup";
98
+ stage = "disclaimer";
98
99
  } finally {
99
100
  confirming = false;
100
101
  }
101
102
  };
102
103
 
103
- const onStartBackup = () =>
104
- defaults.mutate(undefined, { onSuccess: ({ repositoryId }) => {
105
- stage = "finished";
106
- handleCreateBackup(repositoryId).catch(() => void 0);
104
+ const onCreateBackup = () =>
105
+ defaults.mutate(undefined, { onSuccess: (integration) => {
106
+ repositoryId = integration.repositoryId;
107
+ stage = "backup";
107
108
  }
108
109
  });
110
+
111
+ const onClose = () => (stage = "finished");
112
+
113
+ const onStartBackup = () => {
114
+ onClose();
115
+ handleCreateBackup(repositoryId).catch(() => void 0);
116
+ };
109
117
  </script>
110
118
 
111
119
  {#if status === undefined || status.status === "not-ready"}
@@ -174,11 +182,13 @@
174
182
  />
175
183
  </OnboardingStepModal>
176
184
  {:else if stage === "backup"}
177
- <OnboardingStepModal title={$t`Start your first backup`} onClose={onCancel}>
185
+ <OnboardingStepModal title={$t`Start your first backup`} {onClose}>
178
186
  <OnboardingStepFirstBackup
179
- {schedule}
187
+ cron={IMMICH_DEFAULT_CRON}
188
+ defaults={schedules.data?.defaults}
189
+ tz={schedules.data?.tz}
180
190
  storageLocation={$t`FUTO Cloud`}
181
- onStartBackup={() => (stage = "disclaimer")}
191
+ {onStartBackup}
182
192
  />
183
193
  </OnboardingStepModal>
184
194
  {:else if stage === "disclaimer"}
@@ -188,7 +198,7 @@
188
198
  onClose={onCancel}
189
199
  >
190
200
  <OnboardingStepBetaDisclaimer
191
- onConfirm={onStartBackup}
201
+ onConfirm={onCreateBackup}
192
202
  loading={defaults.isPending}
193
203
  />
194
204
  </OnboardingStepModal>
@@ -94,7 +94,7 @@
94
94
 
95
95
  const schedule = $derived(
96
96
  integration
97
- ? schedules.data?.find((entry) => entry.id === integration.scheduleId)
97
+ ? schedules.data?.schedules.find((entry) => entry.id === integration.scheduleId)
98
98
  : undefined,
99
99
  );
100
100
 
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import ScheduleEditor from "../../../schedules/ScheduleEditor.svelte";
2
3
  import Accordion from "../../../ui/Accordion.svelte";
3
4
  import OnEvents from "../../../util/OnEvents.svelte";
4
5
  import {
@@ -14,32 +15,17 @@
14
15
  useScheduleEventHandler,
15
16
  useSchedules,
16
17
  } from "../../../../services/schedule.service";
18
+ import { isValidCron } from "../../../../utils/cron";
17
19
  import {
18
20
  Button,
19
21
  Field,
20
22
  HStack,
21
23
  LoadingSpinner,
22
- Select,
23
24
  Stack,
24
25
  Switch,
25
- Text,
26
26
  } from "@immich/ui";
27
27
  import { mdiClockOutline } from "@mdi/js";
28
- import cronstrue from "cronstrue";
29
- import { msg, t } from "svelte-i18n-lingui";
30
-
31
- type Frequency = "daily" | "weekly" | "monthly";
32
-
33
- const frequencies = [
34
- { value: "daily", label: msg`Daily` },
35
- { value: "weekly", label: msg`Weekly` },
36
- { value: "monthly", label: msg`Monthly` },
37
- ];
38
-
39
- const startTimes = Array.from({ length: 24 }, (_, hour) => ({
40
- value: String(hour),
41
- label: `${String(hour).padStart(2, "0")}:00`,
42
- }));
28
+ import { t } from "svelte-i18n-lingui";
43
29
 
44
30
  const integrations = useIntegrations();
45
31
  const repositories = useRepositories();
@@ -62,7 +48,7 @@
62
48
 
63
49
  const schedule = $derived(
64
50
  integration
65
- ? schedules.data?.find((entry) => entry.id === integration.scheduleId)
51
+ ? schedules.data?.schedules.find((entry) => entry.id === integration.scheduleId)
66
52
  : undefined,
67
53
  );
68
54
 
@@ -70,38 +56,16 @@
70
56
  integrations.isLoading || repositories.isLoading || schedules.isLoading,
71
57
  );
72
58
 
73
- let frequency = $state<Frequency>("daily");
74
- let startTime = $state("3");
59
+ let cron = $state("0 3 * * *");
75
60
  let enabled = $state(true);
76
61
  let loaded = false;
77
62
 
78
- const parse = (cron: string) => {
79
- // notes
80
- // cron rewritten on write
81
- // - minute discarded
82
- // - weekly/monthly forced to set date
83
- // => need server-determined date for load distribution
84
- const [minute, hour, day, , weekday] = cron.split(" ");
85
-
86
- return {
87
- hour: /^\d+$/.test(hour ?? "") ? hour : "3",
88
- minute: /^\d+$/.test(minute ?? "") ? Number(minute) : 0,
89
- frequency: (day !== "*"
90
- ? "monthly"
91
- : weekday !== "*"
92
- ? "weekly"
93
- : "daily") as Frequency,
94
- };
95
- };
96
-
97
63
  const load = () => {
98
64
  if (!schedule) {
99
65
  return;
100
66
  }
101
67
 
102
- const parsed = parse(schedule.cron);
103
- frequency = parsed.frequency;
104
- startTime = parsed.hour;
68
+ cron = schedule.cron;
105
69
  enabled = !schedule.paused;
106
70
  };
107
71
 
@@ -114,24 +78,8 @@
114
78
  load();
115
79
  });
116
80
 
117
- const cron = $derived.by(() => {
118
- const hour = Number(startTime);
119
-
120
- switch (frequency) {
121
- case "weekly": {
122
- return `0 ${hour} * * 0`;
123
- }
124
- case "monthly": {
125
- return `0 ${hour} 1 * *`;
126
- }
127
- default: {
128
- return `0 ${hour} * * *`;
129
- }
130
- }
131
- });
132
-
133
81
  const onSave = () => {
134
- if (!integration || !repository || !schedule) {
82
+ if (!integration || !repository || !schedule || !isValidCron(cron)) {
135
83
  return;
136
84
  }
137
85
 
@@ -174,31 +122,7 @@
174
122
  <Switch bind:checked={enabled} />
175
123
  </Field>
176
124
 
177
- <Field
178
- label={$t`Frequency`}
179
- description={$t`How often backups should run.`}
180
- color="primary"
181
- required="indicator"
182
- disabled={!enabled}
183
- >
184
- <Select options={frequencies.map((option) => ({ ...option, label: $t(option.label) }))} bind:value={frequency} />
185
- </Field>
186
-
187
- <Field
188
- label={$t`Start time`}
189
- description={$t`When the scheduled backup starts.`}
190
- color="primary"
191
- required="indicator"
192
- disabled={!enabled}
193
- >
194
- <Select options={startTimes} bind:value={startTime} />
195
- </Field>
196
-
197
- <Text size="small" color="muted">
198
- {$t`Backups will run`} <span class="lowercase"
199
- >{cronstrue.toString(cron, { verbose: true })}</span
200
- >.
201
- </Text>
125
+ <ScheduleEditor bind:cron disabled={!enabled} />
202
126
 
203
127
  <HStack gap={2} class="justify-end">
204
128
  <Button
@@ -209,7 +133,12 @@
209
133
  >
210
134
  {$t`Reset`}
211
135
  </Button>
212
- <Button shape="round" loading={mutation.isPending} onclick={onSave}>
136
+ <Button
137
+ shape="round"
138
+ disabled={!isValidCron(cron)}
139
+ loading={mutation.isPending}
140
+ onclick={onSave}
141
+ >
213
142
  {$t`Save`}
214
143
  </Button>
215
144
  </HStack>
@@ -69,7 +69,7 @@
69
69
 
70
70
  const schedule = $derived(
71
71
  integration
72
- ? schedules.data?.find((entry) => entry.id === integration.scheduleId)
72
+ ? schedules.data?.schedules.find((entry) => entry.id === integration.scheduleId)
73
73
  : undefined,
74
74
  );
75
75
 
@@ -4,22 +4,58 @@
4
4
  import OnboardingStepLayout, {
5
5
  type OnboardingStepAction,
6
6
  } from "./OnboardingStepLayout.svelte";
7
+ import type { ScheduleDefaultsDto } from "../../../fetch-client";
8
+ import {
9
+ describeSchedule,
10
+ formatTime,
11
+ resolveCron,
12
+ withTimeZone,
13
+ } from "../../../utils/cron";
14
+ import { CronTime } from "cron";
15
+ import { DateTime } from "luxon";
7
16
  import { t } from "svelte-i18n-lingui";
8
17
 
9
18
  type Props = {
10
- schedule: string;
19
+ cron: string;
20
+ defaults?: ScheduleDefaultsDto;
21
+ tz?: string;
11
22
  storageLocation: string;
12
23
  onStartBackup: () => void;
13
24
  loading?: boolean;
14
25
  };
15
26
 
16
27
  const {
17
- schedule,
28
+ cron,
29
+ defaults,
30
+ tz,
18
31
  storageLocation,
19
32
  onStartBackup,
20
33
  loading = false,
21
34
  }: Props = $props();
22
35
 
36
+ const schedule = $derived.by(() => {
37
+ if (!defaults || !tz) {
38
+ return "";
39
+ }
40
+
41
+ const description = describeSchedule(cron, defaults, tz);
42
+ return description.charAt(0).toUpperCase() + description.slice(1);
43
+ });
44
+ const nextBackup = $derived.by(() => {
45
+ if (!defaults || !tz) {
46
+ return "";
47
+ }
48
+
49
+ const run = new CronTime(resolveCron(cron, defaults), tz).sendAt();
50
+ const time = formatTime(run.hour, run.minute);
51
+ return withTimeZone(
52
+ run.hasSame(DateTime.now().setZone(tz), "day")
53
+ ? $t`Next scheduled backup: today at ${time}`
54
+ : $t`Next scheduled backup: tomorrow at ${time}`,
55
+ tz,
56
+ );
57
+ });
58
+
23
59
  const settings = $derived([
24
60
  {
25
61
  icon: mdiImageMultiple,
@@ -30,6 +66,7 @@
30
66
  icon: mdiClock,
31
67
  title: $t`Schedule`,
32
68
  value: schedule,
69
+ detail: nextBackup,
33
70
  },
34
71
  {
35
72
  icon: mdiDownloadBox,
@@ -60,6 +97,9 @@
60
97
  <Stack>
61
98
  <Text fontWeight="semi-bold">{setting.title}</Text>
62
99
  <Text>{setting.value}</Text>
100
+ {#if setting.detail}
101
+ <Text size="small" color="muted">{setting.detail}</Text>
102
+ {/if}
63
103
  </Stack>
64
104
  </HStack>
65
105
  {/each}
@@ -1,5 +1,8 @@
1
+ import type { ScheduleDefaultsDto } from "../../../fetch-client";
1
2
  type Props = {
2
- schedule: string;
3
+ cron: string;
4
+ defaults?: ScheduleDefaultsDto;
5
+ tz?: string;
3
6
  storageLocation: string;
4
7
  onStartBackup: () => void;
5
8
  loading?: boolean;
@@ -44,7 +44,7 @@
44
44
 
45
45
  const actions = $derived<OnboardingStepAction[]>([
46
46
  {
47
- label: $t`Start backup`,
47
+ label: $t`Create backup`,
48
48
  onClick: onConfirm,
49
49
  disabled: !confirm,
50
50
  loading,