2022-10-06 11:25:54 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import {
|
|
|
|
|
notificationController,
|
|
|
|
|
NotificationType,
|
|
|
|
|
} from '$lib/components/shared-components/notification/notification';
|
2023-09-08 22:51:46 -04:00
|
|
|
import { featureFlags } from '$lib/stores/server-config.store';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { getJobName } from '$lib/utils';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2024-02-14 06:38:57 -08:00
|
|
|
import { JobCommand, JobName, sendJobCommand, type AllJobStatusResponseDto, type JobCommandDto } from '@immich/sdk';
|
2025-07-23 23:27:09 +02:00
|
|
|
import { modalManager } from '@immich/ui';
|
2023-10-25 09:48:25 -04:00
|
|
|
import {
|
2024-05-23 12:57:25 -05:00
|
|
|
mdiContentDuplicate,
|
2023-10-25 09:48:25 -04:00
|
|
|
mdiFaceRecognition,
|
|
|
|
|
mdiFileJpgBox,
|
|
|
|
|
mdiFileXmlBox,
|
|
|
|
|
mdiFolderMove,
|
2023-12-16 11:50:46 -05:00
|
|
|
mdiImageSearch,
|
2023-10-25 09:48:25 -04:00
|
|
|
mdiLibraryShelves,
|
|
|
|
|
mdiTable,
|
2024-01-18 00:08:48 -05:00
|
|
|
mdiTagFaces,
|
2023-10-25 09:48:25 -04:00
|
|
|
mdiVideo,
|
|
|
|
|
} from '@mdi/js';
|
2024-11-02 16:49:07 +01:00
|
|
|
import type { Component } from 'svelte';
|
2025-05-12 17:48:05 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-07-01 00:50:47 -04:00
|
|
|
import JobTile from './job-tile.svelte';
|
|
|
|
|
import StorageMigrationDescription from './storage-migration-description.svelte';
|
2022-10-06 11:25:54 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
jobs: AllJobStatusResponseDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { jobs = $bindable() }: Props = $props();
|
2022-12-19 12:13:10 -06:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
interface JobDetails {
|
|
|
|
|
title: string;
|
|
|
|
|
subtitle?: string;
|
2024-11-02 16:49:07 +01:00
|
|
|
description?: Component;
|
2023-07-01 00:50:47 -04:00
|
|
|
allText?: string;
|
2024-10-03 21:58:28 -04:00
|
|
|
refreshText?: string;
|
|
|
|
|
missingText: string;
|
2023-08-18 00:55:26 -04:00
|
|
|
disabled?: boolean;
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: string;
|
2023-07-01 00:50:47 -04:00
|
|
|
handleCommand?: (jobId: JobName, jobCommand: JobCommandDto) => Promise<void>;
|
|
|
|
|
}
|
2023-05-20 21:40:53 -04:00
|
|
|
|
2024-01-18 00:08:48 -05:00
|
|
|
const handleConfirmCommand = async (jobId: JobName, dto: JobCommandDto) => {
|
2023-07-01 00:50:47 -04:00
|
|
|
if (dto.force) {
|
2025-05-12 17:48:05 -04:00
|
|
|
const isConfirmed = await modalManager.showDialog({
|
2024-06-12 12:54:40 +02:00
|
|
|
prompt: $t('admin.confirm_reprocess_all_faces'),
|
2024-05-28 09:10:43 +07:00
|
|
|
});
|
2023-05-20 21:40:53 -04:00
|
|
|
|
2024-05-28 09:10:43 +07:00
|
|
|
if (isConfirmed) {
|
|
|
|
|
await handleCommand(jobId, { command: JobCommand.Start, force: true });
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-20 21:40:53 -04:00
|
|
|
|
2024-01-18 00:08:48 -05:00
|
|
|
return;
|
|
|
|
|
}
|
2024-05-28 09:10:43 +07:00
|
|
|
|
|
|
|
|
await handleCommand(jobId, dto);
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2022-10-06 11:25:54 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let jobDetails: Partial<Record<JobName, JobDetails>> = {
|
2023-07-01 00:50:47 -04:00
|
|
|
[JobName.ThumbnailGeneration]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiFileJpgBox,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.ThumbnailGeneration),
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.thumbnail_generation_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('all'),
|
|
|
|
|
missingText: $t('missing'),
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
|
|
|
|
[JobName.MetadataExtraction]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiTable,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.MetadataExtraction),
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.metadata_extraction_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('all'),
|
|
|
|
|
missingText: $t('missing'),
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
2023-09-20 13:16:33 +02:00
|
|
|
[JobName.Library]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiLibraryShelves,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.Library),
|
2024-06-07 16:01:41 +01:00
|
|
|
subtitle: $t('admin.library_tasks_description'),
|
2025-03-03 04:29:02 +01:00
|
|
|
missingText: $t('rescan'),
|
2023-09-20 13:16:33 +02:00
|
|
|
},
|
2023-07-01 00:50:47 -04:00
|
|
|
[JobName.Sidecar]: {
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.Sidecar),
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiFileXmlBox,
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.sidecar_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('sync'),
|
|
|
|
|
missingText: $t('discover'),
|
2023-08-25 00:15:03 -04:00
|
|
|
disabled: !$featureFlags.sidecar,
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
2023-12-16 11:50:46 -05:00
|
|
|
[JobName.SmartSearch]: {
|
|
|
|
|
icon: mdiImageSearch,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.SmartSearch),
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.smart_search_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('all'),
|
|
|
|
|
missingText: $t('missing'),
|
2024-01-29 09:51:22 -05:00
|
|
|
disabled: !$featureFlags.smartSearch,
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
2024-05-23 12:57:25 -05:00
|
|
|
[JobName.DuplicateDetection]: {
|
|
|
|
|
icon: mdiContentDuplicate,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.DuplicateDetection),
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.duplicate_detection_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('all'),
|
|
|
|
|
missingText: $t('missing'),
|
2024-05-23 12:57:25 -05:00
|
|
|
disabled: !$featureFlags.duplicateDetection,
|
|
|
|
|
},
|
2024-01-18 00:08:48 -05:00
|
|
|
[JobName.FaceDetection]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiFaceRecognition,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.FaceDetection),
|
|
|
|
|
subtitle: $t('admin.face_detection_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('reset'),
|
|
|
|
|
refreshText: $t('refresh'),
|
|
|
|
|
missingText: $t('missing'),
|
2024-01-18 00:08:48 -05:00
|
|
|
handleCommand: handleConfirmCommand,
|
|
|
|
|
disabled: !$featureFlags.facialRecognition,
|
|
|
|
|
},
|
|
|
|
|
[JobName.FacialRecognition]: {
|
|
|
|
|
icon: mdiTagFaces,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.FacialRecognition),
|
|
|
|
|
subtitle: $t('admin.facial_recognition_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('reset'),
|
|
|
|
|
missingText: $t('missing'),
|
2024-01-18 00:08:48 -05:00
|
|
|
handleCommand: handleConfirmCommand,
|
2023-08-25 00:15:03 -04:00
|
|
|
disabled: !$featureFlags.facialRecognition,
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
|
|
|
|
[JobName.VideoConversion]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiVideo,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.VideoConversion),
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.video_conversion_job_description'),
|
2024-10-03 21:58:28 -04:00
|
|
|
allText: $t('all'),
|
|
|
|
|
missingText: $t('missing'),
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
|
|
|
|
[JobName.StorageTemplateMigration]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiFolderMove,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.StorageTemplateMigration),
|
2025-03-03 04:29:02 +01:00
|
|
|
missingText: $t('start'),
|
2024-06-08 11:57:18 +02:00
|
|
|
description: StorageMigrationDescription,
|
2023-07-01 00:50:47 -04:00
|
|
|
},
|
2023-09-25 17:07:21 +02:00
|
|
|
[JobName.Migration]: {
|
2023-10-25 09:48:25 -04:00
|
|
|
icon: mdiFolderMove,
|
2024-06-12 12:54:40 +02:00
|
|
|
title: $getJobName(JobName.Migration),
|
2024-06-07 13:23:13 +02:00
|
|
|
subtitle: $t('admin.migration_job_description'),
|
2025-03-03 04:29:02 +01:00
|
|
|
missingText: $t('start'),
|
2023-09-25 17:07:21 +02:00
|
|
|
},
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2024-11-14 08:43:25 -06:00
|
|
|
|
|
|
|
|
let jobList = Object.entries(jobDetails) as [JobName, JobDetails][];
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
async function handleCommand(jobId: JobName, jobCommand: JobCommandDto) {
|
|
|
|
|
const title = jobDetails[jobId]?.title;
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
try {
|
2024-02-13 17:07:37 -05:00
|
|
|
jobs[jobId] = await sendJobCommand({ id: jobId, jobCommandDto: jobCommand });
|
2023-04-01 06:53:20 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
switch (jobCommand.command) {
|
2024-02-02 04:18:00 +01:00
|
|
|
case JobCommand.Empty: {
|
2023-07-01 00:50:47 -04:00
|
|
|
notificationController.show({
|
2024-06-12 12:54:40 +02:00
|
|
|
message: $t('admin.cleared_jobs', { values: { job: title } }),
|
2023-07-01 00:50:47 -04:00
|
|
|
type: NotificationType.Info,
|
|
|
|
|
});
|
|
|
|
|
break;
|
2024-02-02 04:18:00 +01:00
|
|
|
}
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2024-06-12 12:54:40 +02:00
|
|
|
handleError(error, $t('admin.failed_job_command', { values: { command: jobCommand.command, job: title } }));
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
}
|
2022-10-06 11:25:54 -05:00
|
|
|
</script>
|
|
|
|
|
|
2023-01-26 22:50:22 -06:00
|
|
|
<div class="flex flex-col gap-7">
|
2025-03-03 14:24:26 +00:00
|
|
|
{#each jobList as [jobName, { title, subtitle, description, disabled, allText, refreshText, missingText, icon, handleCommand: handleCommandOverride }] (jobName)}
|
2023-07-01 00:50:47 -04:00
|
|
|
{@const { jobCounts, queueStatus } = jobs[jobName]}
|
|
|
|
|
<JobTile
|
|
|
|
|
{icon}
|
|
|
|
|
{title}
|
2023-08-18 00:55:26 -04:00
|
|
|
{disabled}
|
2023-07-01 00:50:47 -04:00
|
|
|
{subtitle}
|
2024-06-08 11:57:18 +02:00
|
|
|
{description}
|
2025-09-16 00:28:42 -03:00
|
|
|
{allText}
|
|
|
|
|
{refreshText}
|
|
|
|
|
{missingText}
|
2023-07-01 00:50:47 -04:00
|
|
|
{jobCounts}
|
|
|
|
|
{queueStatus}
|
2024-09-19 18:20:09 -04:00
|
|
|
onCommand={(command) => (handleCommandOverride || handleCommand)(jobName, command)}
|
2024-06-08 11:57:18 +02:00
|
|
|
/>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/each}
|
2022-10-06 11:25:54 -05:00
|
|
|
</div>
|