Lots of general clean up and fixes.
This commit is contained in:
107
src/lib/ae_core_functions.ts
Normal file
107
src/lib/ae_core_functions.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
// import { liveQuery } from "dexie";
|
||||
// import { db_core } from "$lib/db_core";
|
||||
|
||||
// let example_li = liveQuery(
|
||||
// () => db_core.badges.toArray()
|
||||
// );
|
||||
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
|
||||
// Updated 2024-03-20
|
||||
async function handle_load_ae_obj_id__site_domain({ api_cfg, fqdn, try_cache=false }) {
|
||||
console.log(`*** handle_load_ae_obj_id__site_domain() *** fqdn=${fqdn}`);
|
||||
|
||||
let no_account_id = false;
|
||||
if (!api_cfg.account_id) {
|
||||
no_account_id = true;
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
// ae_loc.hub.site_domain_id_qry_status = 'loading';
|
||||
ae_promises.load__site_domain_obj = api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
no_account_id: no_account_id,
|
||||
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: 2
|
||||
})
|
||||
.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);
|
||||
});
|
||||
|
||||
return ae_promises.load__site_domain_obj;
|
||||
}
|
||||
|
||||
// handle_load_ae_obj_code__data_store
|
||||
async function handle_load_ae_obj_code__data_store({ api_cfg, code=null, data_type='text' }) {
|
||||
console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
|
||||
|
||||
if (!code) {
|
||||
console.log('No code provided.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!api_cfg.account_id) {
|
||||
console.log('No account_id provided.');
|
||||
return false;
|
||||
}
|
||||
|
||||
ae_promises.load__data_store_obj = api.get_data_store_obj_w_code({
|
||||
api_cfg: api_cfg,
|
||||
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;
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return_this = null;
|
||||
}
|
||||
return return_this;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
return ae_promises.load__data_store_obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let export_obj = {
|
||||
handle_load_ae_obj_id__site_domain: handle_load_ae_obj_id__site_domain,
|
||||
handle_load_ae_obj_code__data_store: handle_load_ae_obj_code__data_store,
|
||||
};
|
||||
export let core_func = export_obj;
|
||||
@@ -47,6 +47,7 @@ let events_local_data_struct: key_val = {
|
||||
show_content__scan_requirements: true,
|
||||
|
||||
auto_view: true,
|
||||
auto_hide_on_sign_in: true,
|
||||
|
||||
show_hidden: false, // These are hidden (archived) leads so the list is not as long.
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { localStorageStore } from '@skeletonlabs/skeleton';
|
||||
import { get, readable, writable } from 'svelte/store';
|
||||
import type { get, Writable } from 'svelte/store';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
|
||||
import { PUBLIC_TESTING, PUBLIC_AE_API_PROTOCOL, PUBLIC_AE_API_SERVER, PUBLIC_AE_API_BAK_SERVER, PUBLIC_AE_API_PORT, PUBLIC_AE_API_PATH, PUBLIC_AE_API_SECRET_KEY, PUBLIC_AE_API_CRUD_SUPER_KEY, PUBLIC_AE_NO_ACCOUNT_ID, PUBLIC_AE_NO_ACCOUNT_ID_TOKEN, PUBLIC_AE_ACCOUNT_ID, PUBLIC_AE_EVENT_ID, PUBLIC_AE_SPONSORSHIP_CFG_ID } from '$env/static/public';
|
||||
// console.log(`AE Stores - PUBLIC_TESTING:`, PUBLIC_TESTING);
|
||||
console.log(`AE Stores - PUBLIC_TESTING:`, PUBLIC_TESTING);
|
||||
|
||||
const api_base_url = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`;
|
||||
const api_base_url_bak = `${PUBLIC_AE_API_PROTOCOL}://${PUBLIC_AE_API_BAK_SERVER}:${PUBLIC_AE_API_PORT}${PUBLIC_AE_API_PATH}`;
|
||||
@@ -21,7 +21,7 @@ const ae_sponsorship_cfg_id = PUBLIC_AE_SPONSORSHIP_CFG_ID;
|
||||
|
||||
// import { getStores, navigating, page, updated } from '$app/stores';
|
||||
// import { assets, base, resolveRoute } from '$app/paths';
|
||||
// console.log(page.path); // Everything after the domian name
|
||||
// console.log(page.path); // Everything after the domain name
|
||||
|
||||
// console.log(import.meta.env.MODE);
|
||||
// console.log(import.meta.env.BASE_URL);
|
||||
|
||||
@@ -59,7 +59,7 @@ export let temp_get_object_percent_completed = 0;
|
||||
export let get_object_percent_completed = temp_get_object_percent_completed;
|
||||
|
||||
// Updated 2022-10-28
|
||||
export let get_object = async function get_object({api_cfg, endpoint='', headers={}, params={}, data={}, timeout=600000, return_meta=false, return_blob=false, filename=null, auto_download=false, as_list=false, log_lvl=0}) {
|
||||
export let get_object = async function get_object({api_cfg, endpoint='', headers={}, params={}, data={}, timeout=60000, return_meta=false, return_blob=false, filename=null, auto_download=false, as_list=false, log_lvl=0}) {
|
||||
if (log_lvl) {
|
||||
console.log('*** get_object() ***');
|
||||
}
|
||||
@@ -226,6 +226,10 @@ export let get_object = async function get_object({api_cfg, endpoint='', headers
|
||||
}
|
||||
return null; // Returning null since there were no results
|
||||
}
|
||||
if (error.code === 'ECONNABORTED') {
|
||||
// Timeout Error (You can implement retry here where suitable)
|
||||
console.log('Timeout Error: ', error.message);
|
||||
}
|
||||
if (log_lvl) {
|
||||
console.log('The response was an error. Returning false.');
|
||||
}
|
||||
@@ -1320,16 +1324,16 @@ export let get_data_store_obj_w_code = async function get_data_store_obj_w_code(
|
||||
// let get_item_result = window.localStorage.getItem(code);
|
||||
|
||||
const endpoint = `/data_store/code/${data_store_code}`;
|
||||
let data_store_obj_get_promise = await api.get_object({api_cfg: api_cfg, endpoint: endpoint, headers: headers, params: params, log_lvl: log_lvl});
|
||||
let data_store_obj_get_promise = await api.get_object({api_cfg: api_cfg, endpoint: endpoint, headers: headers, params: params, timeout: 3000, log_lvl: log_lvl});
|
||||
|
||||
if (data_store_obj_get_promise === false) {
|
||||
console.log('Data Store - RUN AGAIN WITH BACKUP');
|
||||
let original_api_base_url = api_cfg['base_url'];
|
||||
|
||||
let temp_api = api_cfg;
|
||||
temp_api['base_url'] = temp_api['base_url_backup']
|
||||
temp_api['base_url'] = temp_api['base_url_bak']
|
||||
|
||||
data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, log_lvl: log_lvl});
|
||||
data_store_obj_get_promise = await api.get_object({api_cfg: temp_api, endpoint: endpoint, headers: headers, params: params, timeout: 6000, log_lvl: log_lvl});
|
||||
temp_api['base_url'] = original_api_base_url;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ import { ae_loc, ae_sess, ae_api, slct, slct_trigger, ae_trig } from '$lib/ae_st
|
||||
import { ae_util } from '$lib/ae_utils';
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
|
||||
export let expire_minutes: number = 10;
|
||||
|
||||
export let ds_code: string;
|
||||
export let ds_name: null|string = null;
|
||||
export let ds_type: string = 'text';
|
||||
export let for_type: null|string;
|
||||
export let for_id: null|string;
|
||||
export let for_type: null|string = null;
|
||||
export let for_id: null|string = null;
|
||||
console.log(`ae_e_data_store ${ds_code} for_type=${for_type} for_id=${for_id}`);
|
||||
|
||||
export let store: string = 'local';
|
||||
@@ -71,7 +73,37 @@ $ae_sess.ds.submit_status = null;
|
||||
$ae_sess.ds.create_status = null;
|
||||
$ae_sess.ds.update_status = null;
|
||||
|
||||
let trigger: null|string = 'load__ds__code';
|
||||
let trigger: null|string = null;
|
||||
|
||||
// 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) {
|
||||
let loaded_on = new Date($ae_ds_loc.loaded_on);
|
||||
let now = new Date();
|
||||
let diff = now.getTime() - loaded_on.getTime();
|
||||
let diff_minutes = diff / (1000 * 60);
|
||||
if (diff_minutes > expire_minutes) {
|
||||
console.log(`Data Store ${ds_code} stale. Last loaded on: ${loaded_on.toISOString()}`);
|
||||
// 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);
|
||||
console.log(`Random number of milliseconds: ${random_ms}`);
|
||||
setTimeout(() => {
|
||||
trigger = 'load__ds__code';
|
||||
}, random_ms);
|
||||
// trigger = 'load__ds__code';
|
||||
}
|
||||
// let diff_hours = diff / (1000 * 60 * 60);
|
||||
// if (diff_hours > 1) {
|
||||
// trigger = 'load__ds__code';
|
||||
// }
|
||||
} else {
|
||||
console.log('No loaded_on date found. Need to trigger reload.');
|
||||
trigger = 'load__ds__code';
|
||||
}
|
||||
|
||||
// This is a secondary check... The account_id should either be null or match the current account_id.
|
||||
if (!$ae_ds_loc.account_id === null || $ae_loc.account_id == $ae_loc.account_id) {
|
||||
trigger = 'load__ds__code';
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log('Element: Data Store element_data_store.svelte');
|
||||
@@ -123,6 +155,11 @@ async function load_data_store({
|
||||
return false;
|
||||
}
|
||||
|
||||
ds_loaded = true;
|
||||
|
||||
// Set the loaded_on datetime to the current time for reference later. This will be used to determine if the data store is stale.
|
||||
$ae_ds_loc.loaded_on = new Date().toISOString();
|
||||
|
||||
$ae_ds_loc.id = ds_results.data_store_id_random;
|
||||
$ae_ds_loc.account_id = ds_results.account_id_random;
|
||||
$ae_ds_loc.code = ds_results.code; // This will overwrite whatever was passed in.
|
||||
@@ -149,8 +186,6 @@ async function load_data_store({
|
||||
val_text = ds_results.text;
|
||||
return ds_results.text;
|
||||
}
|
||||
|
||||
ds_loaded = true;
|
||||
} else {
|
||||
ds_loaded = false;
|
||||
ds_loading_status = '-- not found --';
|
||||
@@ -654,11 +689,12 @@ async function handle_update__data_store({
|
||||
class="ae_btn_edit__ds btn hover:variant-glass-warning text-xs absolute top-0 right-0 opacity-30 hover:opacity-100 transition delay-700 hover:delay-200 m-1 p-1"
|
||||
class:opacity-5={!$ae_loc.administrator_access}
|
||||
class:hidden={!show_edit_btn || !$ae_loc.trusted_access}
|
||||
on:click={() => {
|
||||
on:dblclick={() => {
|
||||
trigger = 'load__ds__code';
|
||||
show_edit = true;
|
||||
show_view = false;
|
||||
}}
|
||||
title="Double click to edit data store: {ds_code} with {$ae_ds_loc.account_id ? `account ID=${$ae_ds_loc.account_id}` : 'no account ID'}"
|
||||
>
|
||||
<span class="fas fa-edit mx-1"></span>
|
||||
Edit
|
||||
@@ -681,7 +717,7 @@ async function handle_update__data_store({
|
||||
</pre> -->
|
||||
|
||||
{#await ds_get_results}
|
||||
<div class="modal-loading text-xs">
|
||||
<div class="modal-loading text-xs absolute bottom-0 left-0 opacity-30 hover:opacity-100 transition delay-700 hover:delay-200">
|
||||
<span class="fas fa-spinner fa-spin"></span>
|
||||
<span class="loading-text">
|
||||
Loading...
|
||||
|
||||
@@ -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> Æ 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={() => {
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user