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
|
||||
Reference in New Issue
Block a user