Saving more code clean up and removal
This commit is contained in:
@@ -11,6 +11,88 @@ const ae_promises: key_val = {};
|
||||
* --- SITE CRUD ---
|
||||
*/
|
||||
|
||||
// Legacy version
|
||||
// export async function lookup_site_domain({
|
||||
// api_cfg,
|
||||
// fqdn,
|
||||
// view = 'default',
|
||||
// log_lvl = 0
|
||||
// }: {
|
||||
// api_cfg: any;
|
||||
// fqdn: string;
|
||||
// view?: string;
|
||||
// log_lvl?: number;
|
||||
// }): Promise<ae_SiteDomain | null> {
|
||||
// if (log_lvl) {
|
||||
// console.log(`*** lookup_site_domain() *** fqdn=${fqdn}`);
|
||||
// }
|
||||
|
||||
// try {
|
||||
// // We use get_ae_obj_id_crud because we are looking up by a unique field (fqdn) rather than ID.
|
||||
// // This is the older method that uses the /crud/site/domain/:id endpoint.
|
||||
// const result = await api.get_ae_obj_id_crud({
|
||||
// api_cfg,
|
||||
// no_account_id: true,
|
||||
// obj_type: 'site_domain',
|
||||
// obj_id: fqdn,
|
||||
// use_alt_table: true,
|
||||
// use_alt_base: true,
|
||||
// log_lvl
|
||||
// });
|
||||
|
||||
// if (result) {
|
||||
// // Standardize and save to cache
|
||||
// const processed_obj_li = await process_ae_obj__site_domain_props({
|
||||
// obj_li: [result],
|
||||
// log_lvl
|
||||
// });
|
||||
// await db_save_ae_obj_li__ae_obj({
|
||||
// db_instance: db_core,
|
||||
// table_name: 'site_domain',
|
||||
// obj_li: processed_obj_li,
|
||||
// properties_to_save: properties_to_save__site_domain,
|
||||
// log_lvl
|
||||
// });
|
||||
// return result;
|
||||
// }
|
||||
// } catch (error: any) {
|
||||
// console.log('Site domain lookup failed (API Error).', error);
|
||||
// }
|
||||
|
||||
// if (log_lvl) console.log('Attempting to load site domain from local cache...');
|
||||
// const cached = await db_core.site_domain.where('fqdn').equals(fqdn).first();
|
||||
|
||||
// if (cached) {
|
||||
// return cached as any;
|
||||
// }
|
||||
|
||||
// // CRITICAL FALLBACK: If both API and Cache fail, return a "Ghost" site domain object
|
||||
// // to prevent the 403 error from blocking the UI. Page components will handle empty data.
|
||||
// console.error('AE_SITE_CRITICAL: Site domain lookup failed API and CACHE. Returning ghost object.');
|
||||
// return {
|
||||
// id: 'ghost',
|
||||
// id_random: 'ghost',
|
||||
// site_domain_id: 'ghost',
|
||||
// site_domain_id_random: 'ghost',
|
||||
// site_id: 'ghost',
|
||||
// site_id_random: 'ghost',
|
||||
// account_id: 'ghost',
|
||||
// account_id_random: 'ghost',
|
||||
// account_code: 'ghost',
|
||||
// account_name: 'Ghost Account (Offline)',
|
||||
// fqdn: fqdn,
|
||||
// enable: '1',
|
||||
// header_image_path: '',
|
||||
// style_href: '',
|
||||
// google_tracking_id: '',
|
||||
// access_code_kv_json: {},
|
||||
// cfg_json: {},
|
||||
// access_key: '',
|
||||
// site_domain_access_key: ''
|
||||
// } as any;
|
||||
// }
|
||||
|
||||
// Updated 2026-01-26 (Cache-First Optimization)
|
||||
export async function lookup_site_domain({
|
||||
api_cfg,
|
||||
fqdn,
|
||||
@@ -23,88 +105,7 @@ export async function lookup_site_domain({
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_SiteDomain | null> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** lookup_site_domain() *** fqdn=${fqdn}`);
|
||||
}
|
||||
|
||||
try {
|
||||
// We use get_ae_obj_id_crud because we are looking up by a unique field (fqdn) rather than ID.
|
||||
// This is the older method that uses the /crud/site/domain/:id endpoint.
|
||||
const result = await api.get_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
no_account_id: true,
|
||||
obj_type: 'site_domain',
|
||||
obj_id: fqdn,
|
||||
use_alt_table: true,
|
||||
use_alt_base: true,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (result) {
|
||||
// Standardize and save to cache
|
||||
const processed_obj_li = await process_ae_obj__site_domain_props({
|
||||
obj_li: [result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_core,
|
||||
table_name: 'site_domain',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save__site_domain,
|
||||
log_lvl
|
||||
});
|
||||
return result;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('Site domain lookup failed (API Error).', error);
|
||||
}
|
||||
|
||||
if (log_lvl) console.log('Attempting to load site domain from local cache...');
|
||||
const cached = await db_core.site_domain.where('fqdn').equals(fqdn).first();
|
||||
|
||||
if (cached) {
|
||||
return cached as any;
|
||||
}
|
||||
|
||||
// CRITICAL FALLBACK: If both API and Cache fail, return a "Ghost" site domain object
|
||||
// to prevent the 403 error from blocking the UI. Page components will handle empty data.
|
||||
console.error('AE_SITE_CRITICAL: Site domain lookup failed API and CACHE. Returning ghost object.');
|
||||
return {
|
||||
id: 'ghost',
|
||||
id_random: 'ghost',
|
||||
site_domain_id: 'ghost',
|
||||
site_domain_id_random: 'ghost',
|
||||
site_id: 'ghost',
|
||||
site_id_random: 'ghost',
|
||||
account_id: 'ghost',
|
||||
account_id_random: 'ghost',
|
||||
account_code: 'ghost',
|
||||
account_name: 'Ghost Account (Offline)',
|
||||
fqdn: fqdn,
|
||||
enable: '1',
|
||||
header_image_path: '',
|
||||
style_href: '',
|
||||
google_tracking_id: '',
|
||||
access_code_kv_json: {},
|
||||
cfg_json: {},
|
||||
access_key: '',
|
||||
site_domain_access_key: ''
|
||||
} as any;
|
||||
}
|
||||
|
||||
// Updated 2026-01-26 (Cache-First Optimization)
|
||||
export async function lookup_site_domain_v3({
|
||||
api_cfg,
|
||||
fqdn,
|
||||
view = 'default',
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
fqdn: string;
|
||||
view?: string;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_SiteDomain | null> {
|
||||
if (log_lvl) {
|
||||
console.log(`*** lookup_site_domain_v3() *** fqdn=${fqdn} (Cache-First)`);
|
||||
console.log(`*** lookup_site_domain() *** fqdn=${fqdn} (Cache-First)`);
|
||||
}
|
||||
|
||||
// 1. FAST PATH: Check local cache first
|
||||
@@ -115,7 +116,7 @@ export async function lookup_site_domain_v3({
|
||||
if (log_lvl) console.log('BOOTSTRAP: Cache hit. Returning cached site domain immediately.');
|
||||
|
||||
// Trigger background refresh to keep cache fresh, but don't await it
|
||||
_refresh_site_domain_v3_background({ api_cfg, fqdn, view, log_lvl: 0 });
|
||||
_refresh_site_domain_background({ api_cfg, fqdn, view, log_lvl: 0 });
|
||||
|
||||
return cached as any;
|
||||
}
|
||||
@@ -124,13 +125,13 @@ export async function lookup_site_domain_v3({
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: Wait for API if cache is empty
|
||||
return await _refresh_site_domain_v3_background({ api_cfg, fqdn, view, log_lvl });
|
||||
return await _refresh_site_domain_background({ api_cfg, fqdn, view, log_lvl });
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal helper to perform the actual API fetch and cache update
|
||||
*/
|
||||
async function _refresh_site_domain_v3_background({ api_cfg, fqdn, view, log_lvl }: any) {
|
||||
async function _refresh_site_domain_background({ api_cfg, fqdn, view, log_lvl }: any) {
|
||||
try {
|
||||
const guest_api_cfg = { ...api_cfg };
|
||||
guest_api_cfg.headers = { ...api_cfg.headers };
|
||||
|
||||
@@ -60,7 +60,7 @@ export async function load_ae_obj_id__event({
|
||||
if (log_lvl) console.log('EVENT LOAD: Cache hit. Returning stale data immediately.');
|
||||
|
||||
// Trigger background refresh
|
||||
_refresh_event_v3_background({
|
||||
_refresh_event_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_template_li,
|
||||
enabled, hidden,
|
||||
@@ -79,7 +79,7 @@ export async function load_ae_obj_id__event({
|
||||
}
|
||||
|
||||
// 2. SLOW PATH: Wait for API if cache is empty or try_cache is false
|
||||
return await _refresh_event_v3_background({
|
||||
return await _refresh_event_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_template_li,
|
||||
enabled, hidden,
|
||||
@@ -90,7 +90,7 @@ export async function load_ae_obj_id__event({
|
||||
/**
|
||||
* Internal helper to perform the actual API fetch and cache update for events
|
||||
*/
|
||||
async function _refresh_event_v3_background({
|
||||
async function _refresh_event_background({
|
||||
api_cfg, event_id, view, try_cache,
|
||||
inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_presentation_li, inc_presenter_li, inc_template_li,
|
||||
enabled, hidden,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* src/lib/elements/element_qr_scanner_v3.svelte
|
||||
* src/lib/elements/element_qr_scanner.svelte
|
||||
* QR Scanner v3 — Svelte 5 runes, auto-starts, no manual permission step.
|
||||
*
|
||||
* html5-qrcode's .start() handles camera permission internally.
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* element_websocket_v3.svelte — Aether WebSocket V3 Client
|
||||
* element_websocket.svelte — Aether WebSocket V3 Client
|
||||
*
|
||||
* PURPOSE:
|
||||
* Drop-in replacement for element_websocket_v2.svelte using the V3 protocol:
|
||||
@@ -303,7 +303,7 @@
|
||||
<!-- Debug panel — only visible when ws_connect=true and hide__ws_element=false -->
|
||||
<section
|
||||
class:hidden={!ws_connect || hide__ws_element}
|
||||
class="ae_element__websocket_v3 container p-1 bg-pink-100 text-xs mx-auto pb-16 mt-32 mb-32 relative"
|
||||
class="ae_element__websocket container p-1 bg-pink-100 text-xs mx-auto pb-16 mt-32 mb-32 relative"
|
||||
>
|
||||
<span class="absolute top-0 right-0 flex flex-col gap-1">
|
||||
<button
|
||||
@@ -2,7 +2,7 @@
|
||||
// console.log(`ae_root +layout.ts: start`);
|
||||
|
||||
// import { error } from '@sveltejs/kit';
|
||||
import { lookup_site_domain_v3 } from '$lib/ae_core/ae_core__site';
|
||||
import { lookup_site_domain } from '$lib/ae_core/ae_core__site';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
// import type { ae_SiteDomain } from '$lib/types/ae_types';
|
||||
|
||||
@@ -220,7 +220,7 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
}
|
||||
};
|
||||
|
||||
result = await lookup_site_domain_v3({
|
||||
result = await lookup_site_domain({
|
||||
api_cfg: bootstrap_api_cfg,
|
||||
fqdn,
|
||||
view: 'base',
|
||||
@@ -234,7 +234,7 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
} else {
|
||||
// We have a result (cache or native), fire off the refresh in the background to update Dexie
|
||||
if (log_lvl) console.log('ROOT LOAD: Result already obtained. Background refresh triggered.');
|
||||
lookup_site_domain_v3({
|
||||
lookup_site_domain({
|
||||
api_cfg: ae_api_init,
|
||||
fqdn,
|
||||
view: 'base',
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* ae_comp__badge_obj_view_v2.svelte
|
||||
* ae_comp__badge_obj_view_v.svelte
|
||||
*
|
||||
* V2 badge render component — display-only. No inline edit mode.
|
||||
* V3 badge render component — display-only. No inline edit mode.
|
||||
*
|
||||
* Editing is handled entirely by the right-panel controls component
|
||||
* (ae_comp__badge_print_controls.svelte). Changes saved there flow
|
||||
* back via liveQuery (IDB → reactive UI update) automatically.
|
||||
*
|
||||
* Differences from v1 (ae_comp__badge_obj_view.svelte):
|
||||
* Differences from v1/v2 (ae_comp__badge_obj_view.svelte):
|
||||
* - No inline edit mode — floating Edit/Save/Cancel panel removed
|
||||
* - No handle_save_changes / handle_cancel_changes / handle_print_badge
|
||||
* - Print button lives in ae_comp__badge_print_controls.svelte
|
||||
@@ -22,7 +22,7 @@
|
||||
event_badge_id: string;
|
||||
lq__event_badge_obj?: any;
|
||||
lq__event_badge_template_obj?: any;
|
||||
/** Kept for API compatibility; unused in v2 (no inline edit mode). */
|
||||
/** Kept for API compatibility; unused in v33 (no inline edit mode). */
|
||||
is_review_mode?: boolean;
|
||||
/** Optional px override for name font size. null/undefined → auto-scaling runs. */
|
||||
font_size_name?: number | null;
|
||||
@@ -343,13 +343,13 @@
|
||||
/* *** END *** Legacy ticket/option state */
|
||||
</script>
|
||||
|
||||
<!-- Template debug info: screen-only. Shows layout context and v2 marker. -->
|
||||
<!-- Template debug info: screen-only. Shows layout context and v3 marker. -->
|
||||
<div class="print:hidden flex items-center justify-center gap-2 text-xs text-gray-400 font-mono mb-1 h-6">
|
||||
<span title="Badge template name">{$lq__event_badge_template_obj?.name ?? '—'}</span>
|
||||
<span class="text-gray-300">|</span>
|
||||
<span title="Layout code">{$lq__event_badge_template_obj?.layout ?? '(no layout)'}</span>
|
||||
<span class="text-gray-300">|</span>
|
||||
<span class="text-blue-400" title="V2 — auto-scaling text, display-only render">v2</span>
|
||||
<span class="text-blue-400" title="V3 — auto-scaling text, display-only render">v3</span>
|
||||
{#if $ae_loc.edit_mode}
|
||||
<span class="text-gray-300">|</span>
|
||||
<button
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import { Library, LoaderCircle, QrCode, RemoveFormatting, Search } from '@lucide/svelte';
|
||||
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
|
||||
import { events_loc, events_sess } from '$lib/stores/ae_events_stores';
|
||||
import Element_qr_scanner_v3 from '$lib/elements/element_qr_scanner_v3.svelte';
|
||||
import Element_qr_scanner from '$lib/elements/element_qr_scanner.svelte';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
|
||||
// ISHLT 2024 badge type codes
|
||||
@@ -193,7 +193,7 @@
|
||||
<div
|
||||
class="w-full max-w-2xl mx-auto p-4 bg-surface-100-900 rounded-lg shadow-lg"
|
||||
>
|
||||
<Element_qr_scanner_v3
|
||||
<Element_qr_scanner
|
||||
bind:start_qr_scanner={$events_sess.badges.qr_scan_start}
|
||||
on_qr_scan_result={handle_qr_scan_result}
|
||||
/>
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
import Launcher_cfg from '../launcher_cfg.svelte';
|
||||
import Launcher_menu from '../launcher_menu.svelte';
|
||||
import Launcher_session_view from '../launcher_session_view.svelte';
|
||||
import Element_websocket_v3 from '$lib/elements/element_websocket_v3.svelte';
|
||||
import Element_websocket from '$lib/elements/element_websocket.svelte';
|
||||
|
||||
// *** Set initial variables
|
||||
// NOTE: Derived from data.account_id (prop) instead of $slct.account_id (store)
|
||||
@@ -95,7 +95,7 @@
|
||||
// Generate a stable per-device client ID on first load and persist it.
|
||||
// events_loc is backed by svelte-persisted-store (localStorage) so this
|
||||
// survives page reloads. Without this, client_id falls back to Date.now()
|
||||
// inside element_websocket_v3 — a new ID on every reload, which breaks
|
||||
// inside element_websocket — a new ID on every reload, which breaks
|
||||
// direct-target WS messages and doesn't match V3 Vision ID expectations.
|
||||
if (!$events_loc.launcher.controller_client_id) {
|
||||
$events_loc.launcher.controller_client_id = crypto.randomUUID();
|
||||
@@ -1168,7 +1168,7 @@
|
||||
</Modal>
|
||||
|
||||
{#if $events_loc.launcher.controller_group_code && $events_loc.launcher.ws_connect}
|
||||
<Element_websocket_v3
|
||||
<Element_websocket
|
||||
{log_lvl}
|
||||
bind:ws_connect={$events_loc.launcher.ws_connect}
|
||||
bind:ws_connect_status={$events_sess.launcher.ws_connect_status}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import { ae_api, ae_loc } from '$lib/stores/ae_stores';
|
||||
import { events_loc } from '$lib/stores/ae_events_stores';
|
||||
import { events_func } from '$lib/ae_events/ae_events_functions';
|
||||
import Element_qr_scanner_v3 from '$lib/elements/element_qr_scanner_v3.svelte';
|
||||
import Element_qr_scanner from '$lib/elements/element_qr_scanner.svelte';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { Camera, CircleAlert, CircleCheck, Eye, LoaderCircle, RefreshCw, RotateCcw, ShieldOff, X } from '@lucide/svelte';
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
@@ -218,7 +218,7 @@
|
||||
<div class="lead-qr-scanner flex flex-col items-center space-y-4 w-full min-h-100 justify-center">
|
||||
{#if scanning_status === 'idle' || scanning_status === 'scanning'}
|
||||
<div class="w-full max-w-sm mx-auto aspect-square overflow-hidden rounded-xl border-4 border-surface-500/20 shadow-xl relative bg-surface-900/10">
|
||||
<Element_qr_scanner_v3
|
||||
<Element_qr_scanner
|
||||
bind:start_qr_scanner
|
||||
on_qr_scan_result={handle_qr_scan_result}
|
||||
/>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<script lang="ts">
|
||||
|
||||
// *** Import Svelte specific
|
||||
// import { onDestroy } from 'svelte';
|
||||
// import { browser } from '$app/environment';
|
||||
// import { fade } from 'svelte/transition';
|
||||
|
||||
// *** Import other supporting libraries
|
||||
|
||||
@@ -37,32 +34,12 @@
|
||||
console.log(`Event Object selected: ${$lq__event_obj}`);
|
||||
console.log(`Event Object name: ${$lq__event_obj?.name}`);
|
||||
|
||||
// $slct_trigger = 'load__event_obj';
|
||||
// $idaa_trig.event_id = $idaa_slct.event_id;
|
||||
}
|
||||
|
||||
// dayjs.extend(window.dayjs_plugin_utc)
|
||||
// dayjs.extend(window.dayjs_plugin_timezone);
|
||||
// console.log(`UTC offset: ${dayjs().utcOffset()}`);
|
||||
// console.log(`TZ offset: ${dayjs().utcOffset('US/Pacific')}`);
|
||||
// // let test_time = dayjs.utc('2024-01-08 11:55').tz('Asia/Taipei');
|
||||
// // let test_time = dayjs.utc('2024-01-08 14:15').tz('America/New_York');
|
||||
// let test_time = dayjs.tz('2024-01-08 14:15', 'US/Pacific');
|
||||
// console.log(test_time.format('YYYY-MM-DD HH:mm'));
|
||||
// let adjusted_to_local_tz = test_time.tz('America/New_York');
|
||||
// console.log(adjusted_to_local_tz.format('YYYY-MM-DD HH:mm'));
|
||||
|
||||
// let adjusted_to_local_tz_v2 = dayjs.tz('2024-01-08 14:15', 'US/Pacific').tz('America/New_York');
|
||||
// console.log(adjusted_to_local_tz_v2);
|
||||
</script>
|
||||
|
||||
<section
|
||||
class="svelte_component ae_section ae_view event_obj view__event_obj space-y-2"
|
||||
>
|
||||
<!-- <h2 class="ae_title event__title text-2xl font-bold">
|
||||
<span class="ae_icon fas fa-calendar-day"></span>
|
||||
{$lq__event_obj?.name ? $lq__event_obj?.name : 'Recovery Meeting'}
|
||||
</h2> -->
|
||||
|
||||
<div class="p-2 bg-white shadow-md rounded-lg">
|
||||
<div
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import { ArrowRightLeft, Bug, Building2, CircleCheck, Code, Contact, Database, Eye, EyeOff, FlaskConical, Globe, Info, Key, MapPin, RefreshCcw, Satellite, Server, Settings2, ShieldAlert, ShieldCheck, Trash2, Unlock, User, UserCheck, Users, Zap } from '@lucide/svelte';
|
||||
// Core Module Imports
|
||||
import { load_ae_obj_li__account } from '$lib/ae_core/ae_core__account';
|
||||
import { lookup_site_domain_v3 } from '$lib/ae_core/ae_core__site';
|
||||
import { lookup_site_domain } from '$lib/ae_core/ae_core__site';
|
||||
import { load_ae_obj_id__user } from '$lib/ae_core/ae_core__user';
|
||||
import { db_core } from '$lib/ae_core/db_core';
|
||||
import { events_loc } from '$lib/stores/ae_events_stores';
|
||||
@@ -117,7 +117,7 @@
|
||||
|
||||
const test_site_domain_lookup = () => run_test('Site Domain Lookup', async () => {
|
||||
const fqdn = test_fqdn || window.location.host;
|
||||
return await lookup_site_domain_v3({ api_cfg: $ae_api, fqdn, log_lvl: 1 });
|
||||
return await lookup_site_domain({ api_cfg: $ae_api, fqdn, log_lvl: 1 });
|
||||
});
|
||||
|
||||
const test_load_accounts = () => run_test('Load Accounts', async () => {
|
||||
|
||||
Reference in New Issue
Block a user