refactor(lib): standardize helpers and format shared components
- Applied snake_case helper standardization and formatting to element_input_file, hosted_files_clip_video, and websocket_v2. - Cleaned up deprecated legacy imports.
This commit is contained in:
@@ -7,7 +7,14 @@
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
// import { api } from '$lib/api';
|
||||
import { check_hosted_file_obj_w_hash } from '$lib/ae_core/core__check_hosted_file_obj_w_hash';
|
||||
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';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@@ -37,7 +44,16 @@
|
||||
multiple = true,
|
||||
required = true,
|
||||
accept = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh',
|
||||
untrusted_extension_list = ['bin', 'dmg', 'exe', 'js', 'msi', 'php', 'py', 'sh'],
|
||||
untrusted_extension_list = [
|
||||
'bin',
|
||||
'dmg',
|
||||
'exe',
|
||||
'js',
|
||||
'msi',
|
||||
'php',
|
||||
'py',
|
||||
'sh'
|
||||
],
|
||||
legacy_extension_list = ['avi', 'doc', 'ppt', 'xls', 'wmv'],
|
||||
use_selected_file_table = true,
|
||||
file_list_status = $bindable(null),
|
||||
@@ -74,7 +90,9 @@
|
||||
// console.log('*** Start ***');
|
||||
|
||||
// for (let [i, file_item] of file_list.entries()) { // Not sure why this does not work???
|
||||
for await (const [i, file_item] of Array.prototype.entries.call(file_list)) {
|
||||
for await (const [i, file_item] of Array.prototype.entries.call(
|
||||
file_list
|
||||
)) {
|
||||
console.log(i, file_item);
|
||||
|
||||
// NOTE: The file list is readonly. The filenames can not be changed here.
|
||||
@@ -208,7 +226,8 @@
|
||||
} else {
|
||||
}
|
||||
|
||||
file_data['warning_untrusted_extension'] = warning_untrusted_extension;
|
||||
file_data['warning_untrusted_extension'] =
|
||||
warning_untrusted_extension;
|
||||
file_data['warning_legacy_extension'] = warning_legacy_extension;
|
||||
file_data['warning_size'] = warning_size;
|
||||
|
||||
@@ -226,7 +245,9 @@
|
||||
let file_hash = null;
|
||||
|
||||
// Only hash files less than 2 GB (2147483648 bytes)!!!
|
||||
console.log(`File size: ${file_size_bytes / 1048576} MB (${file_size_bytes} bytes)`);
|
||||
console.log(
|
||||
`File size: ${file_size_bytes / 1048576} MB (${file_size_bytes} bytes)`
|
||||
);
|
||||
if (file_size_bytes < 2000000000) {
|
||||
// > 2 GB 2 147 483 648
|
||||
file_hash = await ae_util.get_file_hash(file_item);
|
||||
@@ -243,10 +264,11 @@
|
||||
);
|
||||
file_data['hash_sha256'] = file_hash;
|
||||
|
||||
let check_hosted_file_obj_w_hash_result = await check_hosted_file_obj_w_hash({
|
||||
api_cfg: $ae_api,
|
||||
hosted_file_hash: file_hash
|
||||
});
|
||||
let check_hosted_file_obj_w_hash_result =
|
||||
await check_hosted_file_obj_w_hash({
|
||||
api_cfg: $ae_api,
|
||||
hosted_file_hash: file_hash
|
||||
});
|
||||
|
||||
// console.log(check_hosted_file_obj_w_hash_result);
|
||||
|
||||
@@ -282,7 +304,9 @@
|
||||
const dt = new DataTransfer();
|
||||
// let input = document.getElementById(input_element_id);
|
||||
|
||||
let input_element = document.querySelector('input[type="file"].svelte_input_file_element');
|
||||
let input_element = document.querySelector(
|
||||
'input[type="file"].svelte_input_file_element'
|
||||
);
|
||||
|
||||
if (!input_element) {
|
||||
console.error('Could not find the input element.');
|
||||
@@ -370,7 +394,8 @@
|
||||
<div
|
||||
class="file_list_status ae_warning preset-tonal-warning border border-warning-500 p-1 m-1"
|
||||
>
|
||||
<span class="fas fa-spinner fa-spin m-1"></span> Processing selected file list...
|
||||
<span class="fas fa-spinner fa-spin m-1"></span> Processing selected file
|
||||
list...
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -406,9 +431,13 @@
|
||||
</button>
|
||||
</td>
|
||||
<td class="file_filename">{file_list_item.filename}</td>
|
||||
<td class="file_last_modified">{file_list_item.modified_datetime_string}</td
|
||||
<td class="file_last_modified"
|
||||
>{file_list_item.modified_datetime_string}</td
|
||||
>
|
||||
<td
|
||||
class="file_size"
|
||||
class:bg-pink-200={file_list_item.warning_size}
|
||||
>
|
||||
<td class="file_size" class:bg-pink-200={file_list_item.warning_size}>
|
||||
{file_list_item.file_size_string}
|
||||
<!-- {#if $ae_sess.api_upload_kv[link_to_id]}
|
||||
<span class="text-xs">({$ae_sess.api_upload_kv[link_to_id].percent_completed}%)</span>
|
||||
|
||||
Reference in New Issue
Block a user