diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 48360461..e64fc16d 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -47,14 +47,16 @@ export let ae_snip = string_snippets; // }; // Set the version for the app data. Changing this should force a notification and ask the user to clear and reload the page. -let ver = '2025-04-18_1335'; // KEEP: 2025-04-18_1335 +let ver = '2025-04-29_1545'; // KEEP: 2025-04-18_1335 let ver_idb = '2025-04-18_1100'; // Not used // *** BEGIN *** Longer-term app data. This should be stored to local storage. const ae_app_local_data_defaults: key_val = { last_page_reload: null, // last_idb_reload: null, - last_cache_refresh: null, + // last_cache_refresh: null, // Date.now() + last_cache_refresh: Date.now(), + cache_expired: false, ver: ver, // ver, // '2025-04-18_1100', ver_idb: ver_idb, // '2025-04-18_1100', name: 'Aether - App Hub (SvelteKit 2.x Svelte 4.x)', diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 06497016..2339fd3f 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,84 +1,381 @@ + let iframe = data.url.searchParams.get('iframe'); + if (iframe == 'true') { + console.log('Use iframe layout!'); + $ae_loc.iframe = true; - {#if $ae_loc?.site_google_tracking_id && $ae_loc?.site_google_tracking_id.length > 0} - - {/if} + document.getElementsByTagName('html')[0].classList.add('iframe'); + // document.getElementsByTagName('html')[0].classList.remove('dark'); + // document.getElementsByTagName('html')[0].classList.remove('light'); - - - - - + $ae_loc.app_cfg.show_element__access_type = false; + $ae_loc.app_cfg.show_element__cfg = false; + } else if (iframe == 'false') { + $ae_loc.iframe = false; + + document.getElementsByTagName('html')[0].classList.remove('iframe'); + // document.getElementsByTagName('html')[0].classList.add('dark'); + // document.getElementsByTagName('html')[0].classList.add('light'); + } + + if (!$ae_loc.iframe && $ae_loc.trusted_access) { + $ae_loc.app_cfg.show_element__access_type = true; + $ae_loc.app_cfg.show_element__cfg = true; + } else if ($ae_loc.iframe && $ae_loc.manager_access) { + $ae_loc.app_cfg.show_element__access_type = true; + $ae_loc.app_cfg.show_element__cfg = true; + } else { + $ae_loc.app_cfg.show_element__access_type = true; + $ae_loc.app_cfg.show_element__cfg = false; + } - + // This is mainly for Precon CHOW + if (data.url.searchParams.get('event_id')) { + $events_slct.event_id = data.url.searchParams.get('event_id'); + $events_loc.event_id = data.url.searchParams.get('event_id'); + } - {#if (browser && $ae_loc && $ae_sess && ($ae_loc.ver != $ae_sess.ver))} -
-

New Version Available

-

A new version of the site is available. Please reload the page.

- -
+ // invalidateAll(); + if ($ae_loc?.trusted_access && (Date.now() - $ae_loc?.last_cache_refresh) > trusted_refresh_time) { + if (log_lvl) { + console.log(`ROOT LOOP: Last (trusted) local config reload too old for all caches: ${$ae_loc.last_cache_refresh}`); + } - {:else if $ae_loc?.allow_access} - + // flag_clear_idb = true; + // flag_clear_local = true; + // flag_clear_sess = true; + // flag_reload = true; + // flag_expired = true; - - {@render children?.()} + $ae_loc.allow_access = false; + $ae_loc.cache_expired = true; - {:else if browser} + // location.reload(); -
-

Access Denied

-

You do not have access to this site. You may need a passcode, sign in link, and or URL site key.

- - - - -
-

If you have tried the "Reload and Clear Cache" button, you may need to manually reload the page using your browser's reload button or by pressing Ctrl + R or Cmd + R.

-

This sometimes happens with new versions of the app or when in an iframe.

-
-
- - {/if} - - - - -
- - - - {#if $ae_loc.edit_mode} - - {:else if $ae_loc.authenticated_access} - - {/if} - -
- {#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'} - - - - - {#if $ae_loc.access_type == 'super'} - - - {:else if $ae_loc.access_type == 'manager'} - - - {:else if $ae_loc.access_type == 'administrator'} - - - {:else if $ae_loc.access_type == 'trusted'} - - - {:else if $ae_loc.access_type == 'public'} - Public - - {:else if $ae_loc.access_type == 'authenticated'} - Authenticated - - {:else if $ae_loc.access_type == 'anonymous'} - Anonymous Access - {:else} - Unknown Access - {/if} - - - - {:else} - - {/if} -
- - +{#if (browser && flag_new_ver)} +
+

New Version Available

+

A new version of the site is available. Please reload the page.

- -
- - -
- - - { + window.location.reload(); + }} > - - - + + Reload Page + + +{:else if browser && $ae_loc?.cache_expired} +
+

Expired Cache

+

The cache for this site has expired. Please reload the page.

+ +
+ +{:else if browser && !$ae_loc?.allow_access} + + +
+

Access Denied

+

You do not have access to this site. You may need a passcode, sign in link, and or URL site key.

+ + + + + + +
+

If you have tried the "Reload and Clear Cache" button, you may need to manually reload the page using your browser's reload button or by pressing Ctrl + R or Cmd + R.

+

This sometimes happens with new versions of the app or when in an iframe.

+
+
+ +{:else if (browser && $ae_loc?.allow_access)} + + + + + {@render children?.()} + +{:else if (browser || flag_reload)} + + + Loading... + +{/if} + + + +{#if (browser) } + +
+ + + + {#if $ae_loc.edit_mode} + + {:else if $ae_loc.authenticated_access} + + {/if} + +
+ {#if $ae_loc.access_type && $ae_loc.access_type != 'anonymous'} + + + + + {#if $ae_loc.access_type == 'super'} + + + {:else if $ae_loc.access_type == 'manager'} + + + {:else if $ae_loc.access_type == 'administrator'} + + + {:else if $ae_loc.access_type == 'trusted'} + + + {:else if $ae_loc.access_type == 'public'} + Public + + {:else if $ae_loc.access_type == 'authenticated'} + Authenticated + + {:else if $ae_loc.access_type == 'anonymous'} + Anonymous Access + {:else} + Unknown Access + {/if} + + + - -
- -
- - - - - + }} + class="btn btn-sm variant-outline-surface hover:variant-ghost-warning transition-all hidden" + title="Access mode is currently enabled/unlocked. Click to exit and lock." + > + Lock? + + {:else} + + {/if}
- +