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:
Scott Idem
2026-02-06 14:49:36 -05:00
parent 969e5610bb
commit 67752ccdfe
3 changed files with 131 additions and 47 deletions

View File

@@ -1,6 +1,4 @@
<script lang="ts">
// Imports
// Import components and elements
// import Element_input_files_tbl from '$lib/element_input_files_tbl.svelte';
@@ -102,17 +100,20 @@
let new_filename = formData.get('new_filename') as string;
$ae_sess.files.processed_file_kv[hosted_file_id] = {};
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status =
'clipping';
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = false;
// $ae_sess.files.disable_submit__hosted_file_obj = true;
$ae_loc.files.processed_file_kv[hosted_file_id] = {};
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipping';
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status =
'clipping';
$ae_loc.files.processed_file_kv[hosted_file_id].start_time = start_time;
$ae_loc.files.processed_file_kv[hosted_file_id].end_time = end_time;
$ae_loc.files.processed_file_kv[hosted_file_id].reencode = reencode;
$ae_loc.files.processed_file_kv[hosted_file_id].scale_down = scale_down;
$ae_loc.files.processed_file_kv[hosted_file_id].new_filename = new_filename;
$ae_loc.files.processed_file_kv[hosted_file_id].new_filename =
new_filename;
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = false;
let endpoint = `/hosted_file/${hosted_file_id}/clip_video`;
@@ -152,11 +153,15 @@
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id] = {};
// $ae_loc.files.video_clip_file_kv[result.hosted_file_id] = result;
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete = true;
$ae_sess.files.processed_file_kv[hosted_file_id].submit_status =
'clipped';
$ae_sess.files.processed_file_kv[hosted_file_id].clip_complete =
true;
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipped';
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = true;
$ae_loc.files.processed_file_kv[hosted_file_id].submit_status =
'clipped';
$ae_loc.files.processed_file_kv[hosted_file_id].clip_complete =
true;
submit_status = 'clipped';
clip_complete = true;
@@ -181,7 +186,9 @@
{#each Object.entries(hosted_file_obj_kv) as [hosted_file_id, hosted_file_obj]}
<div class="border border-gray-300 rounded-lg p-2 m-2">
<!-- Download Button (Standardized) -->
<div class="flex flex-row flex-wrap gap-1 justify-center items-center w-full">
<div
class="flex flex-row flex-wrap gap-1 justify-center items-center w-full"
>
<!-- Remove from uploaded file kv list -->
<button
type="button"
@@ -193,7 +200,9 @@
);
// delete $ae_sess.files.uploaded_file_kv[hosted_file_id];
delete $ae_loc.files.uploaded_file_kv[hosted_file_id];
$ae_loc.files.uploaded_file_kv = { ...$ae_loc.files.uploaded_file_kv };
$ae_loc.files.uploaded_file_kv = {
...$ae_loc.files.uploaded_file_kv
};
delete hosted_file_obj_kv[hosted_file_id];
hosted_file_obj_kv = { ...hosted_file_obj_kv };
// delete $ae_loc.files.uploaded_file_kv[hosted_file_obj.hosted_file_id];
@@ -212,8 +221,8 @@
<!-- Download the file -->
<div class:hidden={!$ae_loc.edit_mode}>
<AE_Comp_Hosted_Files_Download_Button
hosted_file_id={hosted_file_id}
hosted_file_obj={hosted_file_obj}
{hosted_file_id}
{hosted_file_obj}
color="primary"
variant="tonal"
classes="novi_btn btn-sm lg:btn-md min-w-72 lg:min-w-96 !justify-start"
@@ -250,7 +259,9 @@
value={hosted_file_obj.hosted_file_id}
/>
<div class="flex flex-row gap-1 justify-center items-center w-full">
<div
class="flex flex-row gap-1 justify-center items-center w-full"
>
<span class="text-xs font-bold w-32">New Filename:</span>
<input
type="text"
@@ -267,14 +278,19 @@
class="label w-48"
title="The start time of the clip. This is the time in the video where the clip will start. You may need to subtract a few seconds to get the exact start time."
>
<span class="text-xs font-bold">Start time (HH:MM:SS)</span>
<span class="text-xs font-bold"
>Start time (HH:MM:SS)</span
>
<input
type="text"
name="start_time"
value={$ae_loc.files.processed_file_kv &&
$ae_loc.files.processed_file_kv[hosted_file_id] &&
$ae_loc.files.processed_file_kv[hosted_file_id].start_time
? $ae_loc.files.processed_file_kv[hosted_file_id].start_time
$ae_loc.files.processed_file_kv[hosted_file_id]
.start_time
? $ae_loc.files.processed_file_kv[
hosted_file_id
].start_time
: '00:00:00'}
placeholder="HH:MM:SS (00:01:30)"
class="input w-32"
@@ -285,14 +301,19 @@
class="label w-48"
title="The end time of the clip. This is the time in the video where the clip will end. You may need to add a few seconds to get the exact end time."
>
<span class="text-xs font-bold">End time (HH:MM:SS)</span>
<span class="text-xs font-bold"
>End time (HH:MM:SS)</span
>
<input
type="text"
name="end_time"
value={$ae_loc.files.processed_file_kv &&
$ae_loc.files.processed_file_kv[hosted_file_id] &&
$ae_loc.files.processed_file_kv[hosted_file_id].end_time
? $ae_loc.files.processed_file_kv[hosted_file_id].end_time
$ae_loc.files.processed_file_kv[hosted_file_id]
.end_time
? $ae_loc.files.processed_file_kv[
hosted_file_id
].end_time
: '00:45:59'}
placeholder="HH:MM:SS (01:05:25)"
class="input w-32"
@@ -315,7 +336,12 @@
True
</label>
<label class="inline-block">
<input type="radio" name="reencode" value="false" class="radio" />
<input
type="radio"
name="reencode"
value="false"
class="radio"
/>
False
</label>
</span>
@@ -336,7 +362,12 @@
True
</label>
<label class="inline-block">
<input type="radio" name="scale_down" value="false" class="radio" />
<input
type="radio"
name="scale_down"
value="false"
class="radio"
/>
False
</label>
</span>
@@ -368,7 +399,9 @@
{#await ae_promises[hosted_file_id]}
<span class="fas fa-spinner fa-spin m-1"></span>
<span class="highlight">Processing... This may take a few minutes.</span>
<span class="highlight"
>Processing... This may take a few minutes.</span
>
{:then}
{#if ae_promises[hosted_file_id]}
<span class="fas fa-download"></span> Ready to download below!