mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-29 17:58:27 +00:00
web/ProcessingQueue: use new types and states, refactor
- added a dedicated ui debug button - fixed scrolling (content is no longer cutting off weirdly) - moved stub to its own component - moved all permanent strings to localization
This commit is contained in:
parent
13ec4f4faf
commit
a8bb64ffb1
|
@ -16,5 +16,6 @@
|
||||||
"save": "save",
|
"save": "save",
|
||||||
"export": "export",
|
"export": "export",
|
||||||
"yes": "yes",
|
"yes": "yes",
|
||||||
"no": "no"
|
"no": "no",
|
||||||
|
"clear": "clear"
|
||||||
}
|
}
|
||||||
|
|
6
web/i18n/en/queue.json
Normal file
6
web/i18n/en/queue.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"title": "processing queue",
|
||||||
|
"stub": "nothing in the queue yet, only two of us.\ntry {{ value }} something!",
|
||||||
|
"stub.download": "downloading",
|
||||||
|
"stub.remux": "remuxing"
|
||||||
|
}
|
|
@ -1,14 +1,15 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { t } from "$lib/i18n/translations";
|
||||||
import { onNavigate } from "$app/navigation";
|
import { onNavigate } from "$app/navigation";
|
||||||
import type { SvelteComponent } from "svelte";
|
import type { SvelteComponent } from "svelte";
|
||||||
import type { QueueItem } from "$lib/types/queue";
|
|
||||||
|
|
||||||
import Meowbalt from "$components/misc/Meowbalt.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";
|
||||||
import ProcessingQueueItem from "$components/queue/ProcessingQueueItem.svelte";
|
import ProcessingQueueItem from "$components/queue/ProcessingQueueItem.svelte";
|
||||||
|
import ProcessingQueueStub from "$components/queue/ProcessingQueueStub.svelte";
|
||||||
|
|
||||||
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
||||||
|
import IconPlus from "@tabler/icons-svelte/IconPlus.svelte";
|
||||||
|
|
||||||
import IconGif from "@tabler/icons-svelte/IconGif.svelte";
|
import IconGif from "@tabler/icons-svelte/IconGif.svelte";
|
||||||
import IconMovie from "@tabler/icons-svelte/IconMovie.svelte";
|
import IconMovie from "@tabler/icons-svelte/IconMovie.svelte";
|
||||||
|
@ -16,64 +17,45 @@
|
||||||
import IconPhoto from "@tabler/icons-svelte/IconPhoto.svelte";
|
import IconPhoto from "@tabler/icons-svelte/IconPhoto.svelte";
|
||||||
import IconVolume3 from "@tabler/icons-svelte/IconVolume3.svelte";
|
import IconVolume3 from "@tabler/icons-svelte/IconVolume3.svelte";
|
||||||
|
|
||||||
|
import settings from "$lib/state/settings";
|
||||||
|
import { addToQueue, queue } from "$lib/state/queue";
|
||||||
|
import type { QueueItem } from "$lib/types/queue";
|
||||||
|
|
||||||
let popover: SvelteComponent;
|
let popover: SvelteComponent;
|
||||||
$: expanded = false;
|
$: expanded = false;
|
||||||
|
|
||||||
$: progress = 0;
|
$: queueItems = Object.entries($queue) as [id: string, item: QueueItem][];
|
||||||
|
|
||||||
|
$: queueLength = Object.keys($queue).length;
|
||||||
$: indeterminate = false;
|
$: indeterminate = false;
|
||||||
|
|
||||||
const itemIcons = {
|
const itemIcons = {
|
||||||
video: IconMovie,
|
video: IconMovie,
|
||||||
|
video_mute: IconVolume3,
|
||||||
audio: IconMusic,
|
audio: IconMusic,
|
||||||
mute: IconVolume3,
|
audio_convert: IconMusic,
|
||||||
image: IconPhoto,
|
image: IconPhoto,
|
||||||
gif: IconGif,
|
gif: IconGif,
|
||||||
};
|
};
|
||||||
|
|
||||||
// dummy data for testing ui rn
|
const addFakeQueueItem = () => {
|
||||||
const processingQueue: QueueItem[] = [
|
return addToQueue({
|
||||||
{
|
id: crypto.randomUUID(),
|
||||||
id: "fake id",
|
status: "waiting",
|
||||||
type: "video",
|
type: "video",
|
||||||
filename: "placeholder.mp4",
|
filename: "test.mp4",
|
||||||
status: "processing: 69%",
|
files: [
|
||||||
progress: 69,
|
{
|
||||||
},
|
type: "video",
|
||||||
{
|
url: "https://",
|
||||||
id: "fake id",
|
},
|
||||||
type: "audio",
|
],
|
||||||
filename: "placeholder.mp3",
|
processingSteps: [],
|
||||||
status: "processing: 3%",
|
});
|
||||||
progress: 3,
|
};
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "fake id",
|
|
||||||
type: "mute",
|
|
||||||
filename: "placeholder.mp4",
|
|
||||||
status: "processing: 55%",
|
|
||||||
progress: 55,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "fake id",
|
|
||||||
type: "image",
|
|
||||||
filename: "placeholder.jpg",
|
|
||||||
status: "processing: 21%",
|
|
||||||
progress: 22,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "fake id",
|
|
||||||
type: "gif",
|
|
||||||
filename: "placeholder.gif",
|
|
||||||
status: "processing: 82%",
|
|
||||||
progress: 82,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const popoverAction = async () => {
|
const popoverAction = async () => {
|
||||||
expanded = !expanded;
|
expanded = !expanded;
|
||||||
if (expanded) {
|
|
||||||
popover.focus();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onNavigate(() => {
|
onNavigate(() => {
|
||||||
|
@ -82,11 +64,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="processing-manager">
|
<div id="processing-manager">
|
||||||
<ProcessingStatus
|
<ProcessingStatus {indeterminate} expandAction={popover?.showPopover} />
|
||||||
{indeterminate}
|
|
||||||
{progress}
|
|
||||||
expandAction={popover?.showPopover}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<PopoverContainer
|
<PopoverContainer
|
||||||
bind:this={popover}
|
bind:this={popover}
|
||||||
|
@ -96,28 +74,34 @@
|
||||||
expandStart="right"
|
expandStart="right"
|
||||||
>
|
>
|
||||||
<div id="processing-header">
|
<div id="processing-header">
|
||||||
<div class="header-title">processing queue</div>
|
<div class="header-title">{$t("queue.title")}</div>
|
||||||
{#if processingQueue.length > 0}
|
<div class="header-buttons">
|
||||||
<button class="clear-button">
|
{#if queueLength > 0}
|
||||||
<IconX />
|
<button class="clear-button">
|
||||||
clear
|
<IconX />
|
||||||
</button>
|
{$t("button.clear")}
|
||||||
{/if}
|
</button>
|
||||||
|
{/if}
|
||||||
|
<!-- button for ui debug -->
|
||||||
|
{#if $settings.advanced.debug}
|
||||||
|
<button class="test-button" on:click={addFakeQueueItem}>
|
||||||
|
<IconPlus />
|
||||||
|
add item
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="processing-list">
|
<div id="processing-list">
|
||||||
{#each processingQueue as item}
|
{#each queueItems as [id, item]}
|
||||||
<ProcessingQueueItem
|
<ProcessingQueueItem
|
||||||
|
{id}
|
||||||
filename={item.filename}
|
filename={item.filename}
|
||||||
status={item.status}
|
status={item.status}
|
||||||
progress={item.progress}
|
|
||||||
icon={itemIcons[item.type]}
|
icon={itemIcons[item.type]}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
{#if processingQueue.length === 0}
|
{#if queueLength === 0}
|
||||||
<div class="list-stub">
|
<ProcessingQueueStub />
|
||||||
<Meowbalt emotion="think" />
|
|
||||||
<span>downloads will appear here!</span>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</PopoverContainer>
|
</PopoverContainer>
|
||||||
|
@ -137,9 +121,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#processing-manager :global(#processing-popover) {
|
#processing-manager :global(#processing-popover) {
|
||||||
padding: 16px;
|
|
||||||
max-width: 425px;
|
max-width: 425px;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#processing-header {
|
#processing-header {
|
||||||
|
@ -153,21 +138,30 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-button {
|
.header-buttons {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: var(--padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-buttons button {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--red);
|
|
||||||
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: none;
|
background: none;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clear-button :global(svg) {
|
.header-buttons button :global(svg) {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clear-button {
|
||||||
|
color: var(--red);
|
||||||
|
}
|
||||||
|
|
||||||
#processing-list {
|
#processing-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -176,23 +170,6 @@
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-stub {
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--gray);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 25px;
|
|
||||||
text-align: center;
|
|
||||||
gap: var(--padding);
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-stub :global(.meowbalt) {
|
|
||||||
height: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 535px) {
|
@media screen and (max-width: 535px) {
|
||||||
#processing-manager {
|
#processing-manager {
|
||||||
top: calc(env(safe-area-inset-top) - var(--padding) + 4px);
|
top: calc(env(safe-area-inset-top) - var(--padding) + 4px);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
||||||
import IconDownload from "@tabler/icons-svelte/IconDownload.svelte";
|
import IconDownload from "@tabler/icons-svelte/IconDownload.svelte";
|
||||||
|
import { removeFromQueue } from "$lib/state/queue";
|
||||||
|
|
||||||
|
export let id: string;
|
||||||
export let filename: string;
|
export let filename: string;
|
||||||
export let status: string;
|
export let status: string;
|
||||||
export let progress: number = 0;
|
export let progress: number = 0;
|
||||||
|
@ -24,13 +26,16 @@
|
||||||
style="width: {Math.min(100, progress)}%"
|
style="width: {Math.min(100, progress)}%"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="file-status">{status}</div>
|
<div class="file-status">{id}: {status}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="file-actions">
|
<div class="file-actions">
|
||||||
<button class="action-button">
|
<button class="action-button">
|
||||||
<IconDownload />
|
<IconDownload />
|
||||||
</button>
|
</button>
|
||||||
<button class="action-button">
|
<button
|
||||||
|
class="action-button"
|
||||||
|
on:click={() => removeFromQueue(id)}
|
||||||
|
>
|
||||||
<IconX />
|
<IconX />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -145,7 +150,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.processing-item:last-child {
|
.processing-item:last-child {
|
||||||
padding-bottom: 0;
|
padding-bottom: 16px;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
44
web/src/components/queue/ProcessingQueueStub.svelte
Normal file
44
web/src/components/queue/ProcessingQueueStub.svelte
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { t } from "$lib/i18n/translations";
|
||||||
|
import Meowbalt from "$components/misc/Meowbalt.svelte";
|
||||||
|
|
||||||
|
const stubActions = ["download", "remux"];
|
||||||
|
|
||||||
|
const randomAction = () => {
|
||||||
|
return stubActions[Math.floor(Math.random() * stubActions.length)];
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="queue-stub">
|
||||||
|
<Meowbalt emotion="think" />
|
||||||
|
<span class="subtext stub-text">
|
||||||
|
{$t("queue.stub", {
|
||||||
|
value: $t(`queue.stub.${randomAction()}`),
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.queue-stub {
|
||||||
|
--base-padding: calc(var(--padding) * 1.5);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--gray);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: var(--base-padding);
|
||||||
|
padding-bottom: calc(var(--base-padding) + 16px);
|
||||||
|
text-align: center;
|
||||||
|
gap: var(--padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
.queue-stub :global(.meowbalt) {
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stub-text {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in a new issue