Mostly working before major fix for data shared.
This commit is contained in:
@@ -68,6 +68,8 @@ console.log(`ae_e_data_store cached: ${ds_code} = `, $ae_ds_loc);
|
|||||||
|
|
||||||
if (!$ae_ds_loc.id) {
|
if (!$ae_ds_loc.id) {
|
||||||
ds_loading_status = '-- loading --';
|
ds_loading_status = '-- loading --';
|
||||||
|
} else {
|
||||||
|
ae_ds_loc.set($ae_ds_loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ae_sess.ds.submit_status = null;
|
$ae_sess.ds.submit_status = null;
|
||||||
@@ -76,8 +78,11 @@ $ae_sess.ds.update_status = null;
|
|||||||
|
|
||||||
let trigger: null|string = null;
|
let trigger: null|string = null;
|
||||||
|
|
||||||
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
// This is a quick check to make sure the data store is not stale. If it is, then we need to trigger a reload.
|
// This is a quick check to make sure the data store is not stale. If it is, then we need to trigger a reload.
|
||||||
if ($ae_ds_loc.loaded_on && $ae_ds_loc.chk_account_id == $ae_loc.account_id) {
|
if (browser && $ae_ds_loc.loaded_on && $ae_ds_loc.chk_account_id == $ae_loc.account_id) {
|
||||||
|
console.log(`ae_data_store ${ds_code} loaded_on: ${$ae_ds_loc.loaded_on}`);
|
||||||
let loaded_on = new Date($ae_ds_loc.loaded_on);
|
let loaded_on = new Date($ae_ds_loc.loaded_on);
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let diff = now.getTime() - loaded_on.getTime();
|
let diff = now.getTime() - loaded_on.getTime();
|
||||||
@@ -91,8 +96,8 @@ if ($ae_ds_loc.loaded_on && $ae_ds_loc.chk_account_id == $ae_loc.account_id) {
|
|||||||
trigger = 'load__ds__code';
|
trigger = 'load__ds__code';
|
||||||
}, random_ms);
|
}, random_ms);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (browser) {
|
||||||
console.log('No loaded_on date found and or the account_id check failed. Need to trigger reload.');
|
console.log('ae_data_store No loaded_on date found and or the account_id check failed. Need to trigger reload.');
|
||||||
trigger = 'load__ds__code';
|
trigger = 'load__ds__code';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +110,7 @@ onMount(() => {
|
|||||||
console.log('Element: Data Store element_data_store.svelte');
|
console.log('Element: Data Store element_data_store.svelte');
|
||||||
|
|
||||||
// Wait for random number of milliseconds to avoid all data stores being reloaded at the same time.
|
// Wait for random number of milliseconds to avoid all data stores being reloaded at the same time.
|
||||||
let random_ms = Math.floor(Math.random() * 500);
|
let random_ms = Math.floor(Math.random() * 750);
|
||||||
console.log(`Random number of milliseconds: ${random_ms}`);
|
console.log(`Random number of milliseconds: ${random_ms}`);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
trigger = 'load__ds__code';
|
trigger = 'load__ds__code';
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ const modalRegistry: Record<string, ModalComponent> = {
|
|||||||
// Highlight JS
|
// Highlight JS
|
||||||
import hljs from 'highlight.js/lib/core';
|
import hljs from 'highlight.js/lib/core';
|
||||||
import 'highlight.js/styles/github-dark.css';
|
import 'highlight.js/styles/github-dark.css';
|
||||||
import type { Writable } from 'svelte/store';
|
// import type { Writable } from 'svelte/store';
|
||||||
import { get } from 'svelte/store';
|
// import { get } from 'svelte/store';
|
||||||
import { page } from "$app/stores";
|
import { browser } from '$app/environment';
|
||||||
|
// import { page } from "$app/stores";
|
||||||
import { localStorageStore, storeHighlightJs } from '@skeletonlabs/skeleton';
|
import { localStorageStore, storeHighlightJs } from '@skeletonlabs/skeleton';
|
||||||
import xml from 'highlight.js/lib/languages/xml'; // for HTML
|
import xml from 'highlight.js/lib/languages/xml'; // for HTML
|
||||||
import css from 'highlight.js/lib/languages/css';
|
import css from 'highlight.js/lib/languages/css';
|
||||||
@@ -60,7 +61,7 @@ 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';
|
||||||
import Element_data_store from '$lib/element_data_store.svelte';
|
import Element_data_store from '$lib/element_data_store.svelte';
|
||||||
|
|
||||||
// Quickly save the data passed from the parent to the Svelte stores.
|
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other. This should catch anything that is a child of this layout.svelte file.
|
||||||
$ae_loc = data.ae_loc;
|
$ae_loc = data.ae_loc;
|
||||||
$ae_api = data.ae_api;
|
$ae_api = data.ae_api;
|
||||||
|
|
||||||
@@ -77,6 +78,26 @@ if ($ae_loc.site_cfg_json.slct__event_id) {
|
|||||||
console.log(`No Event ID set.`);
|
console.log(`No Event ID set.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));
|
||||||
|
|
||||||
|
// This should not be needed here anymore.
|
||||||
|
// if (key == 'hub__site__appshell_header') {
|
||||||
|
// $ae_sess.site_appshell_header = value;
|
||||||
|
// console.log(`$ae_sess.site_appshell_header = `, $ae_sess.site_appshell_header);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// $ae_sess.site_appshell_header = JSON.parse(localStorage.getItem('ae_ds__hub__site__appshell_header'));
|
||||||
|
// console.log(`$ae_sess.site_appshell_header = `, $ae_sess.site_appshell_header);
|
||||||
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
// console.log(`ae_ds__ data:`, data.ae_ds)
|
// console.log(`ae_ds__ data:`, data.ae_ds)
|
||||||
@@ -86,26 +107,7 @@ if ($ae_loc.site_cfg_json.slct__event_id) {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
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);
|
|
||||||
localStorage.setItem(`ae_ds__${key}`, JSON.stringify(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.log('Root: +layout.svelte');
|
console.log('Root: +layout.svelte');
|
||||||
@@ -113,18 +115,9 @@ onMount(() => {
|
|||||||
// Waiting until the browser exists.
|
// Waiting until the browser exists.
|
||||||
// save_ds_to_local(data.ae_ds);
|
// save_ds_to_local(data.ae_ds);
|
||||||
|
|
||||||
|
// $ae_sess.site_appshell_header = JSON.parse(localStorage.getItem('ae_ds__hub__site__appshell_header'));
|
||||||
// console.log(`ae_ds_testing = `, $ds_testing);
|
// console.log(`$ae_sess.site_appshell_header = `, $ae_sess.site_appshell_header);
|
||||||
// $ds_testing = {'test': 'Changed by Scott'};
|
// $ae_sess = $ae_sess;
|
||||||
|
|
||||||
|
|
||||||
// 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') {
|
||||||
@@ -164,21 +157,15 @@ onMount(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// let data_store_obj_get_promises: key_val = {};
|
// $slct_trigger = 'set_access_code_li';
|
||||||
// let get_ds_hub_page_access_code_li_json_promise = handle_get_data_store_obj_w_code({code: 'hub__page__access_code_li_json', data_type: 'json', trigger: 'set_access_code_li'});
|
// $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_code_li_json']) {
|
||||||
// let get_ds_hub_site_header_promise = handle_get_data_store_obj_w_code({code: 'hub_site_header'});
|
// console.log(`$ae_loc.ds['hub__page__access_code_li_json'] = `, $ae_loc.ds['hub__page__access_code_li_json']);
|
||||||
// let get_ds_hub_site_footer_promise = handle_get_data_store_obj_w_code({code: 'hub_site_footer'});
|
// $slct_trigger = null; // Reset the trigger to prevent loops
|
||||||
|
|
||||||
|
// $ae_loc.page_access_code_li = $ae_loc.ds['hub__page__access_code_li_json'];
|
||||||
$slct_trigger = 'set_access_code_li';
|
// $ae_loc = $ae_loc; // Trigger Svelte just in case
|
||||||
$: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_code_li_json']) {
|
// // console.log($ae_loc);
|
||||||
console.log(`$ae_loc.ds['hub__page__access_code_li_json'] = `, $ae_loc.ds['hub__page__access_code_li_json']);
|
// }
|
||||||
$slct_trigger = null; // Reset the trigger to prevent loops
|
|
||||||
|
|
||||||
$ae_loc.page_access_code_li = $ae_loc.ds['hub__page__access_code_li_json'];
|
|
||||||
$ae_loc = $ae_loc; // Trigger Svelte just in case
|
|
||||||
// console.log($ae_loc);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@@ -237,6 +224,8 @@ $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_c
|
|||||||
|
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<!-- OSIT's Aether App -->
|
<!-- OSIT's Aether App -->
|
||||||
|
<!-- {@html (browser ? JSON.parse(localStorage.getItem('ae_ds__hub__site__appshell_header')) : 'not found')} -->
|
||||||
|
<!-- {@html $ae_sess.site_appshell_header} -->
|
||||||
<Element_data_store
|
<Element_data_store
|
||||||
ds_code="hub__site__appshell_header"
|
ds_code="hub__site__appshell_header"
|
||||||
ds_type="html"
|
ds_type="html"
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
|||||||
};
|
};
|
||||||
|
|
||||||
let loading_results = null;
|
let loading_results = null;
|
||||||
// let access_code_li_json = null;
|
|
||||||
|
|
||||||
// First do a site_domain look up to check if it is valid and get the account_id.
|
// First do a site_domain look up to check if it is valid and get the account_id.
|
||||||
if (!url.host) {
|
if (!url.host) {
|
||||||
@@ -86,9 +85,6 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
|||||||
ae_api_tmp['headers']['x-account-id'] = site_domain_results.account_id_random;
|
ae_api_tmp['headers']['x-account-id'] = site_domain_results.account_id_random;
|
||||||
ae_api_tmp['headers']['x-no-account-id'] = null;
|
ae_api_tmp['headers']['x-no-account-id'] = null;
|
||||||
|
|
||||||
// ae_api.set(ae_api_tmp);
|
|
||||||
// console.log(`ae_api = `, get(ae_api));
|
|
||||||
|
|
||||||
ae_loc_tmp['account_id'] = site_domain_results.account_id_random;
|
ae_loc_tmp['account_id'] = site_domain_results.account_id_random;
|
||||||
ae_loc_tmp['site_id'] = site_domain_results.site_id_random;
|
ae_loc_tmp['site_id'] = site_domain_results.site_id_random;
|
||||||
ae_loc_tmp['site_domain_id'] = site_domain_results.site_domain_id_random;
|
ae_loc_tmp['site_domain_id'] = site_domain_results.site_domain_id_random;
|
||||||
@@ -98,33 +94,14 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
|||||||
ae_loc_tmp['site_cfg_json'] = site_domain_results.cfg_json;
|
ae_loc_tmp['site_cfg_json'] = site_domain_results.cfg_json;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
})
|
|
||||||
.then(async function (results) {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
})
|
|
||||||
.finally(function () {
|
|
||||||
|
|
||||||
// console.log(`ae_ ds_code_li = `, ds_code_li);
|
|
||||||
// ae_loc_tmp = {
|
|
||||||
// ...ae_loc_tmp,
|
|
||||||
// 'ds': ds_code_li,
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// console.log(`ae_loc_tmp = `, ae_loc_tmp);
|
|
||||||
// data_struct['ae_loc'] = ae_loc_tmp;
|
|
||||||
|
|
||||||
// ae_loc.set(ae_loc_tmp);
|
|
||||||
// console.log(`ae_loc = `, get(ae_loc));
|
|
||||||
|
|
||||||
// data_struct['ae_ds'] = ds_code_li;
|
|
||||||
|
|
||||||
// console.log(`ae_root +layout.ts loading initial DS still...`);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
// .then(async function (results) {
|
||||||
|
// return true;
|
||||||
|
// })
|
||||||
|
// .finally(function () {
|
||||||
|
// return true;
|
||||||
|
// });
|
||||||
|
|
||||||
let ds_type: null|string = 'json';
|
let ds_type: null|string = 'json';
|
||||||
ds_code = 'hub__page__access_code_li_json';
|
ds_code = 'hub__page__access_code_li_json';
|
||||||
@@ -133,35 +110,26 @@ export async function load({ fetch, params, parent, route, url }) { // params, r
|
|||||||
if (ds_results) {
|
if (ds_results) {
|
||||||
console.log(`ae_ ds_results = `, ds_results);
|
console.log(`ae_ ds_results = `, ds_results);
|
||||||
return 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ds_type = 'text';
|
||||||
|
// ds_code = 'hub__site__appshell_header';
|
||||||
|
// 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;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
data_struct['ae_ds'] = ds_code_li;
|
data_struct['ae_ds'] = ds_code_li;
|
||||||
ae_loc_tmp['access_code_li'] = ds_code_li;
|
ae_loc_tmp['page_access_code_li'] = ds_code_li['hub__page__access_code_li_json'];
|
||||||
data_struct['ae_loc'] = ae_loc_tmp;
|
data_struct['ae_loc'] = ae_loc_tmp;
|
||||||
|
|
||||||
// data_struct['ae_loc'] = loading_results;
|
|
||||||
// console.log(`ae_root +layout.ts load after initial data stores loaded`);
|
|
||||||
return data_struct;
|
return data_struct;
|
||||||
// }
|
|
||||||
|
|
||||||
// Currently we should never make it to this point! 2024-03-06
|
|
||||||
// console.log(`ae_root +layout.ts load function end`);
|
|
||||||
// return data_struct;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user