Wrapping up for the day/week. It is my birthday weekend!
This commit is contained in:
@@ -3,6 +3,9 @@ import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
import { handle_load_ae_obj_li__event_file } from "$lib/ae_events__event_file";
|
||||
import { handle_load_ae_obj_li__event_session } from './ae_events__event_session';
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
@@ -11,11 +14,15 @@ export async function handle_load_ae_obj_id__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_location_id,
|
||||
inc_file_li = false,
|
||||
inc_session_li = false,
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_location_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
@@ -53,6 +60,71 @@ export async function handle_load_ae_obj_id__event_location(
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_location_obj:', ae_promises.load__event_location_obj);
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the location
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for the location now`);
|
||||
}
|
||||
let load_event_file_obj_li = handle_load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
ae_promises.load__event_location_obj.event_file_li = load_event_file_obj_li;
|
||||
}
|
||||
|
||||
if (inc_session_li) {
|
||||
// Load the sessions for the location
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the session list for the location now`);
|
||||
}
|
||||
let load_event_session_obj_li = handle_load_ae_obj_li__event_session({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_session_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_session_obj_li = `, event_session_obj_li);
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`ae_promises.load__event_session_obj = `, ae_promises.load__event_session_obj);
|
||||
// ae_promises.load__event_session_obj.event_session_li = event_session_obj_li;
|
||||
// // Re-save the session object with the new session list
|
||||
// handle_db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: [ae_promises.load__event_session_obj]
|
||||
// });
|
||||
// }
|
||||
return event_session_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
}
|
||||
ae_promises.load__event_location_obj.event_session_li = load_event_session_obj_li;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_location_obj;
|
||||
}
|
||||
|
||||
@@ -62,21 +134,25 @@ export async function handle_load_ae_obj_li__event_location(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
inc_file_li = false,
|
||||
inc_session_li = false,
|
||||
params={},
|
||||
try_cache=true,
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** handle_load_ae_obj_li__event_location() ***`);
|
||||
console.log(`*** handle_load_ae_obj_li__event_location() *** event_id=${event_id}`);
|
||||
|
||||
let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
let limit: number = (params.qry__limit ?? 99); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
@@ -120,6 +196,67 @@ export async function handle_load_ae_obj_li__event_location(
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_location_obj_li:', ae_promises.load__event_location_obj_li);
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the locations
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for each location now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
let event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
let event_location_id = event_location_obj.event_location_id_random;
|
||||
|
||||
let load_event_file_obj_li = handle_load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_session_li) {
|
||||
// Load the sessions for the locations
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the session list for each location now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
let event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
let event_location_id = event_location_obj.event_location_id_random;
|
||||
|
||||
let load_event_session_obj_li = handle_load_ae_obj_li__event_session({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: {qry__enabled: 'all', qry__limit: 100},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_session_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_session_obj_li = `, event_session_obj_li);
|
||||
}
|
||||
return event_session_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_location_obj_li;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,15 +248,15 @@ export async function handle_load_ae_obj_li__event_session(
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
||||
}
|
||||
if (try_cache) {
|
||||
console.log(`event_session_obj = `, event_session_obj);
|
||||
event_session_obj.event_presentation_li = event_presentation_obj_li;
|
||||
// Re-save the session object with the new presentation list
|
||||
handle_db_save_ae_obj_li__event_session({
|
||||
obj_type: 'event_session',
|
||||
obj_li: event_session_obj
|
||||
});
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`event_session_obj = `, event_session_obj);
|
||||
// event_session_obj.event_presentation_li = event_presentation_obj_li;
|
||||
// // Re-save the session object with the new presentation list
|
||||
// handle_db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: event_session_obj
|
||||
// });
|
||||
// }
|
||||
|
||||
return event_presentation_obj_li;
|
||||
});
|
||||
|
||||
@@ -265,6 +265,8 @@ export interface Location {
|
||||
external_id?: null|string;
|
||||
code?: null|string;
|
||||
|
||||
type_code?: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
|
||||
@@ -317,7 +319,7 @@ export interface Session {
|
||||
for_id: string;
|
||||
for_id_random: string;
|
||||
|
||||
type_code: string;
|
||||
type_code?: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
|
||||
@@ -51,6 +51,7 @@ export async function load({ params, parent, url }) { // route
|
||||
let load_event_location_obj_li = await events_func.handle_load_ae_obj_li__event_location({
|
||||
api_cfg: ae_acct.api,
|
||||
event_id: event_id,
|
||||
inc_file_li: true,
|
||||
params: {qry__enabled: 'enabled', qry__limit: 550},
|
||||
try_cache: true
|
||||
})
|
||||
@@ -94,8 +95,9 @@ export async function load({ params, parent, url }) { // route
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
// inc_file_li: false,
|
||||
// inc_presentation_li: false,
|
||||
params: {qry__enabled: 'enabled', qry__limit: 500},
|
||||
params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 150},
|
||||
try_cache: true
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@@ -86,40 +86,6 @@ if (!$events_loc.launcher.slct) {
|
||||
|
||||
if (browser) {
|
||||
console.log(`data.url.searchParams.get('location_id') = `, data.url.searchParams.get('location_id'));
|
||||
// let for_obj_type = 'event_location';
|
||||
// let for_obj_id = data.url.searchParams.get('location_id');
|
||||
|
||||
// ae_acct.slct.event_location_id = for_obj_id;
|
||||
|
||||
// ae_acct.trig.event_session_obj_li = false;
|
||||
// let load_event_session_obj_li = events_func.handle_load_ae_obj_li__event_session({
|
||||
// api_cfg: ae_acct.api,
|
||||
// for_obj_type: for_obj_type,
|
||||
// for_obj_id: for_obj_id,
|
||||
// params: {qry__enabled: 'enabled', qry__limit: 550},
|
||||
// try_cache: true
|
||||
// })
|
||||
// .finally(() => {
|
||||
// // console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
// // ae_acct.trig.event_session_obj_li = false;
|
||||
// });
|
||||
// ae_acct.slct.event_session_obj_li = load_event_session_obj_li;
|
||||
// // console.log(`ae_acct.slct.event_session_obj_li = `, ae_acct.slct.event_session_obj_li);
|
||||
// $events_slct.event_session_obj_li = ae_acct.slct.event_session_obj_li ?? [''];
|
||||
|
||||
// let id_li__event_session = [];
|
||||
|
||||
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
// for (let i = 0; i < load_event_session_obj_li.length; i++) {
|
||||
// let event_session_obj = load_event_session_obj_li[i];
|
||||
// let event_session_id_random = event_session_obj.event_session_id_random;
|
||||
// tmp_li.push(event_session_id_random);
|
||||
// }
|
||||
// id_li__event_session = tmp_li;
|
||||
// console.log(`id_li__event_session:`, id_li__event_session);
|
||||
// ae_acct.slct.id_li__event_session = id_li__event_session;
|
||||
// $events_slct.id_li__event_session = ae_acct.slct.id_li__event_session ?? [''];
|
||||
}
|
||||
|
||||
if (ae_acct.slct.event_id) {
|
||||
@@ -222,6 +188,15 @@ let lq__event_obj = liveQuery(
|
||||
.get($events_loc.launcher.slct.event_id)
|
||||
);
|
||||
|
||||
// Event File - For Location
|
||||
let lq__location_event_file_obj_li = liveQuery(
|
||||
() => db_events.files
|
||||
// .where('event_session_id_random')
|
||||
.where('for_id_random')
|
||||
.equals($events_loc.launcher.slct.event_location_id ?? '')
|
||||
.sortBy('name')
|
||||
);
|
||||
|
||||
// Event Location
|
||||
let lq__event_location_obj = liveQuery(
|
||||
() => db_events.locations
|
||||
@@ -332,6 +307,8 @@ onMount(() => {
|
||||
|
||||
lq__event_obj={lq__event_obj}
|
||||
|
||||
lq__location_event_file_obj_li={lq__location_event_file_obj_li}
|
||||
|
||||
lq__event_location_obj={lq__event_location_obj}
|
||||
lq_get__event_location_obj_li={lq_get__event_location_obj_li}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ let slct_event_location_id: string;
|
||||
$events_trigger = null;
|
||||
|
||||
export let lq__event_obj: any;
|
||||
export let lq__location_event_file_obj_li: any;
|
||||
export let lq__event_location_obj: any;
|
||||
// export let lq__event_location_obj_li: any;
|
||||
export let lq_get__event_location_obj_li: any;
|
||||
@@ -46,7 +47,9 @@ if ($ae_loc.administrator_access) {
|
||||
qry__hidden = 'not_hidden';
|
||||
}
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
let ae_promises: key_val = {
|
||||
get_li__event_file: null,
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
@@ -66,7 +69,7 @@ let ae_promises: key_val = {};
|
||||
Hide Files
|
||||
{:else}
|
||||
<span class="fas fa-eye m-1"></span>
|
||||
Show Hidden Files
|
||||
Hidden Files?
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
@@ -81,7 +84,7 @@ let ae_promises: key_val = {};
|
||||
Hide Sessions
|
||||
{:else}
|
||||
<span class="fas fa-eye m-1"></span>
|
||||
Show Hidden Sessions
|
||||
Hidden Sessions?
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
@@ -141,8 +144,9 @@ let ae_promises: key_val = {};
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: $events_loc.launcher.slct.event_location_id,
|
||||
inc_file_li: false,
|
||||
inc_presentation_li: false,
|
||||
params: {qry__enabled: 'enabled', qry__limit: 550},
|
||||
params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 100},
|
||||
try_cache: true,
|
||||
log_lvl: 1,
|
||||
})
|
||||
@@ -197,6 +201,29 @@ let ae_promises: key_val = {};
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if $lq__location_event_file_obj_li && $lq__location_event_file_obj_li.length > 0}
|
||||
{#each $lq__location_event_file_obj_li as event_file_obj, index}
|
||||
<button
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
on:click={() => {
|
||||
// ae_promises[event_file_obj.event_file_id_random]
|
||||
ae_promises[event_file_obj?.event_file_id_random] = api.download_hosted_file({
|
||||
api_cfg: $ae_api,
|
||||
hosted_file_id: event_file_obj?.hosted_file_id_random,
|
||||
return_file: true,
|
||||
filename: event_file_obj?.filename,
|
||||
auto_download: true,
|
||||
log_lvl: 0
|
||||
});
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-primary hover:variant-filled-primary text-xs py-1 px-2"
|
||||
>
|
||||
<span class="fas fa-file-archive m-1"></span>
|
||||
{event_file_obj?.name}
|
||||
</button>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@ let lq__event_file_obj_li = liveQuery(
|
||||
{/if}
|
||||
</strong></div>
|
||||
</div>
|
||||
<ul>
|
||||
<ul class="space-y-1">
|
||||
{#each $lq__event_file_obj_li as event_file_obj, index}
|
||||
<li
|
||||
class="flex flex-row justify-center gap-1"
|
||||
class:d_none={!$events_loc.launcher.show_hidden_sessions && event_file_obj.hide}
|
||||
class:hidden={!$events_loc.launcher.show_content__hidden_files && event_file_obj.hide}
|
||||
>
|
||||
<button
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
|
||||
@@ -221,7 +221,8 @@ ae_promises[$events_loc.launcher.slct.event_session_id] = events_func.handle_loa
|
||||
{#each $lq__event_file_obj_li as event_file_obj, index}
|
||||
<li
|
||||
class="flex flex-row justify-center gap-1"
|
||||
class:hidden={!$events_loc.launcher.show_content__hidden_sessions && event_file_obj.hide}>
|
||||
class:hidden={!$events_loc.launcher.show_content__hidden_files && event_file_obj.hide}
|
||||
>
|
||||
<button
|
||||
disabled={!$ae_loc.trusted_access}
|
||||
on:click={() => {
|
||||
@@ -307,7 +308,7 @@ ae_promises[$events_loc.launcher.slct.event_session_id] = events_func.handle_loa
|
||||
<!-- Maybe set max with? max-w-screen-md -->
|
||||
<ul class="event_presentation_list max-w-full space-y-2">
|
||||
{#each $lq__event_presentation_obj_li as event_presentation_obj}
|
||||
<li class="border-b-2 border-gray-300">
|
||||
<li class="border-b-2 border-gray-300 my-1 py-1">
|
||||
|
||||
<!-- The presentation information -->
|
||||
<div class="event_presentation_datetime_name flex flex-row justify-evenly gap-4">
|
||||
@@ -322,7 +323,7 @@ ae_promises[$events_loc.launcher.slct.event_session_id] = events_func.handle_loa
|
||||
|
||||
<!-- The presenter list -->
|
||||
{#if $lq__event_presenter_obj_li && $lq__event_presenter_obj_li.length}
|
||||
<ul>
|
||||
<ul class="event_presentation_presenter_list">
|
||||
{#each $lq__event_presenter_obj_li as event_presenter_obj, index}
|
||||
{#if event_presenter_obj.event_presentation_id_random == event_presentation_obj.event_presentation_id_random}
|
||||
<li>
|
||||
|
||||
@@ -20,6 +20,9 @@ let ae_promises: key_val = {
|
||||
slct_event_session_id: null,
|
||||
slct_event_presentation_li: null
|
||||
};
|
||||
|
||||
let hover_timer_wait = 1000;
|
||||
let hover_timer: any = null;
|
||||
</script>
|
||||
|
||||
|
||||
@@ -51,6 +54,38 @@ let ae_promises: key_val = {
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
on:mouseenter={() => {
|
||||
// Start a 750 ms timer to prevent changing the session too quickly.
|
||||
hover_timer = setTimeout(async () => {
|
||||
$events_loc.launcher.slct.event_session_id = null;
|
||||
await tick();
|
||||
|
||||
$events_loc.launcher.slct.event_session_id = event_session_obj?.id;
|
||||
data_url.searchParams.set('session_id', event_session_obj?.id);
|
||||
|
||||
$events_slct.event_session_id = event_session_obj?.id;
|
||||
$events_slct.event_session_obj = event_session_obj;
|
||||
|
||||
ae_promises.slct_event_session_id = events_func.handle_load_ae_obj_id__event_session({
|
||||
api_cfg: $ae_api,
|
||||
event_session_id: event_session_obj?.id,
|
||||
inc_file_li: true,
|
||||
inc_presentation_li: true,
|
||||
try_cache: true,
|
||||
log_lvl: 1
|
||||
})
|
||||
.then(async (load_results) => {
|
||||
console.log(`load_results = `, load_results);
|
||||
|
||||
let new_url = data_url.toString();
|
||||
console.log(new_url);
|
||||
goto(new_url, {replaceState: false});
|
||||
});
|
||||
}, hover_timer_wait);
|
||||
}}
|
||||
on:mouseleave={() => {
|
||||
clearTimeout(hover_timer);
|
||||
}}
|
||||
on:click={async () => {
|
||||
$events_loc.launcher.slct.event_session_id = null;
|
||||
await tick();
|
||||
@@ -116,7 +151,9 @@ let ae_promises: key_val = {
|
||||
// goto(new_url, {replaceState: false});
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-primary hover:variant-filled-primary overflow-hidden text-sm w-full max-w-full text-left transition-all rounded-md flex flex-row justify-between items-center"
|
||||
class:font-bold={$events_loc.launcher.slct.event_session_id === event_session_obj?.id}
|
||||
title={event_session_obj?.name}
|
||||
class:hidden={!$events_loc.launcher.show_content__hidden_sessions && event_session_obj?.hide}
|
||||
>
|
||||
<span>
|
||||
<span class="fas fa-calendar-alt"></span>
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function load({ params, parent }) { // route
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
params: {qry__enabled: 'enabled', qry__limit: 550},
|
||||
params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 200},
|
||||
try_cache: true,
|
||||
log_lvl: 1
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user