Now with upload and download percent! Also better editing for session POC.

This commit is contained in:
Scott Idem
2024-06-21 12:25:36 -04:00
parent fd114bce22
commit 2552e1a839
11 changed files with 433 additions and 64 deletions

View File

@@ -436,6 +436,90 @@ function send_sign_in_poc_email(
<span class="fas fa-barcode"></span>
{$lq__event_session_obj.code}
</span>
{#if $ae_loc.trusted_access}
<Element_ae_crud
trigger_patch={ae_triggers.update_event_session}
api_cfg={$ae_api}
object_type={'event_session'}
object_id={$lq__event_session_obj?.event_session_id_random}
field_name={'name'}
field_type={'text'}
field_value={ae_tmp.name}
allow_null={false}
hide_edit_btn={true}
outline_element={false}
show_crud={false}
display_inline={true}
class_li={'m-1'}
on:ae_crud_updated={e => {
console.log(`ae_crud_updated:`, e.detail);
events_func.handle_load_ae_obj_id__event_session({api_cfg: $ae_api, event_session_id: $lq__event_session_obj?.event_session_id_random, log_lvl: 1})
.then(function (load_results) {
ae_tmp.name = null;
ae_tmp.show__edit_name = false;
// Maybe reload page?
// window.location.reload();
});
}}
>
{#if ae_tmp?.show__edit_name}
<input
type="text"
bind:value={ae_tmp.name}
class="input min-w-fit max-w-md text-sm"
/>
<button
type="button"
disabled={ae_tmp.name == $lq__event_session_obj?.name}
on:click={() => {
console.log('Save the session name.');
let name = ae_tmp.name;
console.log('New session name:', name);
ae_triggers.update_event_session = true;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
>
<span class="fas fa-save mx-1"></span>
Save
</button>
{/if}
{#if ae_tmp.show__edit_name}
<button
type="button"
on:click={() => {
console.log('Cancel the session name.');
ae_tmp.name = null;
ae_tmp.show__edit_name = false;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
>
<span class="fas fa-times mx-1"></span>
Cancel
</button>
{:else}
<button
type="button"
on:click={() => {
console.log('Edit the session name.');
ae_tmp.name = $lq__event_session_obj?.name;
ae_tmp.show__edit_name = true;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
>
<span class="fas fa-edit mx-1"></span>
Edit
</button>
{/if}
</Element_ae_crud>
{/if}
</li>
<li>
<strong class="text-sm">Date time:</strong> {ae_util.iso_datetime_formatter($lq__event_session_obj.start_datetime, 'datetime_long')} - {ae_util.iso_datetime_formatter($lq__event_session_obj.end_datetime, 'datetime_long')}
@@ -548,7 +632,8 @@ function send_sign_in_poc_email(
$slct.person_obj_li = core_func.handle_load_ae_obj_li__person({api_cfg: $ae_api, account_id: $slct.account_id, params: params});
ae_tmp.poc_person_id = $lq__event_session_obj?.poc_person_id_random;ae_tmp.show__edit_poc_person = true;
ae_tmp.poc_person_id = $lq__event_session_obj?.poc_person_id_random;
ae_tmp.show__edit_poc_person = true;
}}
class="btn btn-sm variant-soft-warning hover:variant-ghost-warning"
>
@@ -917,6 +1002,7 @@ function send_sign_in_poc_email(
class="input min-w-96 max-w-96 text-sm"
/>
<!-- disabled={$events_slct.event_presentation_obj.name == event_presentation_obj.name} -->
<button
type="button"
on:click={() => {
@@ -1206,8 +1292,8 @@ function send_sign_in_poc_email(
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Downloading
{#if $ae_sess.download[`/hosted_file/${event_file_obj.hosted_file_id_random}/download`]}
{$ae_sess.download[`/hosted_file/${event_file_obj.hosted_file_id_random}/download`].percent_completed}%
{#if $ae_sess.api_download_kv[event_file_obj.hosted_file_id_random]}
{$ae_sess.api_download_kv[event_file_obj.hosted_file_id_random].percent_completed}%
{/if}
:
</span>

View File

@@ -191,8 +191,14 @@ async function handle_input_upload_files(input_upload_files) {
// Uncomment and the post_promise is not seen by the "await" below
// post_promise = await api.post_object({api_cfg: $cfg.api, endpoint: endpoint, params: params, data:form_data});
// Uncomment so that the post_promise is not seen by the "await" below
ae_promises.upload__hosted_file_obj = await api.post_object({api_cfg: $ae_api, endpoint: endpoint, params: params, form_data: form_data})
ae_promises.upload__hosted_file_obj = api.post_object({
api_cfg: $ae_api,
endpoint: endpoint,
params: params,
form_data: form_data,
task_id: link_to_id,
log_lvl: 1
})
.then(async function (result) {
// NOTE: The /hosted_file/upload_files endpoint will always return a list of successful files uploaded. In this case we are only uploading one file and expecting a list of one item.
let x = 0;
@@ -442,8 +448,28 @@ WARNING: The file upload and management is a work in progress. You can upload an
// handle_submit_form;
}}
>
<span class="fas fa-save mx-1"></span>
{#await ae_promises.upload__hosted_file_obj}
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Uploading
{#if $ae_sess.api_upload_kv[$events_slct.event_presenter_id]}
{$ae_sess.api_upload_kv[$events_slct.event_presenter_id].percent_completed}%
{/if}
</span>
{:then}
<span class="fas fa-upload mx-1"></span>
<span class="text-sm">
Upload:
</span>
<!-- <span class="fas fa-save mx-1"></span> -->
<span class="grow">
File
</span>
{/await}
<!-- <span class="fas fa-save mx-1"></span>
<span class="grow">
Upload File
</span> -->
</button>
</form>
@@ -482,8 +508,8 @@ WARNING: The file upload and management is a work in progress. You can upload an
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">
Downloading
{#if $ae_sess.download[`/hosted_file/${event_file_obj.hosted_file_id_random}/download`]}
{$ae_sess.download[`/hosted_file/${event_file_obj.hosted_file_id_random}/download`].percent_completed}%
{#if $ae_sess.api_download_kv[event_file_obj.hosted_file_id_random]}
{$ae_sess.api_download_kv[event_file_obj.hosted_file_id_random].percent_completed}%
{/if}
:
</span>