General clean up. No working on the new event presenter components.
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
/** @type {import('./$types').LayoutLoad} */
|
||||
|
||||
|
||||
import { api } from '$lib/api';
|
||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
type key_val = {
|
||||
[key: string]: any; // variable key
|
||||
// name: string;
|
||||
};
|
||||
|
||||
|
||||
function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
|
||||
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
|
||||
@@ -89,45 +93,7 @@ export function load({ params, url }) { // route
|
||||
// console.log(`Svelte root layout.ts data = route:`, route);
|
||||
console.log(`Svelte root layout.ts data = url:`, url);
|
||||
|
||||
let site_domain_results = null;
|
||||
let access_code_li_json = null;
|
||||
let ae_core = null;
|
||||
|
||||
if (url.host) {
|
||||
// ae_loc.url_host = data.url.host; // Use this to look up? sub.example.com:123
|
||||
// ae_loc.fqdn = url.host; // Use this to look up? sub.example.com:123
|
||||
// ae_loc.url_hostname = data.url.hostname; // sub.example.com
|
||||
// ae_loc.url_origin = data.url.origin; // Use this to look up? https://sub.example.com:123
|
||||
// ae_loc.site_domain = data.url.origin;
|
||||
// console.log(`ae_loc = `, ae_loc);
|
||||
|
||||
site_domain_results = handle_load_ae_obj_id__site_domain({fqdn: url.host, try_cache: false});
|
||||
|
||||
if (site_domain_results) {
|
||||
console.log(`site_domain_results = `, site_domain_results);
|
||||
|
||||
ae_core = {
|
||||
'account_id': site_domain_results.account_id_random,
|
||||
'site_id': site_domain_results.site_id_random,
|
||||
'site_domain_id': site_domain_results.site_domain_id_random,
|
||||
'enable': site_domain_results.enable,
|
||||
'style_href': site_domain_results.style_href,
|
||||
'google_tracking_id': site_domain_results.google_tracking_id,
|
||||
}
|
||||
}
|
||||
|
||||
access_code_li_json = handle_get_data_store_obj_w_code({code: 'hub__page__access_code_li_json', data_type: 'json'});
|
||||
|
||||
if (access_code_li_json) {
|
||||
console.log(`access_code_li_json = `, access_code_li_json);
|
||||
|
||||
ae_core = {
|
||||
...ae_core,
|
||||
'access_code_li': access_code_li_json,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
let ae_core: key_val = {}
|
||||
|
||||
let data_struct = {
|
||||
ae_core: ae_core,
|
||||
@@ -140,6 +106,162 @@ export function load({ params, url }) { // route
|
||||
url: url,
|
||||
|
||||
};
|
||||
|
||||
let site_domain_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.
|
||||
if (url.host) {
|
||||
// ae_loc.url_host = data.url.host; // Use this to look up? sub.example.com:123
|
||||
// ae_loc.fqdn = url.host; // Use this to look up? sub.example.com:123
|
||||
// ae_loc.url_hostname = data.url.hostname; // sub.example.com
|
||||
// ae_loc.url_origin = data.url.origin; // Use this to look up? https://sub.example.com:123
|
||||
// ae_loc.site_domain = data.url.origin;
|
||||
// console.log(`ae_loc = `, ae_loc);
|
||||
|
||||
site_domain_results = handle_load_ae_obj_id__site_domain({fqdn: url.host, try_cache: false});
|
||||
|
||||
site_domain_results.then(function (site_domain_results) {
|
||||
if (site_domain_results) {
|
||||
console.log(`site_domain_results = `, site_domain_results);
|
||||
|
||||
let ae_api_tmp = get(ae_api);
|
||||
|
||||
ae_api_tmp['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.set(ae_api_tmp);
|
||||
console.log(`ae_api = `, get(ae_api));
|
||||
|
||||
ae_core = {
|
||||
'account_id': site_domain_results.account_id_random,
|
||||
'site_id': site_domain_results.site_id_random,
|
||||
'site_domain_id': site_domain_results.site_domain_id_random,
|
||||
'enable': site_domain_results.enable,
|
||||
'style_href': site_domain_results.style_href,
|
||||
'google_tracking_id': site_domain_results.google_tracking_id,
|
||||
}
|
||||
|
||||
let ae_loc_tmp = get(ae_loc);
|
||||
ae_loc_tmp.account_id = site_domain_results.account_id_random;
|
||||
ae_loc.set(ae_loc_tmp);
|
||||
console.log(`ae_loc = `, get(ae_loc));
|
||||
}
|
||||
|
||||
return site_domain_results;
|
||||
})
|
||||
.then(function (site_domain_results) {
|
||||
access_code_li_json = handle_get_data_store_obj_w_code({code: 'hub__page__access_code_li_json', data_type: 'json'});
|
||||
|
||||
access_code_li_json.then(function (access_code_li_json_results) {
|
||||
if (access_code_li_json_results) {
|
||||
console.log(`access_code_li_json_results = `, access_code_li_json_results);
|
||||
|
||||
ae_core = {
|
||||
...ae_core,
|
||||
'access_code_li': access_code_li_json_results,
|
||||
}
|
||||
|
||||
let ae_loc_tmp = get(ae_loc);
|
||||
let code = 'hub__page__access_code_li_json';
|
||||
|
||||
ae_loc_tmp.hub.ds[code] = access_code_li_json_results;
|
||||
ae_loc.set(ae_loc_tmp);
|
||||
console.log(`ae_loc = `, get(ae_loc));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return site_domain_results;
|
||||
})
|
||||
.then(function (site_domain_results) {
|
||||
let ds_hub_site_header = handle_get_data_store_obj_w_code({code: 'hub_site_header'});
|
||||
|
||||
let ae_loc_tmp = get(ae_loc);
|
||||
let code = '';
|
||||
|
||||
ds_hub_site_header.then(function (ds_hub_site_header_results) {
|
||||
if (ds_hub_site_header_results) {
|
||||
console.log(`ds_hub_site_header_results = `, ds_hub_site_header_results);
|
||||
|
||||
ae_core = {
|
||||
...ae_core,
|
||||
'site_header': ds_hub_site_header_results,
|
||||
}
|
||||
|
||||
code = 'hub_site_header';
|
||||
ae_loc_tmp.hub.ds[code] = ds_hub_site_header_results;
|
||||
|
||||
ae_loc.set(ae_loc_tmp);
|
||||
console.log(`ae_loc = `, get(ae_loc));
|
||||
}
|
||||
});
|
||||
|
||||
let ds_hub_site_footer = handle_get_data_store_obj_w_code({code: 'hub_site_footer'});
|
||||
|
||||
ds_hub_site_footer.then(function (ds_hub_site_footer_results) {
|
||||
if (ds_hub_site_footer_results) {
|
||||
console.log(`ds_hub_site_footer_results = `, ds_hub_site_footer_results);
|
||||
|
||||
ae_core = {
|
||||
...ae_core,
|
||||
'site_footer': ds_hub_site_footer_results,
|
||||
}
|
||||
|
||||
code = 'hub_site_footer';
|
||||
ae_loc_tmp.hub.ds[code] = ds_hub_site_footer_results;
|
||||
|
||||
ae_loc.set(ae_loc_tmp);
|
||||
console.log(`ae_loc = `, get(ae_loc));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
.finally(function () {
|
||||
console.log(`root layout.ts finally load...`);
|
||||
|
||||
data_struct['ae_core'] = ae_core;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// if (site_domain_results) {
|
||||
// console.log(`site_domain_results = `, site_domain_results);
|
||||
|
||||
// ae_api['account_id'] = site_domain_results.account_id_random;
|
||||
// // ae_api['headers']['account_id'] = site_domain_results.account_id_random;
|
||||
// ae_api.set(ae_api);
|
||||
// console.log(`ae_api = `, ae_api);
|
||||
|
||||
// ae_core = {
|
||||
// 'account_id': site_domain_results.account_id_random,
|
||||
// 'site_id': site_domain_results.site_id_random,
|
||||
// 'site_domain_id': site_domain_results.site_domain_id_random,
|
||||
// 'enable': site_domain_results.enable,
|
||||
// 'style_href': site_domain_results.style_href,
|
||||
// 'google_tracking_id': site_domain_results.google_tracking_id,
|
||||
// }
|
||||
|
||||
|
||||
// access_code_li_json = handle_get_data_store_obj_w_code({code: 'hub__page__access_code_li_json', data_type: 'json'});
|
||||
|
||||
// if (access_code_li_json) {
|
||||
// console.log(`access_code_li_json = `, access_code_li_json);
|
||||
|
||||
// ae_core = {
|
||||
// ...ae_core,
|
||||
// 'access_code_li': access_code_li_json,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return data_struct;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user