From a12424ef667746422b0a13e6808e01e4f1f7b541 Mon Sep 17 00:00:00 2001 From: Wim Brand Date: Tue, 4 Aug 2026 13:37:44 +0200 Subject: [PATCH] Add configurable columns to directory view --- svelte/src/filesystem/DetailsWindow.svelte | 39 +++--- svelte/src/filesystem/ErrorPage.svelte | 6 + svelte/src/filesystem/FSNavigator.ts | 11 +- .../edit_window/ThemePresets.svelte | 8 ++ .../filesystem/filemanager/FileManager.svelte | 15 --- .../filesystem/filemanager/ListView.svelte | 123 ++++++++++++++++-- svelte/src/layout/CopyButton.svelte | 10 +- svelte/src/layout/Dialog.svelte | 14 +- svelte/src/layout/SortButton.svelte | 6 +- svelte/src/lib/FilesystemAPI.svelte.ts | 2 + .../src/user_home/dashboard/Dashboard.svelte | 6 +- 11 files changed, 181 insertions(+), 59 deletions(-) diff --git a/svelte/src/filesystem/DetailsWindow.svelte b/svelte/src/filesystem/DetailsWindow.svelte index 0769ea0..c9d3e25 100644 --- a/svelte/src/filesystem/DetailsWindow.svelte +++ b/svelte/src/filesystem/DetailsWindow.svelte @@ -1,5 +1,4 @@ @@ -172,13 +166,6 @@ run(() => { Mode {$nav.base.mode_string} - - Node ID - - Copy - {$nav.base.id} - - {#if $nav.base.type === "file"} File type @@ -201,7 +188,23 @@ run(() => { SHA256 sum{$nav.base.sha256_sum} + {:else if $nav.base.type === "dir"} + + Total directory size + {formatDataVolume($nav.base.recursive_size, 4)} + + + Total directory children + {formatThousands($nav.base.recursive_children)} + {/if} + + Node ID + + Copy + {$nav.base.id} + + Direct link diff --git a/svelte/src/filesystem/ErrorPage.svelte b/svelte/src/filesystem/ErrorPage.svelte index 0bfc6b5..d47f342 100644 --- a/svelte/src/filesystem/ErrorPage.svelte +++ b/svelte/src/filesystem/ErrorPage.svelte @@ -39,6 +39,12 @@ onMount(() => {

This content has been removed for breaking the law.

+ {:else if $nav.navigation_error === "out_of_transfer"} +

Traffic limit exceeded

+

+ The host user has exceeded the traffic limit of their subscription. + They need to upgrade to a higher subscription tier. +

{:else}

Unknown error code

diff --git a/svelte/src/filesystem/FSNavigator.ts b/svelte/src/filesystem/FSNavigator.ts index 66867e6..b064a4b 100644 --- a/svelte/src/filesystem/FSNavigator.ts +++ b/svelte/src/filesystem/FSNavigator.ts @@ -270,9 +270,14 @@ const sort_children = (children: FSNode[], field: string, asc: boolean) => { [a, b] = [b, a] } - // If the two values are equal then we force sort by name, since names - // are always unique - if (a[field] === b[field]) { + if (field === "size") { + // When doing a size comparison we also take the recursive directory + // size into account + return (a.type === "dir" ? a.recursive_size : a.file_size) - + (b.type === "dir" ? b.recursive_size : b.file_size) + } else if (a[field] === b[field]) { + // If the two values are equal then we force sort by name, since + // names are always unique return a.name.localeCompare(b.name, undefined, { numeric: true }) } else if (typeof (a[field]) === "number") { // Sort ints from high to low diff --git a/svelte/src/filesystem/edit_window/ThemePresets.svelte b/svelte/src/filesystem/edit_window/ThemePresets.svelte index edb91dc..1d87f67 100644 --- a/svelte/src/filesystem/edit_window/ThemePresets.svelte +++ b/svelte/src/filesystem/edit_window/ThemePresets.svelte @@ -86,6 +86,14 @@ const themes = [ brand_background_color: "#1e1e2e", brand_body_color: "#181825", brand_card_color: "#313244", + }, { + name: "Dracula", + brand_input_color: "#424450", + brand_highlight_color: "#50FA7B", + brand_danger_color: "#FF5555", + brand_background_color: "#191A21", + brand_body_color: "#21222C", + brand_card_color: "#343746", }, { name: "Nova", brand_input_color: "#28033f", diff --git a/svelte/src/filesystem/filemanager/FileManager.svelte b/svelte/src/filesystem/filemanager/FileManager.svelte index 8198f27..4de60fe 100644 --- a/svelte/src/filesystem/filemanager/FileManager.svelte +++ b/svelte/src/filesystem/filemanager/FileManager.svelte @@ -101,21 +101,6 @@ const navigate_back = () => { // Deletion function const delete_selected = async () => { - let count = nav.children.reduce((acc, cur) => { - if (cur.fm_selected) { - acc++ - } - return acc - }, 0) - - let confirmSingle = `Are you sure you want to delete this file? This action is irreversible.` - let confirmMulti = `Are you sure you want to delete these ${count} files? This action is irreversible.` - if (count === 0 || - (count === 1 && !confirm(confirmSingle)) || - (count > 1 && !confirm(confirmMulti))) { - return - } - try { loading_start() diff --git a/svelte/src/filesystem/filemanager/ListView.svelte b/svelte/src/filesystem/filemanager/ListView.svelte index a1f1a26..9f828d9 100644 --- a/svelte/src/filesystem/filemanager/ListView.svelte +++ b/svelte/src/filesystem/filemanager/ListView.svelte @@ -1,9 +1,13 @@ - + - + {/each} + - @@ -56,11 +107,35 @@ let { {child.name} - + + + + + + +
Name - - Size - + {#each columns as col} + + + {col.label} + + +
+ + {formatDate(child.modified, true, true, false)} + + {formatDate(child.created, true, true, false)} + + {child.created_by} + + {child.mode_string} + + {formatThousands(child.recursive_children)} + + {child.file_type} + {#if child.type === "file"} {formatDataVolume(child.file_size, 3)} + {:else if child.type === "dir"} + {formatDataVolume(child.recursive_size, 3)} {/if} + + {child.id} +
{#if child.abuse_type !== undefined} @@ -91,15 +166,39 @@ let {
+ +

+
+ {#each columns as col} +
+ + +
+ {/each} + +
+
+ diff --git a/svelte/src/lib/FilesystemAPI.svelte.ts b/svelte/src/lib/FilesystemAPI.svelte.ts index 63405f6..f0f5932 100644 --- a/svelte/src/lib/FilesystemAPI.svelte.ts +++ b/svelte/src/lib/FilesystemAPI.svelte.ts @@ -34,6 +34,8 @@ export class FSNode { mode_string: string mode_octal: string created_by: string + recursive_size: number + recursive_children: number abuse_type?: string abuse_report_time?: string diff --git a/svelte/src/user_home/dashboard/Dashboard.svelte b/svelte/src/user_home/dashboard/Dashboard.svelte index 30b836d..1f34069 100644 --- a/svelte/src/user_home/dashboard/Dashboard.svelte +++ b/svelte/src/user_home/dashboard/Dashboard.svelte @@ -32,7 +32,7 @@ const min_card_size = 0 const def_card_size = 1 const max_card_size = 3 -const expand = i => { +const expand = (i: number) => { if (cards[i].size === undefined) { cards[i].size = def_card_size } @@ -41,7 +41,7 @@ const expand = i => { } save() } -const shrink = i => { +const shrink = (i: number) => { if (cards[i].size === undefined) { cards[i].size = def_card_size } @@ -51,7 +51,7 @@ const shrink = i => { save() } -const swap_card = (idx1, idx2) => { +const swap_card = (idx1: number, idx2: number) => { const card1 = cards[idx1] cards[idx1] = cards[idx2] cards[idx2] = card1