2022-10-06 11:25:54 -05:00
|
|
|
<script lang="ts">
|
2023-04-01 22:46:07 +02:00
|
|
|
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';
|
2023-04-01 06:53:20 +02:00
|
|
|
import { AllJobStatusResponseDto, api, JobCommand, JobCommandDto, JobName } from '@api';
|
|
|
|
|
import type { ComponentType } from 'svelte';
|
2022-10-06 11:25:54 -05:00
|
|
|
import JobTile from './job-tile.svelte';
|
2023-04-01 06:53:20 +02:00
|
|
|
import StorageMigrationDescription from './storage-migration-description.svelte';
|
2022-10-06 11:25:54 -05:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
export let jobs: AllJobStatusResponseDto;
|
2022-12-19 12:13:10 -06:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
type JobDetails = {
|
|
|
|
|
title: string;
|
|
|
|
|
subtitle?: string;
|
|
|
|
|
allowForceCommand?: boolean;
|
|
|
|
|
component?: ComponentType;
|
2023-01-21 23:13:36 -05:00
|
|
|
};
|
2022-10-06 11:25:54 -05:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
const jobDetails: { [Key in JobName]?: JobDetails } = {
|
|
|
|
|
[JobName.ThumbnailGenerationQueue]: {
|
|
|
|
|
title: 'Generate Thumbnails',
|
|
|
|
|
subtitle: 'Regenerate JPEG and WebP thumbnails'
|
|
|
|
|
},
|
|
|
|
|
[JobName.MetadataExtractionQueue]: {
|
|
|
|
|
title: 'Extract Metadata',
|
|
|
|
|
subtitle: 'Extract metadata information i.e. GPS, resolution...etc'
|
|
|
|
|
},
|
|
|
|
|
[JobName.ObjectTaggingQueue]: {
|
|
|
|
|
title: 'Tag Objects',
|
|
|
|
|
subtitle:
|
|
|
|
|
'Run machine learning to tag objects\nNote that some assets may not have any objects detected'
|
|
|
|
|
},
|
|
|
|
|
[JobName.ClipEncodingQueue]: {
|
|
|
|
|
title: 'Encode Clip',
|
|
|
|
|
subtitle: 'Run machine learning to generate clip embeddings'
|
|
|
|
|
},
|
|
|
|
|
[JobName.VideoConversionQueue]: {
|
|
|
|
|
title: 'Transcode Videos',
|
|
|
|
|
subtitle: 'Transcode videos not in the desired format'
|
|
|
|
|
},
|
|
|
|
|
[JobName.StorageTemplateMigrationQueue]: {
|
|
|
|
|
title: 'Storage Template Migration',
|
|
|
|
|
allowForceCommand: false,
|
|
|
|
|
component: StorageMigrationDescription
|
|
|
|
|
}
|
|
|
|
|
};
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
const jobDetailsArray = Object.entries(jobDetails) as [JobName, JobDetails][];
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
async function runJob(jobId: JobName, jobCommand: JobCommandDto) {
|
|
|
|
|
const title = jobDetails[jobId]?.title;
|
2023-03-20 11:55:28 -04:00
|
|
|
|
2022-10-06 11:25:54 -05:00
|
|
|
try {
|
2023-04-01 22:46:07 +02:00
|
|
|
const { data } = await api.jobApi.sendJobCommand(jobId, jobCommand);
|
|
|
|
|
jobs[jobId] = data;
|
2023-04-01 06:53:20 +02:00
|
|
|
|
|
|
|
|
switch (jobCommand.command) {
|
2023-04-01 22:46:07 +02:00
|
|
|
case JobCommand.Empty:
|
|
|
|
|
notificationController.show({
|
|
|
|
|
message: `Cleared jobs for: ${title}`,
|
|
|
|
|
type: NotificationType.Info
|
|
|
|
|
});
|
2023-04-01 06:53:20 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2023-01-20 11:35:55 -05:00
|
|
|
} catch (error) {
|
2023-04-01 06:53:20 +02:00
|
|
|
handleError(error, `Command '${jobCommand.command}' failed for job: ${title}`);
|
2022-12-19 12:13:10 -06:00
|
|
|
}
|
2023-04-01 06:53:20 +02: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">
|
2023-04-01 06:53:20 +02:00
|
|
|
{#each jobDetailsArray as [jobName, { title, subtitle, allowForceCommand, component }]}
|
2023-04-01 22:46:07 +02:00
|
|
|
{@const { jobCounts, queueStatus } = jobs[jobName]}
|
2023-01-21 23:13:36 -05:00
|
|
|
<JobTile
|
2023-04-01 06:53:20 +02:00
|
|
|
{title}
|
|
|
|
|
{subtitle}
|
|
|
|
|
{allowForceCommand}
|
2023-04-01 22:46:07 +02:00
|
|
|
{jobCounts}
|
|
|
|
|
{queueStatus}
|
2023-04-01 06:53:20 +02:00
|
|
|
on:command={({ detail }) => runJob(jobName, detail)}
|
2022-12-19 12:13:10 -06:00
|
|
|
>
|
2023-04-01 06:53:20 +02:00
|
|
|
<svelte:component this={component} />
|
2023-01-21 23:13:36 -05:00
|
|
|
</JobTile>
|
2023-04-01 06:53:20 +02:00
|
|
|
{/each}
|
2022-10-06 11:25:54 -05:00
|
|
|
</div>
|