mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 09:28:29 +00:00
web/queue: refactor media icon selection
This commit is contained in:
parent
2c0a1b6990
commit
a998a5720c
@ -21,11 +21,13 @@
|
|||||||
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 IconExclamationCircle from "@tabler/icons-svelte/IconExclamationCircle.svelte";
|
||||||
|
|
||||||
|
import IconFile from "@tabler/icons-svelte/IconFile.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";
|
||||||
import IconPhoto from "@tabler/icons-svelte/IconPhoto.svelte";
|
import IconPhoto from "@tabler/icons-svelte/IconPhoto.svelte";
|
||||||
|
|
||||||
const itemIcons = {
|
const itemIcons = {
|
||||||
|
file: IconFile,
|
||||||
video: IconMovie,
|
video: IconMovie,
|
||||||
audio: IconMusic,
|
audio: IconMusic,
|
||||||
image: IconPhoto,
|
image: IconPhoto,
|
||||||
|
@ -8,14 +8,13 @@ import { uuid } from "$lib/util";
|
|||||||
|
|
||||||
import type { CobaltQueueItem } from "$lib/types/queue";
|
import type { CobaltQueueItem } from "$lib/types/queue";
|
||||||
import type { CobaltCurrentTasks } from "$lib/types/task-manager";
|
import type { CobaltCurrentTasks } from "$lib/types/task-manager";
|
||||||
import type { CobaltPipelineItem, CobaltPipelineResultFileType } from "$lib/types/workers";
|
import { resultFileTypes, type CobaltPipelineItem, type CobaltPipelineResultFileType } from "$lib/types/workers";
|
||||||
import type { CobaltLocalProcessingResponse, CobaltSaveRequestBody } from "$lib/types/api";
|
import type { CobaltLocalProcessingResponse, CobaltSaveRequestBody } from "$lib/types/api";
|
||||||
|
|
||||||
export const getMediaType = (type: string) => {
|
export const getMediaType = (type: string) => {
|
||||||
const kind = type.split('/')[0];
|
const kind = type.split('/')[0] as CobaltPipelineResultFileType;
|
||||||
|
|
||||||
// can't use .includes() here for some reason
|
if (resultFileTypes.includes(kind)) {
|
||||||
if (kind === "video" || kind === "audio" || kind === "image") {
|
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,14 +54,6 @@ export const createRemuxPipeline = (file: File) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mediaIcons: { [key: string]: CobaltPipelineResultFileType } = {
|
|
||||||
merge: "video",
|
|
||||||
mute: "video",
|
|
||||||
audio: "audio",
|
|
||||||
gif: "image",
|
|
||||||
remux: "video"
|
|
||||||
}
|
|
||||||
|
|
||||||
const makeRemuxArgs = (info: CobaltLocalProcessingResponse) => {
|
const makeRemuxArgs = (info: CobaltLocalProcessingResponse) => {
|
||||||
const ffargs = ["-c:v", "copy"];
|
const ffargs = ["-c:v", "copy"];
|
||||||
|
|
||||||
@ -211,7 +202,7 @@ export const createSavePipeline = (
|
|||||||
originalRequest: request,
|
originalRequest: request,
|
||||||
filename: info.output.filename,
|
filename: info.output.filename,
|
||||||
mimeType: info.output.type,
|
mimeType: info.output.type,
|
||||||
mediaType: mediaIcons[info.type],
|
mediaType: getMediaType(info.output.type) || "file",
|
||||||
});
|
});
|
||||||
|
|
||||||
openQueuePopover();
|
openQueuePopover();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { FileInfo } from "$lib/types/libav";
|
import type { FileInfo } from "$lib/types/libav";
|
||||||
import type { UUID } from "./queue";
|
import type { UUID } from "./queue";
|
||||||
|
|
||||||
export const resultFileTypes = ["video", "audio", "image"] as const;
|
export const resultFileTypes = ["video", "audio", "image", "file"] as const;
|
||||||
|
|
||||||
export type CobaltPipelineResultFileType = typeof resultFileTypes[number];
|
export type CobaltPipelineResultFileType = typeof resultFileTypes[number];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user