2022-10-06 11:25:54 -05:00
|
|
|
<script lang="ts">
|
2023-01-26 22:50:22 -06:00
|
|
|
import SelectionSearch from 'svelte-material-icons/SelectionSearch.svelte';
|
|
|
|
|
import Play from 'svelte-material-icons/Play.svelte';
|
2023-04-01 06:53:20 +02:00
|
|
|
import Pause from 'svelte-material-icons/Pause.svelte';
|
|
|
|
|
import FastForward from 'svelte-material-icons/FastForward.svelte';
|
2023-01-26 22:50:22 -06:00
|
|
|
import AllInclusive from 'svelte-material-icons/AllInclusive.svelte';
|
2023-02-22 18:53:08 +01:00
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
2022-10-06 11:25:54 -05:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
2023-04-01 06:53:20 +02:00
|
|
|
import { JobCommand, JobCommandDto, JobCountsDto } from '@api';
|
|
|
|
|
import Badge from '$lib/components/elements/badge.svelte';
|
2022-10-06 11:25:54 -05:00
|
|
|
|
|
|
|
|
export let title: string;
|
2023-04-01 06:53:20 +02:00
|
|
|
export let subtitle: string | undefined = undefined;
|
2023-03-20 11:55:28 -04:00
|
|
|
export let jobCounts: JobCountsDto;
|
2023-04-01 06:53:20 +02:00
|
|
|
export let allowForceCommand = true;
|
2023-01-26 22:50:22 -06:00
|
|
|
|
|
|
|
|
$: isRunning = jobCounts.active > 0 || jobCounts.waiting > 0;
|
2023-04-01 06:53:20 +02:00
|
|
|
$: waitingCount = jobCounts.waiting + jobCounts.paused;
|
|
|
|
|
$: isPause = jobCounts.paused > 0;
|
2023-01-09 22:35:37 +02:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
const dispatch = createEventDispatcher<{ command: JobCommandDto }>();
|
2022-10-06 11:25:54 -05:00
|
|
|
</script>
|
|
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
<div
|
|
|
|
|
class="flex justify-between rounded-3xl bg-gray-100 dark:bg-immich-dark-gray transition-all
|
|
|
|
|
{isRunning ? 'dark:bg-immich-primary/30 bg-immich-primary/20' : ''}
|
|
|
|
|
{isPause ? 'dark:bg-yellow-100/30 bg-yellow-500/20' : ''}"
|
|
|
|
|
>
|
|
|
|
|
<div id="job-info" class="w-full p-9">
|
|
|
|
|
<div class="flex flex-col gap-2 ">
|
|
|
|
|
<div
|
|
|
|
|
class="flex items-center gap-4 text-xl font-semibold text-immich-primary dark:text-immich-dark-primary"
|
|
|
|
|
>
|
|
|
|
|
<span>{title.toUpperCase()}</span>
|
|
|
|
|
<div class="flex gap-2">
|
|
|
|
|
{#if jobCounts.failed > 0}
|
|
|
|
|
<Badge color="danger">
|
|
|
|
|
{jobCounts.failed.toLocaleString($locale)} failed
|
|
|
|
|
</Badge>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
2023-01-26 22:50:22 -06:00
|
|
|
</div>
|
|
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
{#if subtitle}
|
|
|
|
|
<div class="text-sm dark:text-white whitespace-pre-line">{subtitle}</div>
|
2023-01-26 22:50:22 -06:00
|
|
|
{/if}
|
2023-04-01 06:53:20 +02:00
|
|
|
<div class="text-sm dark:text-white">
|
|
|
|
|
<slot />
|
|
|
|
|
</div>
|
2023-01-26 22:50:22 -06:00
|
|
|
|
2023-04-01 06:53:20 +02:00
|
|
|
<div class="flex w-full max-w-md mt-2">
|
2023-01-26 22:50:22 -06:00
|
|
|
<div
|
|
|
|
|
class="flex place-items-center justify-between bg-immich-primary dark:bg-immich-dark-primary text-white dark:text-immich-dark-gray w-full rounded-tl-lg rounded-bl-lg py-4 pl-4 pr-6"
|
|
|
|
|
>
|
|
|
|
|
<p>Active</p>
|
|
|
|
|
<p class="text-2xl">
|
2023-04-01 06:53:20 +02:00
|
|
|
{jobCounts.active.toLocaleString($locale)}
|
2023-01-26 22:50:22 -06:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="flex place-items-center justify-between bg-gray-200 text-immich-dark-bg dark:bg-gray-700 dark:text-immich-gray w-full rounded-tr-lg rounded-br-lg py-4 pr-4 pl-6"
|
|
|
|
|
>
|
|
|
|
|
<p class="text-2xl">
|
2023-04-01 06:53:20 +02:00
|
|
|
{waitingCount.toLocaleString($locale)}
|
2023-01-26 22:50:22 -06:00
|
|
|
</p>
|
|
|
|
|
<p>Waiting</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-10-06 11:25:54 -05:00
|
|
|
</div>
|
2023-04-01 06:53:20 +02:00
|
|
|
<div id="job-action" class="flex flex-col rounded-r-3xl w-32 overflow-hidden">
|
2023-01-26 22:50:22 -06:00
|
|
|
{#if isRunning}
|
|
|
|
|
<button
|
2023-04-01 06:53:20 +02:00
|
|
|
class="job-play-button bg-gray-300/90 dark:bg-gray-600/90"
|
|
|
|
|
on:click={() => dispatch('command', { command: JobCommand.Pause, force: false })}
|
2023-01-26 22:50:22 -06:00
|
|
|
>
|
2023-04-01 06:53:20 +02:00
|
|
|
<Pause size="48" /> PAUSE
|
|
|
|
|
</button>
|
|
|
|
|
{:else if jobCounts.paused > 0}
|
|
|
|
|
<button
|
|
|
|
|
class="job-play-button bg-gray-300 dark:bg-gray-600/90"
|
|
|
|
|
on:click={() => dispatch('command', { command: JobCommand.Resume, force: false })}
|
|
|
|
|
>
|
|
|
|
|
<span class=" {isPause ? 'animate-pulse' : ''}">
|
|
|
|
|
<FastForward size="48" /> RESUME
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
{:else if allowForceCommand}
|
|
|
|
|
<button
|
|
|
|
|
class="job-play-button bg-gray-300 dark:bg-gray-600"
|
|
|
|
|
on:click={() => dispatch('command', { command: JobCommand.Start, force: true })}
|
|
|
|
|
>
|
|
|
|
|
<AllInclusive size="18" /> ALL
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
class="job-play-button bg-gray-300/90 dark:bg-gray-600/90"
|
|
|
|
|
on:click={() => dispatch('command', { command: JobCommand.Start, force: false })}
|
|
|
|
|
>
|
|
|
|
|
<SelectionSearch size="18" /> MISSING
|
|
|
|
|
</button>
|
|
|
|
|
{:else}
|
|
|
|
|
<button
|
|
|
|
|
class="job-play-button bg-gray-300/90 dark:bg-gray-600/90"
|
|
|
|
|
on:click={() => dispatch('command', { command: JobCommand.Start, force: false })}
|
|
|
|
|
>
|
|
|
|
|
<Play size="48" /> START
|
2023-01-26 22:50:22 -06:00
|
|
|
</button>
|
|
|
|
|
{/if}
|
2022-10-06 11:25:54 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|