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 {
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 ConfirmDialogue from '../../shared-components/confirm-dialogue.svelte';
import JobTile from './job-tile.svelte';
import StorageMigrationDescription from './storage-migration-description.svelte';
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;
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;
component?: ComponentType;
handleCommand?: (jobId: JobName, jobCommand: JobCommandDto) => Promise< void > ;
}
2023-05-20 21:40:53 -04:00
2024-01-18 00:08:48 -05:00
let confirmJob: JobName | null = null;
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-01-18 00:08:48 -05:00
confirmJob = jobId;
2023-07-01 00:50:47 -04:00
return;
}
2023-05-20 21:40:53 -04:00
2023-07-01 00:50:47 -04:00
await handleCommand(jobId, dto);
};
2023-05-20 21:40:53 -04:00
2024-02-27 08:37:37 -08:00
const onConfirm = async () => {
2024-01-18 00:08:48 -05:00
if (!confirmJob) {
return;
}
2024-02-27 08:37:37 -08:00
await handleCommand(confirmJob, { command : JobCommand.Start , force : true } );
2024-01-18 00:08:48 -05:00
confirmJob = null;
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),
2023-12-16 11:50:46 -05:00
subtitle: 'Generate large, small and blurred thumbnails for each asset, as well as thumbnails for each person',
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),
2023-12-16 11:50:46 -05:00
subtitle: 'Extract metadata information from each asset, such as GPS and resolution',
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),
2023-09-20 13:16:33 +02:00
subtitle: 'Perform library tasks',
allText: 'ALL',
missingText: 'REFRESH',
},
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,
2023-07-01 00:50:47 -04:00
subtitle: 'Discover or synchronize sidecar metadata from the filesystem',
allText: 'SYNC',
missingText: '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-02-14 08:09:49 -05:00
title: getJobName(JobName.SmartSearch),
2023-12-16 11:50:46 -05:00
subtitle: 'Run machine learning on assets to support smart search',
2024-01-29 09:51:22 -05:00
disabled: !$featureFlags.smartSearch,
2023-07-01 00:50:47 -04:00
},
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),
2023-12-16 11:50:46 -05:00
subtitle: 'Transcode videos for wider compatibility with browsers and devices',
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,
component: StorageMigrationDescription,
},
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),
2023-09-25 17:07:21 +02:00
subtitle: 'Migrate thumbnails for assets and faces to the latest folder structure',
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 >
2024-01-18 00:08:48 -05:00
{ #if confirmJob }
2023-07-01 00:50:47 -04:00
< ConfirmDialogue
prompt="Are you sure you want to reprocess all faces? This will also clear named people."
2024-03-07 04:18:53 +01:00
{ onConfirm }
onClose={() => ( confirmJob = null )}
2023-07-01 00:50:47 -04:00
/>
2023-05-20 21:40:53 -04:00
{ /if }
2023-01-26 22:50:22 -06:00
< div class = "flex flex-col gap-7" >
2023-08-18 00:55:26 -04:00
{ #each jobList as [ jobName , { title , subtitle , disabled , allText , missingText , allowForceCommand , icon , component , 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 }
allText={ allText || 'ALL' }
missingText={ missingText || 'MISSING' }
{ allowForceCommand }
{ jobCounts }
{ queueStatus }
on:command={({ detail }) => ( handleCommandOverride || handleCommand )( jobName , detail )}
>
{ #if component }
< svelte:component this = { component } slot="description" />
{ /if }
< / JobTile >
{ /each }
2022-10-06 11:25:54 -05:00
< / div >