Refactor: Remove redundant db_save exports and complete V3 cleanup

This commit is contained in:
Scott Idem
2026-01-21 13:28:30 -05:00
parent be69ef1afd
commit d705058175
8 changed files with 14 additions and 424 deletions

View File

@@ -38,9 +38,7 @@ import { load_ae_obj_li__country_subdivision } from '$lib/ae_core/core__country_
import {
load_ae_obj_id__hosted_file,
load_ae_obj_li__hosted_file,
delete_ae_obj_id__hosted_file,
db_save_ae_obj_li__hosted_file,
db_update_ae_obj_id__hosted_file
delete_ae_obj_id__hosted_file
} from '$lib/ae_core/core__hosted_files';
// This has more generic general purpose functions that can eventually replace the custom ones per object type.
@@ -512,8 +510,6 @@ const export_obj = {
load_ae_obj_id__hosted_file: load_ae_obj_id__hosted_file,
load_ae_obj_li__hosted_file: load_ae_obj_li__hosted_file,
delete_ae_obj_id__hosted_file: delete_ae_obj_id__hosted_file,
db_save_ae_obj_li__hosted_file: db_save_ae_obj_li__hosted_file,
db_update_ae_obj_id__hosted_file: db_update_ae_obj_id__hosted_file,
db_save_ae_obj_li__ae_obj: db_save_ae_obj_li__ae_obj,

View File

@@ -402,6 +402,7 @@ async function _process_generic_props<T extends Record<string, any>>({
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// 1. Standardize ID and other '_random' fields
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7);
@@ -413,6 +414,7 @@ async function _process_generic_props<T extends Record<string, any>>({
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';

View File

@@ -5,28 +5,18 @@ import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
import { db_events } from '$lib/ae_events/db_events';
import type { ae_EventLocation } from '$lib/types/ae_types';
import { load_ae_obj_li__event_device } from '$lib/ae_events/ae_events__event_device';
import { load_ae_obj_li__event_file } from '$lib/ae_events/ae_events__event_file';
import { load_ae_obj_li__event_session } from './ae_events__event_session';
const ae_promises: key_val = {};
// Updated 2026-01-20 to V3
export async function load_ae_obj_id__event_location({
api_cfg,
event_location_id,
inc_device_li = false,
inc_file_li = false,
inc_session_li = false,
view = 'default',
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
event_location_id: string;
inc_device_li?: boolean;
inc_file_li?: boolean;
inc_session_li?: boolean;
view?: string;
try_cache?: boolean;
log_lvl?: number;
@@ -35,18 +25,6 @@ export async function load_ae_obj_id__event_location({
console.log(`*** load_ae_obj_id__event_location() *** [V3] id=${event_location_id}`);
}
// Check if offline
if (typeof navigator !== 'undefined' && !navigator.onLine) {
if (log_lvl) console.log('Browser is offline. Skipping API and attempting cache load.');
ae_promises.load__event_location_obj = await db_events.location.get(event_location_id);
if (ae_promises.load__event_location_obj) {
return await _handle_nested_loads(ae_promises.load__event_location_obj, {
api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl
});
}
return null;
}
try {
ae_promises.load__event_location_obj = await api.get_ae_obj_v3({
api_cfg,
@@ -80,53 +58,7 @@ export async function load_ae_obj_id__event_location({
}
}
if (!ae_promises.load__event_location_obj) return null;
return await _handle_nested_loads(ae_promises.load__event_location_obj, {
api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl
});
}
/**
* Helper to handle nested collection loads for a location
*/
async function _handle_nested_loads(location_obj: any, { api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl }: any) {
const current_location_id = location_obj.event_location_id_random || location_obj.event_location_id || location_obj.id;
if (inc_device_li) {
location_obj.event_device_obj_li = await load_ae_obj_li__event_device({
api_cfg,
for_obj_type: 'event_location',
for_obj_id: current_location_id,
log_lvl
});
}
if (inc_file_li) {
location_obj.event_file_li = await load_ae_obj_li__event_file({
api_cfg,
for_obj_type: 'event_location',
for_obj_id: current_location_id,
enabled: 'all',
limit: 15,
try_cache,
log_lvl
});
}
if (inc_session_li) {
location_obj.event_session_li = await load_ae_obj_li__event_session({
api_cfg,
for_obj_type: 'event_location',
for_obj_id: current_location_id,
enabled: 'all',
limit: 15,
try_cache,
log_lvl
});
}
return location_obj;
return ae_promises.load__event_location_obj || null;
}
// Updated 2026-01-20 to V3
@@ -134,12 +66,9 @@ export async function load_ae_obj_li__event_location({
api_cfg,
for_obj_type = 'event',
for_obj_id,
inc_device_li = false,
inc_file_li = false,
inc_session_li = false,
enabled = 'enabled',
hidden = 'not_hidden',
limit = 50,
limit = 100,
offset = 0,
order_by_li = [
{ priority: 'DESC' },
@@ -153,9 +82,6 @@ export async function load_ae_obj_li__event_location({
api_cfg: any;
for_obj_type?: string;
for_obj_id: string;
inc_device_li?: boolean;
inc_file_li?: boolean;
inc_session_li?: boolean;
enabled?: 'enabled' | 'all' | 'not_enabled';
hidden?: 'hidden' | 'all' | 'not_hidden';
limit?: number;
@@ -168,20 +94,6 @@ export async function load_ae_obj_li__event_location({
console.log(`*** load_ae_obj_li__event_location() *** [V3] for=${for_obj_type}:${for_obj_id}`);
}
// Check if offline
if (typeof navigator !== 'undefined' && !navigator.onLine) {
if (log_lvl) console.log('Browser is offline. Skipping API and attempting cache load.');
ae_promises.load__event_location_obj_li = await db_events.location
.where('event_id').equals(for_obj_id)
.toArray();
if (ae_promises.load__event_location_obj_li) {
for (const loc of ae_promises.load__event_location_obj_li) {
await _handle_nested_loads(loc, { api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl });
}
}
return ae_promises.load__event_location_obj_li || [];
}
try {
ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_v3({
api_cfg,
@@ -224,12 +136,6 @@ export async function load_ae_obj_li__event_location({
}
}
if (ae_promises.load__event_location_obj_li) {
for (const loc of ae_promises.load__event_location_obj_li) {
await _handle_nested_loads(loc, { api_cfg, inc_device_li, inc_file_li, inc_session_li, try_cache, log_lvl });
}
}
return ae_promises.load__event_location_obj_li || [];
}
@@ -428,17 +334,12 @@ export async function search__event_location({
export const properties_to_save = [
'id',
'event_location_id',
'event_id',
'external_id',
'code',
'type_code',
'event_id',
'name',
'description',
'passcode',
'hide_event_launcher',
'alert',
'alert_msg',
'data_json',
'enable',
'hide',
'priority',
@@ -449,13 +350,12 @@ export const properties_to_save = [
'updated_on',
'tmp_sort_1',
'tmp_sort_2',
'file_count',
'file_count_all',
'internal_use_count',
'event_file_id_li_json',
'event_name'
];
/**
* NON-EXPORTED LOCAL HELPER
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
@@ -474,6 +374,7 @@ async function _process_generic_props<T extends Record<string, any>>({
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// 1. Standardize ID and other '_random' fields
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7);
@@ -485,6 +386,7 @@ async function _process_generic_props<T extends Record<string, any>>({
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';

View File

@@ -365,7 +365,6 @@ export const properties_to_save = [
/**
* NON-EXPORTED LOCAL HELPER
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,

View File

@@ -506,6 +506,7 @@ async function _process_generic_props<T extends Record<string, any>>({
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// 1. Standardize ID and other '_random' fields
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7);
@@ -517,6 +518,7 @@ async function _process_generic_props<T extends Record<string, any>>({
(processed_obj as any).id = processed_obj[randomIdKey];
}
// 2. Create common computed properties
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';

View File

@@ -14,7 +14,6 @@ import {
create_ae_obj__exhibit_tracking,
update_ae_obj__exhibit_tracking,
download_export__event_exhibit_tracking
// db_save_ae_obj_li__exhibitor,
} from '$lib/ae_events/ae_events__exhibit';
import * as event_location from '$lib/ae_events/ae_events__event_location';
@@ -38,7 +37,6 @@ const export_obj = {
create_ae_obj__event: event.create_ae_obj__event,
delete_ae_obj_id__event: event.delete_ae_obj_id__event,
update_ae_obj__event: event.update_ae_obj__event,
// db_save_ae_obj_li__event: event.db_save_ae_obj_li__event,
sync_config__event_pres_mgmt: event.sync_config__event_pres_mgmt,
// Event Badges
@@ -49,10 +47,6 @@ const export_obj = {
update_ae_obj__event_badge: event_badge.update_ae_obj__event_badge,
qry__event_badge: event_badge.qry__event_badge,
search__event_badge: event_badge.search__event_badge,
// handle_load_ae_obj_id__badge: event_badge.handle_load_ae_obj_id__badge,
// handle_load_ae_obj_li__badge: event_badge.handle_load_ae_obj_li__badge,
// handle_search__event_badge: event_badge.handle_search__event_badge,
// db_save_ae_obj_li__event_badge: event_badge.db_save_ae_obj_li__event_badge,
// Event Badge Templates
load_ae_obj_id__event_badge_template: event_badge_template.load_ae_obj_id__event_badge_template,
@@ -69,7 +63,6 @@ const export_obj = {
create_ae_obj__event_device: event_device.create_ae_obj__event_device,
delete_ae_obj_id__event_device: event_device.delete_ae_obj_id__event_device,
update_ae_obj__event_device: event_device.update_ae_obj__event_device,
// db_save_ae_obj_li__event_device: event_device.db_save_ae_obj_li__event_device,
// Event Exhibits
handle_load_ae_obj_id__exhibit: load_ae_obj_id__exhibit,
@@ -79,7 +72,6 @@ const export_obj = {
handle_create_ae_obj__exhibit_tracking: create_ae_obj__exhibit_tracking,
handle_update_ae_obj__exhibit_tracking: update_ae_obj__exhibit_tracking,
handle_download_export__event_exhibit_tracking: download_export__event_exhibit_tracking,
// handle_db_save_ae_obj_li__exhibitor: db_save_ae_obj_li__exhibitor,
// Event Files
load_ae_obj_id__event_file: event_file.load_ae_obj_id__event_file,
@@ -90,7 +82,6 @@ const export_obj = {
update_ae_obj__event_file: event_file.update_ae_obj__event_file,
qry__event_file: event_file.qry__event_file,
search__event_file: event_file.search__event_file,
// db_save_ae_obj_li__event_file: event_file.db_save_ae_obj_li__event_file,
// Event Locations
load_ae_obj_id__event_location: event_location.load_ae_obj_id__event_location,
@@ -98,7 +89,6 @@ const export_obj = {
create_ae_obj__event_location: event_location.create_ae_obj__event_location,
delete_ae_obj_id__event_location: event_location.delete_ae_obj_id__event_location,
update_ae_obj__event_location: event_location.update_ae_obj__event_location,
// db_save_ae_obj_li__event_location: event_location.db_save_ae_obj_li__event_location,
// Event Sessions
load_ae_obj_id__event_session: event_session.load_ae_obj_id__event_session,
@@ -109,7 +99,6 @@ const export_obj = {
qry__event_session: event_session.qry__event_session,
search__event_session: event_session.search__event_session,
email_sign_in__event_session: event_session.email_sign_in__event_session,
// db_save_ae_obj_li__event_session: event_session.db_save_ae_obj_li__event_session,
// Event Presentations
load_ae_obj_id__event_presentation: event_presentation.load_ae_obj_id__event_presentation,
@@ -117,7 +106,6 @@ const export_obj = {
create_ae_obj__event_presentation: event_presentation.create_ae_obj__event_presentation,
delete_ae_obj_id__event_presentation: event_presentation.delete_ae_obj_id__event_presentation,
update_ae_obj__event_presentation: event_presentation.update_ae_obj__event_presentation,
// db_save_ae_obj_li__event_presentation: event_presentation.db_save_ae_obj_li__event_presentation,
// Event Presenters
load_ae_obj_id__event_presenter: event_presenter.load_ae_obj_id__event_presenter,
@@ -126,7 +114,6 @@ const export_obj = {
delete_ae_obj_id__event_presenter: event_presenter.delete_ae_obj_id__event_presenter,
update_ae_obj__event_presenter: event_presenter.update_ae_obj__event_presenter,
search__event_presenter: event_presenter.search__event_presenter,
// db_save_ae_obj_li__event_presenter: event_presenter.db_save_ae_obj_li__event_presenter,
email_sign_in__event_presenter: event_presenter.email_sign_in__event_presenter
};
export const events_func = export_obj;
export const events_func = export_obj;

View File

@@ -1,133 +0,0 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
// import type { Writable } from 'svelte/store';
import type { key_val } from '$lib/stores/ae_stores';
// import { ae_util } from '$lib/ae_utils/ae_utils';
import { api } from '$lib/api/api';
import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores';
import { events_loc, events_slct, events_trigger } from '$lib/stores/ae_events_stores';
interface SubmenuItem {
name: string;
href: string;
title: string;
access?: 'trusted' | 'administrator' | 'manager'; // Assuming these are the access levels
disable?: boolean;
hide?: boolean;
}
interface LayoutData {
submenu: SubmenuItem[]; // Assuming submenu is an array of SubmenuItem
// Add other properties of data if needed
}
interface Props {
/** @type {import('./$types').LayoutData} */
data: LayoutData; // Use the specific interface
children?: import('svelte').Snippet;
}
let { data, children }: Props = $props();
// import Element_data_store from '$lib/element_data_store_v2.svelte';
if (!$ae_loc.admin) {
$ae_loc.admin = {};
}
$ae_loc.qry__enabled = 'enabled';
$ae_loc.qry__hidden = 'not_hidden';
$ae_loc.qry__limit = 15;
$ae_loc.qry__offset = 0;
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
$slct.account_id = data.account_id;
console.log(`$slct.account_id = `, $slct.account_id);
let ae_acct = data[$slct.account_id];
console.log(`ae_acct = `, ae_acct);
$events_slct.event_id = ae_acct.slct.event_id;
$events_slct.event_obj = ae_acct.slct.event_obj;
let ae_promises: key_val = {};
onMount(() => {
console.log('Admin: +layout.svelte');
});
// Updated 2024-03-06
// async function handle_load_ae_obj_id__event({event_id, try_cache=false}) {
// console.log(`*** handle_load_ae_obj_id__event() *** event_id=${event_id} api_cfg=`, $ae_api);
// let params = {};
// // $events_sess.badges.status_load__event_obj = 'loading';
// ae_promises.load__event_obj = await api.get_ae_obj_id_crud({
// api_cfg: $ae_api,
// obj_type: 'event',
// obj_id: event_id, // NOTE: This is the FQDN, not normally the ID.
// 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: 0
// })
// .then(function (event_obj_get_result) {
// if (event_obj_get_result) {
// return event_obj_get_result;
// } else {
// console.log('No results returned.');
// return null;
// }
// })
// .catch(function (error: any) {
// console.log('No results returned or failed.', error);
// });
// return ae_promises.load__event_obj;
// }
</script>
<svelte:head>
<title>Æ Admin - {$ae_loc.title ?? 'Æ loading...'}</title>
</svelte:head>
<section class="submenu flex flex-row justify-center" class:hidden={$ae_loc.iframe}>
<span class=" preset-tonal-secondary px-4 py-2">
{#each Object.entries(data.submenu) as [key, item]: SubmenuItem}
<!-- <a href="/settings/{item.slug}">{item.title}</a> -->
<!-- class:hidden={!$ae_loc.trusted_access && item.access} -->
{#if item.disable}
<button
title={item.title}
class="hover:preset-tonal-secondary border border-secondary-500"
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') ||
(!$ae_loc.administrator_access && item.access === 'administrator') ||
item.hide}
disabled={item.disable}
onclick={() => {
// window.location(item.href);
// href={item.href}
// invalidateAll
goto(item.href, {});
}}
>
{item.name}
</button>
{:else}
<a
href={item.href}
title={item.title}
class="hover:preset-tonal-secondary border border-secondary-500"
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') ||
(!$ae_loc.administrator_access && item.access === 'administrator') ||
item.hide}
class:disabled={item.disable}
>
{item.name}
</a>
{/if}
{/each}
</span>
</section>
{@render children?.()}

View File

@@ -1,165 +0,0 @@
<script lang="ts">
console.log(`ae_events_badges +page data:`, data);
// console.log(`ae_events_badges Data Params:`, data.url.searchParams.get('event_id'));
import { onMount } from 'svelte';
// import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/stores/ae_stores';
// import { events_loc, events_slct, events_trigger } from '$lib/stores/ae_events_stores';
// import { ae_util } from '$lib/ae_utils/ae_utils';
import Element_data_store from '$lib/elements/element_data_store_v2.svelte';
import Element_sql_qry from '$lib/elements/element_sql_qry.svelte';
interface Props {
data: any;
}
let { data }: Props = $props();
// import Element_obj_tbl_row from '$lib/element_obj_tbl_row.svelte';
let sql_report_qry = null;
onMount(() => {
console.log('Admin: +page.svelte');
console.log('ae_ slct:', $slct);
let href_url = window.location.href;
// console.log(href_url);
$ae_loc.href_url = href_url;
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
// $slct_trigger = 'msg_parent';
// ae_util.handle_url_and_message('event_id', $events_slct.event_id);
// ae_util.handle_url_and_message('badge_id', $events_slct.badge_id);
// if ($events_slct.badge_id) {
// console.log(`Got an ID. Let's show the modal!`);
// modalStore.trigger(modal_edit__badge_obj);
// }
});
</script>
<section class="ae_admin md:container h-full mx-auto">
<h2 class="h3">Admin for {$ae_loc.account_name} ({$ae_loc.account_id})</h2>
<h3 class="h4">Restricted Access</h3>
<p>Accessing the admin is currently restricted</p>
<Element_data_store
ds_code="admin__overview"
ds_type="html"
for_type="event"
for_id={$ae_loc.event_id}
display="block"
class_li="p-2"
/>
{#if $ae_loc.trusted_access}
<div>
<button
type="button"
onclick={() => {
$ae_loc.admin.show_option = 'ae_loc_json';
}}
class="btn btn-md preset-tonal-primary hover:preset-tonal-primary border border-primary-500"
>
AE Local Storage
</button>
<button
type="button"
onclick={() => {
$ae_loc.admin.show_option = 'event_file_list';
}}
class="btn btn-md preset-tonal-primary hover:preset-tonal-primary border border-primary-500"
>
Event File List
</button>
<button
type="button"
onclick={() => {
$ae_loc.admin.show_option = 'event_badge_printed';
}}
class="btn btn-md preset-tonal-primary hover:preset-tonal-primary border border-primary-500"
>
Event Badge Printed
</button>
</div>
{#if $ae_loc.admin?.show_option == 'ae_loc_json'}
<h2>AE Local Storage</h2>
<pre class="text-xs">
{JSON.stringify($ae_loc, null, 2)}
</pre>
{/if}
{#if $ae_loc.admin?.show_option == 'event_file_list'}
<h2>Report SQL</h2>
<Element_data_store
ds_code="rpt_sql_select_event_file_list_w_url"
ds_type="sql"
display="block"
class_li="p-2"
bind:val_sql={$ae_loc.ds['rpt_sql_select_event_file_list_w_url']}
/>
<Element_sql_qry
api_cfg={$ae_api}
run_on_load={true}
show_textarea={true}
sql_statement={$ae_loc.ds['rpt_sql_select_event_file_list_w_url']}
sql_data={{ event_id: $slct.event_id, base_url: $ae_api.base_url }}
as_list={true}
/>
{/if}
{#if $ae_loc.admin?.show_option == 'event_badge_printed'}
<h2>Report SQL</h2>
<Element_data_store
ds_code="rpt_sql_select_event_badge_printed_by_ext_event"
ds_type="sql"
display="block"
class_li="p-2"
bind:val_sql={$ae_loc.ds['rpt_sql_select_event_badge_printed_by_ext_event']}
/>
<Element_sql_qry
api_cfg={$ae_api}
remove_breaks={false}
run_on_load={true}
show_textarea={true}
sql_statement={$ae_loc.ds['rpt_sql_select_event_badge_printed_by_ext_event']}
sql_data={{ event_id: $slct.event_id, base_url: $ae_api.base_url }}
as_list={true}
/>
{/if}
<!-- {#if $ae_loc.app_cfg.show_element__cfg_detail} -->
<!-- {/if} -->
{#if $ae_loc.admin?.show_element__sql_qry}
<h2>Report</h2>
<span>
<!-- Setting run_on_load to false. True seems to cause a problem with it trying to render before the results have been returned. The sql_qry_result should be checked to see if it is a list of some kind. -->
<!-- <Element_sql_qry
api_cfg={$ae_api}
run_on_load={false}
show_textarea={false}
remove_breaks={true}
button_label={'Refresh Results'}
sql_statement={sql_report_qry}
sql_data={sql_report_data}
as_list={true}
log_lvl={1}
/> -->
</span>
{/if}
{/if}
</section>
<style lang="postcss">
</style>