mirror of
https://github.com/wukko/cobalt.git
synced 2025-03-23 17:47:10 +01:00
web/ProcessingQueueItem: state icons, localized strings, fix line break
This commit is contained in:
parent
73d2f45dae
commit
c3cc6c09f4
6 changed files with 73 additions and 33 deletions
|
@ -2,5 +2,9 @@
|
||||||
"title": "processing queue",
|
"title": "processing queue",
|
||||||
"stub": "nothing in the queue yet, only two of us.\ntry {{ value }} something!",
|
"stub": "nothing in the queue yet, only two of us.\ntry {{ value }} something!",
|
||||||
"stub.download": "downloading",
|
"stub.download": "downloading",
|
||||||
"stub.remux": "remuxing"
|
"stub.remux": "remuxing",
|
||||||
|
|
||||||
|
"state.waiting": "queued",
|
||||||
|
"state.starting": "starting...",
|
||||||
|
"state.running.remux": "remuxing"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
import { onNavigate } from "$app/navigation";
|
import { onNavigate } from "$app/navigation";
|
||||||
|
import type { SvelteComponent } from "svelte";
|
||||||
|
|
||||||
import { clearQueue, queue } from "$lib/state/queen-bee/queue";
|
import { clearQueue, queue } from "$lib/state/queen-bee/queue";
|
||||||
|
|
||||||
import type { SvelteComponent } from "svelte";
|
|
||||||
import type { CobaltQueueItem } from "$lib/types/queue";
|
|
||||||
|
|
||||||
import SectionHeading from "$components/misc/SectionHeading.svelte";
|
import SectionHeading from "$components/misc/SectionHeading.svelte";
|
||||||
import PopoverContainer from "$components/misc/PopoverContainer.svelte";
|
import PopoverContainer from "$components/misc/PopoverContainer.svelte";
|
||||||
import ProcessingStatus from "$components/queue/ProcessingStatus.svelte";
|
import ProcessingStatus from "$components/queue/ProcessingStatus.svelte";
|
||||||
|
@ -19,15 +17,11 @@
|
||||||
let popover: SvelteComponent;
|
let popover: SvelteComponent;
|
||||||
$: expanded = false;
|
$: expanded = false;
|
||||||
|
|
||||||
$: queueItems = Object.entries($queue) as [
|
$: queueItems = Object.entries($queue);
|
||||||
id: string,
|
|
||||||
item: CobaltQueueItem,
|
|
||||||
][];
|
|
||||||
|
|
||||||
$: queueLength = Object.keys($queue).length;
|
$: queueLength = Object.keys($queue).length;
|
||||||
$: completedQueueItems = queueItems.filter(([id, item]) => {
|
|
||||||
return item.state === "done";
|
$: cleanQueueLength = queueItems.filter(([id, item]) => item.state !== "error").length;
|
||||||
}).length;
|
$: completedQueueItems = queueItems.filter(([id, item]) => item.state === "done").length;
|
||||||
|
|
||||||
// TODO: toggle this only when progress is unknown
|
// TODO: toggle this only when progress is unknown
|
||||||
$: indeterminate = false;
|
$: indeterminate = false;
|
||||||
|
@ -43,7 +37,7 @@
|
||||||
|
|
||||||
<div id="processing-queue" class:expanded>
|
<div id="processing-queue" class:expanded>
|
||||||
<ProcessingStatus
|
<ProcessingStatus
|
||||||
progress={(completedQueueItems / queueLength) * 100}
|
progress={(completedQueueItems / cleanQueueLength) * 100}
|
||||||
{indeterminate}
|
{indeterminate}
|
||||||
expandAction={popover?.showPopover}
|
expandAction={popover?.showPopover}
|
||||||
/>
|
/>
|
||||||
|
@ -140,7 +134,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-button {
|
.clear-button {
|
||||||
color: var(--red);
|
color: var(--medium-red);
|
||||||
}
|
}
|
||||||
|
|
||||||
#processing-list {
|
#processing-list {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { t } from "$lib/i18n/translations";
|
||||||
import { formatFileSize } from "$lib/util";
|
import { formatFileSize } from "$lib/util";
|
||||||
import { downloadFile } from "$lib/download";
|
import { downloadFile } from "$lib/download";
|
||||||
import { removeItem } from "$lib/state/queen-bee/queue";
|
import { removeItem } from "$lib/state/queen-bee/queue";
|
||||||
|
@ -9,7 +10,9 @@
|
||||||
import Skeleton from "$components/misc/Skeleton.svelte";
|
import Skeleton from "$components/misc/Skeleton.svelte";
|
||||||
|
|
||||||
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
||||||
|
import IconCheck from "@tabler/icons-svelte/IconCheck.svelte";
|
||||||
import IconDownload from "@tabler/icons-svelte/IconDownload.svelte";
|
import IconDownload from "@tabler/icons-svelte/IconDownload.svelte";
|
||||||
|
import IconExclamationCircle from "@tabler/icons-svelte/IconExclamationCircle.svelte";
|
||||||
|
|
||||||
import IconMovie from "@tabler/icons-svelte/IconMovie.svelte";
|
import IconMovie from "@tabler/icons-svelte/IconMovie.svelte";
|
||||||
import IconMusic from "@tabler/icons-svelte/IconMusic.svelte";
|
import IconMusic from "@tabler/icons-svelte/IconMusic.svelte";
|
||||||
|
@ -25,8 +28,6 @@
|
||||||
export let info: CobaltQueueItem;
|
export let info: CobaltQueueItem;
|
||||||
export let runningWorker: CobaltCurrentTaskItem | undefined;
|
export let runningWorker: CobaltCurrentTaskItem | undefined;
|
||||||
|
|
||||||
$: state = info.state;
|
|
||||||
|
|
||||||
$: progress = runningWorker?.progress;
|
$: progress = runningWorker?.progress;
|
||||||
$: size = formatFileSize(runningWorker?.progress?.size);
|
$: size = formatFileSize(runningWorker?.progress?.size);
|
||||||
|
|
||||||
|
@ -38,44 +39,63 @@
|
||||||
|
|
||||||
<div class="processing-item">
|
<div class="processing-item">
|
||||||
<div class="processing-info">
|
<div class="processing-info">
|
||||||
|
|
||||||
<div class="file-title">
|
<div class="file-title">
|
||||||
<div class="processing-type">
|
<div class="processing-type">
|
||||||
<svelte:component this={itemIcons[info.mediaType]} />
|
<svelte:component this={itemIcons[info.mediaType]} />
|
||||||
</div>
|
</div>
|
||||||
<span>
|
<span class="filename">
|
||||||
{info.filename}
|
{info.filename}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{#if state === "running"}
|
|
||||||
|
{#if info.state === "running"}
|
||||||
<div class="file-progress">
|
<div class="file-progress">
|
||||||
{#if progress?.percentage}
|
{#if progress?.percentage}
|
||||||
<div
|
<div
|
||||||
class="progress"
|
class="progress"
|
||||||
style="width: {Math.min(100, progress?.percentage || 0)}%"
|
style="width: {Math.min(
|
||||||
|
100,
|
||||||
|
progress?.percentage || 0
|
||||||
|
)}%"
|
||||||
></div>
|
></div>
|
||||||
{:else}
|
{:else}
|
||||||
<Skeleton height="6px" width="100%" class="elevated indeterminate-progress" />
|
<Skeleton
|
||||||
|
height="6px"
|
||||||
|
width="100%"
|
||||||
|
class="elevated indeterminate-progress"
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="file-status">
|
|
||||||
|
<div class="file-status {info.state}">
|
||||||
{#if info.state === "done"}
|
{#if info.state === "done"}
|
||||||
done: {formatFileSize(info.resultFile?.size)}
|
<IconCheck /> {formatFileSize(info.resultFile?.size)}
|
||||||
{:else if info.state === "running"}
|
|
||||||
{#if progress && progress.percentage}
|
|
||||||
processing: {Math.ceil(progress.percentage)}%, {size}
|
|
||||||
{:else if progress && size}
|
|
||||||
processing: {size}
|
|
||||||
{:else}
|
|
||||||
processing...
|
|
||||||
{/if}
|
{/if}
|
||||||
{:else if info.state === "error"}
|
|
||||||
error: {info.errorCode}
|
{#if info.state === "running"}
|
||||||
|
{#if runningWorker && progress && progress.percentage}
|
||||||
|
{$t(`queue.state.running.${runningWorker.type}`)}: {Math.ceil(
|
||||||
|
progress.percentage
|
||||||
|
)}%, {size}
|
||||||
|
{:else if runningWorker && progress && size}
|
||||||
|
{$t(`queue.state.running.${runningWorker.type}`)}: {size}
|
||||||
{:else}
|
{:else}
|
||||||
queued
|
{$t("queue.state.starting")}
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if info.state === "error"}
|
||||||
|
<IconExclamationCircle /> {info.errorCode}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if info.state === "waiting"}
|
||||||
|
{$t("queue.state.waiting")}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="file-actions">
|
<div class="file-actions">
|
||||||
{#if info.state === "done" && info.resultFile}
|
{#if info.state === "done" && info.resultFile}
|
||||||
<button
|
<button
|
||||||
|
@ -154,10 +174,29 @@
|
||||||
line-break: anywhere;
|
line-break: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filename {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: pre;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.file-status {
|
.file-status {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--gray);
|
color: var(--gray);
|
||||||
line-break: anywhere;
|
line-break: anywhere;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-status.error {
|
||||||
|
color: var(--medium-red);
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-status :global(svg) {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
stroke-width: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-actions {
|
.file-actions {
|
||||||
|
|
|
@ -24,6 +24,7 @@ export const checkTasks = () => {
|
||||||
const pipelineItem = task.pipeline[i];
|
const pipelineItem = task.pipeline[i];
|
||||||
|
|
||||||
addWorkerToQueue(pipelineItem.workerId, {
|
addWorkerToQueue(pipelineItem.workerId, {
|
||||||
|
type: pipelineItem.worker,
|
||||||
parentId: task.id,
|
parentId: task.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { CobaltWorkerProgress } from "$lib/types/workers";
|
import type { CobaltWorkerProgress, CobaltWorkerType } from "$lib/types/workers";
|
||||||
|
|
||||||
export type CobaltCurrentTaskItem = {
|
export type CobaltCurrentTaskItem = {
|
||||||
|
type: CobaltWorkerType,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
progress?: CobaltWorkerProgress,
|
progress?: CobaltWorkerProgress,
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
--gray: #75757e;
|
--gray: #75757e;
|
||||||
|
|
||||||
--red: #ed2236;
|
--red: #ed2236;
|
||||||
|
--medium-red: #ce3030;
|
||||||
--dark-red: #d61c2e;
|
--dark-red: #d61c2e;
|
||||||
--green: #51cf5e;
|
--green: #51cf5e;
|
||||||
--blue: #2f8af9;
|
--blue: #2f8af9;
|
||||||
|
|
Loading…
Add table
Reference in a new issue