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';
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-02-14 08:09:49 -05:00
import type { ComponentType } from 'svelte';
2023-07-01 00:50:47 -04:00
import JobTile from './job-tile.svelte';
import StorageMigrationDescription from './storage-migration-description.svelte';
2024-05-28 09:10:43 +07:00
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
2024-06-04 21:53:00 +02:00
import { t } from 'svelte-i18n';
2022-10-06 11:25:54 -05:00
2023-07-01 00:50:47 -04:00
export let jobs: AllJobStatusResponseDto;
2022-12-19 12:13:10 -06:00
2023-07-01 00:50:47 -04:00
interface JobDetails {
title: string;
subtitle?: string;
2024-06-08 11:57:18 +02:00
description?: ComponentType;
2023-07-01 00:50:47 -04:00
allText?: 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
allowForceCommand?: boolean;
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) {
2024-05-28 09:10:43 +07:00
const isConfirmed = await dialogController.show({
id: 'confirm-reprocess-all-faces',
prompt: 'Are you sure you want to reprocess all faces? This will also clear named people.',
});
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
2023-08-18 00:55:26 -04:00
$: 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-02-14 08:09:49 -05:00
title: getJobName(JobName.ThumbnailGeneration),
2024-06-07 13:23:13 +02:00
subtitle: $t('admin.thumbnail_generation_job_description'),
2023-07-01 00:50:47 -04:00
},
[JobName.MetadataExtraction]: {
2023-10-25 09:48:25 -04:00
icon: mdiTable,
2024-02-14 08:09:49 -05:00
title: getJobName(JobName.MetadataExtraction),
2024-06-07 13:23:13 +02:00
subtitle: $t('admin.metadata_extraction_job_description'),
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-02-14 08:09:49 -05:00
title: getJobName(JobName.Library),
2024-06-07 16:01:41 +01:00
subtitle: $t('admin.library_tasks_description'),
2024-06-04 21:53:00 +02:00
allText: $t('all').toUpperCase(),
missingText: $t('refresh').toUpperCase(),
2023-09-20 13:16:33 +02:00
},
2023-07-01 00:50:47 -04:00
[JobName.Sidecar]: {
2024-02-14 08:09:49 -05: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-06-04 21:53:00 +02:00
allText: $t('sync').toUpperCase(),
missingText: $t('discover').toUpperCase(),
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-02-14 08:09:49 -05:00
title: getJobName(JobName.SmartSearch),
2024-06-07 13:23:13 +02:00
subtitle: $t('admin.smart_search_job_description'),
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,
title: getJobName(JobName.DuplicateDetection),
2024-06-07 13:23:13 +02:00
subtitle: $t('admin.duplicate_detection_job_description'),
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-02-14 08:09:49 -05:00
title: getJobName(JobName.FaceDetection),
2024-01-18 00:08:48 -05:00
subtitle:
'Detect the faces in assets using machine learning. For videos, only the thumbnail is considered. "All" (re-)processes all assets. "Missing" queues assets that haven\'t been processed yet. Detected faces will be queued for Facial Recognition after Face Detection is complete, grouping them into existing or new people.',
handleCommand: handleConfirmCommand,
disabled: !$featureFlags.facialRecognition,
},
[JobName.FacialRecognition]: {
icon: mdiTagFaces,
2024-02-14 08:09:49 -05:00
title: getJobName(JobName.FacialRecognition),
2024-01-18 00:08:48 -05:00
subtitle:
'Group detected faces into people. This step runs after Face Detection is complete. "All" (re-)clusters all faces. "Missing" queues faces that don\'t have a person assigned.',
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-02-14 08:09:49 -05:00
title: getJobName(JobName.VideoConversion),
2024-06-07 13:23:13 +02:00
subtitle: $t('admin.video_conversion_job_description'),
2023-07-01 00:50:47 -04:00
},
[JobName.StorageTemplateMigration]: {
2023-10-25 09:48:25 -04:00
icon: mdiFolderMove,
2024-02-14 08:09:49 -05:00
title: getJobName(JobName.StorageTemplateMigration),
2023-07-01 00:50:47 -04:00
allowForceCommand: false,
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-02-14 08:09:49 -05:00
title: getJobName(JobName.Migration),
2024-06-07 13:23:13 +02:00
subtitle: $t('admin.migration_job_description'),
2023-09-25 17:07:21 +02:00
allowForceCommand: false,
},
2023-07-01 00:50:47 -04:00
};
2023-08-18 00:55:26 -04:00
$: 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({
message: `Cleared jobs for: ${ title } `,
type: NotificationType.Info,
});
break;
2024-02-02 04:18:00 +01:00
}
2023-07-01 00:50:47 -04:00
}
} catch (error) {
handleError(error, `Command '${ jobCommand . command } ' failed for job: ${ title } `);
}
}
2022-10-06 11:25:54 -05:00
< / script >
2023-01-26 22:50:22 -06:00
< div class = "flex flex-col gap-7" >
2024-06-08 11:57:18 +02:00
{ #each jobList as [ jobName , { title , subtitle , description , disabled , allText , missingText , allowForceCommand , icon , handleCommand : handleCommandOverride }]}
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 }
2024-06-04 21:53:00 +02:00
allText={ allText || $t ( 'all' ). toUpperCase ()}
missingText={ missingText || $t ( 'missing' ). toUpperCase ()}
2023-07-01 00:50:47 -04:00
{ allowForceCommand }
{ jobCounts }
{ queueStatus }
on:command={({ detail }) => ( handleCommandOverride || handleCommand )( jobName , detail )}
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 >