2022-10-06 11:25:54 -05:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {
|
|
|
|
|
notificationController,
|
|
|
|
|
NotificationType
|
|
|
|
|
} from '$lib/components/shared-components/notification/notification';
|
2023-01-20 11:35:55 -05:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2022-10-06 11:25:54 -05:00
|
|
|
import { AllJobStatusResponseDto, api, JobCommand, JobId } from '@api';
|
|
|
|
|
import { onDestroy, onMount } from 'svelte';
|
|
|
|
|
import JobTile from './job-tile.svelte';
|
|
|
|
|
|
2023-01-21 23:13:36 -05:00
|
|
|
let jobs: AllJobStatusResponseDto;
|
|
|
|
|
let timer: NodeJS.Timer;
|
2022-12-19 12:13:10 -06:00
|
|
|
|
2023-01-21 23:13:36 -05:00
|
|
|
const load = async () => {
|
2022-10-06 11:25:54 -05:00
|
|
|
const { data } = await api.jobApi.getAllJobsStatus();
|
2023-01-21 23:13:36 -05:00
|
|
|
jobs = data;
|
|
|
|
|
};
|
2022-10-06 11:25:54 -05:00
|
|
|
|
2023-01-21 23:13:36 -05:00
|
|
|
onMount(async () => {
|
|
|
|
|
await load();
|
|
|
|
|
timer = setInterval(async () => await load(), 5_000);
|
2022-10-06 11:25:54 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onDestroy(() => {
|
2023-01-21 23:13:36 -05:00
|
|
|
clearInterval(timer);
|
2022-10-06 11:25:54 -05:00
|
|
|
});
|
|
|
|
|
|
2023-01-21 23:13:36 -05:00
|
|
|
const run = async (jobId: JobId, jobName: string, emptyMessage: string) => {
|
2022-10-06 11:25:54 -05:00
|
|
|
try {
|
2023-01-21 23:13:36 -05:00
|
|
|
const { data } = await api.jobApi.sendJobCommand(jobId, { command: JobCommand.Start });
|
2022-10-06 11:25:54 -05:00
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
|
notificationController.show({
|
2023-01-21 23:13:36 -05:00
|
|
|
message: `Started ${jobName}`,
|
2022-10-06 11:25:54 -05:00
|
|
|
type: NotificationType.Info
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2023-01-21 23:13:36 -05:00
|
|
|
notificationController.show({ message: emptyMessage, type: NotificationType.Info });
|
2022-10-06 11:25:54 -05:00
|
|
|
}
|
2023-01-20 11:35:55 -05:00
|
|
|
} catch (error) {
|
2023-01-21 23:13:36 -05:00
|
|
|
handleError(error, `Unable to start ${jobName}`);
|
2022-12-19 12:13:10 -06:00
|
|
|
}
|
|
|
|
|
};
|
2022-10-06 11:25:54 -05:00
|
|
|
</script>
|
|
|
|
|
|
2022-10-25 21:41:46 -05:00
|
|
|
<div class="flex flex-col gap-10">
|
2023-01-21 23:13:36 -05:00
|
|
|
{#if jobs}
|
|
|
|
|
<JobTile
|
|
|
|
|
title={'Generate thumbnails'}
|
|
|
|
|
subtitle={'Regenerate missing thumbnail (JPEG, WEBP)'}
|
|
|
|
|
on:click={() =>
|
|
|
|
|
run(JobId.ThumbnailGeneration, 'thumbnail generation', 'No missing thumbnails found')}
|
|
|
|
|
jobCounts={jobs[JobId.ThumbnailGeneration]}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<JobTile
|
|
|
|
|
title={'Extract EXIF'}
|
|
|
|
|
subtitle={'Extract missing EXIF information'}
|
|
|
|
|
on:click={() => run(JobId.MetadataExtraction, 'extract EXIF', 'No missing EXIF found')}
|
|
|
|
|
jobCounts={jobs[JobId.MetadataExtraction]}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<JobTile
|
|
|
|
|
title={'Detect objects'}
|
|
|
|
|
subtitle={'Run machine learning process to detect and classify objects'}
|
|
|
|
|
on:click={() =>
|
|
|
|
|
run(JobId.MachineLearning, 'object detection', 'No missing object detection found')}
|
|
|
|
|
jobCounts={jobs[JobId.MachineLearning]}
|
|
|
|
|
>
|
|
|
|
|
Note that some assets may not have any objects detected, this is normal.
|
|
|
|
|
</JobTile>
|
|
|
|
|
|
|
|
|
|
<JobTile
|
|
|
|
|
title={'Video transcoding'}
|
|
|
|
|
subtitle={'Run video transcoding process to transcode videos not in the desired format'}
|
|
|
|
|
on:click={() =>
|
|
|
|
|
run(
|
|
|
|
|
JobId.VideoConversion,
|
|
|
|
|
'video conversion',
|
|
|
|
|
'No videos without an encoded version found'
|
|
|
|
|
)}
|
2023-01-21 22:30:50 -06:00
|
|
|
jobCounts={jobs[JobId.VideoConversion]}
|
2023-01-21 23:13:36 -05:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<JobTile
|
|
|
|
|
title={'Storage migration'}
|
|
|
|
|
subtitle={''}
|
|
|
|
|
on:click={() =>
|
|
|
|
|
run(
|
|
|
|
|
JobId.StorageTemplateMigration,
|
|
|
|
|
'storage template migration',
|
|
|
|
|
'All files have been migrated to the new storage template'
|
|
|
|
|
)}
|
|
|
|
|
jobCounts={jobs[JobId.StorageTemplateMigration]}
|
2022-12-19 12:13:10 -06:00
|
|
|
>
|
2023-01-21 23:13:36 -05:00
|
|
|
Apply the current
|
|
|
|
|
<a
|
|
|
|
|
href="/admin/system-settings?open=storage-template"
|
|
|
|
|
class="text-immich-primary dark:text-immich-dark-primary">Storage template</a
|
|
|
|
|
>
|
|
|
|
|
to previously uploaded assets
|
|
|
|
|
</JobTile>
|
|
|
|
|
{/if}
|
2022-10-06 11:25:54 -05:00
|
|
|
</div>
|