From 80965167a5129c5390c8cff2cff554f97c8de801 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 6 Nov 2024 13:15:16 -0500 Subject: [PATCH] We can now see a list of archive content and it doesn't look terrible. --- src/lib/ae_archives/ae_archives__archive.ts | 2 +- .../ae_archives__archive_content.ts | 6 +- src/lib/db_archives.ts | 11 +- .../idaa/(idaa)/archives/+layout.svelte | 4 +- src/routes/idaa/(idaa)/archives/+page.svelte | 8 +- .../(idaa)/archives/[archive_id]/+layout.ts | 48 ++++ .../(idaa)/archives/[archive_id]/+page.svelte | 110 +++++++++ .../(idaa)/archives/[archive_id]/+page.ts | 82 +++++++ ...e_idaa_comp__archive_content_obj_li.svelte | 223 ++++++++++++++++++ .../ae_idaa_comp__archive_obj_id_edit.svelte | 1 + .../ae_idaa_comp__archive_obj_id_view.svelte | 107 +++++++++ .../archives/[archive_id]/del +layout.svelte | 0 .../ae_idaa_comp__archive_obj_li.svelte | 16 +- 13 files changed, 603 insertions(+), 15 deletions(-) create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/+layout.ts create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/+page.ts create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_content_obj_li.svelte create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_edit.svelte create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_view.svelte create mode 100644 src/routes/idaa/(idaa)/archives/[archive_id]/del +layout.svelte diff --git a/src/lib/ae_archives/ae_archives__archive.ts b/src/lib/ae_archives/ae_archives__archive.ts index 11e80697..7d1fb6f7 100644 --- a/src/lib/ae_archives/ae_archives__archive.ts +++ b/src/lib/ae_archives/ae_archives__archive.ts @@ -69,7 +69,7 @@ export async function load_ae_obj_id__archive( api_cfg: api_cfg, for_obj_type: 'archive', for_obj_id: archive_id, - params: {qry__enabled: 'all', qry__limit: 25}, + params: {qry__enabled: 'all', qry__limit: 99}, try_cache: try_cache, log_lvl: log_lvl }) diff --git a/src/lib/ae_archives/ae_archives__archive_content.ts b/src/lib/ae_archives/ae_archives__archive_content.ts index c9ea7128..ccb6ef3d 100644 --- a/src/lib/ae_archives/ae_archives__archive_content.ts +++ b/src/lib/ae_archives/ae_archives__archive_content.ts @@ -63,7 +63,7 @@ export async function load_ae_obj_li__archive_content( api_cfg, for_obj_type = 'archive', for_obj_id, - order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'original_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, params = {}, try_cache = true, log_lvl = 0 @@ -280,7 +280,7 @@ export function db_save_ae_obj_li__archive_content( url: obj.url, url_text: obj.url_text, - hosted_file_id: obj.hosted_file_id, + hosted_file_id: obj.hosted_file_id_random, file_path: obj.file_path, @@ -309,6 +309,8 @@ export function db_save_ae_obj_li__archive_content( // From SQL view archive_code: obj.archive_code, archive_name: obj.archive_name, + + hash_sha256: obj.hosted_file_hash_sha256 }); // console.log(`Put obj with ID: ${obj.archive_content_id_random} or ${id_random}`); } catch (error) { diff --git a/src/lib/db_archives.ts b/src/lib/db_archives.ts index ebd24cca..73974232 100644 --- a/src/lib/db_archives.ts +++ b/src/lib/db_archives.ts @@ -112,6 +112,8 @@ export interface Archive_Content { // Additional fields for convenience (database views) archive_code?: null|string; archive_name?: null|string; + + hash_sha256?: null|string; } @@ -137,12 +139,13 @@ export class MySubClassedDexie extends Dexie { archive_content_type, name, hosted_file_id, - file_path, - filename, file_extension, - original_datetime, original_timezone, original_location, original_url, original_url_text, - enable_for_public, enable, hide, priority, sort, group, notes, created_on, updated_on`, }); + + // file_path, + // filename, file_extension, + // original_datetime, original_timezone, original_location, original_url, original_url_text, + // enable_for_public, } } diff --git a/src/routes/idaa/(idaa)/archives/+layout.svelte b/src/routes/idaa/(idaa)/archives/+layout.svelte index bb46e5a7..c627d36d 100644 --- a/src/routes/idaa/(idaa)/archives/+layout.svelte +++ b/src/routes/idaa/(idaa)/archives/+layout.svelte @@ -2,7 +2,7 @@ /** @type {import('./$types').LayoutData} */ export let data: any; let log_lvl = 2; -console.log(`ae_idaa_archives +layout.svelte data:`, data); +console.log(`ae_idaa_archives +layout.svelte data:`, data); import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores'; import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores'; @@ -13,7 +13,7 @@ $slct.account_id = data.account_id; let ae_acct = data[$slct.account_id]; console.log(`ae_acct = `, ae_acct); -$idaa_slct.post_obj_li = ae_acct.slct.post_obj_li; +$idaa_slct.archive_obj_li = ae_acct.slct.archive_obj_li; diff --git a/src/routes/idaa/(idaa)/archives/+page.svelte b/src/routes/idaa/(idaa)/archives/+page.svelte index f216f075..10f35b1b 100644 --- a/src/routes/idaa/(idaa)/archives/+page.svelte +++ b/src/routes/idaa/(idaa)/archives/+page.svelte @@ -44,9 +44,9 @@ $: lq__archive_obj = liveQuery(async () => { }); $: lq__archive_content_obj_li = liveQuery(async () => { - let results = await db_posts.comment - .where('post_id') - .equals($idaa_slct.post_id) + let results = await db_archives.content + .where('archive_id') + .equals($idaa_slct.archive_id) .reverse() .sortBy('updated_on'); // .sortBy('title'); @@ -55,7 +55,7 @@ $: lq__archive_content_obj_li = liveQuery(async () => { }); $: lq__archive_content_obj = liveQuery(async () => { - let results = await db_posts.comment + let results = await db_archives.content .get($idaa_slct.archive_content_id); return results; diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/+layout.ts b/src/routes/idaa/(idaa)/archives/[archive_id]/+layout.ts new file mode 100644 index 00000000..7cf70ad3 --- /dev/null +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/+layout.ts @@ -0,0 +1,48 @@ +/** @type {import('./$types').LayoutLoad} */ +console.log(`IDAA Archives - [archive_id] +layout.ts start`); + +import { error } from '@sveltejs/kit'; +import { browser } from '$app/environment'; +import { archives_func } from '$lib/ae_archives/ae_archives_functions'; + +export async function load({ params, parent }) { // route + // let log_lvl = 0; + + // let data = await parent(); + // data.log_lvl = log_lvl; + + // let account_id = data.account_id; + // let ae_acct = data[account_id]; + // console.log(`ae_acct = `, ae_acct); + + // let archive_id = params.archive_id; + // if (!archive_id) { + // console.log(`ae IDAA Archives - [archive_id] +layout.ts: The archive_id was not found!!!`); + // error(404, { + // message: 'IDAA Archives - Archive ID not found' + // }); + // } + + // ae_acct.slct.archive_id = archive_id; + + // if (browser) { + // if (log_lvl) { + // console.log(`ae_idaa_archives archives [archive_id] +layout.ts: archive_id = `, archive_id); + // } + // // Load event archive object + // let load_archive_obj = archives_func.load_ae_obj_id__archive({ + // api_cfg: ae_acct.api, + // archive_id: archive_id, + // inc_content_li: true, + // try_cache: true + // }); + + // console.log(`load_archive_obj = `, load_archive_obj); + // ae_acct.slct.archive_obj = load_archive_obj; + // } + + // WARNING: Precaution against shared data between sites and sessions. + // data[account_id] = ae_acct; + + // return data; +} diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte new file mode 100644 index 00000000..cd87dfcd --- /dev/null +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte @@ -0,0 +1,110 @@ + + + +
+ + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/+page.ts b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.ts new file mode 100644 index 00000000..3833100e --- /dev/null +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.ts @@ -0,0 +1,82 @@ +/** @type {import('./$types').PageLoad} */ +import { error } from '@sveltejs/kit'; +console.log(`ae_p_idaa_archives [archive_id] +page.ts start`); + +import { browser } from '$app/environment'; +import { archives_func } from '$lib/ae_archives/ae_archives_functions'; + +export async function load({ params, parent }) { // route + let log_lvl = 1; + + let data = await parent(); + data.log_lvl = log_lvl; + + let account_id = data.account_id; + let ae_acct = data[account_id]; + + let archive_id = params.archive_id; + if (!archive_id) { + console.log(`ae_idaa_archives archives [archive_id] +page.ts: The archive_id was not found in the params!!!`); + error(404, { + message: 'IDAA Archives - Archive ID not found' + }); + } + ae_acct.slct.archive_id = archive_id; + + if (browser) { + if (log_lvl) { + console.log(`ae_idaa_archives archives [archive_id] +page.ts: archive_id = `, archive_id); + } + // Load event archive object + let load_archive_obj = archives_func.load_ae_obj_id__archive({ + api_cfg: ae_acct.api, + archive_id: archive_id, + inc_content_li: true, + try_cache: true + }); + + ae_acct.slct.archive_obj = load_archive_obj; + + // Load archive contents for the archive + // let load_archive_content_obj_li = archives_func.load_ae_obj_li__archive_content({ + // api_cfg: ae_acct.api, + // for_obj_type: 'archive', + // for_obj_id: archive_id, + // params: {qry__enabled: 'all', qry__limit: 99}, + // try_cache: true + // }) + // .then((archive_content_obj_li) => { + // if (log_lvl) { + // console.log(`archive_content_obj_li = `, archive_content_obj_li); + // } + // for (let index = 0; index < archive_content_obj_li.length; index++) { + // let archive_content_obj = archive_content_obj_li[index]; + // let archive_content_id = archive_content_obj.archive_content_id_random; + + // let load_archive_content_obj_li = archives_func.load_ae_obj_li__archive_content({ + // api_cfg: ae_acct.api, + // for_obj_type: 'archive_content', + // for_obj_id: archive_content_id, + // params: {qry__enabled: 'all', qry__limit: 15}, + // try_cache: true + // }); + // if (log_lvl) { + // console.log(`load_archive_content_obj_li = `, load_archive_content_obj_li); + // } + // archive_content_obj_li[index].archive_content_li = load_archive_content_obj_li; + // } + + // return archive_content_obj_li; + // }); + // if (log_lvl) { + // console.log(`load_archive_content_obj_li = `, load_archive_content_obj_li); + // } + // ae_acct.slct.archive_content_obj_li = load_archive_content_obj_li; + + } + + // WARNING: Precaution against shared data between sites and presentations. + data[account_id] = ae_acct; + + return data; +} diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_content_obj_li.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_content_obj_li.svelte new file mode 100644 index 00000000..88b89eba --- /dev/null +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_content_obj_li.svelte @@ -0,0 +1,223 @@ + + + +
+{#if $lq__archive_content_obj_li && $lq__archive_content_obj_li.length} + +{#each $lq__archive_content_obj_li as idaa_archive_content_obj, index} +
+ +
+

+ {@html idaa_archive_content_obj.name} +

+ + {#if idaa_archive_content_obj.original_location} + — +

+ + {idaa_archive_content_obj.original_location} +

+ {/if} +
+ + {#if idaa_archive_content_obj.description}
{@html idaa_archive_content_obj.description}
{/if} + +
+ + + {#if $ae_loc.trusted_access && idaa_archive_content_obj?.hosted_file_id} + + + + + {/if} + + {#if $ae_loc.trusted_access} + + {/if} +
+ + + {#if idaa_archive_content_obj.archive_content_id == $idaa_sess.archives.show_view__archive_content_media} + + Player Goes Here + {/if} + + +
+ {#if idaa_archive_content_obj?.description} +
+
Description:
+
+ {idaa_archive_content_obj?.description} +
+
+ {/if} + + {#if idaa_archive_content_obj?.content_html} +
+
Content:
+
+ {@html idaa_archive_content_obj?.content_html} +
+
+ {/if} + +
+ Original date/time: + {#if idaa_archive_content_obj.original_datetime} + {ae_util.iso_datetime_formatter(idaa_archive_content_obj.original_datetime, 'datetime_long')} + {/if} + {#if idaa_archive_content_obj.original_timezone} + Timezone: + {idaa_archive_content_obj.original_timezone} + {/if} +
+ +
+ + + + +
+{/each} + +{:else} +

No archive content available to show.

+{/if} +
+ diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_edit.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_edit.svelte new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_edit.svelte @@ -0,0 +1 @@ + diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_view.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_view.svelte new file mode 100644 index 00000000..b1a374ed --- /dev/null +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/ae_idaa_comp__archive_obj_id_view.svelte @@ -0,0 +1,107 @@ + + + +
+ +
+

{@html $lq__archive_obj?.name} - {$lq__archive_content_obj_li?.length}

+
+ +
+ {#if $lq__archive_obj?.description}
{@html $lq__archive_obj?.description}
{/if} + {#if $lq__archive_obj?.content_html}
{@html $lq__archive_obj?.content_html}
{/if} + {#if $lq__archive_obj?.original_url} +
+ URL: + {$lq__archive_obj?.original_url} +
+ {/if} + {#if $lq__archive_obj?.original_datetime} +
+ Start Date: + {ae_util.iso_datetime_formatter($lq__archive_obj?.original_datetime, 'datetime_long')} +
+ {/if} + {#if $lq__archive_obj?.original_timezone} + Timezone: + {$lq__archive_obj?.original_timezone} + {/if} + {#if $lq__archive_obj?.original_location} +
+ Location: + {$lq__archive_obj?.original_location} +
+ {/if} +
+ +
+
+
+ Created on: + {ae_util.iso_datetime_formatter($lq__archive_obj?.created_on, 'datetime_iso_no_seconds')} + {#if $lq__archive_obj?.updated_on} + Updated on: + {ae_util.iso_datetime_formatter($lq__archive_obj?.updated_on, 'datetime_iso_no_seconds')} + {/if} +
+
+ + {#if $ae_loc.trusted_access} +
+ {#if $ae_loc.trusted_access || $lq__archive_obj?.external_person_id === $idaa_loc.novi_uuid} + + + + {/if} +
+ {/if} +
+ +
\ No newline at end of file diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/del +layout.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/del +layout.svelte new file mode 100644 index 00000000..e69de29b diff --git a/src/routes/idaa/(idaa)/archives/ae_idaa_comp__archive_obj_li.svelte b/src/routes/idaa/(idaa)/archives/ae_idaa_comp__archive_obj_li.svelte index 55d53dc8..6c8b30ec 100644 --- a/src/routes/idaa/(idaa)/archives/ae_idaa_comp__archive_obj_li.svelte +++ b/src/routes/idaa/(idaa)/archives/ae_idaa_comp__archive_obj_li.svelte @@ -43,7 +43,18 @@ onMount(() => { {#if idaa_archive_obj.description}
{@html idaa_archive_obj.description}
{/if}
-