Wrapping up for the day
This commit is contained in:
@@ -97,7 +97,7 @@ console.log(`AE Stores - App Local Storage Data:`, ae_app_local_data_struct);
|
||||
|
||||
// This works and uses local storage:
|
||||
export let ae_loc: Writable<key_val> = localStorageStore('ae_loc', ae_app_local_data_struct);
|
||||
console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
|
||||
|
||||
|
||||
// This does not work yet...? Don't use.
|
||||
@@ -211,47 +211,3 @@ let slct_obj_template: key_val = {
|
||||
|
||||
// This works and uses local storage:
|
||||
export let slct: Writable<key_val> = localStorageStore('ae_slct', slct_obj_template);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// export let handle_load_ae_obj_id__site_domain = 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 = {};
|
||||
|
||||
// // ae_loc.hub.site_domain_id_qry_status = 'loading';
|
||||
// let ae_site_domain_obj_get_promise = api.get_ae_obj_id_crud({
|
||||
// api_cfg: 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: 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_site_domain_obj_get_promise;
|
||||
// }
|
||||
|
||||
|
||||
169
src/lib/element_app_cfg.svelte
Normal file
169
src/lib/element_app_cfg.svelte
Normal file
@@ -0,0 +1,169 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount, tick } from 'svelte';
|
||||
|
||||
import { ae_util } from '$lib/ae_utils';
|
||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
||||
|
||||
let notes: null|string = null;
|
||||
let all: boolean = false;
|
||||
let trigger: null|string = null;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
|
||||
onMount(() => {
|
||||
console.log('** Element Mounted: ** Element App Config');
|
||||
});
|
||||
|
||||
|
||||
// $: if (entered_passcode && entered_passcode.length >= 5) {
|
||||
// console.log(`entered_passcode=${entered_passcode}`);
|
||||
// handle_check_access_type_passcode();
|
||||
// }
|
||||
|
||||
// $: if (trigger && $ae_loc.access_type) {
|
||||
// console.log(`$ae_loc.access_type=${$ae_loc.access_type}`);
|
||||
|
||||
// let access_checks_results = ae_util.process_permission_checks($ae_loc.access_type);
|
||||
|
||||
// $ae_loc = {...$ae_loc, ...access_checks_results};
|
||||
// } else if (trigger) {
|
||||
// console.log(`$ae_loc.access_type=not set`);
|
||||
|
||||
// // Send an empty string to reset the permissions. This is the same as sending 'anonymous'.
|
||||
// let access_checks_results = ae_util.process_permission_checks('');
|
||||
|
||||
// $ae_loc = {...$ae_loc, ...access_checks_results};
|
||||
// }
|
||||
|
||||
|
||||
function handle_something() {
|
||||
// console.log('*** handle_something() ***');
|
||||
|
||||
}
|
||||
|
||||
function handle_clear_storage(item: null|string) {
|
||||
// console.log('*** handle_clear_storage() ***');
|
||||
// window.localStorage.setItem('access_type', 'anonymous');
|
||||
// return true;
|
||||
}
|
||||
|
||||
function dispatch_something_changed() {
|
||||
console.log('*** dispatch_something_changed() ***');
|
||||
|
||||
console.log(ae_util);
|
||||
console.log($ae_loc);
|
||||
|
||||
dispatch('access_type_changed', {
|
||||
access_type: $ae_loc.access_type
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<section id="AE-App-Cfg" class="ae_app_cfg transition duration-300 delay-150 hover:delay-300 hover:transition-all hidden-print">
|
||||
{#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'}
|
||||
{#if $ae_loc.access_type == 'super'}
|
||||
<span class="fas fa-secret"></span> Super Access
|
||||
{:else if $ae_loc.access_type == 'manager'}
|
||||
<span class="fas fa-user-shield"></span> Manager Access
|
||||
{:else if $ae_loc.access_type == 'administrator'}
|
||||
<span class="fas fa-user-ninja"></span> Administrator Access
|
||||
{:else if $ae_loc.access_type == 'trusted'}
|
||||
<span class="fas fa-user-nurse"></span> Trusted Access
|
||||
{:else if $ae_loc.access_type == 'authenticated'}
|
||||
<span class="fas fa-user-friends"></span> Authenticated Access
|
||||
{:else if $ae_loc.access_type == 'anonymous'}
|
||||
<span class="fas fa-users"></span> Anonymous Access
|
||||
{:else}
|
||||
<span class="fas fa-unlock mx-1"></span> Unknown Access
|
||||
{/if}
|
||||
|
||||
<button
|
||||
class="btn btn-sm access_type_lock_btn hover:transition-all"
|
||||
on:click={() => {
|
||||
handle_clear_access();
|
||||
}}
|
||||
title="Access mode is currently enabled/unlocked. Click to exit and lock."
|
||||
>
|
||||
<span class="fas fa-lock mx-1"></span> Lock
|
||||
</button>
|
||||
{:else}
|
||||
Not logged in
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
|
||||
<style lang="postcss">
|
||||
/* BEGIN: AE's Svelte Quick Access Type component */
|
||||
#AE-App-Cfg {
|
||||
/* position: absolute; */
|
||||
position: fixed;
|
||||
/* position: relative; */
|
||||
/* position: static; */
|
||||
/* position: sticky; */
|
||||
/* top: 1em; */
|
||||
bottom: 1.5rem;
|
||||
left: 0rem;
|
||||
|
||||
padding: .5rem;
|
||||
|
||||
/* lightyellow */
|
||||
/* background-color: hsla(60,100%,90%,.30); */
|
||||
background-color: rgba(var(--color-surface-500) / .5);
|
||||
|
||||
border-top: solid thin black;
|
||||
border-left: solid thin black;
|
||||
border-bottom: solid thin black;
|
||||
border-top-left-radius: .5em;
|
||||
border-bottom-left-radius: .5em;
|
||||
|
||||
opacity: .50;
|
||||
|
||||
font-size: .75rem;
|
||||
|
||||
z-index: 5;
|
||||
|
||||
/* NOTE: transition when no longer hovering */
|
||||
transition-property: opacity, background-color;
|
||||
transition-delay: .1s;
|
||||
transition-duration: .4s;
|
||||
transition-timing-function: linear;
|
||||
}
|
||||
|
||||
#AE-App-Cfg:hover {
|
||||
/* lightyellow */
|
||||
/* background-color: hsla(60,100%,90%,.95); */
|
||||
background-color: rgba(var(--color-surface-500) / 1);
|
||||
opacity: 1;
|
||||
|
||||
/* NOTE: transition when hover starts */
|
||||
transition-property: opacity, background-color;
|
||||
/* transition-delay: .5s; */
|
||||
transition-duration: .10s;
|
||||
transition-timing-function: linear;
|
||||
}
|
||||
|
||||
/* #Access-Type .unlock_text {
|
||||
transition: width 2s, height 2s, background-color 2s, transform 2s;
|
||||
} */
|
||||
/* END: Svelte Access Type component */
|
||||
|
||||
.access_type_unlock_btn .unlock_text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.access_type_unlock_btn:hover .unlock_text {
|
||||
display: initial;
|
||||
/* outline: solid thin red; */
|
||||
}
|
||||
|
||||
.access_type .current_text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.access_type:hover .current_text {
|
||||
display: initial;
|
||||
/* outline: solid thin red; */
|
||||
}
|
||||
</style>
|
||||
@@ -53,6 +53,7 @@ console.log($ae_loc, $ae_sess, $ae_api);
|
||||
|
||||
|
||||
import Element_access_type from '$lib/element_access_type.svelte';
|
||||
import Element_app_cfg from '$lib/element_app_cfg.svelte';
|
||||
|
||||
export let data;
|
||||
console.log(`ae_ Svelte +Layout page data:`, data);
|
||||
@@ -326,6 +327,8 @@ $: if ($slct_trigger == 'set_access_code_li' && !$ae_loc.ds['hub__page__access_c
|
||||
|
||||
<Element_access_type />
|
||||
|
||||
<Element_app_cfg />
|
||||
|
||||
|
||||
<style lang="postcss">
|
||||
</style>
|
||||
|
||||
@@ -6,94 +6,18 @@ import type { key_val } from '$lib/ae_stores';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
|
||||
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 = {};
|
||||
|
||||
// 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: 1
|
||||
})
|
||||
.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_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}`);
|
||||
|
||||
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) {
|
||||
|
||||
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 data_store_obj_get_promise;
|
||||
}
|
||||
|
||||
|
||||
export async function load({ params, url }) { // route
|
||||
console.log(`Svelte root layout.ts data = params:`, params);
|
||||
// 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);
|
||||
// console.log(`Svelte root layout.ts data = url:`, url);
|
||||
|
||||
let ae_loc_tmp = get(ae_loc);
|
||||
console.log(`ae_loc = `, ae_loc_tmp);
|
||||
// console.log(`ae_loc = `, ae_loc_tmp);
|
||||
|
||||
let ds_code_li: null|key_val = ae_loc_tmp.ds;
|
||||
console.log(`ae_ ds_code_li = `, ds_code_li);
|
||||
// console.log(`ae_ ds_code_li = `, ds_code_li);
|
||||
let ds_code: null|string = null;
|
||||
|
||||
|
||||
@@ -111,7 +35,7 @@ export async function load({ params, url }) { // route
|
||||
};
|
||||
|
||||
let loading_results = null;
|
||||
let access_code_li_json = 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) {
|
||||
@@ -362,6 +286,79 @@ export async function load({ params, url }) { // route
|
||||
}
|
||||
|
||||
|
||||
// export const ssr = false;
|
||||
// export const prerender = true;
|
||||
/// export const trailingSlash = 'always'; // 'never' | 'always' | 'ignore'
|
||||
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 = {};
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
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}`);
|
||||
|
||||
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) {
|
||||
|
||||
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 data_store_obj_get_promise;
|
||||
}
|
||||
|
||||
@@ -5,59 +5,38 @@ import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
|
||||
export function load({ params, url }) { // route
|
||||
export async function load({ params, url }) { // route
|
||||
// console.log(`Svelte Event Speakers layout.ts data = params:`, params);
|
||||
// console.log(`Svelte Event Speakers layout.ts data = route:`, route);
|
||||
console.log(`Svelte Event Speakers layout.ts data = url:`, url);
|
||||
|
||||
let event_obj_results = null;
|
||||
// console.log(`Svelte Event Speakers layout.ts data = url:`, url);
|
||||
|
||||
let event_id = url.searchParams.get('event_id');
|
||||
|
||||
event_obj_results = handle_load_ae_obj_id__event({event_id: event_id, try_cache: false});
|
||||
await handle_load_ae_obj_id__event({event_id: event_id, try_cache: false})
|
||||
.then(function (event_obj_results) {
|
||||
if (event_obj_results) {
|
||||
console.log(`event_obj_results = `, event_obj_results);
|
||||
|
||||
event_obj_results.then(function (event_obj_results) {
|
||||
if (event_obj_results) {
|
||||
console.log(`event_obj_results = `, event_obj_results);
|
||||
let ae_loc_tmp = get(ae_loc);
|
||||
ae_loc_tmp.event_id = event_obj_results.event_id_random;
|
||||
ae_loc_tmp.mod.events.event_id = event_obj_results.event_id_random;
|
||||
ae_loc.set(ae_loc_tmp);
|
||||
console.log(`ae_loc = `, get(ae_loc));
|
||||
|
||||
// let ae_api_tmp = get(ae_api);
|
||||
let slct_tmp = get(slct);
|
||||
slct_tmp.event_id = event_obj_results.event_id_random;
|
||||
slct_tmp.event_obj = event_obj_results;
|
||||
slct.set(slct_tmp);
|
||||
console.log(`slct = `, get(slct));
|
||||
|
||||
// ae_api_tmp['account_id'] = event_obj_results.account_id_random;
|
||||
// ae_api_tmp['headers']['x-account-id'] = event_obj_results.account_id_random;
|
||||
// ae_api_tmp['headers']['x-no-account-id'] = null;
|
||||
let slct_trigger_tmp = get(slct_trigger);
|
||||
slct_trigger_tmp = 'load__event_presenter_obj_li';
|
||||
slct_trigger.set(slct_trigger_tmp);
|
||||
console.log(`slct_trigger = `, get(slct_trigger));
|
||||
}
|
||||
|
||||
// ae_api.set(ae_api_tmp);
|
||||
// console.log(`ae_api = `, get(ae_api));
|
||||
|
||||
// ae_core = {
|
||||
// 'account_id': event_obj_results.account_id_random,
|
||||
// 'site_id': event_obj_results.site_id_random,
|
||||
// 'site_domain_id': event_obj_results.site_domain_id_random,
|
||||
// 'enable': event_obj_results.enable,
|
||||
// 'style_href': event_obj_results.style_href,
|
||||
// 'google_tracking_id': event_obj_results.google_tracking_id,
|
||||
// }
|
||||
|
||||
let ae_loc_tmp = get(ae_loc);
|
||||
ae_loc_tmp.event_id = event_obj_results.event_id_random;
|
||||
ae_loc_tmp.mod.events.event_id = event_obj_results.event_id_random;
|
||||
ae_loc.set(ae_loc_tmp);
|
||||
console.log(`ae_loc = `, get(ae_loc));
|
||||
|
||||
let slct_tmp = get(slct);
|
||||
slct_tmp.event_id = event_obj_results.event_id_random;
|
||||
slct_tmp.event_obj = event_obj_results;
|
||||
slct.set(slct_tmp);
|
||||
console.log(`slct = `, get(slct));
|
||||
|
||||
let slct_trigger_tmp = get(slct_trigger);
|
||||
slct_trigger_tmp = 'load__event_presenter_obj_li';
|
||||
slct_trigger.set(slct_trigger_tmp);
|
||||
console.log(`slct_trigger = `, get(slct_trigger));
|
||||
}
|
||||
|
||||
return event_obj_results;
|
||||
})
|
||||
return event_obj_results;
|
||||
})
|
||||
|
||||
let data_struct = {
|
||||
params: params,
|
||||
@@ -86,16 +65,10 @@ function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
||||
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
})
|
||||
.then(function (event_obj_get_result) {
|
||||
if (event_obj_get_result) {
|
||||
// slct.event_obj = event_obj_get_result;
|
||||
// console.log(`event object:`, get(slct).event_obj);
|
||||
|
||||
// ae_loc.account_id = $slct.event_obj.account_id_random;
|
||||
// ae_loc.site_id = $slct.event_obj.site_id_random;
|
||||
// ae_loc.event_id = $slct.event_obj.event_id_random;
|
||||
return event_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
@@ -107,4 +80,4 @@ function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
|
||||
});
|
||||
|
||||
return ae_event_obj_get_promise;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user