2022-12-09 15:51:42 -05:00
|
|
|
<script lang="ts">
|
2024-02-14 06:38:57 -08:00
|
|
|
import AdminSettings from '$lib/components/admin-page/settings/admin-settings.svelte';
|
2024-05-13 16:40:33 -04:00
|
|
|
import AuthSettings from '$lib/components/admin-page/settings/auth/auth-settings.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import FFmpegSettings from '$lib/components/admin-page/settings/ffmpeg/ffmpeg-settings.svelte';
|
2024-05-13 16:40:33 -04:00
|
|
|
import ImageSettings from '$lib/components/admin-page/settings/image/image-settings.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import JobSettings from '$lib/components/admin-page/settings/job-settings/job-settings.svelte';
|
2024-02-14 06:38:57 -08:00
|
|
|
import LibrarySettings from '$lib/components/admin-page/settings/library-settings/library-settings.svelte';
|
|
|
|
|
import LoggingSettings from '$lib/components/admin-page/settings/logging-settings/logging-settings.svelte';
|
2023-08-25 00:15:03 -04:00
|
|
|
import MachineLearningSettings from '$lib/components/admin-page/settings/machine-learning-settings/machine-learning-settings.svelte';
|
2023-09-08 22:51:46 -04:00
|
|
|
import MapSettings from '$lib/components/admin-page/settings/map-settings/map-settings.svelte';
|
2024-02-14 06:38:57 -08:00
|
|
|
import NewVersionCheckSettings from '$lib/components/admin-page/settings/new-version-check-settings/new-version-check-settings.svelte';
|
2024-05-02 16:43:18 +02:00
|
|
|
import NotificationSettings from '$lib/components/admin-page/settings/notification-settings/notification-settings.svelte';
|
2024-05-13 16:40:33 -04:00
|
|
|
import ServerSettings from '$lib/components/admin-page/settings/server/server-settings.svelte';
|
2023-07-01 00:50:47 -04:00
|
|
|
import StorageTemplateSettings from '$lib/components/admin-page/settings/storage-template/storage-template-settings.svelte';
|
2024-02-14 06:38:57 -08:00
|
|
|
import ThemeSettings from '$lib/components/admin-page/settings/theme/theme-settings.svelte';
|
2023-10-13 11:02:28 -04:00
|
|
|
import TrashSettings from '$lib/components/admin-page/settings/trash-settings/trash-settings.svelte';
|
2024-03-06 00:45:40 -05:00
|
|
|
import UserSettings from '$lib/components/admin-page/settings/user-settings/user-settings.svelte';
|
2023-10-13 11:02:28 -04:00
|
|
|
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
|
2024-02-14 06:38:57 -08:00
|
|
|
import Icon from '$lib/components/elements/icon.svelte';
|
2023-10-13 11:02:28 -04:00
|
|
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
2024-05-13 16:40:33 -04:00
|
|
|
import SettingAccordionState from '$lib/components/shared-components/settings/setting-accordion-state.svelte';
|
|
|
|
|
import SettingAccordion from '$lib/components/shared-components/settings/setting-accordion.svelte';
|
|
|
|
|
import { QueryParameter } from '$lib/constants';
|
2023-08-25 19:44:52 +02:00
|
|
|
import { downloadManager } from '$lib/stores/download';
|
2023-09-08 22:51:46 -04:00
|
|
|
import { featureFlags } from '$lib/stores/server-config.store';
|
2024-02-14 06:38:57 -08:00
|
|
|
import { copyToClipboard } from '$lib/utils';
|
2023-08-25 19:44:52 +02:00
|
|
|
import { downloadBlob } from '$lib/utils/asset-utils';
|
2024-05-13 16:40:33 -04:00
|
|
|
import type { SystemConfigDto } from '@immich/sdk';
|
2024-04-24 21:43:43 +02:00
|
|
|
import { mdiAlert, mdiContentCopy, mdiDownload, mdiUpload } from '@mdi/js';
|
2024-02-14 06:38:57 -08:00
|
|
|
import type { PageData } from './$types';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2022-12-09 15:51:42 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
export let data: PageData;
|
2023-01-09 16:32:58 -05:00
|
|
|
|
2024-01-12 18:44:11 +01:00
|
|
|
let config = data.configs;
|
2024-04-24 21:43:43 +02:00
|
|
|
let handleSave: (update: Partial<SystemConfigDto>) => Promise<void>;
|
2024-02-11 00:25:02 +01:00
|
|
|
|
|
|
|
|
type Settings =
|
2024-05-13 16:40:33 -04:00
|
|
|
| typeof AuthSettings
|
2024-02-11 00:25:02 +01:00
|
|
|
| typeof JobSettings
|
|
|
|
|
| typeof LibrarySettings
|
|
|
|
|
| typeof LoggingSettings
|
|
|
|
|
| typeof MachineLearningSettings
|
|
|
|
|
| typeof MapSettings
|
|
|
|
|
| typeof ServerSettings
|
|
|
|
|
| typeof StorageTemplateSettings
|
|
|
|
|
| typeof ThemeSettings
|
2024-04-02 00:56:56 -04:00
|
|
|
| typeof ImageSettings
|
2024-02-11 00:25:02 +01:00
|
|
|
| typeof TrashSettings
|
|
|
|
|
| typeof NewVersionCheckSettings
|
2024-05-02 16:43:18 +02:00
|
|
|
| typeof NotificationSettings
|
2024-03-06 00:45:40 -05:00
|
|
|
| typeof FFmpegSettings
|
|
|
|
|
| typeof UserSettings;
|
2023-08-25 19:44:52 +02:00
|
|
|
|
2023-10-13 11:02:28 -04:00
|
|
|
const downloadConfig = () => {
|
2024-01-12 18:44:11 +01:00
|
|
|
const blob = new Blob([JSON.stringify(config, null, 2)], { type: 'application/json' });
|
2023-08-25 19:44:52 +02:00
|
|
|
const downloadKey = 'immich-config.json';
|
|
|
|
|
downloadManager.add(downloadKey, blob.size);
|
|
|
|
|
downloadManager.update(downloadKey, blob.size);
|
|
|
|
|
downloadBlob(blob, downloadKey);
|
2024-02-02 04:18:00 +01:00
|
|
|
setTimeout(() => downloadManager.clear(downloadKey), 5000);
|
2023-08-25 19:44:52 +02:00
|
|
|
};
|
2024-01-12 18:44:11 +01:00
|
|
|
|
2024-04-24 21:43:43 +02:00
|
|
|
let inputElement: HTMLInputElement;
|
|
|
|
|
const uploadConfig = (e: Event) => {
|
|
|
|
|
const file = (e.target as HTMLInputElement).files?.[0];
|
|
|
|
|
if (!file) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const reader = async () => {
|
|
|
|
|
const text = await file.text();
|
|
|
|
|
const newConfig = JSON.parse(text);
|
|
|
|
|
await handleSave(newConfig);
|
|
|
|
|
};
|
|
|
|
|
reader().catch((error) => console.error('Error handling JSON config upload', error));
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-11 00:25:02 +01:00
|
|
|
const settings: Array<{
|
|
|
|
|
item: Settings;
|
|
|
|
|
title: string;
|
|
|
|
|
subtitle: string;
|
|
|
|
|
key: string;
|
|
|
|
|
}> = [
|
2024-05-13 16:40:33 -04:00
|
|
|
{
|
|
|
|
|
item: AuthSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.authentication_settings'),
|
|
|
|
|
subtitle: $t('admin.authentication_settings_description'),
|
2024-05-13 16:40:33 -04:00
|
|
|
key: 'image',
|
|
|
|
|
},
|
2024-04-02 00:56:56 -04:00
|
|
|
{
|
|
|
|
|
item: ImageSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.image_settings'),
|
|
|
|
|
subtitle: $t('admin.image_settings_description'),
|
2024-04-02 00:56:56 -04:00
|
|
|
key: 'image',
|
|
|
|
|
},
|
2024-01-12 18:44:11 +01:00
|
|
|
{
|
|
|
|
|
item: JobSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.job_settings'),
|
|
|
|
|
subtitle: $t('admin.job_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'job',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: LibrarySettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.library_settings'),
|
|
|
|
|
subtitle: $t('admin.library_settings_description'),
|
2024-03-08 16:49:44 +00:00
|
|
|
key: 'external-library',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: LoggingSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.logging_settings'),
|
|
|
|
|
subtitle: $t('admin.manage_log_settings'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'logging',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: MachineLearningSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.machine_learning_settings'),
|
|
|
|
|
subtitle: $t('admin.machine_learning_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'machine-learning',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: MapSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.map_settings'),
|
|
|
|
|
subtitle: $t('admin.map_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'location',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
2024-05-02 16:43:18 +02:00
|
|
|
{
|
|
|
|
|
item: NotificationSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.notification_settings'),
|
|
|
|
|
subtitle: $t('admin.notification_settings_description'),
|
2024-05-02 16:43:18 +02:00
|
|
|
key: 'notifications',
|
|
|
|
|
},
|
2024-01-12 18:44:11 +01:00
|
|
|
{
|
|
|
|
|
item: ServerSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.server_settings'),
|
|
|
|
|
subtitle: $t('admin.server_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'server',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: StorageTemplateSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.storage_template_settings'),
|
|
|
|
|
subtitle: $t('admin.storage_template_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'storage-template',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: ThemeSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.theme_settings'),
|
|
|
|
|
subtitle: $t('admin.theme_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'theme',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: TrashSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.trash_settings'),
|
|
|
|
|
subtitle: $t('admin.trash_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'trash',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
2024-03-06 00:45:40 -05:00
|
|
|
{
|
|
|
|
|
item: UserSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.user_settings'),
|
|
|
|
|
subtitle: $t('admin.user_settings_description'),
|
2024-03-06 00:45:40 -05:00
|
|
|
key: 'user-settings',
|
|
|
|
|
},
|
2024-01-12 18:44:11 +01:00
|
|
|
{
|
|
|
|
|
item: NewVersionCheckSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.version_check_settings'),
|
|
|
|
|
subtitle: $t('admin.version_check_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'version-check',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
item: FFmpegSettings,
|
2024-06-04 21:53:00 +02:00
|
|
|
title: $t('admin.transcoding_settings'),
|
|
|
|
|
subtitle: $t('admin.transcoding_settings_description'),
|
2024-02-11 00:25:02 +01:00
|
|
|
key: 'video-transcoding',
|
2024-01-12 18:44:11 +01:00
|
|
|
},
|
|
|
|
|
];
|
2022-12-09 15:51:42 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-04-24 21:43:43 +02:00
|
|
|
<input bind:this={inputElement} type="file" accept=".json" style="display: none" on:change={uploadConfig} />
|
|
|
|
|
|
2024-02-01 13:05:30 -08:00
|
|
|
<div class="h-svh flex flex-col overflow-hidden">
|
|
|
|
|
{#if $featureFlags.configFile}
|
|
|
|
|
<div class="flex flex-row items-center gap-2 bg-gray-100 p-3 dark:bg-gray-800">
|
|
|
|
|
<Icon path={mdiAlert} class="text-yellow-400" size={18} />
|
|
|
|
|
<h2 class="text-md text-immich-primary dark:text-immich-dark-primary">
|
2024-06-12 12:54:40 +02:00
|
|
|
{$t('admin.config_set_by_file')}
|
2024-02-01 13:05:30 -08:00
|
|
|
</h2>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2023-08-25 19:44:52 +02:00
|
|
|
|
2024-02-01 13:05:30 -08:00
|
|
|
<UserPageLayout title={data.meta.title} admin>
|
|
|
|
|
<div class="flex justify-end gap-2" slot="buttons">
|
|
|
|
|
<LinkButton on:click={() => copyToClipboard(JSON.stringify(config, null, 2))}>
|
|
|
|
|
<div class="flex place-items-center gap-2 text-sm">
|
|
|
|
|
<Icon path={mdiContentCopy} size="18" />
|
2024-06-12 12:54:40 +02:00
|
|
|
{$t('copy_to_clipboard')}
|
2024-02-01 13:05:30 -08:00
|
|
|
</div>
|
|
|
|
|
</LinkButton>
|
|
|
|
|
<LinkButton on:click={() => downloadConfig()}>
|
|
|
|
|
<div class="flex place-items-center gap-2 text-sm">
|
|
|
|
|
<Icon path={mdiDownload} size="18" />
|
2024-06-12 12:54:40 +02:00
|
|
|
{$t('export_as_json')}
|
2024-02-01 13:05:30 -08:00
|
|
|
</div>
|
|
|
|
|
</LinkButton>
|
2024-04-24 21:43:43 +02:00
|
|
|
<LinkButton on:click={() => inputElement?.click()}>
|
|
|
|
|
<div class="flex place-items-center gap-2 text-sm">
|
|
|
|
|
<Icon path={mdiUpload} size="18" />
|
2024-06-12 12:54:40 +02:00
|
|
|
{$t('import_from_json')}
|
2024-04-24 21:43:43 +02:00
|
|
|
</div>
|
|
|
|
|
</LinkButton>
|
2024-02-01 13:05:30 -08:00
|
|
|
</div>
|
2023-08-29 09:58:00 -04:00
|
|
|
|
2024-04-24 21:43:43 +02:00
|
|
|
<AdminSettings bind:config let:handleReset bind:handleSave let:savedConfig let:defaultConfig>
|
2024-02-01 13:05:30 -08:00
|
|
|
<section id="setting-content" class="flex place-content-center sm:mx-4">
|
|
|
|
|
<section class="w-full pb-28 sm:w-5/6 md:w-[850px]">
|
2024-02-28 22:40:08 +01:00
|
|
|
<SettingAccordionState queryParam={QueryParameter.IS_OPEN}>
|
|
|
|
|
{#each settings as { item, title, subtitle, key }}
|
|
|
|
|
<SettingAccordion {title} {subtitle} {key}>
|
|
|
|
|
<svelte:component
|
|
|
|
|
this={item}
|
|
|
|
|
on:save={({ detail }) => handleSave(detail)}
|
|
|
|
|
on:reset={({ detail }) => handleReset(detail)}
|
|
|
|
|
disabled={$featureFlags.configFile}
|
|
|
|
|
{defaultConfig}
|
|
|
|
|
{config}
|
|
|
|
|
{savedConfig}
|
|
|
|
|
/>
|
|
|
|
|
</SettingAccordion>
|
|
|
|
|
{/each}
|
|
|
|
|
</SettingAccordionState>
|
2024-02-01 13:05:30 -08:00
|
|
|
</section>
|
2024-01-12 18:44:11 +01:00
|
|
|
</section>
|
2024-02-01 13:05:30 -08:00
|
|
|
</AdminSettings>
|
|
|
|
|
</UserPageLayout>
|
|
|
|
|
</div>
|