Finally getting the initial loading better
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
/** @type {import('./$types').LayoutData} */
|
/** @type {import('./$types').LayoutData} */
|
||||||
export let data: any;
|
export let data: any;
|
||||||
// console.log(`ae_ Svelte root +layout data:`, data);
|
console.log(`ae_ Svelte root +layout data:`, data);
|
||||||
|
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import '../app.postcss';
|
import '../app.postcss';
|
||||||
@@ -54,7 +54,7 @@ import { api } from '$lib/api';
|
|||||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
||||||
import { events_loc, events_slct } from '$lib/ae_events_stores';
|
import { events_loc, events_slct } from '$lib/ae_events_stores';
|
||||||
import type { key_val } from '$lib/ae_stores';
|
import type { key_val } from '$lib/ae_stores';
|
||||||
// console.log($ae_loc, $ae_sess, $ae_api);
|
console.log($ae_loc, $ae_sess, $ae_api);
|
||||||
|
|
||||||
import Element_access_type from '$lib/element_access_type.svelte';
|
import Element_access_type from '$lib/element_access_type.svelte';
|
||||||
import Element_app_cfg from '$lib/element_app_cfg.svelte';
|
import Element_app_cfg from '$lib/element_app_cfg.svelte';
|
||||||
@@ -78,16 +78,53 @@ if ($ae_loc.site_cfg_json.slct__event_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We want to loop through all of the data store (ds) key value pairs and set them to localStorage
|
// We want to loop through all of the data store (ds) key value pairs and set them to localStorage
|
||||||
if (data.ae_ds) {
|
// $: if (data.ae_ds) {
|
||||||
for (let [key, value] of Object.entries(data.ae_ds)) {
|
// console.log(`ae_ds__ data:`, data.ae_ds)
|
||||||
|
// for (let [key, value] of Object.entries(data.ae_ds)) {
|
||||||
|
// console.log(`ae_ds__ key: ${key}, value:`, value);
|
||||||
|
// localStorageStore(`ae_ds__${key}`, value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
|
// async function save_ds_to_local (ae_ds: any) {
|
||||||
|
// console.log(`ae_ds__ data:`, ae_ds)
|
||||||
|
// for (let [key, value] of Object.entries(ae_ds)) {
|
||||||
|
// console.log(`ae_ds__ key: ${key}, value:`, value);
|
||||||
|
// localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (browser) {
|
||||||
|
// Waiting until the browser exists.
|
||||||
|
// save_ds_to_local(data.ae_ds);
|
||||||
|
let ae_ds = data.ae_ds;
|
||||||
|
console.log(`ae_ds__ data:`, ae_ds)
|
||||||
|
for (let [key, value] of Object.entries(ae_ds)) {
|
||||||
console.log(`ae_ds__ key: ${key}, value:`, value);
|
console.log(`ae_ds__ key: ${key}, value:`, value);
|
||||||
localStorageStore(`ae_ds__${key}`, value);
|
localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
// console.log('Root: +layout.svelte');
|
console.log('Root: +layout.svelte');
|
||||||
|
|
||||||
|
// Waiting until the browser exists.
|
||||||
|
// save_ds_to_local(data.ae_ds);
|
||||||
|
|
||||||
|
|
||||||
|
// console.log(`ae_ds_testing = `, $ds_testing);
|
||||||
|
// $ds_testing = {'test': 'Changed by Scott'};
|
||||||
|
|
||||||
|
|
||||||
|
// if (data.ae_ds) {
|
||||||
|
// console.log(`ae_ds__ data:`, data.ae_ds)
|
||||||
|
// for (let [key, value] of Object.entries(data.ae_ds)) {
|
||||||
|
// console.log(`ae_ds__ key: ${key}, value:`, value);
|
||||||
|
// localStorageStore(`ae_ds__${key}`, value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
let iframe = data.url.searchParams.get('iframe');
|
let iframe = data.url.searchParams.get('iframe');
|
||||||
if (iframe == 'true') {
|
if (iframe == 'true') {
|
||||||
|
|||||||
@@ -100,34 +100,10 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|
||||||
.then(async function (results) {
|
.then(async function (results) {
|
||||||
|
|
||||||
ds_code = 'hub__page__access_code_li_json';
|
|
||||||
await core_func.handle_load_ae_obj_code__data_store({api_cfg: ae_api_tmp, code: ds_code, data_type: 'json'})
|
|
||||||
.then(function (access_code_li_json_results) {
|
|
||||||
if (access_code_li_json_results) {
|
|
||||||
// console.log(`ae_ access_code_li_json_results = `, access_code_li_json_results);
|
|
||||||
|
|
||||||
// ae_loc_tmp = get(ae_loc);
|
|
||||||
ae_loc_tmp = {
|
|
||||||
...ae_loc_tmp,
|
|
||||||
'access_code_li': access_code_li_json_results,
|
|
||||||
}
|
|
||||||
|
|
||||||
// ae_loc_tmp = get(ae_loc);
|
|
||||||
// let code = 'hub__page__access_code_li_json';
|
|
||||||
|
|
||||||
ds_code_li[ds_code] = access_code_li_json_results;
|
|
||||||
// ae_loc.set(ae_loc_tmp);
|
|
||||||
// console.log(`ae_loc = `, get(ae_loc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
|
|
||||||
// console.log(`ae_ ds_code_li = `, ds_code_li);
|
// console.log(`ae_ ds_code_li = `, ds_code_li);
|
||||||
@@ -138,18 +114,48 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
|||||||
|
|
||||||
|
|
||||||
// console.log(`ae_loc_tmp = `, ae_loc_tmp);
|
// console.log(`ae_loc_tmp = `, ae_loc_tmp);
|
||||||
data_struct['ae_loc'] = ae_loc_tmp;
|
// data_struct['ae_loc'] = ae_loc_tmp;
|
||||||
|
|
||||||
// ae_loc.set(ae_loc_tmp);
|
// ae_loc.set(ae_loc_tmp);
|
||||||
// console.log(`ae_loc = `, get(ae_loc));
|
// console.log(`ae_loc = `, get(ae_loc));
|
||||||
|
|
||||||
data_struct['ae_ds'] = ds_code_li;
|
// data_struct['ae_ds'] = ds_code_li;
|
||||||
|
|
||||||
// console.log(`ae_root +layout.ts loading initial DS still...`);
|
// console.log(`ae_root +layout.ts loading initial DS still...`);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let ds_type: null|string = 'json';
|
||||||
|
ds_code = 'hub__page__access_code_li_json';
|
||||||
|
ds_code_li[ds_code] = await core_func.handle_load_ae_obj_code__data_store({api_cfg: ae_api_tmp, code: ds_code, data_type: ds_type})
|
||||||
|
.then(function (ds_results) {
|
||||||
|
if (ds_results) {
|
||||||
|
console.log(`ae_ ds_results = `, ds_results);
|
||||||
|
return ds_results;
|
||||||
|
|
||||||
|
// // ae_loc_tmp = get(ae_loc);
|
||||||
|
// ae_loc_tmp['access_code_li'] = ds_results;
|
||||||
|
// // ae_loc_tmp = {
|
||||||
|
// // ...ae_loc_tmp,
|
||||||
|
// // 'access_code_li': ds_results,
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // ae_loc_tmp = get(ae_loc);
|
||||||
|
// // let code = 'hub__page__access_code_li_json';
|
||||||
|
|
||||||
|
// ds_code_li[ds_code] = ds_results;
|
||||||
|
// // ae_loc.set(ae_loc_tmp);
|
||||||
|
// // console.log(`ae_loc = `, get(ae_loc));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
data_struct['ae_ds'] = ds_code_li;
|
||||||
|
ae_loc_tmp['access_code_li'] = ds_code_li;
|
||||||
|
data_struct['ae_loc'] = ae_loc_tmp;
|
||||||
|
|
||||||
// data_struct['ae_loc'] = loading_results;
|
// data_struct['ae_loc'] = loading_results;
|
||||||
// console.log(`ae_root +layout.ts load after initial data stores loaded`);
|
// console.log(`ae_root +layout.ts load after initial data stores loaded`);
|
||||||
return data_struct;
|
return data_struct;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export async function load({ params, parent, url }) { // route
|
|||||||
manage: {name: 'Manage', href: '/events_badges/manage', access: 'administrator', disable: true, hide: true},
|
manage: {name: 'Manage', href: '/events_badges/manage', access: 'administrator', disable: true, hide: true},
|
||||||
review: {name: 'Review', href: '/events_badges/review', access: false, disable: true, hide: false},
|
review: {name: 'Review', href: '/events_badges/review', access: false, disable: true, hide: false},
|
||||||
print: {name: 'Print', href: '/events_badges/print', access: 'trusted', disable: true, hide: false},
|
print: {name: 'Print', href: '/events_badges/print', access: 'trusted', disable: true, hide: false},
|
||||||
view: {name: 'View', href: '/events_badges/view', access: 'trusted', hide: true}, // event_badge_id
|
// view: {name: 'View', href: '/events_badges/view', access: 'trusted', hide: true}, // event_badge_id
|
||||||
// new: {name: 'New', href: '/events_badges/new'},
|
// new: {name: 'New', href: '/events_badges/new'},
|
||||||
// sponsorships: {name: 'Sponsorships', href: '/sponsorships', disable: true, hide: true},
|
// sponsorships: {name: 'Sponsorships', href: '/sponsorships', disable: true, hide: true},
|
||||||
};
|
};
|
||||||
@@ -42,4 +42,4 @@ export async function load({ params, parent, url }) { // route
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export const prerender = false;
|
// export const prerender = false;
|
||||||
export const prerender = true;
|
// export const prerender = true;
|
||||||
@@ -25,8 +25,8 @@ onMount(() => {
|
|||||||
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
|
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
|
||||||
|
|
||||||
// $slct_trigger = 'msg_parent';
|
// $slct_trigger = 'msg_parent';
|
||||||
ae_util.handle_url_and_message('event_id', $events_slct.event_id);
|
// ae_util.handle_url_and_message('event_id', $events_slct.event_id);
|
||||||
ae_util.handle_url_and_message('badge_id', $events_slct.badge_id);
|
// ae_util.handle_url_and_message('badge_id', $events_slct.badge_id);
|
||||||
// if ($events_slct.badge_id) {
|
// if ($events_slct.badge_id) {
|
||||||
// console.log(`Got an ID. Let's show the modal!`);
|
// console.log(`Got an ID. Let's show the modal!`);
|
||||||
// modalStore.trigger(modal_edit__badge_obj);
|
// modalStore.trigger(modal_edit__badge_obj);
|
||||||
|
|||||||
@@ -77,12 +77,6 @@ $events_loc.show_view__event_badge_obj = false;
|
|||||||
let ae_event_badge_get_promise: Promise<any>;
|
let ae_event_badge_get_promise: Promise<any>;
|
||||||
let ae_event_obj_get_promise;
|
let ae_event_obj_get_promise;
|
||||||
|
|
||||||
// Load the AE Obj with ID based on the URL param.
|
|
||||||
if (data.url.searchParams.get('event_id')) {
|
|
||||||
console.log(`Got an event_id: ${data.url.searchParams.get('event_id')}`);
|
|
||||||
$events_slct.event_id = data.url.searchParams.get('event_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($events_slct.event_id) {
|
if ($events_slct.event_id) {
|
||||||
console.log('Selected Event ID:', $events_slct.event_id);
|
console.log('Selected Event ID:', $events_slct.event_id);
|
||||||
$events_trigger = 'load__event_badge_obj_li';
|
$events_trigger = 'load__event_badge_obj_li';
|
||||||
@@ -93,29 +87,20 @@ if ($events_slct.event_id) {
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.log('Events Badges [New/Edit]: +page.svelte');
|
console.log('Events Badges [New/Edit]: +page.svelte');
|
||||||
|
|
||||||
// console.log(`$ae_loc = `, $ae_loc);
|
// Load the AE Obj with ID based on the URL param.
|
||||||
|
if (data.url.searchParams.get('event_id')) {
|
||||||
|
$events_loc.event_id = data.url.searchParams.get('event_id');
|
||||||
|
$events_slct.event_id = data.url.searchParams.get('event_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the Event Presenter Obj with ID based on the URL param.
|
||||||
|
if (data.url.searchParams.get('event_badge_id')) {
|
||||||
|
$events_slct.badge_id = data.url.searchParams.get('event_badge_id');
|
||||||
|
}
|
||||||
|
|
||||||
let url = window.location.href;
|
let url = window.location.href;
|
||||||
// console.log(url);
|
|
||||||
|
|
||||||
$ae_loc.href_url = url;
|
$ae_loc.href_url = url;
|
||||||
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
|
|
||||||
|
|
||||||
// ae_util.handle_url_and_message('event_badge_id', $events_slct.event_badge_id);
|
|
||||||
// if ($events_slct.event_badge_id) {
|
|
||||||
// console.log(`Got an ID. Let's show the modal!`);
|
|
||||||
// modalStore.trigger(modal_edit__event_badge);
|
|
||||||
// } else {
|
|
||||||
// console.log(`No ID. Nothing to show.`);
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
// console.log(`$ae_loc = `, $ae_loc);
|
|
||||||
// $ae_loc.href_url = url;
|
|
||||||
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$: if ($events_trigger == 'load__event_obj' && $events_slct.event_id) {
|
$: if ($events_trigger == 'load__event_obj' && $events_slct.event_id) {
|
||||||
@@ -168,9 +153,6 @@ async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load the Event Presenter Obj with ID based on the URL param.
|
|
||||||
// $events_slct.event_badge_id = data.url.searchParams.get('ae_id');
|
|
||||||
$events_slct.event_badge_id = data.url.searchParams.get('event_badge_id');
|
|
||||||
if ($events_slct.event_badge_id) {
|
if ($events_slct.event_badge_id) {
|
||||||
console.log('Selected Event Presenter ID:', $events_slct.event_badge_id);
|
console.log('Selected Event Presenter ID:', $events_slct.event_badge_id);
|
||||||
$events_trigger = 'load__event_badge';
|
$events_trigger = 'load__event_badge';
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ if (!$ae_api.account_id || !$ae_api.headers['x-account-id']) {
|
|||||||
$ae_api.account_id = $ae_loc.account_id;
|
$ae_api.account_id = $ae_loc.account_id;
|
||||||
$ae_api.headers['x-account-id'] = $ae_loc.account_id;
|
$ae_api.headers['x-account-id'] = $ae_loc.account_id;
|
||||||
} else {
|
} else {
|
||||||
goto('/');
|
console.log(`Account ID not set!!!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,4 +36,4 @@ export async function load({ parent }) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const prerender = true;
|
// export const prerender = true;
|
||||||
@@ -140,20 +140,6 @@ function handle_check_event_exhibit_staff_passcode(entered_passcode: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// function open_exhibit_tracking(event_exhibit_id_random) {
|
|
||||||
// console.log(`open_exhibit_tracking() event_exhibit_id_random=${event_exhibit_id_random}`);
|
|
||||||
|
|
||||||
// if (!event_exhibit_id_random) {
|
|
||||||
// console.log('No event exhibit ID provided.');
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if ($events_loc.leads.auto_view) {
|
|
||||||
// goto($events_sess.leads.open_href, {invalidateAll: true});
|
|
||||||
// } else {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -189,4 +189,4 @@ export async function load({ params, parent, url }) { // route
|
|||||||
// return ae_event_obj_get_promise;
|
// return ae_event_obj_get_promise;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export const prerender = true;
|
// export const prerender = true;
|
||||||
@@ -173,4 +173,4 @@ export async function load({ params, parent, url }) { // route
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export const prerender = false;
|
// export const prerender = false;
|
||||||
export const prerender = true;
|
// export const prerender = true;
|
||||||
Reference in New Issue
Block a user