refactor: standardize event file actions and apply batch formatting

- Updated 'create_event_file_obj_from_hosted_file_async' to use the modern V3 action endpoint.
- Standardized 'prevent_default' helper names in root Event and Archive components.
- Applied batch formatting (printWidth: 80) across the settings and events modules.
This commit is contained in:
Scott Idem
2026-02-06 16:17:31 -05:00
parent 433862ad00
commit d21e2f8e6f
20 changed files with 846 additions and 453 deletions

View File

@@ -111,11 +111,15 @@
let csv_row = [];
csv_row.push(ae_obj_li[i].event_file_id);
csv_row.push(
ae_obj_li[i].filename ? `"${ae_util.clean_filename(ae_obj_li[i].filename)}"` : ''
ae_obj_li[i].filename
? `"${ae_util.clean_filename(ae_obj_li[i].filename)}"`
: ''
);
csv_row.push(ae_obj_li[i].extension ? ae_obj_li[i].extension : '');
csv_row.push(
ae_obj_li[i].file_size ? ae_util.format_bytes(ae_obj_li[i].file_size) : ''
ae_obj_li[i].file_size
? ae_util.format_bytes(ae_obj_li[i].file_size)
: ''
);
csv_row.push(ae_obj_li[i].hash_sha256.slice(0, 10) + '...');
csv_row.push(
@@ -135,8 +139,16 @@
: ''
);
csv_row.push(ae_obj_li[i].event_session_id ? ae_obj_li[i].event_session_id : '');
csv_row.push(ae_obj_li[i].event_session_code ? ae_obj_li[i].event_session_code : '');
csv_row.push(
ae_obj_li[i].event_session_id
? ae_obj_li[i].event_session_id
: ''
);
csv_row.push(
ae_obj_li[i].event_session_code
? ae_obj_li[i].event_session_code
: ''
);
csv_row.push(ae_obj_li[i].event_session_name ?? '');
csv_row.push(
ae_obj_li[i].event_session_start_datetime
@@ -148,7 +160,9 @@
);
csv_row.push(
ae_obj_li[i].event_presentation_id ? ae_obj_li[i].event_presentation_id : ''
ae_obj_li[i].event_presentation_id
? ae_obj_li[i].event_presentation_id
: ''
);
csv_row.push(ae_obj_li[i].event_presentation_name ?? '');
csv_row.push(
@@ -160,10 +174,16 @@
: ''
);
csv_row.push(ae_obj_li[i].event_presenter_id ? ae_obj_li[i].event_presenter_id : '');
csv_row.push(
ae_obj_li[i].event_presenter_id
? ae_obj_li[i].event_presenter_id
: ''
);
csv_row.push(ae_obj_li[i].event_presenter_full_name ?? '');
csv_row.push(
ae_obj_li[i].event_presenter_email ? ae_obj_li[i].event_presenter_email : ''
ae_obj_li[i].event_presenter_email
? ae_obj_li[i].event_presenter_email
: ''
);
csv_row.push(
@@ -189,17 +209,24 @@
csv_content_str += '\n';
});
const blob = new Blob([csv_content_str], { type: 'text/csv;charset=utf-8;' });
const blob = new Blob([csv_content_str], {
type: 'text/csv;charset=utf-8;'
});
const obj_url = URL.createObjectURL(blob);
const download_link = document.createElement('a');
download_link.setAttribute('href', obj_url);
download_link.setAttribute('download', `file_list_${ae_util.iso_datetime_formatter()}.csv`);
download_link.setAttribute(
'download',
`file_list_${ae_util.iso_datetime_formatter()}.csv`
);
download_link.setAttribute('style', 'display: none;');
download_link.textContent = 'Download CSV';
// document.querySelector('body').appendChild(download_link);
document.getElementById('download_csv_container').appendChild(download_link);
document
.getElementById('download_csv_container')
.appendChild(download_link);
// Automatically download the file
download_link.click();
@@ -216,15 +243,22 @@
>
<!-- {#if event_file_id_random_li && $lq_kv__event_file_obj_li && $lq_kv__event_file_obj_li?.length > 0 && $lq_kv__event_file_obj_li?.length == event_file_id_random_li?.length} -->
{#if $lq__event_file_obj_li && $lq__event_file_obj_li?.length}
<div bind:this={horiz_check_element} id="tbl_container" class="space-y-2 pb-8">
<header class="flex flex-row flex-wrap gap-1 items-center justify-between">
<div
bind:this={horiz_check_element}
id="tbl_container"
class="space-y-2 pb-8"
>
<header
class="flex flex-row flex-wrap gap-1 items-center justify-between"
>
<h2 class="h3">
<span class="text-base"> Results: </span>
{#if $lq__event_file_obj_li.length}
<span
class="text-3xl font-bold preset-filled-success-100-900 px-4 rounded-lg"
title="Count {$lq__event_file_obj_li.length ?? 'None'}"
title="Count {$lq__event_file_obj_li.length ??
'None'}"
>
<span class="fas fa-list-ol mx-4"></span>
{$lq__event_file_obj_li.length ?? 'None'}&times;
@@ -236,14 +270,21 @@
class="flex flex-row flex-wrap gap-1 items-center justify-end"
class:hidden={!$ae_loc.edit_mode}
>
<button type="button"
<button
type="button"
class="btn btn-sm preset-tonal-warning border border-warning-500 mb-1 generate_csv_btn"
onclick={() => {
if (!confirm('Generate and download a CSV file with the file list?')) {
if (
!confirm(
'Generate and download a CSV file with the file list?'
)
) {
return false;
}
let csv_data = generate_file_export_csv($lq__event_file_obj_li);
let csv_data = generate_file_export_csv(
$lq__event_file_obj_li
);
console.log('CSV Data:', csv_data);
}}
>
@@ -253,7 +294,8 @@
<span id="download_csv_container"></span>
{#if show_session_fields}
<button type="button"
<button
type="button"
onclick={() => {
show_session_fields = !show_session_fields;
}}
@@ -266,7 +308,8 @@
Showing Session Fields
</button>
{:else}
<button type="button"
<button
type="button"
onclick={() => {
show_session_fields = !show_session_fields;
}}
@@ -282,7 +325,8 @@
<!-- Show or hide the session code -->
{#if !hide_session_code}
<button type="button"
<button
type="button"
onclick={() => {
hide_session_code = true;
}}
@@ -293,7 +337,8 @@
Showing Session Code
</button>
{:else}
<button type="button"
<button
type="button"
onclick={() => {
hide_session_code = false;
}}
@@ -306,9 +351,11 @@
{/if}
{#if show_presentation_fields}
<button type="button"
<button
type="button"
onclick={() => {
show_presentation_fields = !show_presentation_fields;
show_presentation_fields =
!show_presentation_fields;
}}
class="btn btn-sm {show_presentation_fields
? 'ae_btn_surface'
@@ -319,9 +366,11 @@
Showing Presentation Fields
</button>
{:else}
<button type="button"
<button
type="button"
onclick={() => {
show_presentation_fields = !show_presentation_fields;
show_presentation_fields =
!show_presentation_fields;
}}
class="btn btn-sm {show_presentation_fields
? 'ae_btn_surface'
@@ -335,21 +384,33 @@
</div>
</header>
<table class="table table-auto table-striped w-full text-xs lg:text-sm">
<table
class="table table-auto table-striped w-full text-xs lg:text-sm"
>
<thead class="">
<tr>
<th class="px-4 py-2">
Filename
<!-- ({$lq__event_file_obj_li?.length}&times;) -->
</th>
<th class="px-4 py-2" class:hidden={!show_direct_download}> Link </th>
<th
class="px-4 py-2"
class:hidden={!show_direct_download}
>
Link
</th>
<th class="px-4 py-2">Size</th>
<th class="px-4 py-2">Uploaded</th>
{#if show_location_fields}
<th class="px-4 py-2">Location</th>
{/if}
{#if show_session_fields}
<th class="px-4 py-2" class:hidden={hide_session_code}> Code </th>
<th
class="px-4 py-2"
class:hidden={hide_session_code}
>
Code
</th>
<th class="px-4 py-2"> Session </th>
<th class="px-4 py-2">Start datetime</th>
{/if}
@@ -370,7 +431,7 @@
hosted_file_id={event_file_obj?.hosted_file_id}
hosted_file_obj={event_file_obj}
show_divider={true}
show_direct_download={show_direct_download}
{show_direct_download}
max_filename={50}
classes="btn btn-sm preset-tonal-primary hover:preset-filled-primary-500 min-w-72"
/>
@@ -384,7 +445,9 @@
class:hidden={!show_direct_download}
class="flex flex-row gap-0.5"
>
<span class="text-xs text-gray-500 w-32"> Original: </span>
<span class="text-xs text-gray-500 w-32">
Original:
</span>
<a
href="{$ae_api.base_url}/event/file/{event_file_obj?.event_file_id}/download?filename={ae_util.clean_filename(
event_file_obj?.filename
@@ -392,7 +455,8 @@
class="btn btn-sm p-1 preset-tonal-secondary *:hover:inline lg:text-xs underline"
title={`Download this file:\n${ae_util.clean_filename(event_file_obj?.filename)}\n[API] SHA256: ${event_file_obj?.hash_sha256.slice(0, 10)}...\nHosted ID: ${event_file_obj?.hosted_file_id} Event File ID: ${event_file_obj?.event_file_id}`}
>
<span class="fas fa-download mx-1"></span>
<span class="fas fa-download mx-1"
></span>
<span class="hidden"> Download </span>
</a>
<!-- <button type="button"
@@ -412,7 +476,8 @@
)}
btn_text="Copy Link"
btn_title="Copy the direct download file link: {ae_util.clean_filename(
event_file_obj?.filename ?? 'unknown'
event_file_obj?.filename ??
'unknown'
)}"
btn_class="btn btn-sm p-1 preset-tonal-secondary lg:text-xs"
></MyClipboard>
@@ -422,17 +487,25 @@
class="flex flex-row gap-0.5"
class:hidden={!show_direct_download}
>
<span class="text-xs text-gray-500 w-32"> Session Name: </span>
<span class="text-xs text-gray-500 w-32">
Session Name:
</span>
<a
href="{$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_presentation_name)
.substring(0, 20)}-{ae_util.clean_filename(
.clean_filename(
event_file_obj?.event_presentation_name
)
.substring(
0,
20
)}-{ae_util.clean_filename(
event_file_obj?.event_presenter_full_name
)}.{event_file_obj?.extension}&key={$ae_api.account_id}"
class="btn btn-sm p-1 preset-tonal-secondary *:hover:inline lg:text-xs underline"
title={`Download renamed with session name to: ${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}`}
>
<span class="fas fa-download mx-1"></span>
<span class="fas fa-download mx-1"
></span>
<span class="hidden"> Renamed </span>
</a>
<!-- <button type="button"
@@ -464,14 +537,20 @@
</span>
<a
href="{$ae_api.base_url}/event/file/{event_file_obj?.event_file_id}/download?filename={event_file_obj?.event_session_code}-{ae_util
.clean_filename(event_file_obj?.event_presentation_name)
.substring(0, 20)}-{ae_util.clean_filename(
.clean_filename(
event_file_obj?.event_presentation_name
)
.substring(
0,
20
)}-{ae_util.clean_filename(
event_file_obj?.event_presenter_full_name
)}.{event_file_obj?.extension}&key=${$ae_api.account_id}"
class="btn btn-sm p-1 preset-tonal-secondary *:hover:inline lg:text-xs underline"
title={`Download renamed with presentation name to: ${event_file_obj?.event_session_code}-${ae_util.clean_filename(event_file_obj?.event_presentation_name).substring(0, 20)}-${ae_util.clean_filename(event_file_obj?.event_presenter_full_name)}.${event_file_obj?.extension}`}
>
<span class="fas fa-download mx-1"></span>
<span class="fas fa-download mx-1"
></span>
<span class="hidden"> Renamed </span>
</a>
<!-- <button type="button"
@@ -495,7 +574,9 @@
</div>
</td>
<td class="px-4 py-2"
>{ae_util.format_bytes(event_file_obj?.file_size)}</td
>{ae_util.format_bytes(
event_file_obj?.file_size
)}</td
>
<td class="px-4 py-2">
<div>
@@ -513,18 +594,27 @@
</span>
</div>
<span
class:bg-yellow-200={ae_util.is_datetime_recent({
datetime: event_file_obj?.created_on,
minutes: 30
})}
class:bg-green-200={ae_util.is_datetime_recent({
datetime: event_file_obj?.created_on,
minutes: 240
})}
class:bg-blue-200={ae_util.is_datetime_recent({
datetime: event_file_obj?.created_on,
minutes: 2880
})}
class:bg-yellow-200={ae_util.is_datetime_recent(
{
datetime:
event_file_obj?.created_on,
minutes: 30
}
)}
class:bg-green-200={ae_util.is_datetime_recent(
{
datetime:
event_file_obj?.created_on,
minutes: 240
}
)}
class:bg-blue-200={ae_util.is_datetime_recent(
{
datetime:
event_file_obj?.created_on,
minutes: 2880
}
)}
>
{ae_util.iso_datetime_formatter(
event_file_obj?.created_on,
@@ -544,11 +634,16 @@
{/if}
{#if show_session_fields}
<td class="px-4 py-2 lg:text-xs" class:hidden={hide_session_code}>
{event_file_obj?.event_session_code ?? '-- not set --'}
<td
class="px-4 py-2 lg:text-xs"
class:hidden={hide_session_code}
>
{event_file_obj?.event_session_code ??
'-- not set --'}
</td>
<td class="px-4 py-2 lg:text-xs">
<span class="fas fa-chalkboard-teacher"></span>
<span class="fas fa-chalkboard-teacher"
></span>
<a
href="/events/{event_file_obj?.event_id}/session/{event_file_obj?.event_session_id}"
class="text-blue-500 underline hover:text-blue-800"