Lots of general clean up and fixes.

This commit is contained in:
Scott Idem
2024-03-20 13:31:42 -04:00
parent fbbaa1392b
commit 84e3098b72
10 changed files with 375 additions and 173 deletions

View File

@@ -261,13 +261,18 @@ $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_c
slotTrail="place-content-end"
>
<svelte:fragment slot="lead">
{#if $ae_loc.ds['hub__page__appshell_header_lead']}
<Element_data_store
ds_code="hub__page__appshell_header_lead"
ds_type="html"
display="block"
/>
<!-- {#if $ae_loc.ds['hub__page__appshell_header_lead']}
{@html $ae_loc.ds['hub__page__appshell_header_lead']}
{:else}
<a href="/" class="btn variant-gradiant-surface text-xl">
<span class="fas fa-laptop-house mx-1"></span> &AElig; Home
</a>
{/if}
{/if} -->
</svelte:fragment>
<!-- OSIT's Aether App -->
@@ -278,7 +283,12 @@ $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_c
display="block"
/>
<svelte:fragment slot="trail">
{#if $ae_loc.ds['hub__page__appshell_header_trail']}
<Element_data_store
ds_code="hub__page__appshell_header_trail"
ds_type="html"
display="block"
/>
<!-- {#if $ae_loc.ds['hub__page__appshell_header_trail']}
{@html $ae_loc.ds['hub__page__appshell_header_trail']}
{:else}
<a
@@ -307,7 +317,7 @@ $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_c
class="btn btn-sm variant-ghost-surface"
class:active={$page.url.pathname==='/events_leads'}
href="/events_leads">Leads</a>
{/if}
{/if} -->
</svelte:fragment>
</AppBar>
@@ -352,10 +362,16 @@ $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_c
<svelte:fragment slot="footer">
<div
class="flex justify-between text-slate-400 hover:text-slate-800 transition px-1"
class="flex text-sm sm:text-sm md:text-md lg:text-md xl:text-md 2xl:text-lg text-slate-400 hover:text-slate-800 transition px-1"
class:ae_debug={$ae_loc.debug}
>
{@html $ae_loc.ds['hub__site__appshell_footer']}
<!-- {@html $ae_loc.ds['hub__site__appshell_footer']} -->
<Element_data_store
ds_code="hub__site__appshell_footer"
ds_type="html"
display="block"
class_li="grow flex flex-row justify-between"
/>
<button
on:click={() => {

View File

@@ -1,30 +1,36 @@
/** @type {import('./$types').LayoutLoad} */
// console.log(`ae_root +layout.ts start`);
import { get } from 'svelte/store';
import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import { core_func } from '$lib/ae_core_functions';
import type { key_val } from '$lib/ae_stores';
// There is not an initial data store from SvelteKit for this, so we will just use the API to get the data.
// properties: params, route, url
// functions: fetch, setHeaders, parent, depends, untrack
export async function load({ params, url }) { // params, route, url
// console.log(`Svelte root layout.ts data = params:`, params);
// console.log(`Svelte root layout.ts data = route:`, route);
// console.log(`Svelte root layout.ts data = url:`, url);
export async function load({ fetch, params, parent, route, url }) { // params, route, url
// console.log(`Svelte root layout.ts params:`, params);
// console.log(`Svelte root layout.ts route:`, route);
// console.log(`Svelte root layout.ts url:`, url);
let ae_loc_tmp = get(ae_loc);
// console.log(`ae_loc = `, ae_loc_tmp);
let ae_api_tmp = get(ae_api);
console.log(`ae_api = `, ae_api_tmp);
let ds_code_li: null|key_val = ae_loc_tmp.ds;
// console.log(`ae_ ds_code_li = `, ds_code_li);
let ds_code: null|string = null;
let data_struct = {
ae_loc: get(ae_loc),
ae_api: get(ae_api),
ae_loc: ae_loc_tmp,
ae_api: ae_api_tmp,
ae_ds: {},
ae_hub: {}, // was ae_core
ae_m_sponsorships: {},
@@ -51,7 +57,10 @@ export async function load({ params, url }) { // params, route, url
// 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) {
if (!url.host) {
console.log(`ERROR: No host found in the URL!!!`);
return false;
}
// 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
@@ -59,13 +68,15 @@ export async function load({ params, url }) { // params, route, url
// ae_loc.site_domain = data.url.origin;
// console.log(`ae_loc = `, ae_loc);
loading_results = await handle_load_ae_obj_id__site_domain({fqdn: url.host, try_cache: false})
// const res = await fetch(`https://api.example.com/data`);
loading_results = await core_func.handle_load_ae_obj_id__site_domain({api_cfg: ae_api_tmp, fqdn: url.host, try_cache: false})
.then(function (site_domain_results) {
if (site_domain_results) {
// console.log(`ae_ site_domain_results = `, site_domain_results);
let ae_api_tmp = get(ae_api);
// 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;
@@ -96,7 +107,7 @@ export async function load({ params, url }) { // params, route, url
.then(async function (results) {
ds_code = 'hub__page__access_code_li_json';
await handle_get_data_store_obj_w_code({code: ds_code, data_type: '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);
@@ -120,102 +131,102 @@ export async function load({ params, url }) { // params, route, url
return true;
})
.then(async function (results) {
// We are intentionally loading these in series, not parallel to limit the number of simultaneous requests.
// .then(async function (results) {
// // We are intentionally loading these in series, not parallel to limit the number of simultaneous requests.
// let ae_loc_tmp = get(ae_loc);
// // let ae_loc_tmp = get(ae_loc);
// Loading the header and footer in series, not parallel.
ds_code = 'hub__site__appshell_header';
await handle_get_data_store_obj_w_code({code: ds_code})
.then(function (ds_hub_site_header_results) {
// // Loading the header and footer in series, not parallel.
// ds_code = 'hub__site__appshell_header';
// await handle_get_data_store_obj_w_code({code: ds_code})
// .then(function (ds_hub_site_header_results) {
if (ds_hub_site_header_results) {
// console.log(`ae_ ds_hub_site_header_results = `, ds_hub_site_header_results);
// let ae_loc_tmp = get(ae_loc);
// if (ds_hub_site_header_results) {
// // console.log(`ae_ ds_hub_site_header_results = `, ds_hub_site_header_results);
// // let ae_loc_tmp = get(ae_loc);
ds_code_li[ds_code] = ds_hub_site_header_results;
// ds_code_li[ds_code] = ds_hub_site_header_results;
// ae_loc.set(ae_loc_tmp);
// console.log(`ae_loc = `, get(ae_loc));
}
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
// }
})
// })
.then(async function () {
// .then(async function () {
ds_code = 'hub__site__appshell_footer';
await handle_get_data_store_obj_w_code({code: ds_code})
.then(function (ds_hub_site_footer_results) {
if (ds_hub_site_footer_results) {
// console.log(`ae_ hub__site__appshell_footer = `, ds_hub_site_footer_results);
// let ae_loc_tmp = get(ae_loc);
// ds_code = 'hub__site__appshell_footer';
// await handle_get_data_store_obj_w_code({code: ds_code})
// .then(function (ds_hub_site_footer_results) {
// if (ds_hub_site_footer_results) {
// // console.log(`ae_ hub__site__appshell_footer = `, ds_hub_site_footer_results);
// // let ae_loc_tmp = get(ae_loc);
ds_code_li[ds_code] = ds_hub_site_footer_results;
// ds_code_li[ds_code] = ds_hub_site_footer_results;
// ae_loc.set(ae_loc_tmp);
// console.log(`ae_loc = `, get(ae_loc));
}
});
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
// }
// });
})
// })
.then(async function () {
// .then(async function () {
ds_code = 'hub__site__root_page_content';
await handle_get_data_store_obj_w_code({code: ds_code})
.then(function (ds_code_results) {
if (ds_code_results) {
// console.log(`ae_ hub__site__root_page_content = `, ds_code_results);
// let ae_loc_tmp = get(ae_loc);
// ds_code = 'hub__site__root_page_content';
// await handle_get_data_store_obj_w_code({code: ds_code})
// .then(function (ds_code_results) {
// if (ds_code_results) {
// // console.log(`ae_ hub__site__root_page_content = `, ds_code_results);
// // let ae_loc_tmp = get(ae_loc);
ds_code_li[ds_code] = ds_code_results;
// ds_code_li[ds_code] = ds_code_results;
// ae_loc.set(ae_loc_tmp);
// console.log(`ae_loc = `, get(ae_loc));
}
});
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
// }
// });
})
// })
.then(async function () {
// .then(async function () {
// Loading the header and footer in series, not parallel.
ds_code = 'hub__page__appshell_header_lead';
await handle_get_data_store_obj_w_code({code: ds_code})
.then(function (ds_code_results) {
if (ds_code_results) {
// console.log(`ae_ hub__page__appshell_header_lead = `, ds_code_results);
// let ae_loc_tmp = get(ae_loc);
// // Loading the header and footer in series, not parallel.
// ds_code = 'hub__page__appshell_header_lead';
// await handle_get_data_store_obj_w_code({code: ds_code})
// .then(function (ds_code_results) {
// if (ds_code_results) {
// // console.log(`ae_ hub__page__appshell_header_lead = `, ds_code_results);
// // let ae_loc_tmp = get(ae_loc);
ds_code_li[ds_code] = ds_code_results;
// ds_code_li[ds_code] = ds_code_results;
// ae_loc.set(ae_loc_tmp);
// console.log(`ae_loc = `, get(ae_loc));
}
});
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
// }
// });
})
// })
.then(async function () {
// .then(async function () {
ds_code = 'hub__page__appshell_header_trail';
await handle_get_data_store_obj_w_code({code: ds_code})
.then(function (ds_code_results) {
if (ds_code_results) {
// console.log(`hub__page__appshell_header_trail = `, ds_code_results);
// let ae_loc_tmp = get(ae_loc);
// ds_code = 'hub__page__appshell_header_trail';
// await handle_get_data_store_obj_w_code({code: ds_code})
// .then(function (ds_code_results) {
// if (ds_code_results) {
// // console.log(`hub__page__appshell_header_trail = `, ds_code_results);
// // let ae_loc_tmp = get(ae_loc);
ds_code_li[ds_code] = ds_code_results;
// ds_code_li[ds_code] = ds_code_results;
// ae_loc.set(ae_loc_tmp);
// console.log(`ae_loc = `, get(ae_loc));
}
});
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
// }
// });
});
// });
})
// })
.finally(function () {
let iframe = url.searchParams.get('iframe');
@@ -244,7 +255,7 @@ export async function load({ params, url }) { // params, route, url
data_struct['ae_ds'] = ds_code_li;
console.log(`ae_root +layout.ts loaded initial DS`);
console.log(`ae_root +layout.ts loading initial DS still...`);
return true;
});
@@ -294,89 +305,89 @@ export async function load({ params, url }) { // params, route, url
// }
// data_struct['ae_loc'] = loading_results;
console.log(`ae_root +layout.ts load after DS loading?`);
console.log(`ae_root +layout.ts load after initial data stores loaded`);
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;
// console.log(`ae_root +layout.ts load function end`);
// return data_struct;
}
async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
// async function handle_load_ae_obj_id__site_domain({fqdn, try_cache=false}) {
// console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
let params = {};
// let params = {};
// ae_loc.hub.site_domain_id_qry_status = 'loading';
let ae_site_domain_obj_get_promise = api.get_ae_obj_id_crud({
api_cfg: get(ae_api),
no_account_id: true,
obj_type: 'site_domain',
obj_id: fqdn, // NOTE: This is the FQDN, not normally the ID.
use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: true, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: 0
})
.then(function (site_domain_obj_get_result) {
if (site_domain_obj_get_result) {
// slct.site_domain_obj = site_domain_obj_get_result;
// console.log(`site_domain object:`, get(slct).site_domain_obj);
// // ae_loc.hub.site_domain_id_qry_status = 'loading';
// let ae_site_domain_obj_get_promise = api.get_ae_obj_id_crud({
// api_cfg: get(ae_api),
// no_account_id: true,
// obj_type: 'site_domain',
// obj_id: fqdn, // NOTE: This is the FQDN, not normally the ID.
// use_alt_table: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
// use_alt_base: true, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
// params: params,
// log_lvl: 0
// })
// .then(function (site_domain_obj_get_result) {
// if (site_domain_obj_get_result) {
// // slct.site_domain_obj = site_domain_obj_get_result;
// // console.log(`site_domain object:`, get(slct).site_domain_obj);
// ae_loc.account_id = $slct.site_domain_obj.account_id_random;
// ae_loc.site_id = $slct.site_domain_obj.site_id_random;
// ae_loc.site_domain_id = $slct.site_domain_obj.site_domain_id_random;
return site_domain_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
// // ae_loc.account_id = $slct.site_domain_obj.account_id_random;
// // ae_loc.site_id = $slct.site_domain_obj.site_id_random;
// // ae_loc.site_domain_id = $slct.site_domain_obj.site_domain_id_random;
// return site_domain_obj_get_result;
// } else {
// console.log('No results returned.');
// return null;
// }
// })
// .catch(function (error) {
// console.log('No results returned or failed.', error);
// });
return ae_site_domain_obj_get_promise;
}
// return ae_site_domain_obj_get_promise;
// }
// let ds_obj_get_promises: key_val = {};
async function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
// async function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
// console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
if (!code) {
console.log('No code provided.');
return;
}
// if (!code) {
// console.log('No code provided.');
// return;
// }
let data_store_obj_get_promise = api.get_data_store_obj_w_code({
api_cfg: get(ae_api),
data_store_code: code,
data_type: data_type,
log_lvl: 0
})
.then(function (get_data_store_result) {
let return_this = null;
if (get_data_store_result) {
// let data_store_obj_get_promise = api.get_data_store_obj_w_code({
// api_cfg: get(ae_api),
// data_store_code: code,
// data_type: data_type,
// log_lvl: 0
// })
// .then(function (get_data_store_result) {
// let return_this = null;
// if (get_data_store_result) {
if (data_type == 'text') {
// console.log(get_data_store_result.text);
return_this = get_data_store_result.text;
} else if (data_type == 'json') {
// console.log(get_data_store_result.json);
return_this = get_data_store_result.json;
}
// if (data_type == 'text') {
// // console.log(get_data_store_result.text);
// return_this = get_data_store_result.text;
// } else if (data_type == 'json') {
// // console.log(get_data_store_result.json);
// return_this = get_data_store_result.json;
// }
} else {
console.log('No results returned.');
return_this = null;
}
return return_this;
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
// } else {
// console.log('No results returned.');
// return_this = null;
// }
// return return_this;
// })
// .catch(function (error) {
// console.log('No results returned or failed.', error);
// });
return data_store_obj_get_promise;
}
// return data_store_obj_get_promise;
// }

View File

@@ -74,6 +74,7 @@ onMount(() => {
</div>
<Element_data_store
expire_minutes={2}
ds_code="hub__site__root_page_footer"
ds_type="html"
for_type={null}

View File

@@ -601,7 +601,8 @@ function handle_qr_camera(event) {
{/if}
<span class="fas fa-credit-card mx-1"></span>
</svelte:fragment>
Payment
<span class="text-xs">License
Payment</span>
</Tab>
<Tab
@@ -621,7 +622,7 @@ function handle_qr_camera(event) {
name="tab_add_scan"
value={'add_scan'}
disabled={!$events_slct.exhibit_obj || !$events_loc?.leads.auth_exhibit_kv || !$events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id]}
regionTab={!$events_slct.exhibit_obj || !$events_loc?.leads.auth_exhibit_kv || !$events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id] ? 'text-slate-400' : ''}
regionTab={!$events_slct.exhibit_obj || !$events_loc?.leads.auth_exhibit_kv || !$events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id] ? 'text-slate-400' : 'text-tertiary-500'}
>
<svelte:fragment slot="lead">
<span class="fas fa-qrcode"></span>
@@ -650,11 +651,13 @@ function handle_qr_camera(event) {
value={'manage'}
disabled={!$events_slct.exhibit_obj || !$events_loc?.leads.auth_exhibit_kv || !$events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id]}
regionTab={!$events_slct.exhibit_obj || !$events_loc?.leads.auth_exhibit_kv || !$events_loc.leads.auth_exhibit_kv[$events_slct.exhibit_id] ? 'text-slate-400' : ''}
title="Manage the exhibit settings, licenses, and other."
>
<svelte:fragment slot="lead">
<span class="fas fa-cogs"></span>
</svelte:fragment>
Manage
<!-- Manage -->
Conf
</Tab>
</TabGroup>
@@ -835,6 +838,16 @@ function handle_qr_camera(event) {
updated_on: new Date().toISOString()
};
}
if ($events_loc.leads.auto_hide_on_sign_in) {
$events_loc.leads.tab[$events_slct.exhibit_id] = 'add_scan';
$ae_loc.iframe = true;
// document.getElementsByTagName('html')[0].classList.add('iframe');
// document.getElementsByTagName('html')[0].classList.remove('dark');
// document.getElementsByTagName('html')[0].classList.remove('light');
}
}}
class="btn btn-sm text-sm variant-soft-primary"
title="Sign in using this license"

View File

@@ -149,6 +149,19 @@ export let get_event_exhibit_tracking_export = async function get_event_exhibit_
{#if $events_loc?.leads.auth_exhibit_kv[$events_slct.exhibit_id]}
Auto hide on sign in:
<button
type="button"
on:click={() => {
console.log('Auto hide on sign in');
$events_loc.leads.auto_hide_on_sign_in = !$events_loc.leads.auto_hide_on_sign_in;
}}
class="btn btn-sm variant-soft w-48"
>
<span class="fas fa-eye-slash mx-1"></span>
Turn {$events_loc.leads.auto_hide_on_sign_in ? 'off' : 'on'} auto hide
</button>
Turn on iframe mode:
<button
type="button"