From c96e59c6605a331ded659ade45c8f56cc96b0965 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 18 Mar 2025 15:01:30 -0400 Subject: [PATCH] Getting ready to make the new hosted file management and tools live on dev. Then on prod... --- .../ae_comp__hosted_files_clip_video.svelte | 21 +++-- src/lib/ae_core/core__hosted_files.ts | 23 ++++++ src/lib/ae_stores.ts | 1 + src/lib/element_manage_hosted_file_li.svelte | 82 ++++++++++++------- .../element_manage_hosted_file_li_all.svelte | 9 +- src/routes/hosted_files/+layout.ts | 10 ++- src/routes/hosted_files/+page.svelte | 59 ++++++++++--- 7 files changed, 155 insertions(+), 50 deletions(-) diff --git a/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte b/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte index 1195e417..7ad7dfdd 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte @@ -122,6 +122,7 @@ function handle_clip_video(event) { api_cfg: $ae_api, endpoint: endpoint, params: params, + timeout: 300000, // 5 minutes // return_blob: true, // filename: event.target.new_filename.value, // auto_download: false, @@ -160,12 +161,19 @@ function handle_clip_video(event) { -
+
-

{Object.entries(hosted_file_obj_kv).length}× files uploaded

+

+ {Object.entries(hosted_file_obj_kv).length}× files uploaded +

+ {#each Object.entries(hosted_file_obj_kv) as [hosted_file_id, hosted_file_obj]}
@@ -367,4 +374,4 @@ function handle_clip_video(event) { {/if} {/await} --> -
\ No newline at end of file +
\ No newline at end of file diff --git a/src/lib/ae_core/core__hosted_files.ts b/src/lib/ae_core/core__hosted_files.ts index 1eec7abc..97e6e6b8 100644 --- a/src/lib/ae_core/core__hosted_files.ts +++ b/src/lib/ae_core/core__hosted_files.ts @@ -154,6 +154,7 @@ export async function delete_ae_obj_id__hosted_file( rm_orphan = false, fake_delete = false, // Fake the delete result to "true" params = {}, + try_cache = true, log_lvl = 0 }: { api_cfg: any, @@ -163,6 +164,7 @@ export async function delete_ae_obj_id__hosted_file( rm_orphan?: boolean, fake_delete?: boolean, params?: key_val, + try_cache?: boolean, log_lvl?: number } ) { @@ -191,8 +193,29 @@ export async function delete_ae_obj_id__hosted_file( params: params, // return_meta: return_meta, log_lvl: log_lvl + }) + .then(function (hosted_file_obj_li_get_result) { + if (hosted_file_obj_li_get_result) { + if (try_cache) { + if (log_lvl) { + console.log(`Attempting to remove IDB entry for hosted_file_id=${hosted_file_id}`); + } + db_core.file.delete(hosted_file_id); // Delete from the DB no matter what. + } + return hosted_file_obj_li_get_result; + } else { + console.log('No results returned.'); + return []; + } + }) + .catch(function (error) { + console.log('No results returned or failed.', error); }); + if (log_lvl) { + console.log('ae_promises.delete__hosted_file_obj:', ae_promises.delete__hosted_file_obj); + } + return ae_promises.delete__hosted_file_obj; } diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 19dc7c31..5329ac13 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -116,6 +116,7 @@ export let ae_app_local_data_struct: key_val = { processed_file_kv: {}, uploaded_file_kv: {}, video_clip_file_kv: {}, + add_to_use_files_method: 'upload', // upload, select }, 'ds': {}, diff --git a/src/lib/element_manage_hosted_file_li.svelte b/src/lib/element_manage_hosted_file_li.svelte index d574d7be..831a0cec 100644 --- a/src/lib/element_manage_hosted_file_li.svelte +++ b/src/lib/element_manage_hosted_file_li.svelte @@ -18,21 +18,27 @@ import { core_func } from '$lib/ae_core/ae_core_functions'; interface Props { log_lvl?: number; - container_class_li?: string|Array; + class_li_default?: string; + class_li?: string; lq__hosted_file_obj_li: any; link_to_type: string; link_to_id: string; // export let allow_moderator: boolean = false; display_mode?: string; // 'default', 'compact', 'minimal', 'launcher' + max_file_count?: number; + file_type?: string; // 'image', 'video', 'audio', 'document', 'other' } let { log_lvl = 0, - container_class_li = [], + class_li_default = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1 max-h-96 overflow-auto', + class_li = '', lq__hosted_file_obj_li = $bindable([]), link_to_type, link_to_id, - display_mode = 'default' + display_mode = 'default', + max_file_count = 19, + file_type = 'all' }: Props = $props(); // export let show_convert_btn: null|boolean = null; @@ -47,8 +53,25 @@ ae_tmp.show__direct_download = $ae_loc.core?.show__direct_download ?? false; +
+ +

+ Manage Files: + + + {@html $lq__hosted_file_obj_li ? `${$lq__hosted_file_obj_li.length}×` : '-- none --'} + +

+
+ + +
{ {/snippet} +
+
+ +
+ +
+ +

+ Step 2: Clip Video -

Step 2: Clip Video

- {#if $ae_loc.files.uploaded_file_kv && Object.entries($ae_loc.files.uploaded_file_kv).length > 0} + + {#if $ae_loc.files.uploaded_file_kv && Object.entries($ae_loc.files.uploaded_file_kv).length > 0} { {/if} -

Step 3: Download Video Clips

- {#if $ae_loc.files.video_clip_file_kv && Object.entries($ae_loc.files.video_clip_file_kv).length > 0} +

+ Step 3: Download Recently Processed Video Clips + +

+ {#if $ae_loc.files.video_clip_file_kv && Object.entries($ae_loc.files.video_clip_file_kv).length > 0} { -

Step X: Manage Files

+ - + /> -->