|
|
|
|
@@ -26,7 +26,7 @@ let upload__hosted_file_obj_promise: any;
|
|
|
|
|
let prom_api__archive_content_obj: any;
|
|
|
|
|
let prom_api__archive_content_obj__hosted_file: any;
|
|
|
|
|
|
|
|
|
|
let disable_submit_btn = true;
|
|
|
|
|
let disable_submit_btn = false;
|
|
|
|
|
|
|
|
|
|
if ($idaa_slct.archive_content_id) {
|
|
|
|
|
console.log(`Archive Content ID selected: ${$idaa_slct.archive_content_id}`);
|
|
|
|
|
@@ -127,12 +127,11 @@ async function handle_submit_form(event) {
|
|
|
|
|
let archive_content_do: key_val = {};
|
|
|
|
|
|
|
|
|
|
if (!$idaa_slct.archive_content_id) {
|
|
|
|
|
archive_content_do['account_id_random'] = $ae_loc.account_id;
|
|
|
|
|
archive_content_do['archive_id_random'] = $idaa_slct.archive_id;
|
|
|
|
|
// archive_content_do['enable'] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
archive_content_do['name'] = archive_content_di.name;
|
|
|
|
|
|
|
|
|
|
// Check if the description_new_html exists and is a string
|
|
|
|
|
if (typeof $idaa_slct.archive_content_obj.description_new_html === 'string') {
|
|
|
|
|
console.log('New description is a string');
|
|
|
|
|
@@ -148,11 +147,11 @@ async function handle_submit_form(event) {
|
|
|
|
|
archive_content_do['archive_content_type'] = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
archive_content_do['enable_for_public'] = !!!archive_content_di.enable_for_public;
|
|
|
|
|
// archive_content_do['enable_for_public'] = !!!archive_content_di.enable_for_public;
|
|
|
|
|
|
|
|
|
|
archive_content_do['file_path'] = archive_content_di.file_path;
|
|
|
|
|
archive_content_do['filename'] = archive_content_di.filename.trim();
|
|
|
|
|
archive_content_do['file_extension'] = archive_content_di.file_extension.trim();
|
|
|
|
|
// archive_content_do['file_path'] = archive_content_di.file_path;
|
|
|
|
|
archive_content_do['filename'] = archive_content_di?.filename?.trim() ?? null;
|
|
|
|
|
archive_content_do['file_extension'] = archive_content_di?.file_extension?.trim() ?? null;
|
|
|
|
|
|
|
|
|
|
let date_time_str = null;
|
|
|
|
|
let date_part = archive_content_di.original_datetime_date.trim();
|
|
|
|
|
@@ -184,11 +183,8 @@ async function handle_submit_form(event) {
|
|
|
|
|
archive_content_do['group'] = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if the enable exists and is a string
|
|
|
|
|
console.log(`archive_content_di.enable = ${archive_content_di.enable}`);
|
|
|
|
|
// if (typeof archive_content_di.enable !== 'undefined') {
|
|
|
|
|
archive_content_do['enable'] = !!archive_content_di.enable;
|
|
|
|
|
// }
|
|
|
|
|
// console.log(`archive_content_di.enable = ${archive_content_di.enable}`);
|
|
|
|
|
archive_content_do['enable'] = !!archive_content_di.enable;
|
|
|
|
|
|
|
|
|
|
// Check if the notes_new_html exists and is a string
|
|
|
|
|
if (typeof $idaa_slct.archive_content_obj.notes_new_html === 'string') {
|
|
|
|
|
@@ -202,12 +198,11 @@ async function handle_submit_form(event) {
|
|
|
|
|
console.log(archive_content_do);
|
|
|
|
|
|
|
|
|
|
if (!$idaa_slct.archive_content_id) {
|
|
|
|
|
create_archive_content_obj_promise = api.create_ae_obj_crud({
|
|
|
|
|
prom_api__archive_content_obj = archives_func.create_ae_obj__archive_content({
|
|
|
|
|
api_cfg: $ae_api,
|
|
|
|
|
obj_type: 'archive_content',
|
|
|
|
|
fields: archive_content_do,
|
|
|
|
|
key: $ae_api.api_crud_super_key,
|
|
|
|
|
log_lvl: 1
|
|
|
|
|
archive_id: $idaa_slct.archive_id,
|
|
|
|
|
data_kv: archive_content_do,
|
|
|
|
|
log_lvl: 2
|
|
|
|
|
})
|
|
|
|
|
.then(async function (archive_content_obj_create_result) {
|
|
|
|
|
if (!archive_content_obj_create_result) {
|
|
|
|
|
@@ -216,78 +211,17 @@ async function handle_submit_form(event) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$idaa_slct.archive_content_id = archive_content_obj_create_result.obj_id_random;
|
|
|
|
|
$idaa_slct.archive_content_obj = archive_content_obj_create_result;
|
|
|
|
|
|
|
|
|
|
// Get ready to upload the file now that we have a new archive_content_id.
|
|
|
|
|
const form_data = new FormData();
|
|
|
|
|
|
|
|
|
|
form_data.append('account_id', $ae_loc.account_id);
|
|
|
|
|
form_data.append('link_to_type', 'archive_content');
|
|
|
|
|
form_data.append('link_to_id', $idaa_slct.archive_content_id);
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < event.target.file_list.files.length; i++) {
|
|
|
|
|
form_data.append(`file_list`, event.target.archive_content_file_upload_list.files[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let params = null;
|
|
|
|
|
|
|
|
|
|
let endpoint = '/hosted_file/upload_files';
|
|
|
|
|
|
|
|
|
|
console.log(form_data);
|
|
|
|
|
|
|
|
|
|
params = null;
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
upload__hosted_file_obj_promise = await api.post_object({api_cfg: $ae_api, endpoint: endpoint, params: params, form_data: form_data});
|
|
|
|
|
console.log(upload__hosted_file_obj_promise);
|
|
|
|
|
let hosted_file_id = upload__hosted_file_obj_promise[0].hosted_file_id_random;
|
|
|
|
|
|
|
|
|
|
archive_content_do = {};
|
|
|
|
|
archive_content_do['hosted_file_id_random'] = hosted_file_id;
|
|
|
|
|
archive_content_do['file_path'] = `/hosted_file/download/${hosted_file_id}?filename=${archive_content_di.filename.trim()}`;
|
|
|
|
|
archive_content_do['archive_content_type'] = 'hosted_file';
|
|
|
|
|
|
|
|
|
|
update_archive_content_obj_promise = await api.update_ae_obj_id_crud({
|
|
|
|
|
api_cfg: $ae_api,
|
|
|
|
|
obj_type: 'archive_content',
|
|
|
|
|
obj_id: $idaa_slct.archive_content_id,
|
|
|
|
|
fields: archive_content_do,
|
|
|
|
|
key: $ae_api.api_crud_super_key,
|
|
|
|
|
log_lvl: 1
|
|
|
|
|
})
|
|
|
|
|
.then(function (archive_content_obj_update_result) {
|
|
|
|
|
if (!archive_content_obj_update_result) {
|
|
|
|
|
console.log('The result was null or false.');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return archive_content_obj_update_result;
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log('Something went wrong.');
|
|
|
|
|
console.log(error);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// update_archive_content_obj_promise = await update_archive_content_obj({archive_content_id: $idaa_slct.archive_content_id, data: archive_content_do})
|
|
|
|
|
// console.log(update_archive_content_obj_promise);
|
|
|
|
|
return update_archive_content_obj_promise
|
|
|
|
|
})
|
|
|
|
|
.then(function (archive_content_obj_create_result) {
|
|
|
|
|
|
|
|
|
|
// dispatch(
|
|
|
|
|
// 'created__archive_content_obj',
|
|
|
|
|
// {
|
|
|
|
|
// archive_content_id: $idaa_slct.archive_content_id,
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
return archive_content_obj_create_result;
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log('Something went wrong.');
|
|
|
|
|
console.log(error);
|
|
|
|
|
return false;
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
disable_submit_btn = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return create_archive_content_obj_promise;
|
|
|
|
|
@@ -313,46 +247,16 @@ async function handle_submit_form(event) {
|
|
|
|
|
return false;
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
// We need to do this since the comment has changed and the idaa_slct object does automatically update (yet...???).
|
|
|
|
|
$idaa_slct.archive_content_obj = $lq__archive_content_obj;
|
|
|
|
|
disable_submit_btn = false;
|
|
|
|
|
// $idaa_sess.archives.show__modal_edit__archive_content_id = false;
|
|
|
|
|
// We need to do all of this since the DB object has changed and the SLCT object does automatically update (yet...??? Svelte 5?).
|
|
|
|
|
// $idaa_slct.archive_content_obj = await $lq__archive_content_obj;
|
|
|
|
|
|
|
|
|
|
$idaa_slct.archive_content_id = null;
|
|
|
|
|
$idaa_slct.archive_content_obj = {};
|
|
|
|
|
$idaa_sess.archives.show__modal_edit__archive_content_id = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return prom_api__archive_content_obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// update_archive_content_obj_promise = api.update_ae_obj_id_crud({
|
|
|
|
|
// api_cfg: $ae_api,
|
|
|
|
|
// obj_type: 'archive_content',
|
|
|
|
|
// obj_id: $idaa_slct.archive_content_id,
|
|
|
|
|
// fields: archive_content_do,
|
|
|
|
|
// key: $ae_api.api_crud_super_key,
|
|
|
|
|
// log_lvl: 1
|
|
|
|
|
// })
|
|
|
|
|
// .then(function (archive_content_obj_update_result) {
|
|
|
|
|
// if (!archive_content_obj_update_result) {
|
|
|
|
|
// console.log('The result was null or false.');
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // dispatch(
|
|
|
|
|
// // 'updated__archive_content_obj',
|
|
|
|
|
// // {
|
|
|
|
|
// // archive_content_id: $idaa_slct.archive_content_id,
|
|
|
|
|
// // }
|
|
|
|
|
// // );
|
|
|
|
|
|
|
|
|
|
// return archive_content_obj_update_result;
|
|
|
|
|
// })
|
|
|
|
|
// .catch(function (error) {
|
|
|
|
|
// console.log('Something went wrong.');
|
|
|
|
|
// console.log(error);
|
|
|
|
|
// return false;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// return update_archive_content_obj_promise;
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$: if ($idaa_slct.archive_content_obj.upload_complete && $idaa_slct.archive_content_obj.hosted_file_id_li?.length && $idaa_slct.archive_content_obj.hosted_file_obj_li?.length) {
|
|
|
|
|
@@ -441,7 +345,7 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
|
|
|
|
<select
|
|
|
|
|
id="archive_content_type"
|
|
|
|
|
name="archive_content_type"
|
|
|
|
|
value={$idaa_slct.archive_content_obj.archive_content_type}
|
|
|
|
|
bind:value={$idaa_slct.archive_content_obj.archive_content_type}
|
|
|
|
|
class="select w-52"
|
|
|
|
|
>
|
|
|
|
|
<option value="">-- None --</option>
|
|
|
|
|
@@ -476,51 +380,42 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
|
|
|
|
>
|
|
|
|
|
</label>
|
|
|
|
|
</fieldset> -->
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<h3>File?</h3>
|
|
|
|
|
<section
|
|
|
|
|
class="ae_section archive_content__hosted_file border border-gray-200 rounded p-2 space-y-2"
|
|
|
|
|
class:hidden={$idaa_slct.archive_content_obj.archive_content_type !== 'hosted_file' && !$idaa_slct.archive_content_id}
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
{#if $ae_loc.trusted_access && $idaa_slct.archive_content_id}
|
|
|
|
|
<Comp_hosted_files_upload
|
|
|
|
|
class_li="border border-gray-300 rounded-md p-2 bg-gray-100 hover:bg-gray-200"
|
|
|
|
|
link_to_type="archive_content"
|
|
|
|
|
link_to_id={$idaa_slct.archive_content_obj.archive_content_id}
|
|
|
|
|
bind:hosted_file_id_li={$idaa_slct.archive_content_obj.hosted_file_id_li}
|
|
|
|
|
bind:hosted_file_obj_li={$idaa_slct.archive_content_obj.hosted_file_obj_li}
|
|
|
|
|
bind:upload_complete={$idaa_slct.archive_content_obj.upload_complete}
|
|
|
|
|
log_lvl={2}
|
|
|
|
|
>
|
|
|
|
|
<span slot="label">
|
|
|
|
|
<div>
|
|
|
|
|
<span class="fas fa-upload"></span>
|
|
|
|
|
<strong class="bg-green-100 p-1">Upload archive files</strong>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
|
|
|
|
|
<strong>Aether hosted files only</strong><br>
|
|
|
|
|
Recommended: PowerPoint (pptx) or Keynote (key) or Adobe PDF<br>
|
|
|
|
|
Media: Audio (mp3, m4a) and videos (mp4, mkv)<br>
|
|
|
|
|
Supplemental files: Word Doc, Excel, txt, etc
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</Comp_hosted_files_upload>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<!-- {$idaa_slct.archive_content_obj.hosted_file_id_li?.length ? $idaa_slct.archive_content_obj.hosted_file_id_li.length : 'waiting...'} -->
|
|
|
|
|
<!-- {$idaa_slct.archive_content_obj.upload_complete ? 'Upload complete' : 'Upload not complete'} -->
|
|
|
|
|
<h3 class="h3">Upload/Manage Hosted File</h3>
|
|
|
|
|
|
|
|
|
|
{#if !$idaa_slct.archive_content_obj.hosted_file_id}
|
|
|
|
|
No file uploaded yet.
|
|
|
|
|
|
|
|
|
|
<!-- FILE INPUT GOES HERE -->
|
|
|
|
|
<!-- <Element_input_file_hashing
|
|
|
|
|
multiple = {false}
|
|
|
|
|
required = {true}
|
|
|
|
|
accept = {''}
|
|
|
|
|
element_id = {'archive_content_file_upload_list'}
|
|
|
|
|
|
|
|
|
|
on:input_file_list_updated = {handle_input_file_list_updated}
|
|
|
|
|
use_selected_file_table={true}
|
|
|
|
|
/> -->
|
|
|
|
|
<!-- bind:input_file_list = {$idaa_loc.archives.form_file_upload_list} -->
|
|
|
|
|
{#if $ae_loc.trusted_access}
|
|
|
|
|
<Comp_hosted_files_upload
|
|
|
|
|
class_li="border border-gray-300 rounded-md p-2 bg-gray-100 hover:bg-gray-200"
|
|
|
|
|
link_to_type="archive_content"
|
|
|
|
|
link_to_id={$idaa_slct.archive_content_obj.archive_content_id}
|
|
|
|
|
bind:hosted_file_id_li={$idaa_slct.archive_content_obj.hosted_file_id_li}
|
|
|
|
|
bind:hosted_file_obj_li={$idaa_slct.archive_content_obj.hosted_file_obj_li}
|
|
|
|
|
bind:upload_complete={$idaa_slct.archive_content_obj.upload_complete}
|
|
|
|
|
log_lvl={2}
|
|
|
|
|
>
|
|
|
|
|
<span slot="label">
|
|
|
|
|
<div>
|
|
|
|
|
<span class="fas fa-upload"></span>
|
|
|
|
|
<strong class="bg-green-100 p-1">Upload archive files</strong>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="text-sm text-gray-600 dark:text-gray-400 italic">
|
|
|
|
|
<strong>Aether hosted files only</strong><br>
|
|
|
|
|
Recommended: PowerPoint (pptx) or Keynote (key) or Adobe PDF<br>
|
|
|
|
|
Media: Audio (mp3, m4a) and videos (mp4, mkv)<br>
|
|
|
|
|
Supplemental files: Word Doc, Excel, txt, etc
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</Comp_hosted_files_upload>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{:else}
|
|
|
|
|
|
|
|
|
|
@@ -557,7 +452,8 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
|
|
|
|
log_lvl: log_lvl
|
|
|
|
|
})
|
|
|
|
|
.then(function (archive_content_obj_update_result) {
|
|
|
|
|
// ???
|
|
|
|
|
// We need to do all of this since the DB object has changed and the SLCT object does automatically update (yet...??? Svelte 5?).
|
|
|
|
|
// $idaa_slct.archive_content_obj = $lq__archive_content_obj;
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
|
|
|
|
console.log('Something went wrong.');
|
|
|
|
|
@@ -571,15 +467,11 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
|
|
|
|
return false;
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
// We need to do all of this since the DB object has changed and the SLCT object does automatically update (yet...??? Svelte 5?).
|
|
|
|
|
$idaa_slct.archive_content_obj.hosted_file_id = null;
|
|
|
|
|
$idaa_slct.archive_content_obj.file_path = null;
|
|
|
|
|
$idaa_slct.archive_content_obj.filename = null;
|
|
|
|
|
$idaa_slct.archive_content_obj.file_extension = null;
|
|
|
|
|
|
|
|
|
|
// We need to do this since the comment has changed and the idaa_slct object does automatically update (yet...???).
|
|
|
|
|
$idaa_slct.archive_content_obj = $lq__archive_content_obj;
|
|
|
|
|
// disable_submit_btn = false;
|
|
|
|
|
// $idaa_sess.archives.show__modal_edit__archive_content_id = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -812,27 +704,55 @@ async function handle_hosted_files_uploaded(hosted_file_id_li: string[], hosted_
|
|
|
|
|
</label>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
<div class="text-sm text-gray-600 dark:text-gray-400">
|
|
|
|
|
{$lq__archive_content_obj?.updated_on ? `DB Updated on: ${$lq__archive_content_obj?.updated_on}` : ''}
|
|
|
|
|
{$idaa_slct.archive_content_obj?.updated_on ? `SLCT Updated on: ${$idaa_slct.archive_content_obj?.updated_on}` : ''}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</section> <!-- END: section post__admin_options -->
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section class="ae_section ae_options flex flex-row gap-1 items-center justify-center">
|
|
|
|
|
<button type="submit" class="btn btn-md variant-ghost-primary">
|
|
|
|
|
<span class="fas fa-check m-1"></span> Save Archive Content
|
|
|
|
|
<button
|
|
|
|
|
type="submit"
|
|
|
|
|
disabled={disable_submit_btn}
|
|
|
|
|
class="btn btn-md variant-ghost-primary"
|
|
|
|
|
>
|
|
|
|
|
<span class="fas fa-check m-1"></span>
|
|
|
|
|
Save Archive Content
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
{#if $idaa_slct.archive_content_id}
|
|
|
|
|
{#if $idaa_slct.archive_content_id && !$idaa_slct.archive_content_obj.hosted_file_id}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
if (!confirm('Are you sure you want to delete this archive content?')) {return false;}
|
|
|
|
|
handle_delete_archive_content_obj({archive_content_id: $idaa_slct.archive_content_id, hosted_file_id: $idaa_slct.archive_content_obj.hosted_file_id_random});
|
|
|
|
|
|
|
|
|
|
prom_api__archive_content_obj = archives_func.delete_ae_obj_id__archive_content({
|
|
|
|
|
api_cfg: $ae_api,
|
|
|
|
|
archive_content_id: $idaa_slct.archive_content_id,
|
|
|
|
|
method: 'disable',
|
|
|
|
|
log_lvl: log_lvl
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$idaa_slct.archive_content_id = null;
|
|
|
|
|
$idaa_slct.archive_content_obj = {};
|
|
|
|
|
$idaa_sess.archives.show__modal_edit__archive_content_id = false;
|
|
|
|
|
}}
|
|
|
|
|
class="btn btn-sm variant-soft-warning" type="button">
|
|
|
|
|
<span class="fas fa-minus m-1"></span> Delete
|
|
|
|
|
class="btn btn-sm variant-soft-warning"
|
|
|
|
|
title="Disable this archive content"
|
|
|
|
|
>
|
|
|
|
|
<span class="fas fa-minus m-1"></span>
|
|
|
|
|
Delete
|
|
|
|
|
{#if $ae_loc.administrator_access}
|
|
|
|
|
(Disable)
|
|
|
|
|
{/if}
|
|
|
|
|
</button>
|
|
|
|
|
{:else if $idaa_slct.archive_content_obj.hosted_file_id}
|
|
|
|
|
{#if $ae_loc.administrator_access}
|
|
|
|
|
Can not delete. Remove hosted file first.
|
|
|
|
|
{/if}
|
|
|
|
|
{/if}
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|