From 39d0a210f310d54e423aa111f0bcd1adcccf3783 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Mon, 17 Mar 2025 19:38:38 -0400 Subject: [PATCH] Lots of work on file management and video processing (ffmpeg). --- .../ae_comp__hosted_files_clip_video.svelte | 135 ++++++++--- ...ae_comp__hosted_files_clip_video_li.svelte | 26 +- .../ae_comp__hosted_files_upload.svelte | 42 ++-- src/lib/ae_stores.ts | 1 + src/lib/ae_utils/ae_utils__datetime_format.ts | 6 + src/lib/element_manage_hosted_file_li.svelte | 111 +++++++-- .../element_manage_hosted_file_li_all.svelte | 29 ++- src/routes/hosted_files/+layout.ts | 14 +- src/routes/hosted_files/+page.svelte | 228 +++++------------- 9 files changed, 334 insertions(+), 258 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 14663912..1195e417 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 @@ -1,5 +1,5 @@ diff --git a/src/lib/ae_core/ae_comp__hosted_files_upload.svelte b/src/lib/ae_core/ae_comp__hosted_files_upload.svelte index 170355b1..1a13836b 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_upload.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_upload.svelte @@ -43,9 +43,13 @@ let ae_triggers: key_val = {}; let input_element_id = 'ae_comp__hosted_files_upload__input'; // Functions and Logic -async function handle_submit_form_files(event) { +async function handle_submit_form_files(event: SubmitEvent) { console.log('*** handle_submit_form() ***'); + if (!event) { + return; + } + $ae_sess.files.disable_submit__hosted_file_obj = true; $ae_sess.files.submit_status = 'saving'; submit_status = 'saving'; @@ -57,7 +61,8 @@ async function handle_submit_form_files(event) { let hosted_file_results; - if (event.target[input_element_id].files.length > 0) { + const target = event.target as HTMLFormElement; + if (target && target[input_element_id] && (target[input_element_id] as HTMLInputElement)?.files && (target[input_element_id] as HTMLInputElement).files.length > 0) { task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead? // Loop through each file and upload them individually in event.target[input_element_id].files @@ -68,7 +73,11 @@ async function handle_submit_form_files(event) { task_id = $ae_sess.files.processed_file_list[i].hash_sha256; - hosted_file_results = await handle_input_upload_files([tmp_file], task_id); + // hosted_file_results = await handle_input_upload_files([tmp_file], task_id); + hosted_file_results = await handle_input_upload_files({ + input_upload_files: [tmp_file], + task_id: task_id + }); if (hosted_file_results) { console.log(`hosted_file_results:`, hosted_file_results); @@ -78,7 +87,7 @@ async function handle_submit_form_files(event) { } // hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id); $ae_sess.files.processed_file_list = []; - $ae_sess = $ae_sess; + $ae_sess = $ae_sess; // Is this needed? 2025-03-17 event.target.reset(); // await tick(); @@ -87,21 +96,6 @@ async function handle_submit_form_files(event) { } else if (log_lvl > 1) { console.log('hosted_file_results:', hosted_file_results); } - - // db_events.files.clear(); - - // let params = { - // qry__enabled: 'all', - // qry__hidden: 'all', - // } - - // events_func.load_ae_obj_li__event_file({ - // api_cfg: $ae_api, - // for_obj_type: link_to_type, - // for_obj_id: link_to_id, - // params: params, - // try_cache: true - // }); } $ae_sess.files.disable_submit__hosted_file_obj = false; @@ -111,7 +105,15 @@ async function handle_submit_form_files(event) { } -async function handle_input_upload_files(input_upload_files, task_id) { +async function handle_input_upload_files( + { + input_upload_files, + task_id + } : { + input_upload_files: any[], + task_id: string + } + ) { console.log('*** handle_input_upload_files() ***'); const form_data = new FormData(); diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 0d486693..19dc7c31 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -227,6 +227,7 @@ export let ae_app_session_data_struct: key_val = { // uploaded_file_list: [], video_clip_file_list: [], submit_status: null, // 'saving', 'created', 'updated', 'saved' + clip_complete: null, }, 'hub': { diff --git a/src/lib/ae_utils/ae_utils__datetime_format.ts b/src/lib/ae_utils/ae_utils__datetime_format.ts index da290a56..df088de1 100644 --- a/src/lib/ae_utils/ae_utils__datetime_format.ts +++ b/src/lib/ae_utils/ae_utils__datetime_format.ts @@ -92,6 +92,12 @@ export let iso_datetime_formatter = function iso_datetime_formatter( case 'datetime_12_long': datetime_string = dayjs(raw_datetime).format('MMMM D, YYYY hh:mm A'); break; + case 'datetime_medium_sec': + datetime_string = dayjs(raw_datetime).format('MMM D, YYYY H:mm:ss'); + break; + case 'datetime_12_medium_sec': + datetime_string = dayjs(raw_datetime).format('MMM D, YYYY h:mm:ss A'); + break; case 'datetime_short_month': datetime_string = dayjs(raw_datetime).format('MMM D hh:mm A'); break; diff --git a/src/lib/element_manage_hosted_file_li.svelte b/src/lib/element_manage_hosted_file_li.svelte index de802647..d574d7be 100644 --- a/src/lib/element_manage_hosted_file_li.svelte +++ b/src/lib/element_manage_hosted_file_li.svelte @@ -1,5 +1,4 @@ diff --git a/src/routes/hosted_files/+layout.ts b/src/routes/hosted_files/+layout.ts index d190b998..9623c3b6 100644 --- a/src/routes/hosted_files/+layout.ts +++ b/src/routes/hosted_files/+layout.ts @@ -15,14 +15,14 @@ export async function load({ params, parent }) { // route let ae_acct = data[account_id]; // console.log(`ae_acct = `, ae_acct); - if (!account_id) { - console.log(`ae Core - [account_id] +page.ts: The account_id was not found!!!`); - error(404, { - message: 'Account ID not found' - }); - } + // if (!account_id) { + // console.log(`ae Core - [account_id] +page.ts: The account_id was not found!!!`); + // error(404, { + // message: 'Account ID not found' + // }); + // } - ae_acct.slct.account_id = account_id; + // ae_acct.slct.account_id = account_id; if (browser) { let load_hosted_file_obj_li = core_func.load_ae_obj_li__hosted_file({ diff --git a/src/routes/hosted_files/+page.svelte b/src/routes/hosted_files/+page.svelte index 4759ec52..35112d24 100644 --- a/src/routes/hosted_files/+page.svelte +++ b/src/routes/hosted_files/+page.svelte @@ -1,5 +1,6 @@ @@ -237,16 +135,18 @@ function handle_submit_form(event) { bind:upload_complete={$ae_sess.files.upload_complete} log_lvl={log_lvl} > - -
- - Upload video files -
- - Aether hosted files only
- Recommended: video (mp4, mkv)
+ {#snippet label()} + +
+ + Upload video files +
+ + Aether hosted files only
+ Recommended: video (mp4, mkv)
+
-
+ {/snippet} @@ -266,8 +166,6 @@ function handle_submit_form(event) { class_li="border border-gray-300 rounded-md p-2 bg-gray-100 hover:bg-gray-200" link_to_type="account" link_to_id={$ae_loc.account_id} - bind:hosted_file_id_li={hosted_file_clip.hosted_file_id_li} - bind:hosted_file_obj_li={hosted_file_clip.hosted_file_obj_li} bind:hosted_file_obj_kv={$ae_loc.files.uploaded_file_kv} bind:video_clip_file_kv={$ae_loc.files.video_clip_file_kv} bind:clip_complete={$ae_sess.files.clip_complete}