From e5ff309d83268a499356b4b51929b2c9b250c2d7 Mon Sep 17 00:00:00 2001 From: Maya Date: Sat, 18 Oct 2025 20:57:52 +0300 Subject: [PATCH] feat: view info submitted for transparency, see the exact details that is sent automatically to the owner of the instance: - job id - convert from - convert to - ffmpeg stderr - actual video file (if submitted) --- messages/en.json | 7 +++ src/lib/components/functional/Dialog.svelte | 25 ++++---- .../components/functional/VertdError.svelte | 54 +++++++++++++--- .../functional/VertdErrorDetails.svelte | 52 +++++++++++++++ src/lib/components/layout/Dialogs.svelte | 4 +- src/lib/converters/vertd.svelte.ts | 3 + src/lib/store/DialogProvider.ts | 63 ++++++++++++++----- 7 files changed, 170 insertions(+), 38 deletions(-) create mode 100644 src/lib/components/functional/VertdErrorDetails.svelte diff --git a/messages/en.json b/messages/en.json index 08263c2..d873daa 100644 --- a/messages/en.json +++ b/messages/en.json @@ -85,6 +85,13 @@ "vertd_generic_yes": "Submit video", "vertd_generic_no": "Don't submit", "vertd_failed_to_keep": "Failed to keep the video on the server: {error}", + "vertd_details": "View error details", + "vertd_details_body": "If you submit your file, your video will also be attached alongside the error log being sent to us for review. The following information is the log that we automatically receive:", + "vertd_details_job_id": "Job ID: {jobId}", + "vertd_details_from": "From format: {from}", + "vertd_details_to": "To format: {to}", + "vertd_details_error_message": "Error message: [view_link]View error logs[/view_link]", + "vertd_details_close": "Close", "unsupported_format": "Only image, video, audio, and document files are supported", "vertd_not_found": "Could not find the vertd instance to start video conversion. Are you sure the instance URL is set correctly?", "worker_downloading": "The {type} converter is currently being initialized, please wait a few moments.", diff --git a/src/lib/components/functional/Dialog.svelte b/src/lib/components/functional/Dialog.svelte index a093108..1bd5f97 100644 --- a/src/lib/components/functional/Dialog.svelte +++ b/src/lib/components/functional/Dialog.svelte @@ -3,19 +3,13 @@ import { removeDialog } from "$lib/store/DialogProvider"; import { BanIcon, CheckIcon, InfoIcon, TriangleAlert } from "lucide-svelte"; import { quintOut } from "svelte/easing"; + import type { Dialog as DialogType } from "$lib/store/DialogProvider"; - type Props = { - id: number; - title: string; - message: string; - buttons: { - text: string; - action: () => void; - }[]; - type: "success" | "error" | "info" | "warning"; - }; + type Props = DialogType; - let { id, title, message, buttons, type }: Props = $props(); + let props: Props = $props(); + const { id, title, message, buttons, type } = props; + const additional = "additional" in props ? props.additional : undefined; const colors = { success: "purple", @@ -59,7 +53,14 @@
-

{message}

+ {#if typeof message === "string"} +

{message}

+ {:else} + {@const MessageComponent = message} +
+ +
+ {/if}
{#each buttons as { text, action }, i} diff --git a/src/lib/components/functional/VertdError.svelte b/src/lib/components/functional/VertdError.svelte index 827e09d..091bcaa 100644 --- a/src/lib/components/functional/VertdError.svelte +++ b/src/lib/components/functional/VertdError.svelte @@ -2,6 +2,10 @@ export interface VertdErrorProps { jobId: string; auth: string; + from?: string; + to?: string; + errorMessage?: string; + fileName?: string; } @@ -10,6 +14,8 @@ import { m } from "$lib/paraglide/messages"; import { ToastManager, type ToastProps } from "$lib/toast/index.svelte"; + import { addDialog } from "$lib/store/DialogProvider"; + import VertdErrorDetails from "./VertdErrorDetails.svelte"; const toast: ToastProps = $props(); @@ -52,22 +58,50 @@ ToastManager.remove(toast.id); }; + + const showDetails = () => { + addDialog( + m["convert.errors.vertd_details"](), + VertdErrorDetails as any, + [ + { + text: "Close", + action: () => {}, + }, + ], + "info", + { + jobId: toast.additional.jobId || "Unknown", + from: toast.additional.from || "Unknown", + to: toast.additional.to || "Unknown", + errorMessage: toast.additional.errorMessage || "Unknown error", + }, + ); + };

{m["convert.errors.vertd_generic_body"]()}

-
+
- View Details Submitted +
+ + +
diff --git a/src/lib/components/functional/VertdErrorDetails.svelte b/src/lib/components/functional/VertdErrorDetails.svelte new file mode 100644 index 0000000..140b09d --- /dev/null +++ b/src/lib/components/functional/VertdErrorDetails.svelte @@ -0,0 +1,52 @@ + + +
+

{@html m["convert.errors.vertd_details_body"]()}

+

+ + {@html m["convert.errors.vertd_details_job_id"]({ + jobId: additional.jobId, + })} + +

+

+ + {@html m["convert.errors.vertd_details_from"]({ from: additional.from })} + +

+

+ + {@html m["convert.errors.vertd_details_to"]({ to: additional.to })} + +

+

+ + {@html link( + ["view_link"], + m["convert.errors.vertd_details_error_message"](), + [ + URL.createObjectURL( + new Blob([additional.errorMessage], { type: "text/plain" }) + ) + ], + [true], + ["text-blue-500 font-normal hover:underline"] + )} + +

+
diff --git a/src/lib/components/layout/Dialogs.svelte b/src/lib/components/layout/Dialogs.svelte index d8c4fa2..7914117 100644 --- a/src/lib/components/layout/Dialogs.svelte +++ b/src/lib/components/layout/Dialogs.svelte @@ -26,9 +26,9 @@ easing: quintOut, }} > - {#each dialogList as { id, title, message, buttons, type }, i} + {#each dialogList as dialog, i} {#if i === 0} - + {/if} {/each}
diff --git a/src/lib/converters/vertd.svelte.ts b/src/lib/converters/vertd.svelte.ts index 52dd596..2db5c72 100644 --- a/src/lib/converters/vertd.svelte.ts +++ b/src/lib/converters/vertd.svelte.ts @@ -377,6 +377,9 @@ export class VertdConverter extends Converter { additional: { jobId: uploadRes.id, auth: uploadRes.auth, + from: input.from, + to: to, + errorMessage: msg.data.message, }, }); } diff --git a/src/lib/store/DialogProvider.ts b/src/lib/store/DialogProvider.ts index fa12840..c76ccf8 100644 --- a/src/lib/store/DialogProvider.ts +++ b/src/lib/store/DialogProvider.ts @@ -1,17 +1,39 @@ +import type { Component } from "svelte"; import { writable } from "svelte/store"; type DialogType = "success" | "error" | "info" | "warning"; -export interface Dialog { +type BaseDialog = { id: number; title: string; - message: string; buttons: { text: string; action: () => void; }[]; type: DialogType; -} +}; + +export type StringDialog = BaseDialog & { + message: string; +}; + +export type ComponentDialog = BaseDialog & { + message: Component>; + additional: T; +}; + +export type Dialog = StringDialog | ComponentDialog; + +export type DialogProps = { + id: number; + title: string; + type: DialogType; + buttons: { + text: string; + action: () => void; + }[]; + additional: T; +}; const dialogs = writable([]); @@ -19,20 +41,33 @@ let dialogId = 0; function addDialog( title: string, - message: string, - buttons: Dialog["buttons"], + message: string | Component, + buttons: BaseDialog["buttons"], type: DialogType, -) { + additional?: unknown, +): number { const id = dialogId++; - const newDialog: Dialog = { - id, - title, - message, - buttons, - type, - }; - dialogs.update((currentDialogs) => [...currentDialogs, newDialog]); + if (typeof message === "string") { + const newDialog: StringDialog = { + id, + title, + message, + buttons, + type, + }; + dialogs.update((currentDialogs) => [...currentDialogs, newDialog]); + } else { + const newDialog: ComponentDialog = { + id, + title, + message, + buttons, + type, + additional, + }; + dialogs.update((currentDialogs) => [...currentDialogs, newDialog]); + } return id; }