mirror of
https://github.com/wukko/cobalt.git
synced 2025-04-30 14:34:27 +02:00
web/ProcessingQueue: open the queue popover when new item is added
This commit is contained in:
parent
714e71751e
commit
1137ccfd3b
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
import { formatFileSize } from "$lib/util";
|
import { formatFileSize } from "$lib/util";
|
||||||
import { clearFileStorage, getStorageQuota } from "$lib/storage";
|
import { clearFileStorage, getStorageQuota } from "$lib/storage";
|
||||||
|
|
||||||
|
import { queueVisible } from "$lib/state/queue-visibility";
|
||||||
import { currentTasks } from "$lib/state/queen-bee/current-tasks";
|
import { currentTasks } from "$lib/state/queen-bee/current-tasks";
|
||||||
import { clearQueue, queue as readableQueue } from "$lib/state/queen-bee/queue";
|
import { clearQueue, queue as readableQueue } from "$lib/state/queen-bee/queue";
|
||||||
|
|
||||||
@ -17,10 +19,6 @@
|
|||||||
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
import IconX from "@tabler/icons-svelte/IconX.svelte";
|
||||||
|
|
||||||
let popover: SvelteComponent;
|
let popover: SvelteComponent;
|
||||||
$: expanded = false;
|
|
||||||
|
|
||||||
$: queue = Object.entries($readableQueue);
|
|
||||||
|
|
||||||
let quotaUsage = 0;
|
let quotaUsage = 0;
|
||||||
|
|
||||||
const updateQuota = async () => {
|
const updateQuota = async () => {
|
||||||
@ -28,10 +26,16 @@
|
|||||||
quotaUsage = storageInfo?.usage || 0;
|
quotaUsage = storageInfo?.usage || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const popoverAction = () => {
|
||||||
|
$queueVisible = !$queueVisible;
|
||||||
|
};
|
||||||
|
|
||||||
const totalItemProgress = (completed: number, current: number, total: number) => {
|
const totalItemProgress = (completed: number, current: number, total: number) => {
|
||||||
return (completed * 100 + current) / total
|
return (completed * 100 + current) / total
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: queue = Object.entries($readableQueue);
|
||||||
|
|
||||||
$: totalProgress = queue.length ? queue.map(([, item]) => {
|
$: totalProgress = queue.length ? queue.map(([, item]) => {
|
||||||
if (item.state === "done" || item.state === "error") {
|
if (item.state === "done" || item.state === "error") {
|
||||||
return 100;
|
return 100;
|
||||||
@ -47,16 +51,12 @@
|
|||||||
|
|
||||||
$: indeterminate = queue.length > 0 && totalProgress === 0;
|
$: indeterminate = queue.length > 0 && totalProgress === 0;
|
||||||
|
|
||||||
const popoverAction = () => {
|
$: if ($queueVisible) {
|
||||||
expanded = !expanded;
|
|
||||||
};
|
|
||||||
|
|
||||||
$: if (expanded) {
|
|
||||||
updateQuota();
|
updateQuota();
|
||||||
}
|
}
|
||||||
|
|
||||||
onNavigate(() => {
|
onNavigate(() => {
|
||||||
expanded = false;
|
$queueVisible = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@ -65,7 +65,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="processing-queue" class:expanded>
|
<div id="processing-queue" class:expanded={$queueVisible}>
|
||||||
<ProcessingStatus
|
<ProcessingStatus
|
||||||
progress={totalProgress * 100}
|
progress={totalProgress * 100}
|
||||||
{indeterminate}
|
{indeterminate}
|
||||||
@ -75,7 +75,7 @@
|
|||||||
<PopoverContainer
|
<PopoverContainer
|
||||||
bind:this={popover}
|
bind:this={popover}
|
||||||
id="processing-popover"
|
id="processing-popover"
|
||||||
{expanded}
|
expanded={$queueVisible}
|
||||||
expandStart="right"
|
expandStart="right"
|
||||||
>
|
>
|
||||||
<div id="processing-header">
|
<div id="processing-header">
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import mime from "mime";
|
import mime from "mime";
|
||||||
|
|
||||||
import { addItem } from "$lib/state/queen-bee/queue";
|
import { addItem } from "$lib/state/queen-bee/queue";
|
||||||
|
import { showQueuePopover } from "$lib/state/queue-visibility";
|
||||||
|
|
||||||
import type { CobaltPipelineItem } from "$lib/types/workers";
|
import type { CobaltPipelineItem } from "$lib/types/workers";
|
||||||
import type { CobaltLocalProcessingResponse, CobaltSaveRequestBody } from "$lib/types/api";
|
import type { CobaltLocalProcessingResponse, CobaltSaveRequestBody } from "$lib/types/api";
|
||||||
|
|
||||||
@ -46,7 +48,9 @@ export const createRemuxPipeline = (file: File) => {
|
|||||||
filename: file.name,
|
filename: file.name,
|
||||||
mimeType: file.type,
|
mimeType: file.type,
|
||||||
mediaType,
|
mediaType,
|
||||||
})
|
});
|
||||||
|
|
||||||
|
showQueuePopover();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +69,7 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse, request:
|
|||||||
workerArgs: {
|
workerArgs: {
|
||||||
url: tunnel,
|
url: tunnel,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline.push({
|
pipeline.push({
|
||||||
@ -83,7 +87,7 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse, request:
|
|||||||
format: info.filename.split(".").pop(),
|
format: info.filename.split(".").pop(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
addItem({
|
addItem({
|
||||||
id: parentId,
|
id: parentId,
|
||||||
@ -94,5 +98,7 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse, request:
|
|||||||
filename: info.filename,
|
filename: info.filename,
|
||||||
mimeType: mime.getType(info.filename) || undefined,
|
mimeType: mime.getType(info.filename) || undefined,
|
||||||
mediaType: "video",
|
mediaType: "video",
|
||||||
})
|
});
|
||||||
|
|
||||||
|
showQueuePopover();
|
||||||
}
|
}
|
||||||
|
10
web/src/lib/state/queue-visibility.ts
Normal file
10
web/src/lib/state/queue-visibility.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { get, writable } from "svelte/store";
|
||||||
|
|
||||||
|
export const queueVisible = writable(false);
|
||||||
|
|
||||||
|
export const showQueuePopover = () => {
|
||||||
|
const visible = get(queueVisible);
|
||||||
|
if (!visible) {
|
||||||
|
return queueVisible.update(v => !v);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user