From 1ae7b5642df085de21fe434cb4ddd2fe3904dd3d Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 3 Feb 2026 10:27:01 -0500 Subject: [PATCH] General clean up the _random appends. About to work on a new Hosted File Download Svelte component. --- .../ae_archives__archive_content.ts | 1 - ...ae_comp__hosted_files_clip_video_li.svelte | 2 +- ...ae_comp__hosted_files_clip_video_v1.svelte | 432 ------------------ ...p__hosted_files_download_button_v1.svelte} | 18 +- .../ae_comp__hosted_files_upload.svelte | 2 - .../ae_journals/ae_journals__journal_entry.ts | 342 +++++++------- .../events/ae_comp__event_files_upload.svelte | 4 +- .../video_util/hold_video_util.svelte | 2 +- .../ae_comp__journal_entry_obj_file_li.svelte | 58 +-- 9 files changed, 211 insertions(+), 650 deletions(-) delete mode 100644 src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte rename src/lib/ae_core/{ae_comp__hosted_files_download_button.svelte => ae_comp__hosted_files_download_button_v1.svelte} (93%) diff --git a/src/lib/ae_archives/ae_archives__archive_content.ts b/src/lib/ae_archives/ae_archives__archive_content.ts index d270e6dc..fc9d4fd6 100644 --- a/src/lib/ae_archives/ae_archives__archive_content.ts +++ b/src/lib/ae_archives/ae_archives__archive_content.ts @@ -298,7 +298,6 @@ export const properties_to_save = [ 'url', 'url_text', 'hosted_file_id', - 'hosted_file_id_random', 'file_path', 'filename', 'file_extension', diff --git a/src/lib/ae_core/ae_comp__hosted_files_clip_video_li.svelte b/src/lib/ae_core/ae_comp__hosted_files_clip_video_li.svelte index f877a32c..5692f766 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_clip_video_li.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_clip_video_li.svelte @@ -63,7 +63,7 @@ // window.postMessage({ type: 'download_event_file', hosted_file_id: idaa_archive_content_obj.hosted_file_id, filename: idaa_archive_content_obj.filename, auto_download: true }, '*'); }} class="novi_btn btn btn-sm lg:btn-md preset-tonal-primary hover:preset-filled-primary-500 min-w-72 lg:min-w-96" - title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id_random}`} + title={`Download this file:\n${hosted_file_obj.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}... Hosted ID: ${hosted_file_obj.hosted_file_id}`} > {#await ae_promises[hosted_file_id]} diff --git a/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte b/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte deleted file mode 100644 index c14a14b4..00000000 --- a/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte +++ /dev/null @@ -1,432 +0,0 @@ - - -
- -
- - - - - - {#await ae_promises.upload__hosted_file_obj} -
- - - Uploading - {#if $ae_sess.api_upload_kv[task_id]} - {$ae_sess.api_upload_kv[task_id].percent_completed}% - {/if} - -
- {/await} - - - - - - - - - - -
- - {#await ae_promises.upload__hosted_file_obj} - -

Converting... This may take a few minutes.

- {:then} - {#if ae_promises.upload__hosted_file_obj} - Ready to Download - {:else} -

Fill out the form and select the video file to clip.

- {/if} - {/await} -
diff --git a/src/lib/ae_core/ae_comp__hosted_files_download_button.svelte b/src/lib/ae_core/ae_comp__hosted_files_download_button_v1.svelte similarity index 93% rename from src/lib/ae_core/ae_comp__hosted_files_download_button.svelte rename to src/lib/ae_core/ae_comp__hosted_files_download_button_v1.svelte index fce2907d..b4e4a926 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_download_button.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_download_button_v1.svelte @@ -52,7 +52,7 @@ } let { - log_lvl = 0, + log_lvl = $bindable(0), hosted_file_id, hosted_file_obj, filename = $bindable(null), @@ -76,9 +76,9 @@ let ae_promises: key_val = $state({}); $effect(() => { - if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id_random]?.percent_completed) { + if ($ae_sess?.api_download_kv[hosted_file_obj?.hosted_file_id]?.percent_completed) { download_percent = - $ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id_random].percent_completed; + $ae_sess.api_download_kv[hosted_file_obj?.hosted_file_id].percent_completed; } }); @@ -91,10 +91,10 @@ onclick={() => { download_complete = false; download_status_msg = 'Downloading...'; - ae_promises[hosted_file_obj.hosted_file_id_random] = api + ae_promises[hosted_file_obj.hosted_file_id] = api .download_hosted_file({ api_cfg: $ae_api, - hosted_file_id: hosted_file_obj.hosted_file_id_random, + hosted_file_id: hosted_file_obj.hosted_file_id, return_file: true, filename: filename ?? hosted_file_obj.filename, auto_download: auto_download, @@ -119,14 +119,14 @@ return result; }); }} - title={`Download this file:\n${filename ?? hosted_file_obj?.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}...\nHosted ID: ${hosted_file_obj?.hosted_file_id_random}\n Linked to: ${linked_to_type} ID: ${linked_to_id}`} + title={`Download this file:\n${filename ?? hosted_file_obj?.filename}\n[API] SHA256: ${hosted_file_obj?.hash_sha256?.slice(0, 10)}...\nHosted ID: ${hosted_file_obj?.hosted_file_id}\n Linked to: ${linked_to_type} ID: ${linked_to_id}`} > - {#await ae_promises[hosted_file_obj.hosted_file_id_random]} + {#await ae_promises[hosted_file_obj.hosted_file_id]} Downloading - {#if $ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random]} - {$ae_sess.api_download_kv[hosted_file_obj.hosted_file_id_random] + {#if $ae_sess.api_download_kv[hosted_file_obj.hosted_file_id]} + {$ae_sess.api_download_kv[hosted_file_obj.hosted_file_id] .percent_completed}% {/if} : 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 fa38d832..d6be72da 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_upload.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_upload.svelte @@ -206,10 +206,8 @@ let hosted_file_data: key_val = {}; hosted_file_data['id'] = hosted_file_id; // Same as the hosted_file_id hosted_file_data['hosted_file_id'] = hosted_file_id; - // hosted_file_data['hosted_file_id_random'] = hosted_file_id; hosted_file_data['for_type'] = link_to_type; hosted_file_data['for_id'] = link_to_id; - // hosted_file_data['for_id_random'] = link_to_id; hosted_file_data['hash_sha256'] = hosted_file_obj.hash_sha256; hosted_file_data['filename'] = hosted_file_obj.filename; hosted_file_data['extension'] = hosted_file_obj.extension; diff --git a/src/lib/ae_journals/ae_journals__journal_entry.ts b/src/lib/ae_journals/ae_journals__journal_entry.ts index f4dfb3e7..9c7474ba 100644 --- a/src/lib/ae_journals/ae_journals__journal_entry.ts +++ b/src/lib/ae_journals/ae_journals__journal_entry.ts @@ -565,215 +565,213 @@ export async function update_ae_obj__journal_entry({ } } -// This function will loop through the journal_entry_obj_li and save each one to the DB. -// Updated 2025-05-09 -export async function db_save_ae_obj_li__journal_entry({ - obj_type, - obj_li, - log_lvl = 0 -}: { - obj_type: string; - obj_li: any; - log_lvl?: number; -}) { - // log_lvl = 1; - if (log_lvl) { - console.log(`*** db_save_ae_obj_li__journal_entry() *** obj_type=${obj_type}`, obj_li); - } +// // This function will loop through the journal_entry_obj_li and save each one to the DB. +// // Updated 2025-05-09 +// export async function db_save_ae_obj_li__journal_entry({ +// obj_type, +// obj_li, +// log_lvl = 0 +// }: { +// obj_type: string; +// obj_li: any; +// log_lvl?: number; +// }) { +// // log_lvl = 1; +// if (log_lvl) { +// console.log(`*** db_save_ae_obj_li__journal_entry() *** obj_type=${obj_type}`, obj_li); +// } - if (obj_li && obj_li.length) { - // let obj_li_id = obj_li.map((obj: any) => obj.journal_entry_id_random); - const obj_li_id: string[] = []; +// if (obj_li && obj_li.length) { +// // let obj_li_id = obj_li.map((obj: any) => obj.journal_entry_id_random); +// const obj_li_id: string[] = []; - for (const obj of obj_li) { - // obj_li.forEach(async function (obj: any) { - if (log_lvl) { - console.log(`Processing ae_obj ${obj_type}:`, obj); - } +// for (const obj of obj_li) { +// // obj_li.forEach(async function (obj: any) { +// if (log_lvl) { +// console.log(`Processing ae_obj ${obj_type}:`, obj); +// } - let content = obj.content ?? ''; - // remove the most common zerowidth characters from the start of the file - let content_cleaned: null | string = null; - let content_md_html: null | string = null; // await marked.parse(content_cleaned ?? '') ?? null; - // let content_md_html_alt: null|string = await marked.parse(content_cleaned ?? '', { gfm: false }) ?? null; +// let content = obj.content ?? ''; +// // remove the most common zerowidth characters from the start of the file +// let content_cleaned: null | string = null; +// let content_md_html: null | string = null; // await marked.parse(content_cleaned ?? '') ?? null; +// // let content_md_html_alt: null|string = await marked.parse(content_cleaned ?? '', { gfm: false }) ?? null; - if (obj.content_encrypted) { - // In theory "content" should be null if "content_encrypted" has a value. - content = null; // obj.content_encrypted; - content_cleaned = null; - content_md_html = null; - } else { - content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ''); - content_md_html = (await marked.parse(content_cleaned ?? '')) ?? null; - } +// if (obj.content_encrypted) { +// // In theory "content" should be null if "content_encrypted" has a value. +// content = null; // obj.content_encrypted; +// content_cleaned = null; +// content_md_html = null; +// } else { +// content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ''); +// content_md_html = (await marked.parse(content_cleaned ?? '')) ?? null; +// } - let history = obj.history ?? ''; - let history_cleaned: null | string = null; - let history_md_html: null | string = null; // await marked.parse(history_cleaned ?? '') ?? null; +// let history = obj.history ?? ''; +// let history_cleaned: null | string = null; +// let history_md_html: null | string = null; // await marked.parse(history_cleaned ?? '') ?? null; - if (obj.history_encrypted) { - // In theory "history" should be null if "history_encrypted" has a value. - history = null; // obj.history_encrypted; - history_cleaned = null; - history_md_html = null; - } else { - history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ''); - history_md_html = (await marked.parse(history_cleaned ?? '')) ?? null; - } +// if (obj.history_encrypted) { +// // In theory "history" should be null if "history_encrypted" has a value. +// history = null; // obj.history_encrypted; +// history_cleaned = null; +// history_md_html = null; +// } else { +// history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, ''); +// history_md_html = (await marked.parse(history_cleaned ?? '')) ?? null; +// } - const obj_record = { - id: obj.journal_entry_id_random, - journal_entry_id: obj.journal_entry_id_random, - journal_entry_id_random: obj.journal_entry_id_random, +// const obj_record = { +// id: obj.journal_entry_id, +// journal_entry_id: obj.journal_entry_id, - journal_id: obj.journal_id_random, - journal_id_random: obj.journal_id_random, +// journal_id: obj.journal_id, - code: obj.code, +// code: obj.code, - for_type: obj.for_type, - for_id: obj.for_id, +// for_type: obj.for_type, +// for_id: obj.for_id, - journal_entry_type: obj.journal_entry_type, +// journal_entry_type: obj.journal_entry_type, - person_id: obj.person_id_random, +// person_id: obj.person_id, - template: obj.template ?? null, // Allow for a template to be used, otherwise null +// template: obj.template ?? null, // Allow for a template to be used, otherwise null - activity_code: obj.activity_code, - category_code: obj.category_code, - type_code: obj.type_code, - topic_code: obj.topic_code, - tags: obj.tags, +// activity_code: obj.activity_code, +// category_code: obj.category_code, +// type_code: obj.type_code, +// topic_code: obj.topic_code, +// tags: obj.tags, - public: obj.public, - private: obj.private, - personal: obj.personal, - professional: obj.professional, +// public: obj.public, +// private: obj.private, +// personal: obj.personal, +// professional: obj.professional, - name: obj.name, - short_name: obj.short_name ?? null, - summary: obj.summary, - outline: obj.outline, - // description: obj.description, +// name: obj.name, +// short_name: obj.short_name ?? null, +// summary: obj.summary, +// outline: obj.outline, +// // description: obj.description, - content: obj.content, - content_md_html: content_md_html ?? undefined, - // content_md_html_alt: content_md_html_alt, - content_html: obj.content_html, - content_json: obj.content_json, - content_encrypted: obj.content_encrypted, +// content: obj.content, +// content_md_html: content_md_html ?? undefined, +// // content_md_html_alt: content_md_html_alt, +// content_html: obj.content_html, +// content_json: obj.content_json, +// content_encrypted: obj.content_encrypted, - history: obj.history, - history_md_html: history_md_html ?? undefined, - history_encrypted: obj.history_encrypted, +// history: obj.history, +// history_md_html: history_md_html ?? undefined, +// history_encrypted: obj.history_encrypted, - passcode_hash: obj.passcode_hash, +// passcode_hash: obj.passcode_hash, - // url: obj.url, - // url_text: obj.url_text, +// // url: obj.url, +// // url_text: obj.url_text, - // hosted_file_id: obj.hosted_file_id_random, +// // hosted_file_id: obj.hosted_file_id, - // file_path: obj.file_path, +// // file_path: obj.file_path, - // filename: obj.filename, - // file_extension: obj.file_extension, +// // filename: obj.filename, +// // file_extension: obj.file_extension, - // start_datetime: obj.start_datetime, - // end_datetime: obj.end_datetime, - // timezone: obj.timezone, +// // start_datetime: obj.start_datetime, +// // end_datetime: obj.end_datetime, +// // timezone: obj.timezone, - // original_datetime: obj.original_datetime, - // original_timezone: obj.original_timezone, - // original_location: obj.original_location, - // original_url: obj.original_url, - // original_url_text: obj.original_url_text, +// // original_datetime: obj.original_datetime, +// // original_timezone: obj.original_timezone, +// // original_location: obj.original_location, +// // original_url: obj.original_url, +// // original_url_text: obj.original_url_text, - // enable_for_public: obj.enable_for_public, +// // enable_for_public: obj.enable_for_public, - alert: obj.alert, - alert_msg: obj.alert_msg, +// alert: obj.alert, +// alert_msg: obj.alert_msg, - // cfg_json: obj.cfg_json ?? {}, - data_json: obj.data_json ?? {}, +// // cfg_json: obj.cfg_json ?? {}, +// data_json: obj.data_json ?? {}, - // This only allows for basic access to the data. - // passcode_read: obj.passcode_read, // For LLM (AI) generated summary...??? - // passcode_read_expire: obj.passcode_read_expire, - // passcode_write: obj.passcode_write, - // passcode_write_expire: obj.passcode_write_expire, +// // This only allows for basic access to the data. +// // passcode_read: obj.passcode_read, // For LLM (AI) generated summary...??? +// // passcode_read_expire: obj.passcode_read_expire, +// // passcode_write: obj.passcode_write, +// // passcode_write_expire: obj.passcode_write_expire, - enable: obj.enable, - hide: obj.hide, - archive: obj.archive, - archive_on: obj.archive_on, - priority: obj.priority, - sort: obj.sort, - group: obj.group, - notes: obj.notes, - created_on: obj.created_on, - updated_on: obj.updated_on, +// enable: obj.enable, +// hide: obj.hide, +// archive: obj.archive, +// archive_on: obj.archive_on, +// priority: obj.priority, +// sort: obj.sort, +// group: obj.group, +// notes: obj.notes, +// created_on: obj.created_on, +// updated_on: obj.updated_on, - // Generated fields for sorting locally only - tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`, - tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`, - // tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`, - // tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`, +// // Generated fields for sorting locally only +// tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`, +// tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`, +// // tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`, +// // tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`, - // Generated fields for sorting locally only - // tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`, - // tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`, +// // Generated fields for sorting locally only +// // tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`, +// // tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`, - // From SQL view - journal_code: obj.journal_code, - journal_name: obj.journal_name +// // From SQL view +// journal_code: obj.journal_code, +// journal_name: obj.journal_name - // A key value list of the others - // journal_other_kv: obj.journal_other_kv, - // journal_other_li: obj.journal_other_li, - }; +// // A key value list of the others +// // journal_other_kv: obj.journal_other_kv, +// // journal_other_li: obj.journal_other_li, +// }; - let id_random = null; +// let id_random = null; - try { - id_random = await db_journals.journal_entry.update(obj_record.id, obj_record); - } catch (error) { - console.log(`Error: Failed to update ${obj_record.id}: ${error}`); - } - if (!id_random) { - if (log_lvl) { - console.log(`Failed to update record with ID: ${obj_record.id}. Trying put...`); - } - try { - id_random = await db_journals.journal_entry.put(obj_record); - } catch (error) { - console.log(`Error: Failed to put ${obj.journal_entry_id_random}: ${error}`); - } - } else { - if (log_lvl) { - console.log(`Updated record with ID: ${obj_record.id}`); - } - obj_li_id.push(obj_record.id); - } - if (!id_random) { - console.log(`Failed to save record with ID: ${obj_record.id}`); - } else { - if (log_lvl) { - console.log(`Saved record with ID: ${obj_record.id}`); - } - } - // }); - } +// try { +// id_random = await db_journals.journal_entry.update(obj_record.id, obj_record); +// } catch (error) { +// console.log(`Error: Failed to update ${obj_record.id}: ${error}`); +// } +// if (!id_random) { +// if (log_lvl) { +// console.log(`Failed to update record with ID: ${obj_record.id}. Trying put...`); +// } +// try { +// id_random = await db_journals.journal_entry.put(obj_record); +// } catch (error) { +// console.log(`Error: Failed to put ${obj.journal_entry_id_random}: ${error}`); +// } +// } else { +// if (log_lvl) { +// console.log(`Updated record with ID: ${obj_record.id}`); +// } +// obj_li_id.push(obj_record.id); +// } +// if (!id_random) { +// console.log(`Failed to save record with ID: ${obj_record.id}`); +// } else { +// if (log_lvl) { +// console.log(`Saved record with ID: ${obj_record.id}`); +// } +// } +// // }); +// } - return obj_li_id; - } else { - if (log_lvl) { - console.log('No objects to save.'); - } - return []; - } -} +// return obj_li_id; +// } else { +// if (log_lvl) { +// console.log('No objects to save.'); +// } +// return []; +// } +// } // Updated 2025-05-09 const properties_to_save = [ diff --git a/src/routes/events/ae_comp__event_files_upload.svelte b/src/routes/events/ae_comp__event_files_upload.svelte index 4cb076db..0dbafee8 100644 --- a/src/routes/events/ae_comp__event_files_upload.svelte +++ b/src/routes/events/ae_comp__event_files_upload.svelte @@ -186,14 +186,12 @@ } let hosted_file_obj = result[x]; - let hosted_file_id = hosted_file_obj.hosted_file_id_random; + let hosted_file_id = hosted_file_obj.hosted_file_id; let event_file_data: key_val = {}; event_file_data['hosted_file_id'] = hosted_file_id; - // event_file_data['hosted_file_id_random'] = hosted_file_id; event_file_data['for_type'] = link_to_type; event_file_data['for_id'] = link_to_id; - // event_file_data['for_id_random'] = link_to_id; event_file_data['filename'] = hosted_file_obj.filename; event_file_data['extension'] = hosted_file_obj.extension; event_file_data['enable'] = true; diff --git a/src/routes/hosted_files/video_util/hold_video_util.svelte b/src/routes/hosted_files/video_util/hold_video_util.svelte index 7619c662..1c08e2a1 100644 --- a/src/routes/hosted_files/video_util/hold_video_util.svelte +++ b/src/routes/hosted_files/video_util/hold_video_util.svelte @@ -170,7 +170,7 @@ History: {#each Object.entries($ae_loc.files.uploaded_file_kv) as [hosted_file_id, hosted_file_obj]}
- {hosted_file_obj.hosted_file_id_random} + {hosted_file_obj.hosted_file_id} {hosted_file_obj.filename} {hosted_file_obj.extension} - + {#if $ae_loc.edit_mode} -