Now with more download and copy link options.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { process_permission_checks } from './ae_utils__perm_checks';
|
||||
import { iso_datetime_formatter } from './ae_utils__datetime_format';
|
||||
import { is_datetime_recent } from './ae_utils__is_datetime_recent';
|
||||
import { format_bytes, guess_file_name, guess_file_extension, get_file_hash } from './ae_utils__files';
|
||||
import { clean_filename, format_bytes, guess_file_name, guess_file_extension, get_file_hash } from './ae_utils__files';
|
||||
|
||||
type key_str = {
|
||||
[key: string]: string;
|
||||
@@ -710,6 +710,7 @@ export let ae_util = {
|
||||
is_datetime_recent: is_datetime_recent,
|
||||
process_permission_checks: process_permission_checks,
|
||||
iso_datetime_formatter: iso_datetime_formatter,
|
||||
clean_filename: clean_filename,
|
||||
format_bytes: format_bytes,
|
||||
number_w_commas: number_w_commas,
|
||||
guess_file_name: guess_file_name,
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
// These are all file related functions.
|
||||
|
||||
// Use a defined list of unacceptable characters to remove from a filename.
|
||||
// Updated 2024-10-18
|
||||
export let clean_filename = function clean_filename(filename: any|string, unacceptable_chars: RegExp = /[ <>:"/\\|?*]/g, replacement_char: string = '_') {
|
||||
// console.log('*** clean_filename() ***');
|
||||
if (!filename) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let cleaned_filename = filename.replace(unacceptable_chars, replacement_char);
|
||||
// console.log(cleaned_filename);
|
||||
return cleaned_filename;
|
||||
}
|
||||
|
||||
|
||||
export let format_bytes = function format_bytes(
|
||||
bytes: number,
|
||||
decimals: number = 2
|
||||
|
||||
@@ -30,7 +30,7 @@ export let display_mode: string = 'default'; // 'default', 'compact', 'minimal',
|
||||
let ae_promises: key_val = {};
|
||||
let ae_tmp: key_val = {};
|
||||
ae_tmp.show__file_li = true;
|
||||
ae_tmp.show__direct_download = false;
|
||||
ae_tmp.show__direct_download = $events_loc.pres_mgmt.show__direct_download;
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
onMount(() => {
|
||||
@@ -196,30 +196,95 @@ onMount(() => {
|
||||
{event_file_obj.file_purpose}
|
||||
</span>
|
||||
</button>
|
||||
<a
|
||||
href="{$ae_api.base_url}/event/file/{event_file_obj.event_file_id_random}/download?filename={event_file_obj.filename}&x_no_account_id_token=direct-download"
|
||||
class="btn btn-sm variant-soft-secondary m-0.5 *:hover:inline"
|
||||
|
||||
<span
|
||||
class="px-4 py-2 flex flex-col gap-0.5"
|
||||
class:hidden={!ae_tmp.show__direct_download}
|
||||
title={`Download this file:\n${event_file_obj.filename}\n[API] SHA256: ${event_file_obj.hash_sha256.slice(0, 10)}... Hosted ID: ${event_file_obj.hosted_file_id_random} Event File ID: ${event_file_obj.event_file_id_random}`}
|
||||
>
|
||||
<span class="fas fa-download mx-1"></span>
|
||||
<div class="hidden">
|
||||
Download
|
||||
<div class="flex flex-row gap-0.5">
|
||||
<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_random}/download?filename={ae_util.clean_filename(event_file_obj?.filename)}&x_no_account_id_token=direct-download"
|
||||
class="btn btn-sm p-1 variant-soft-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_random} Event File ID: ${event_file_obj?.event_file_id_random}`}
|
||||
>
|
||||
<span class="fas fa-download mx-1"></span>
|
||||
<span class="hidden">
|
||||
Download
|
||||
</span>
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
use:clipboard={encodeURI(`${$ae_api.base_url}/event/file/${event_file_obj?.event_file_id_random}/download?filename=${ae_util.clean_filename(event_file_obj?.filename)}&x_no_account_id_token=direct-download`)}
|
||||
class="btn btn-sm p-1 variant-soft-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the direct download file link: {ae_util.clean_filename(event_file_obj?.filename ?? 'unknown')}"
|
||||
>
|
||||
<span class="fas fa-copy mx-1"></span>
|
||||
<span class="hidden">
|
||||
Copy Link
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
use:clipboard={encodeURI(`${$ae_api.base_url}/event/file/${event_file_obj.event_file_id_random}/download?filename=${event_file_obj.filename}&x_no_account_id_token=direct-download`)}
|
||||
class="btn btn-sm variant-soft-secondary m-0.5 *:hover:inline"
|
||||
class:hidden={!ae_tmp.show__direct_download}
|
||||
title="Copy the direct download file link to the clipboard."
|
||||
>
|
||||
<span class="fas fa-copy mx-1"></span>
|
||||
<div class="hidden">
|
||||
Copy Link
|
||||
|
||||
<div class="flex flex-row gap-0.5">
|
||||
<span class="text-xs text-gray-500 w-32">
|
||||
Session Name:
|
||||
</span>
|
||||
<a
|
||||
href="{$ae_api.base_url}/event/file/{event_file_obj?.event_file_id_random}/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(event_file_obj?.event_presenter_full_name)}.{event_file_obj?.extension}&x_no_account_id_token=direct-download"
|
||||
class="btn btn-sm p-1 variant-soft-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="hidden">
|
||||
Renamed
|
||||
</span>
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
use:clipboard={encodeURI(`${$ae_api.base_url}/event/file/${event_file_obj?.event_file_id_random}/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}&x_no_account_id_token=direct-download`)}
|
||||
class="btn btn-sm p-1 variant-soft-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the renamed file link"
|
||||
>
|
||||
<span class="fas fa-copy mx-1"></span>
|
||||
<span class="hidden">
|
||||
Copy Renamed
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div class="flex flex-row gap-0.5">
|
||||
<span class="text-xs text-gray-500 w-32">
|
||||
Presentation Name:
|
||||
</span>
|
||||
<a
|
||||
href="{$ae_api.base_url}/event/file/{event_file_obj?.event_file_id_random}/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(event_file_obj?.event_presenter_full_name)}.{event_file_obj?.extension}&x_no_account_id_token=direct-download"
|
||||
class="btn btn-sm p-1 variant-soft-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="hidden">
|
||||
Renamed
|
||||
</span>
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
use:clipboard={encodeURI(`${$ae_api.base_url}/event/file/${event_file_obj?.event_file_id_random}/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(event_file_obj?.event_presenter_full_name)}.${event_file_obj?.extension}&x_no_account_id_token=direct-download`)}
|
||||
class="btn btn-sm p-1 variant-soft-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the renamed file link"
|
||||
>
|
||||
<span class="fas fa-copy mx-1"></span>
|
||||
<span class="hidden">
|
||||
Copy Renamed
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
{:else}
|
||||
|
||||
<!-- Show change filename input field here -->
|
||||
<span
|
||||
class="flex flex-col gap-1 text-sm"
|
||||
|
||||
Reference in New Issue
Block a user