refactor: stabilize event file management and ID synchronization

- Updated 'process_ae_obj__event_file_props' to synchronize generic 'for_id' with specific object IDs (e.g., 'event_presenter_id').
- Standardized 'element_manage_event_file_li_direct.svelte' to use specific ID filtering.
- Fixed missing 'prevent_default' in 'ae_comp__hosted_files_clip_video.svelte'.
- Resolved miscellaneous type and syntax errors identified by svelte-check.
This commit is contained in:
Scott Idem
2026-02-06 16:41:44 -05:00
parent 2e8e4c7a7b
commit df9d3ad3d2
5 changed files with 575 additions and 166 deletions

View File

@@ -83,6 +83,13 @@
}; };
// *** Functions and Logic // *** Functions and Logic
function prevent_default<T extends Event>(fn: (event: T) => void) {
return function (event: T) {
event.preventDefault();
fn(event);
};
}
function handle_clip_video(event: Event) { function handle_clip_video(event: Event) {
console.log('*** handle_clip_video() ***'); console.log('*** handle_clip_video() ***');

View File

@@ -22,31 +22,66 @@ export async function load_ae_obj_id__event_file({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_EventFile | null> { }): Promise<ae_EventFile | null> {
if (log_lvl) { if (log_lvl) {
console.log(`*** load_ae_obj_id__event_file() *** [V3] id=${event_file_id} (SWR)`); console.log(
`*** load_ae_obj_id__event_file() *** [V3] id=${event_file_id} (SWR)`
);
} }
if (try_cache) { if (try_cache) {
try { try {
const cached = await db_events.file.get(event_file_id); const cached = await db_events.file.get(event_file_id);
if (cached) { if (cached) {
_refresh_file_id_background({ api_cfg, event_file_id, view, try_cache, log_lvl: 0 }); _refresh_file_id_background({
api_cfg,
event_file_id,
view,
try_cache,
log_lvl: 0
});
return cached; return cached;
} }
} catch (e) {} } catch (e) {}
} }
return await _refresh_file_id_background({ api_cfg, event_file_id, view, try_cache, log_lvl }); return await _refresh_file_id_background({
api_cfg,
event_file_id,
view,
try_cache,
log_lvl
});
} }
async function _refresh_file_id_background({ api_cfg, event_file_id, view, try_cache, log_lvl }: any) { async function _refresh_file_id_background({
api_cfg,
event_file_id,
view,
try_cache,
log_lvl
}: any) {
if (typeof navigator !== 'undefined' && !navigator.onLine) return null; if (typeof navigator !== 'undefined' && !navigator.onLine) return null;
try { try {
const result = await api.get_ae_obj_v3({ api_cfg, obj_type: 'event_file', obj_id: event_file_id, view, log_lvl }); const result = await api.get_ae_obj_v3({
api_cfg,
obj_type: 'event_file',
obj_id: event_file_id,
view,
log_lvl
});
if (result) { if (result) {
const processed = await process_ae_obj__event_file_props({ obj_li: [result], log_lvl }); const processed = await process_ae_obj__event_file_props({
obj_li: [result],
log_lvl
});
const processed_obj = processed[0]; const processed_obj = processed[0];
if (try_cache) { if (try_cache) {
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'file', obj_li: [processed_obj], properties_to_save, log_lvl }); await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'file',
obj_li: [processed_obj],
properties_to_save,
log_lvl
});
} }
return processed_obj; return processed_obj;
} }
@@ -84,30 +119,92 @@ export async function load_ae_obj_li__event_file({
log_lvl?: number; log_lvl?: number;
}): Promise<ae_EventFile[]> { }): Promise<ae_EventFile[]> {
if (log_lvl) { if (log_lvl) {
console.log(`*** load_ae_obj_li__event_file() *** [V3] for=${for_obj_type}:${for_obj_id} (SWR)`); console.log(
`*** load_ae_obj_li__event_file() *** [V3] for=${for_obj_type}:${for_obj_id} (SWR)`
);
} }
if (try_cache) { if (try_cache) {
try { try {
const cached_li = await db_events.file.where('for_id').equals(for_obj_id).toArray(); const cached_li = await db_events.file
.where('for_id')
.equals(for_obj_id)
.toArray();
if (cached_li && cached_li.length > 0) { if (cached_li && cached_li.length > 0) {
_refresh_file_li_background({ api_cfg, for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl: 0 }); _refresh_file_li_background({
api_cfg,
for_obj_type,
for_obj_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
try_cache,
log_lvl: 0
});
return cached_li; return cached_li;
} }
} catch (e) {} } catch (e) {}
} }
return await _refresh_file_li_background({ api_cfg, for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl }); return await _refresh_file_li_background({
api_cfg,
for_obj_type,
for_obj_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
try_cache,
log_lvl
});
} }
async function _refresh_file_li_background({ api_cfg, for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, try_cache, log_lvl }: any) { async function _refresh_file_li_background({
api_cfg,
for_obj_type,
for_obj_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
try_cache,
log_lvl
}: any) {
if (typeof navigator !== 'undefined' && !navigator.onLine) return []; if (typeof navigator !== 'undefined' && !navigator.onLine) return [];
try { try {
const result_li = await api.get_ae_obj_li_v3({ api_cfg, obj_type: 'event_file', for_obj_type, for_obj_id, enabled, hidden, view, limit, offset, order_by_li, log_lvl }); const result_li = await api.get_ae_obj_li_v3({
api_cfg,
obj_type: 'event_file',
for_obj_type,
for_obj_id,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
log_lvl
});
if (result_li) { if (result_li) {
const processed = await process_ae_obj__event_file_props({ obj_li: result_li, log_lvl }); const processed = await process_ae_obj__event_file_props({
obj_li: result_li,
log_lvl
});
if (try_cache) { if (try_cache) {
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'file', obj_li: processed, properties_to_save, log_lvl }); await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'file',
obj_li: processed,
properties_to_save,
log_lvl
});
} }
return processed; return processed;
} }
@@ -165,7 +262,13 @@ export async function delete_ae_obj_id__event_file({
try_cache?: boolean; try_cache?: boolean;
log_lvl?: number; log_lvl?: number;
}) { }) {
const result = await api.delete_ae_obj_v3({ api_cfg, obj_type: 'event_file', obj_id: event_file_id, params: { ...params, delete_hosted_file: true, rm_orphan: true }, log_lvl }); const result = await api.delete_ae_obj_v3({
api_cfg,
obj_type: 'event_file',
obj_id: event_file_id,
params: { ...params, delete_hosted_file: true, rm_orphan: true },
log_lvl
});
if (try_cache) await db_events.file.delete(event_file_id); if (try_cache) await db_events.file.delete(event_file_id);
return result; return result;
} }
@@ -185,27 +288,111 @@ export async function update_ae_obj__event_file({
try_cache?: boolean; try_cache?: boolean;
log_lvl?: number; log_lvl?: number;
}): Promise<ae_EventFile | null> { }): Promise<ae_EventFile | null> {
const result = await api.update_ae_obj_v3({ api_cfg, obj_type: 'event_file', obj_id: event_file_id, fields: data_kv, params, log_lvl }); const result = await api.update_ae_obj_v3({
api_cfg,
obj_type: 'event_file',
obj_id: event_file_id,
fields: data_kv,
params,
log_lvl
});
if (result && try_cache) { if (result && try_cache) {
const processed = await process_ae_obj__event_file_props({ obj_li: [result], log_lvl }); const processed = await process_ae_obj__event_file_props({
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'file', obj_li: processed, properties_to_save, log_lvl }); obj_li: [result],
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'file',
obj_li: processed,
properties_to_save,
log_lvl
});
} }
return result; return result;
} }
export async function search__event_file({ export async function search__event_file({
api_cfg, event_id, qry_str = '', qry_created_on = null, qry_min_file_size = null, qry_file_purpose = null, enabled = 'enabled', hidden = 'not_hidden', view = 'default', limit = 25, offset = 0, order_by_li = [{ priority: 'DESC' }, { sort: 'DESC' }, { updated_on: 'DESC' }], try_cache = true, log_lvl = 0 api_cfg,
event_id,
qry_str = '',
qry_created_on = null,
qry_min_file_size = null,
qry_file_purpose = null,
enabled = 'enabled',
hidden = 'not_hidden',
view = 'default',
limit = 25,
offset = 0,
order_by_li = [
{ priority: 'DESC' },
{ sort: 'DESC' },
{ updated_on: 'DESC' }
],
try_cache = true,
log_lvl = 0
}: { }: {
api_cfg: any; event_id: string; qry_str?: string; qry_created_on?: string | null; qry_min_file_size?: null | number; qry_file_purpose?: string | null; enabled?: 'enabled' | 'all' | 'not_enabled'; hidden?: 'hidden' | 'all' | 'not_hidden'; view?: string; limit?: number; offset?: number; order_by_li?: any; try_cache?: boolean; log_lvl?: number; api_cfg: any;
event_id: string;
qry_str?: string;
qry_created_on?: string | null;
qry_min_file_size?: null | number;
qry_file_purpose?: string | null;
enabled?: 'enabled' | 'all' | 'not_enabled';
hidden?: 'hidden' | 'all' | 'not_hidden';
view?: string;
limit?: number;
offset?: number;
order_by_li?: any;
try_cache?: boolean;
log_lvl?: number;
}): Promise<ae_EventFile[]> { }): Promise<ae_EventFile[]> {
const search_query: any = { q: qry_str, and: [{ field: 'event_id', op: 'eq', value: event_id }] }; const search_query: any = {
if (qry_min_file_size) search_query.and.push({ field: 'hosted_file_size', op: 'gt', value: qry_min_file_size }); q: qry_str,
if (qry_created_on) search_query.and.push({ field: 'created_on', op: 'gte', value: qry_created_on }); and: [{ field: 'event_id', op: 'eq', value: event_id }]
if (qry_file_purpose) search_query.and.push({ field: 'file_purpose', op: 'eq', value: qry_file_purpose }); };
const result_li = await api.search_ae_obj_v3({ api_cfg, obj_type: 'event_file', search_query, enabled, hidden, view, order_by_li, limit, offset, log_lvl }); if (qry_min_file_size)
search_query.and.push({
field: 'hosted_file_size',
op: 'gt',
value: qry_min_file_size
});
if (qry_created_on)
search_query.and.push({
field: 'created_on',
op: 'gte',
value: qry_created_on
});
if (qry_file_purpose)
search_query.and.push({
field: 'file_purpose',
op: 'eq',
value: qry_file_purpose
});
const result_li = await api.search_ae_obj_v3({
api_cfg,
obj_type: 'event_file',
search_query,
enabled,
hidden,
view,
order_by_li,
limit,
offset,
log_lvl
});
if (result_li && try_cache) { if (result_li && try_cache) {
const processed = await process_ae_obj__event_file_props({ obj_li: result_li, log_lvl }); const processed = await process_ae_obj__event_file_props({
await db_save_ae_obj_li__ae_obj({ db_instance: db_events, table_name: 'file', obj_li: processed, properties_to_save, log_lvl }); obj_li: result_li,
log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_events,
table_name: 'file',
obj_li: processed,
properties_to_save,
log_lvl
});
} }
return result_li || []; return result_li || [];
} }
@@ -213,10 +400,71 @@ export async function search__event_file({
export const qry__event_file = search__event_file; export const qry__event_file = search__event_file;
export const properties_to_save = [ export const properties_to_save = [
'id', 'event_file_id', 'event_file_id_random', 'hosted_file_id', 'hosted_file_id_random', 'hash_sha256', 'for_type', 'for_id', 'for_id_random', 'event_id', 'event_id_random', 'event_session_id', 'event_presentation_id', 'event_presenter_id', 'event_location_id', 'filename', 'extension', 'open_in_os', 'lu_file_purpose_id', 'lu_event_file_purpose_name', 'file_purpose', 'enable', 'hide', 'priority', 'sort', 'group', 'notes', 'created_on', 'updated_on', 'tmp_sort_1', 'tmp_sort_2', 'filename_no_ext', 'filename_w_ext', 'hosted_file_content_type', 'file_size', 'hosted_file_size', 'event_location_code', 'event_location_name', 'event_session_code', 'event_session_type_code', 'event_session_name', 'event_session_start_datetime', 'event_session_end_datetime', 'event_presentation_code', 'event_presentation_type_code', 'event_presentation_name', 'event_presentation_start_datetime', 'event_presentation_end_datetime', 'event_presenter_given_name', 'event_presenter_family_name', 'event_presenter_full_name', 'event_presenter_email' 'id',
'event_file_id',
'event_file_id_random',
'hosted_file_id',
'hosted_file_id_random',
'hash_sha256',
'for_type',
'for_id',
'for_id_random',
'event_id',
'event_id_random',
'event_session_id',
'event_presentation_id',
'event_presenter_id',
'event_location_id',
'filename',
'extension',
'open_in_os',
'lu_file_purpose_id',
'lu_event_file_purpose_name',
'file_purpose',
'enable',
'hide',
'priority',
'sort',
'group',
'notes',
'created_on',
'updated_on',
'tmp_sort_1',
'tmp_sort_2',
'filename_no_ext',
'filename_w_ext',
'hosted_file_content_type',
'file_size',
'hosted_file_size',
'event_location_code',
'event_location_name',
'event_session_code',
'event_session_type_code',
'event_session_name',
'event_session_start_datetime',
'event_session_end_datetime',
'event_presentation_code',
'event_presentation_type_code',
'event_presentation_name',
'event_presentation_start_datetime',
'event_presentation_end_datetime',
'event_presenter_given_name',
'event_presenter_family_name',
'event_presenter_full_name',
'event_presenter_email'
]; ];
async function _process_generic_props<T extends Record<string, any>>({ obj_li, obj_type, log_lvl = 0, specific_processor }: { obj_li: T[]; obj_type: string; log_lvl?: number; specific_processor?: (obj: T) => Promise<T> | T; }): Promise<T[]> { async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (!obj_li || obj_li.length === 0) return []; if (!obj_li || obj_li.length === 0) return [];
const processed_obj_li: T[] = []; const processed_obj_li: T[] = [];
for (const original_obj of obj_li) { for (const original_obj of obj_li) {
@@ -228,20 +476,53 @@ async function _process_generic_props<T extends Record<string, any>>({ obj_li, o
} }
} }
const randomIdKey = `${obj_type}_id_random`; const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) (processed_obj as any).id = processed_obj[randomIdKey]; if (processed_obj[randomIdKey])
(processed_obj as any).id = processed_obj[randomIdKey];
const group = processed_obj.group ?? '0'; const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0; const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0'; const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on; const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? ''; const name = processed_obj.name ?? '';
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`; (processed_obj as any).tmp_sort_1 =
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`; `${group}_${priority}_${sort}_${updated}`;
if (specific_processor) processed_obj = await Promise.resolve(specific_processor(processed_obj)); (processed_obj as any).tmp_sort_2 =
`${group}_${priority}_${sort}_${name}_${updated}`;
if (specific_processor)
processed_obj = await Promise.resolve(
specific_processor(processed_obj)
);
processed_obj_li.push(processed_obj as T); processed_obj_li.push(processed_obj as T);
} }
return processed_obj_li; return processed_obj_li;
} }
export async function process_ae_obj__event_file_props({ obj_li, log_lvl = 0 }: { obj_li: any[]; log_lvl?: number; }) { export async function process_ae_obj__event_file_props({
return _process_generic_props({ obj_li, obj_type: 'event_file', log_lvl }); obj_li,
} log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'event_file',
log_lvl,
specific_processor: (obj) => {
// SYNC: Ensure for_id matches the specific object ID it was linked to
if (obj.for_type && !obj.for_id) {
const specific_id_key = `${obj.for_type}_id`;
if (obj[specific_id_key]) {
obj.for_id = obj[specific_id_key];
}
}
// SYNC: Ensure specific object ID is populated if for_id is present
if (obj.for_type && obj.for_id) {
const specific_id_key = `${obj.for_type}_id`;
if (!obj[specific_id_key]) {
obj[specific_id_key] = obj.for_id;
}
}
return obj;
}
});
}

View File

@@ -8,7 +8,14 @@
import { api } from '$lib/api/api'; import { api } from '$lib/api/api';
// import { core_func } from '$lib/ae_core_functions'; // import { core_func } from '$lib/ae_core_functions';
import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/stores/ae_stores'; import {
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { db_events } from '$lib/ae_events/db_events'; import { db_events } from '$lib/ae_events/db_events';
import { import {
events_loc, events_loc,
@@ -55,7 +62,9 @@
console.log( console.log(
`Element - Manage Event File List: link_to_type: ${link_to_type}; link_to_id: ${link_to_id}` `Element - Manage Event File List: link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`
); );
console.log(`allow_basic: ${allow_basic}; allow_moderator: ${allow_moderator}`); console.log(
`allow_basic: ${allow_basic}; allow_moderator: ${allow_moderator}`
);
} }
}); });
@@ -119,12 +128,17 @@
class="svelte_component event_file_uploaded_manage {container_class_li}" class="svelte_component event_file_uploaded_manage {container_class_li}"
class:text-sm={display_mode != 'default'} class:text-sm={display_mode != 'default'}
> >
<h3 class="h6" class:hidden={!$lq__event_file_obj_li?.length || display_mode != 'default'}> <h3
class="h6"
class:hidden={!$lq__event_file_obj_li?.length ||
display_mode != 'default'}
>
Manage Files: Manage Files:
<span <span
class="font-bold bg-success-100 px-4 border rounded-lg border-success-200" class="font-bold bg-success-100 px-4 border rounded-lg border-success-200"
title="Files for {link_to_type ?? '-- not set --'}: {link_to_id ?? title="Files for {link_to_type ?? '-- not set --'}: {link_to_id ??
'-- not set --'} (files: {$lq__event_file_obj_li?.length ?? 'None'})" '-- not set --'} (files: {$lq__event_file_obj_li?.length ??
'None'})"
> >
<span class="fas fa-folder-open mx-1"></span> <span class="fas fa-folder-open mx-1"></span>
{@html $lq__event_file_obj_li {@html $lq__event_file_obj_li
@@ -143,15 +157,15 @@
{#if display_mode === 'default'} {#if display_mode === 'default'}
<th <th
class="text-center" class="text-center"
class:hidden={!allow_basic && !$ae_loc.trusted_access} class:hidden={!allow_basic &&
>Options</th !$ae_loc.trusted_access}>Options</th
> >
{/if} {/if}
{#if display_mode === 'default'} {#if display_mode === 'default'}
<th <th
class="text-center" class="text-center"
class:hidden={!allow_basic && !$ae_loc.trusted_access} class:hidden={!allow_basic &&
>Status</th !$ae_loc.trusted_access}>Status</th
> >
{/if} {/if}
<th class="text-center">Meta</th> <th class="text-center">Meta</th>
@@ -181,8 +195,12 @@
<div <div
class="px-4 py-2 flex flex-col gap-0.5 bg-surface-100/50 rounded-lg border border-surface-500/10" class="px-4 py-2 flex flex-col gap-0.5 bg-surface-100/50 rounded-lg border border-surface-500/10"
> >
<div class="flex flex-row items-center gap-2"> <div
<span class="text-[10px] font-bold uppercase opacity-50 w-24"> class="flex flex-row items-center gap-2"
>
<span
class="text-[10px] font-bold uppercase opacity-50 w-24"
>
Access Link: Access Link:
</span> </span>
<MyClipboard <MyClipboard
@@ -193,7 +211,7 @@
btn_title="Copy the direct download link to the clipboard." btn_title="Copy the direct download link to the clipboard."
btn_class="btn btn-xs preset-tonal-warning hover:preset-filled-warning-500" btn_class="btn btn-xs preset-tonal-warning hover:preset-filled-warning-500"
></MyClipboard> ></MyClipboard>
<MyClipboard <MyClipboard
value={encodeURI( value={encodeURI(
`${$ae_api.base_url}/v3/action/event_file/${event_file_obj?.event_file_id}/download?filename=${event_file_obj?.event_session_code}-${ae_util.clean_filename(event_file_obj?.event_session_name).substring(0, 20)}-${ae_util.clean_filename(event_file_obj?.event_presenter_full_name)}.${event_file_obj?.extension}&key=${$ae_api.account_id}` `${$ae_api.base_url}/v3/action/event_file/${event_file_obj?.event_file_id}/download?filename=${event_file_obj?.event_session_code}-${ae_util.clean_filename(event_file_obj?.event_session_name).substring(0, 20)}-${ae_util.clean_filename(event_file_obj?.event_presenter_full_name)}.${event_file_obj?.extension}&key=${$ae_api.account_id}`
@@ -214,7 +232,8 @@
size="12" size="12"
placeholder="Filename" placeholder="Filename"
bind:value={ bind:value={
$events_sess.pres_mgmt.tmp_val__filename_no_ext $events_sess.pres_mgmt
.tmp_val__filename_no_ext
} }
data-original_value={event_file_obj.filename} data-original_value={event_file_obj.filename}
class="input min-w-72 lg:min-w-96 text-sm bg-warning-100" class="input min-w-72 lg:min-w-96 text-sm bg-warning-100"
@@ -227,10 +246,12 @@
let new_filename = let new_filename =
$events_sess.pres_mgmt.tmp_val__filename_no_ext.trim(); $events_sess.pres_mgmt.tmp_val__filename_no_ext.trim();
// Remove possible double extension // Remove possible double extension
new_filename = new_filename.replace( new_filename =
'.' + event_file_obj.extension, new_filename.replace(
'' '.' +
); event_file_obj.extension,
''
);
// Add the extension back // Add the extension back
new_filename = new_filename =
@@ -239,43 +260,57 @@
event_file_obj.extension; event_file_obj.extension;
// Remove any double dots // Remove any double dots
new_filename = new_filename.replace( new_filename =
/\.\./g, new_filename.replace(
'.' /\.\./g,
); '.'
);
let event_file_data = { let event_file_data = {
filename: new_filename filename: new_filename
}; };
ae_promises.update__event_file_obj = events_func ae_promises.update__event_file_obj =
.update_ae_obj__event_file({ events_func
api_cfg: $ae_api, .update_ae_obj__event_file(
event_file_id: {
event_file_obj.event_file_id, api_cfg:
data_kv: event_file_data, $ae_api,
log_lvl: 0 event_file_id:
}) event_file_obj.event_file_id,
.then(function (update_results) { data_kv:
console.log( event_file_data,
`Update results:`, log_lvl: 0
update_results }
)
.then(
function (
update_results
) {
console.log(
`Update results:`,
update_results
);
$events_sess.pres_mgmt.show_field_edit__filename = false;
}
); );
$events_sess.pres_mgmt.show_field_edit__filename = false;
});
}} }}
class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success" class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success"
title="Save changes" title="Save changes"
> >
{#await ae_promises.update__event_file_obj} {#await ae_promises.update__event_file_obj}
<span class="fas fa-spinner fa-spin mx-1" <span
class="fas fa-spinner fa-spin mx-1"
></span> ></span>
<span class="" <span class=""
>Saving {event_file_obj.extension}</span >Saving {event_file_obj.extension}</span
> >
{:then} {:then}
<span class="fas fa-save mx-1"></span> <span
Save {event_file_obj.extension} filename? class="fas fa-save mx-1"
></span>
Save {event_file_obj.extension}
filename?
{/await} {/await}
</button> </button>
{/if} {/if}
@@ -286,12 +321,14 @@
{#if display_mode === 'default'} {#if display_mode === 'default'}
<td <td
class="event_file__options" class="event_file__options"
class:hidden={!allow_basic && !$ae_loc.trusted_access} class:hidden={!allow_basic &&
!$ae_loc.trusted_access}
> >
<div class="flex flex-col gap-1 text-sm"> <div class="flex flex-col gap-1 text-sm">
<button <button
type="button" type="button"
disabled={!allow_basic && !$ae_loc.trusted_access} disabled={!allow_basic &&
!$ae_loc.trusted_access}
onclick={() => { onclick={() => {
if ( if (
$events_sess.pres_mgmt $events_sess.pres_mgmt
@@ -309,12 +346,14 @@
} }
}} }}
class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success" class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success"
class:preset-tonal-warning={$events_sess.pres_mgmt class:preset-tonal-warning={$events_sess
.pres_mgmt
.show_field_edit__filename == .show_field_edit__filename ==
event_file_obj.event_file_id} event_file_obj.event_file_id}
title={`Rename this file? "${event_file_obj.filename}"}`} title={`Rename this file? "${event_file_obj.filename}"}`}
> >
<span class="fas fa-edit mx-1"></span> <span class="fas fa-edit mx-1"
></span>
{#if $events_sess.pres_mgmt?.show_field_edit__filename == event_file_obj.event_file_id} {#if $events_sess.pres_mgmt?.show_field_edit__filename == event_file_obj.event_file_id}
Cancel? Cancel?
{:else} {:else}
@@ -324,40 +363,57 @@
<button <button
type="button" type="button"
disabled={!allow_basic && !$ae_loc.trusted_access} disabled={!allow_basic &&
!$ae_loc.trusted_access}
onclick={async () => { onclick={async () => {
let event_file_data = { let event_file_data = {
hide: !event_file_obj.hide hide: !event_file_obj.hide
}; };
ae_promises.update__event_file_obj = events_func ae_promises.update__event_file_obj =
.update_ae_obj__event_file({ events_func
api_cfg: $ae_api, .update_ae_obj__event_file(
event_file_id: event_file_obj.event_file_id, {
data_kv: event_file_data, api_cfg:
log_lvl: 0 $ae_api,
}) event_file_id:
.then(function (update_results) { event_file_obj.event_file_id,
console.log( data_kv:
`Update results:`, event_file_data,
update_results log_lvl: 0
}
)
.then(
function (
update_results
) {
console.log(
`Update results:`,
update_results
);
// 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,
enabled:
'all',
hidden: 'all',
// params: params,
try_cache: true
}
);
}
); );
// 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,
enabled: 'all',
hidden: 'all',
// params: params,
try_cache: true
});
});
}} }}
class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success" class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success"
title="Hide this file from the presentation launcher" title="Hide this file from the presentation launcher"
@@ -367,22 +423,28 @@
--> -->
{#await ae_promises.update__event_file_obj} {#await ae_promises.update__event_file_obj}
<span class="fas fa-spinner fa-spin mx-1"></span> <span
class="fas fa-spinner fa-spin mx-1"
></span>
<span class="" <span class=""
>Saving {event_file_obj.extension}</span >Saving {event_file_obj.extension}</span
> >
{:then} {:then}
{#if event_file_obj.hide} {#if event_file_obj.hide}
<span class="fas fa-eye m-1"></span> Unhide File <span class="fas fa-eye m-1"
></span> Unhide File
{:else} {:else}
<span class="fas fa-eye-slash m-1"></span> Hide <span
class="fas fa-eye-slash m-1"
></span> Hide
{/if} {/if}
{/await} {/await}
</button> </button>
<button <button
type="button" type="button"
disabled={!allow_basic && !$ae_loc.trusted_access} disabled={!allow_basic &&
!$ae_loc.trusted_access}
onclick={async () => { onclick={async () => {
if ( if (
!confirm( !confirm(
@@ -395,16 +457,20 @@
// ae_promises[event_file_obj.event_file_id] = handle_delete__event_file({event_file_id: event_file_obj.event_file_id}); // ae_promises[event_file_obj.event_file_id] = handle_delete__event_file({event_file_id: event_file_obj.event_file_id});
ae_promises.delete__event_file_obj = ae_promises.delete__event_file_obj =
await events_func.delete_ae_obj_id__event_file({ await events_func.delete_ae_obj_id__event_file(
api_cfg: $ae_api, {
event_file_id: event_file_obj.event_file_id, api_cfg: $ae_api,
log_lvl: 1 event_file_id:
}); event_file_obj.event_file_id,
log_lvl: 1
}
);
}} }}
class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success" class="btn btn-sm preset-tonal-tertiary hover:preset-tonal-success"
title="Delete this file" title="Delete this file"
> >
<span class="fas fa-trash-alt mx-1"></span> <span class="fas fa-trash-alt mx-1"
></span>
<!-- <span class="fas fa-minus mx-1"></span> --> <!-- <span class="fas fa-minus mx-1"></span> -->
Delete Delete
</button> </button>
@@ -415,22 +481,30 @@
{#if display_mode === 'default'} {#if display_mode === 'default'}
<td <td
class="event_file__status" class="event_file__status"
class:hidden={!allow_basic && !$ae_loc.trusted_access} class:hidden={!allow_basic &&
!$ae_loc.trusted_access}
> >
<div <div
class="flex flex-col gap-1 items-center justify-center text-sm" class="flex flex-col gap-1 items-center justify-center text-sm"
> >
<div class=""> <div class="">
{#if event_file_obj.open_in_os == 'win'} {#if event_file_obj.open_in_os == 'win'}
MS Windows <span class="fab fa-windows"></span> MS Windows <span
class="fab fa-windows"
></span>
{:else if event_file_obj.open_in_os == 'mac'} {:else if event_file_obj.open_in_os == 'mac'}
Apple macOS <span class="fab fa-apple"></span> Apple macOS <span
class="fab fa-apple"
></span>
{/if} {/if}
</div> </div>
<!-- Select from options for the purpose of this file --> <!-- Select from options for the purpose of this file -->
<div> <div>
<label for="file_purpose" class="text-sm mx-1 hidden"> <label
for="file_purpose"
class="text-sm mx-1 hidden"
>
Purpose: Purpose:
</label> </label>
<select <select
@@ -447,26 +521,37 @@
); );
let event_file_data = { let event_file_data = {
event_file_id: event_file_obj.event_file_id, event_file_id:
file_purpose: (e.target as HTMLInputElement).value event_file_obj.event_file_id,
file_purpose: (
e.target as HTMLInputElement
).value
}; };
events_func events_func
.update_ae_obj__event_file({ .update_ae_obj__event_file(
api_cfg: $ae_api, {
event_file_id: api_cfg:
event_file_obj.event_file_id, $ae_api,
data_kv: event_file_data, event_file_id:
log_lvl: 1 event_file_obj.event_file_id,
}) data_kv:
.then(function (update_results) { event_file_data,
console.log( log_lvl: 1
`Update results:`, }
)
.then(
function (
update_results update_results
); ) {
$slct_trigger = console.log(
'load__event_file_obj_li'; `Update results:`,
}); update_results
);
$slct_trigger =
'load__event_file_obj_li';
}
);
// ae_triggers.update_event_file_purpose = true; // ae_triggers.update_event_file_purpose = true;
}} }}
@@ -511,8 +596,13 @@
<div class="flex flex-col gap-0.5 text-xs"> <div class="flex flex-col gap-0.5 text-xs">
<!-- {event_file_obj.hosted_file_content_type} --> <!-- {event_file_obj.hosted_file_content_type} -->
<span class="w-full flex flex-col lg:flex-row justify-between"> <span
<span class:hidden={display_mode != 'default'}> class="w-full flex flex-col lg:flex-row justify-between"
>
<span
class:hidden={display_mode !=
'default'}
>
Type: Type:
<strong <strong
>{event_file_obj.extension} >{event_file_obj.extension}
@@ -533,7 +623,10 @@
{/if} --> {/if} -->
</span> </span>
<span> <span>
<span class:hidden={display_mode != 'default'}> <span
class:hidden={display_mode !=
'default'}
>
Size: Size:
</span> </span>
<strong <strong
@@ -544,46 +637,73 @@
</span> </span>
</span> </span>
<span class="w-full flex flex-col lg:flex-row justify-between"> <span
<span title="SHA 256: {event_file_obj.hash_sha256}"> class="w-full flex flex-col lg:flex-row justify-between"
<span class:hidden={display_mode != 'default'}> >
<span
title="SHA 256: {event_file_obj.hash_sha256}"
>
<span
class:hidden={display_mode !=
'default'}
>
Hash: Hash:
</span> </span>
<strong class:font-normal={display_mode != 'default'} <strong
>{event_file_obj.hash_sha256.slice(0, 10)}…</strong class:font-normal={display_mode !=
'default'}
>{event_file_obj.hash_sha256.slice(
0,
10
)}…</strong
> >
</span> </span>
<span <span
class:hidden={!$ae_loc.administrator_access || class:hidden={!$ae_loc.administrator_access ||
display_mode != 'default'} display_mode != 'default'}
> >
<span class:hidden={display_mode != 'default'}> <span
class:hidden={display_mode !=
'default'}
>
ID: ID:
</span> </span>
<strong>{event_file_obj.hosted_file_id}</strong> <strong
>{event_file_obj.hosted_file_id}</strong
>
</span> </span>
</span> </span>
<!-- If this file was uploaded (created) within the last 15 minutes we want to highlight it in blue. --> <!-- If this file was uploaded (created) within the last 15 minutes we want to highlight it in blue. -->
<span <span
class:bg-yellow-200={ae_util.is_datetime_recent({ class:bg-yellow-200={ae_util.is_datetime_recent(
datetime: event_file_obj?.created_on, {
minutes: 30 datetime:
})} event_file_obj?.created_on,
class:bg-green-200={ae_util.is_datetime_recent({ minutes: 30
datetime: event_file_obj?.created_on, }
minutes: 240 )}
})} class:bg-green-200={ae_util.is_datetime_recent(
class:bg-blue-200={ae_util.is_datetime_recent({ {
datetime: event_file_obj?.created_on, datetime:
minutes: 2880 event_file_obj?.created_on,
})} minutes: 240
}
)}
class:bg-blue-200={ae_util.is_datetime_recent(
{
datetime:
event_file_obj?.created_on,
minutes: 2880
}
)}
> >
{#if display_mode == 'default'} {#if display_mode == 'default'}
<!-- <span class="fas fa-cloud-upload-alt mx-1"></span> --> <!-- <span class="fas fa-cloud-upload-alt mx-1"></span> -->
<!-- Uploaded: --> <!-- Uploaded: -->
<!-- <span class="fas fa-calendar-day mx-1"></span> --> <!-- <span class="fas fa-calendar-day mx-1"></span> -->
<span class="fas fa-clock mx-1"></span> <span class="fas fa-clock mx-1"
></span>
<strong> <strong>
{ae_util.iso_datetime_formatter( {ae_util.iso_datetime_formatter(
event_file_obj.created_on, event_file_obj.created_on,
@@ -627,11 +747,14 @@
</table> </table>
</div> </div>
{:else} {:else}
<p class="w-96 text-center text-gray-500" class:hidden={display_mode != 'default'}> <p
class="w-96 text-center text-gray-500"
class:hidden={display_mode != 'default'}
>
No files uploaded to display No files uploaded to display
</p> </p>
{/if} {/if}
</section> </section>
<style> <style>
</style> </style>

View File

@@ -38,7 +38,7 @@
ae_tmp.show__direct_download = false; ae_tmp.show__direct_download = false;
// let ae_triggers: key_val = {}; // let ae_triggers: key_val = {};
let dq__where_val: string = `${link_to_type}_id_random`; let dq__where_val: string = `${link_to_type}_id`;
let dq__where_eq_val: string = link_to_id; let dq__where_eq_val: string = link_to_id;
// This should include all files that are associated with an object (event, location, session, presenter, etc.) // This should include all files that are associated with an object (event, location, session, presenter, etc.)

View File

@@ -39,9 +39,8 @@
ae_tmp.show__direct_download = false; ae_tmp.show__direct_download = false;
// let ae_triggers: key_val = {}; // let ae_triggers: key_val = {};
let dq__where_val: string = `for_type`; let dq__where_val: string = `${link_to_type}_id`;
let dq__where_eq_val: string = link_to_type; let dq__where_eq_val: string = link_to_id;
let dq__where_for_id_eq_val: string = link_to_id;
// This should only include files that are directly linked to an object (event, location, session, presenter, etc.). // This should only include files that are directly linked to an object (event, location, session, presenter, etc.).
// I am not sure why, but doing reverse() and then sortBy() seems to sort in descending order. // I am not sure why, but doing reverse() and then sortBy() seems to sort in descending order.
@@ -50,7 +49,6 @@
let results = await db_events.file let results = await db_events.file
.where(dq__where_val) .where(dq__where_val)
.equals(dq__where_eq_val) .equals(dq__where_eq_val)
.and((file) => file.for_id == dq__where_for_id_eq_val)
.reverse() .reverse()
.sortBy('created_on'); .sortBy('created_on');
// .toArray() // .toArray()