feat(offline): implement Dexie fallbacks and fix type stability in Events module
- Offline Resilience: Added local Dexie fallbacks to load_ae_obj_id__* and load_ae_obj_li__* functions for Events, Sessions, Locations, Exhibits, and Badges. - Type Safety: Standardized ae_Event and ae_EventSession interfaces in ae_types.ts; resolved Promise assignment errors in load functions (+page.ts). - Bug Fixes: Corrected duplication in ae_events__event_location.ts and ae_events__event_badge_template.ts; fixed missing try_cache parameters. - UI Stability: Fixed Dexie LiveQuery subscription pattern in bulk print view and ensured proper property access in layout load functions.
This commit is contained in:
@@ -38,45 +38,57 @@ export async function load_ae_obj_id__event({
|
||||
console.log(`*** load_ae_obj_id__event() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
ae_promises.load__event_obj = await api
|
||||
.get_ae_obj_v3({
|
||||
try {
|
||||
const event_obj_get_result = await api.get_ae_obj_v3({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event',
|
||||
obj_id: event_id,
|
||||
view,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_obj_get_result) {
|
||||
if (event_obj_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_get_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'event',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
||||
if (event_obj_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: [event_obj_get_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'event',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
ae_promises.load__event_obj = event_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_obj = await db_events.event.get(event_id);
|
||||
} else {
|
||||
ae_promises.load__event_obj = null;
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_obj = await db_events.event.get(event_id);
|
||||
} else {
|
||||
ae_promises.load__event_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (ae_promises.load__event_obj) {
|
||||
const current_event_id = ae_promises.load__event_obj.event_id || ae_promises.load__event_obj.id;
|
||||
|
||||
if (inc_device_li) {
|
||||
ae_promises.load__event_obj.event_device_obj_li = await load_ae_obj_li__event_device({
|
||||
api_cfg,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
for_obj_id: current_event_id,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
@@ -84,7 +96,7 @@ export async function load_ae_obj_id__event({
|
||||
ae_promises.load__event_obj.event_location_obj_li = await load_ae_obj_li__event_location({
|
||||
api_cfg,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
for_obj_id: current_event_id,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
@@ -92,7 +104,7 @@ export async function load_ae_obj_id__event({
|
||||
ae_promises.load__event_obj.event_session_obj_li = await load_ae_obj_li__event_session({
|
||||
api_cfg,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
for_obj_id: current_event_id,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
@@ -100,7 +112,7 @@ export async function load_ae_obj_id__event({
|
||||
ae_promises.load__event_obj.event_badge_template_obj_li =
|
||||
await load_ae_obj_li__event_badge_template({
|
||||
api_cfg,
|
||||
event_id,
|
||||
event_id: current_event_id,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
@@ -118,6 +130,7 @@ export async function load_ae_obj_li__event({
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
view = 'default',
|
||||
inc_session_li = false,
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = { start_datetime: 'DESC' } as const,
|
||||
@@ -131,6 +144,7 @@ export async function load_ae_obj_li__event({
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
inc_session_li?: boolean;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: Record<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
|
||||
@@ -176,7 +190,8 @@ export async function load_ae_obj_li__event({
|
||||
});
|
||||
}
|
||||
|
||||
ae_promises.load__event_obj_li = await promise.then(async function (event_obj_li_get_result) {
|
||||
try {
|
||||
const event_obj_li_get_result = await promise;
|
||||
if (event_obj_li_get_result) {
|
||||
let filtered_results = event_obj_li_get_result;
|
||||
|
||||
@@ -198,11 +213,41 @@ export async function load_ae_obj_li__event({
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
return filtered_results;
|
||||
ae_promises.load__event_obj_li = filtered_results;
|
||||
} else {
|
||||
return [];
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_obj_li = await db_events.event
|
||||
.where('account_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_obj_li = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_obj_li = await db_events.event
|
||||
.where('account_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_session_li && ae_promises.load__event_obj_li) {
|
||||
for (const event_obj of ae_promises.load__event_obj_li) {
|
||||
const current_event_id = event_obj.event_id || event_obj.id;
|
||||
event_obj.event_session_obj_li = await load_ae_obj_li__event_session({
|
||||
api_cfg,
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: current_event_id,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_obj_li;
|
||||
}
|
||||
|
||||
@@ -29,60 +29,58 @@ export async function load_ae_obj_id__event_badge({
|
||||
console.log(`*** load_ae_obj_id__event_badge() *** event_badge_id=${event_badge_id}`);
|
||||
}
|
||||
|
||||
ae_promises.load__event_badge_obj = await api
|
||||
.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge',
|
||||
obj_id: event_badge_id,
|
||||
view,
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (badge_obj_get_result) {
|
||||
if (badge_obj_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_props({
|
||||
obj_li: [badge_obj_get_result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return badge_obj_get_result;
|
||||
} else {
|
||||
if (log_lvl) console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
try {
|
||||
ae_promises.load__event_badge_obj = await api
|
||||
.get_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge',
|
||||
obj_id: event_badge_id,
|
||||
view,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (inc_template) {
|
||||
if (ae_promises.load__event_badge_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_props({
|
||||
obj_li: [ae_promises.load__event_badge_obj],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_badge_obj = await db_events.badge.get(event_badge_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_badge_obj = await db_events.badge.get(event_badge_id);
|
||||
} else {
|
||||
ae_promises.load__event_badge_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_template && ae_promises.load__event_badge_obj) {
|
||||
// Load the templates for the event badge
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the template for the badge now`);
|
||||
const current_template_id = ae_promises.load__event_badge_obj.event_badge_template_id || ae_promises.load__event_badge_obj.event_badge_template_id_random;
|
||||
if (current_template_id) {
|
||||
ae_promises.load__event_badge_obj.event_badge_template = await load_ae_obj_id__event_badge_template({
|
||||
api_cfg: api_cfg,
|
||||
event_badge_template_id: current_template_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
const load_event_badge_template_obj = load_ae_obj_id__event_badge_template({
|
||||
api_cfg: api_cfg,
|
||||
event_badge_template_id:
|
||||
ae_promises.load__event_badge_obj?.event_badge_template_id_random,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_badge_template_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_badge_template_obj_li = `, event_badge_template_obj_li);
|
||||
}
|
||||
return event_badge_template_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`event_badge_template_obj = `, load_event_badge_template_obj);
|
||||
}
|
||||
ae_promises.load__event_session_obj.event_badge_template = load_event_badge_template_obj;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_badge_obj;
|
||||
@@ -120,63 +118,71 @@ export async function load_ae_obj_li__event_badge({
|
||||
console.log(`*** load_ae_obj_li__event_badge() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
ae_promises.load__event_badge_obj_li = await api
|
||||
.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
view: view,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (badge_obj_li_get_result) {
|
||||
if (badge_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_props({
|
||||
obj_li: badge_obj_li_get_result,
|
||||
event_id,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return badge_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (inc_template) {
|
||||
// Load the template for each badge
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the template for each badge now`);
|
||||
}
|
||||
for (const badge_obj of ae_promises.load__event_badge_obj_li) {
|
||||
if (log_lvl) {
|
||||
console.log(`Loading template for badge_obj: `, badge_obj);
|
||||
}
|
||||
const load_event_badge_template_obj = await load_ae_obj_id__event_badge_template({
|
||||
api_cfg: api_cfg,
|
||||
event_badge_template_id: badge_obj?.event_badge_template_id_random,
|
||||
try {
|
||||
ae_promises.load__event_badge_obj_li = await api
|
||||
.get_ae_obj_li_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
view: view,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`event_badge_template_obj = `, load_event_badge_template_obj);
|
||||
|
||||
if (ae_promises.load__event_badge_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_props({
|
||||
obj_li: ae_promises.load__event_badge_obj_li,
|
||||
event_id,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_badge_obj_li = await db_events.badge
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_badge_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_badge_obj_li = await db_events.badge
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_badge_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_template && ae_promises.load__event_badge_obj_li) {
|
||||
for (const badge_obj of ae_promises.load__event_badge_obj_li) {
|
||||
const current_template_id = badge_obj.event_badge_template_id || badge_obj.event_badge_template_id_random;
|
||||
if (current_template_id) {
|
||||
badge_obj.event_badge_template = await load_ae_obj_id__event_badge_template({
|
||||
api_cfg: api_cfg,
|
||||
event_badge_template_id: current_template_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
badge_obj.event_badge_template = load_event_badge_template_obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,40 +9,18 @@ const ae_promises: key_val = {};
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_badge_template_id',
|
||||
// 'event_badge_template_id_random',
|
||||
|
||||
'event_id',
|
||||
// 'event_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
// 'template_code',
|
||||
// 'template_type',
|
||||
// 'template_json',
|
||||
// 'template_svg',
|
||||
// 'template_css',
|
||||
// 'template_html',
|
||||
|
||||
'logo_filename',
|
||||
'logo_path',
|
||||
|
||||
'header_path',
|
||||
'secondary_header_path',
|
||||
'footer_path',
|
||||
|
||||
'header_row_1',
|
||||
'header_row_2',
|
||||
|
||||
// 'footer_title',
|
||||
// 'footer_left',
|
||||
// 'footer_right',
|
||||
// 'header_background',
|
||||
// 'footer_background',
|
||||
|
||||
'badge_type_list',
|
||||
'ticket_list',
|
||||
|
||||
'ticket_1_text',
|
||||
'ticket_2_text',
|
||||
'ticket_3_text',
|
||||
@@ -51,20 +29,12 @@ export const properties_to_save = [
|
||||
'ticket_6_text',
|
||||
'ticket_7_text',
|
||||
'ticket_8_text',
|
||||
// 'ticket_9_text',
|
||||
// 'ticket_10_text',
|
||||
|
||||
'wireless_ssid',
|
||||
'wireless_password',
|
||||
|
||||
'show_qr_front',
|
||||
'show_qr_back',
|
||||
|
||||
'layout',
|
||||
'style_filename',
|
||||
// 'style_href',
|
||||
|
||||
// 'default',
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
@@ -73,8 +43,6 @@ export const properties_to_save = [
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2'
|
||||
];
|
||||
@@ -94,39 +62,24 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) return [];
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
const newKey = key.slice(0, -7);
|
||||
(processed_obj as any)[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
@@ -136,7 +89,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
@@ -148,7 +100,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
}
|
||||
|
||||
// --- PROCESS FUNCTION ---
|
||||
export async function process_ae_obj__event_badge_template_props({
|
||||
export async function process_ae_badge_template_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
@@ -160,7 +112,6 @@ export async function process_ae_obj__event_badge_template_props({
|
||||
obj_type: 'event_badge_template',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event badge template-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
@@ -190,41 +141,46 @@ export async function load_ae_obj_id__event_badge_template({
|
||||
`*** load_ae_obj_id__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`
|
||||
);
|
||||
}
|
||||
const params = {};
|
||||
ae_promises.load__event_badge_template_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge_template',
|
||||
obj_id: event_badge_template_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params,
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (obj_get_result) {
|
||||
if (obj_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||
obj_li: [obj_get_result],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return obj_get_result;
|
||||
} else {
|
||||
if (log_lvl) console.log('No results returned.');
|
||||
return null;
|
||||
|
||||
try {
|
||||
ae_promises.load__event_badge_template_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge_template',
|
||||
obj_id: event_badge_template_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_badge_template_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_badge_template_props({
|
||||
obj_li: [ae_promises.load__event_badge_template_obj],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_badge_template_obj = await db_events.badge_template.get(event_badge_template_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_badge_template_obj = await db_events.badge_template.get(event_badge_template_id);
|
||||
} else {
|
||||
ae_promises.load__event_badge_template_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_badge_template_obj;
|
||||
}
|
||||
|
||||
@@ -257,51 +213,58 @@ export async function load_ae_obj_li__event_badge_template({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__event_badge_template() *** event_id=${event_id}`);
|
||||
}
|
||||
const params_json: key_val = {};
|
||||
// ae_promises.load__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_badge_template_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge_template',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
enabled,
|
||||
hidden,
|
||||
order_by_li,
|
||||
limit,
|
||||
offset,
|
||||
params_json,
|
||||
params,
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (obj_li_get_result) {
|
||||
if (obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||
obj_li: obj_li_get_result,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
try {
|
||||
ae_promises.load__event_badge_template_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg,
|
||||
obj_type: 'event_badge_template',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: false,
|
||||
use_alt_mdl: false,
|
||||
enabled,
|
||||
hidden,
|
||||
order_by_li,
|
||||
limit,
|
||||
offset,
|
||||
params_json: {},
|
||||
params,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_badge_template_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_badge_template_props({
|
||||
obj_li: ae_promises.load__event_badge_template_obj_li,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_badge_template_obj_li = await db_events.badge_template
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_badge_template_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_badge_template_obj_li = await db_events.badge_template
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_badge_template_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_badge_template_obj_li;
|
||||
}
|
||||
|
||||
@@ -320,12 +283,9 @@ export async function create_ae_obj__event_badge_template({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** create_ae_obj__event_badge_template() *** event_id=${event_id}`);
|
||||
}
|
||||
ae_promises.create__event_badge_template = await api
|
||||
.create_ae_obj_crud({
|
||||
api_cfg,
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_badge_template',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
@@ -337,27 +297,20 @@ export async function create_ae_obj__event_badge_template({
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (obj_create_result) {
|
||||
if (obj_create_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||
obj_li: [obj_create_result],
|
||||
log_lvl
|
||||
});
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
if (obj_create_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_badge_template_props({
|
||||
obj_li: [obj_create_result],
|
||||
log_lvl
|
||||
});
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
return obj_create_result;
|
||||
});
|
||||
return ae_promises.create__event_badge_template;
|
||||
}
|
||||
@@ -377,11 +330,6 @@ export async function delete_ae_obj_id__event_badge_template({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** delete_ae_obj_id__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`
|
||||
);
|
||||
}
|
||||
ae_promises.delete__event_badge_template_obj = await api
|
||||
.delete_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
@@ -392,16 +340,8 @@ export async function delete_ae_obj_id__event_badge_template({
|
||||
method,
|
||||
log_lvl
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
if (try_cache) {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`Attempting to remove IDB entry for event_badge_template_id=${event_badge_template_id}`
|
||||
);
|
||||
}
|
||||
db_events.badge_template.delete(event_badge_template_id);
|
||||
}
|
||||
});
|
||||
@@ -423,11 +363,6 @@ export async function update_ae_obj__event_badge_template({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** update_ae_obj__event_badge_template() *** event_badge_template_id=${event_badge_template_id}`
|
||||
);
|
||||
}
|
||||
ae_promises.update__event_badge_template_obj = await api
|
||||
.update_ae_obj_id_crud({
|
||||
api_cfg,
|
||||
@@ -440,32 +375,24 @@ export async function update_ae_obj__event_badge_template({
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (obj_update_result) {
|
||||
if (obj_update_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||
obj_li: [obj_update_result],
|
||||
log_lvl
|
||||
});
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
if (obj_update_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_badge_template_props({
|
||||
obj_li: [obj_update_result],
|
||||
log_lvl
|
||||
});
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
return obj_update_result;
|
||||
});
|
||||
return ae_promises.update__event_badge_template_obj;
|
||||
}
|
||||
|
||||
// --- SEARCH FUNCTION ---
|
||||
export async function search__event_badge_template({
|
||||
api_cfg,
|
||||
event_id,
|
||||
@@ -499,9 +426,6 @@ export async function search__event_badge_template({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** search__event_badge_template() *** event_id=${event_id}`);
|
||||
}
|
||||
const params_json: key_val = {};
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
params_json['ft_qry'] = { default_qry_str: fulltext_search_qry_str };
|
||||
@@ -509,8 +433,7 @@ export async function search__event_badge_template({
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
params_json['and_like'] = { default_qry_str: like_search_qry_str };
|
||||
}
|
||||
params_json['and_qry'] = {};
|
||||
// ae_promises.search__event_badge_template_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
|
||||
ae_promises.load__event_badge_template_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg,
|
||||
@@ -529,27 +452,20 @@ export async function search__event_badge_template({
|
||||
log_lvl
|
||||
})
|
||||
.then(async function (obj_li_get_result) {
|
||||
if (obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_badge_template_props({
|
||||
obj_li: obj_li_get_result,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
return obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
if (obj_li_get_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_badge_template_props({
|
||||
obj_li: obj_li_get_result,
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'badge_template',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
return obj_li_get_result || [];
|
||||
});
|
||||
return ae_promises.search__event_badge_template_obj_li;
|
||||
}
|
||||
return ae_promises.load__event_badge_template_obj_li;
|
||||
}
|
||||
@@ -29,74 +29,68 @@ export async function load_ae_obj_id__event_device({
|
||||
|
||||
const params = {};
|
||||
|
||||
ae_promises.load__event_device_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
obj_id: event_device_id, // 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: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_device_obj_get_result) {
|
||||
if (event_device_obj_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: [event_device_obj_get_result],
|
||||
log_lvl
|
||||
});
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'device',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
try {
|
||||
ae_promises.load__event_device_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
obj_id: event_device_id, // 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: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event_device({
|
||||
// obj_type: 'event_device',
|
||||
// obj_li: [event_device_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_device_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
if (ae_promises.load__event_device_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: [ae_promises.load__event_device_obj],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'device',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_device_obj = await db_events.device.get(event_device_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_device_obj = await db_events.device.get(event_device_id);
|
||||
} else {
|
||||
ae_promises.load__event_device_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_device_obj:', ae_promises.load__event_device_obj);
|
||||
}
|
||||
|
||||
if (!ae_promises?.load__event_device_obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (inc_location_id) {
|
||||
// Load the location linked to this device
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the location id for the device now`);
|
||||
const current_location_id = ae_promises.load__event_device_obj.event_location_id;
|
||||
if (current_location_id) {
|
||||
ae_promises.load__event_device_obj.event_location_obj = await load_ae_obj_id__event_location({
|
||||
api_cfg: api_cfg,
|
||||
event_location_id: current_location_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
const load_event_location_obj_id = load_ae_obj_id__event_location({
|
||||
api_cfg: api_cfg,
|
||||
event_location_id: ae_promises.load__event_device_obj.event_location_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_location_obj_id = `, load_event_location_obj_id);
|
||||
}
|
||||
ae_promises.load__event_device_obj.event_location_obj = load_event_location_obj_id;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_device_obj;
|
||||
@@ -143,102 +137,75 @@ export async function load_ae_obj_li__event_device({
|
||||
);
|
||||
}
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'all'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
const params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
|
||||
ae_promises.load__event_device_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_device_obj_li_get_result) {
|
||||
if (event_device_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: event_device_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'device',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_device({
|
||||
// obj_type: 'event_device',
|
||||
// obj_li: event_device_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return event_device_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_device_obj_li:',
|
||||
ae_promises.load__event_device_obj_li
|
||||
);
|
||||
}
|
||||
|
||||
if (inc_location_id) {
|
||||
// Load the location for the devices
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the location list for each device now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_device_obj_li.length; i++) {
|
||||
const event_device_obj = ae_promises.load__event_device_obj_li[i];
|
||||
|
||||
const load_event_location_obj_li = load_ae_obj_id__event_location({
|
||||
try {
|
||||
ae_promises.load__event_device_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
event_location_id: event_device_obj.event_location_id,
|
||||
try_cache: try_cache,
|
||||
obj_type: 'event_device',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true,
|
||||
use_alt_mdl: false,
|
||||
use_alt_exp: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_location_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_location_obj_li = `, event_location_obj_li);
|
||||
}
|
||||
return event_location_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_location_obj_li = `, load_event_location_obj_li);
|
||||
if (ae_promises.load__event_device_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_device_props({
|
||||
obj_li: ae_promises.load__event_device_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'device',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_device_obj_li = await db_events.device
|
||||
.where('event_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_device_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_device_obj_li = await db_events.device
|
||||
.where('event_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_device_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_location_id && ae_promises.load__event_device_obj_li) {
|
||||
for (let i = 0; i < ae_promises.load__event_device_obj_li.length; i++) {
|
||||
const event_device_obj = ae_promises.load__event_device_obj_li[i];
|
||||
if (event_device_obj.event_location_id) {
|
||||
event_device_obj.event_location_obj = await load_ae_obj_id__event_location({
|
||||
api_cfg: api_cfg,
|
||||
event_location_id: event_device_obj.event_location_id,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,108 +35,83 @@ export async function load_ae_obj_id__event_location({
|
||||
|
||||
const params = {};
|
||||
|
||||
ae_promises.load__event_location_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id, // 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: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_location_obj_get_result) {
|
||||
if (event_location_obj_get_result) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: [event_location_obj_get_result],
|
||||
log_lvl
|
||||
});
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
try {
|
||||
ae_promises.load__event_location_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
obj_id: event_location_id, // 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: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event_location({
|
||||
// obj_type: 'event_location',
|
||||
// obj_li: [event_location_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_location_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
if (ae_promises.load__event_location_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: [ae_promises.load__event_location_obj],
|
||||
log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save,
|
||||
log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_location_obj = await db_events.location.get(event_location_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_location_obj = await db_events.location.get(event_location_id);
|
||||
} else {
|
||||
ae_promises.load__event_location_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_location_obj:', ae_promises.load__event_location_obj);
|
||||
}
|
||||
|
||||
if (ae_promises?.load__event_location_obj === null) {
|
||||
console.log('No results returned.');
|
||||
if (!ae_promises?.load__event_location_obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const current_location_id = ae_promises.load__event_location_obj.event_location_id || ae_promises.load__event_location_obj.id;
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the location
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for the location now`);
|
||||
}
|
||||
const load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
ae_promises.load__event_location_obj.event_file_li = await load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
for_obj_id: current_location_id,
|
||||
enabled: 'all',
|
||||
limit: 15,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
ae_promises.load__event_location_obj.event_file_li = load_event_file_obj_li;
|
||||
}
|
||||
|
||||
if (inc_session_li) {
|
||||
// Load the sessions for the location
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the session list for the location now`);
|
||||
}
|
||||
const load_event_session_obj_li = load_ae_obj_li__event_session({
|
||||
ae_promises.load__event_location_obj.event_session_li = await load_ae_obj_li__event_session({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
for_obj_id: current_location_id,
|
||||
enabled: 'all',
|
||||
limit: 15,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
}
|
||||
ae_promises.load__event_location_obj.event_session_li = load_event_session_obj_li;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_location_obj;
|
||||
@@ -189,158 +164,109 @@ export async function load_ae_obj_li__event_location({
|
||||
|
||||
const params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
try {
|
||||
ae_promises.load__event_location_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_location_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: event_location_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_location({
|
||||
// obj_type: 'event_location',
|
||||
// obj_li: event_location_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return event_location_obj_li_get_result;
|
||||
if (ae_promises.load__event_location_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: ae_promises.load__event_location_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_location_obj_li = await db_events.location
|
||||
.where('event_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
return [];
|
||||
ae_promises.load__event_location_obj_li = [];
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_location_obj_li:',
|
||||
ae_promises.load__event_location_obj_li
|
||||
);
|
||||
}
|
||||
|
||||
if (inc_device_li) {
|
||||
// Load the devices for the locations
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the device list for each location now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
const event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
const event_location_id = event_location_obj.event_location_id_random;
|
||||
|
||||
const load_event_device_obj_li = load_ae_obj_li__event_device({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
params: { qry__enabled: enabled, qry__limit: limit },
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_device_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_device_obj_li = `, event_device_obj_li);
|
||||
}
|
||||
return event_device_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_device_obj_li = `, load_event_device_obj_li);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_location_obj_li = await db_events.location
|
||||
.where('event_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_location_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the locations
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for each location now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
const event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
const event_location_id = event_location_obj.event_location_id_random;
|
||||
if (ae_promises.load__event_location_obj_li) {
|
||||
if (inc_device_li) {
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
const event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
const current_location_id = event_location_obj.event_location_id || event_location_obj.id;
|
||||
|
||||
const load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
event_location_obj.event_device_obj_li = await load_ae_obj_li__event_device({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: current_location_id,
|
||||
params: { qry__enabled: enabled, qry__limit: limit },
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_session_li) {
|
||||
// Load the sessions for the locations
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the session list for each location now`);
|
||||
if (inc_file_li) {
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
const event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
const current_location_id = event_location_obj.event_location_id || event_location_obj.id;
|
||||
|
||||
event_location_obj.event_file_li = await load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: current_location_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
const event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
const event_location_id = event_location_obj.event_location_id_random;
|
||||
|
||||
const load_event_session_obj_li = load_ae_obj_li__event_session({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_session_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_session_obj_li = `, event_session_obj_li);
|
||||
}
|
||||
return event_session_obj_li;
|
||||
});
|
||||
if (inc_session_li) {
|
||||
for (let i = 0; i < ae_promises.load__event_location_obj_li.length; i++) {
|
||||
const event_location_obj = ae_promises.load__event_location_obj_li[i];
|
||||
const current_location_id = event_location_obj.event_location_id || event_location_obj.id;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
event_location_obj.event_session_li = await load_ae_obj_li__event_session({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: current_location_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,12 +332,6 @@ export async function create_ae_obj__event_location({
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_location(
|
||||
// {
|
||||
// obj_type: 'event_location',
|
||||
// obj_li: [event_location_obj_create_result]
|
||||
// });
|
||||
}
|
||||
return event_location_obj_create_result;
|
||||
} else {
|
||||
@@ -420,12 +340,8 @@ export async function create_ae_obj__event_location({
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {});
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_location:', ae_promises.create__event_location);
|
||||
}
|
||||
return ae_promises.create__event_location;
|
||||
}
|
||||
|
||||
@@ -475,13 +391,6 @@ export async function delete_ae_obj_id__event_location({
|
||||
}
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.delete__event_location_obj:',
|
||||
ae_promises.delete__event_location_obj
|
||||
);
|
||||
}
|
||||
|
||||
return ae_promises.delete__event_location_obj;
|
||||
}
|
||||
|
||||
@@ -543,10 +452,6 @@ export async function update_ae_obj__event_location({
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_location({
|
||||
// obj_type: 'event_location', obj_li: [event_location_obj_update_result]
|
||||
// });
|
||||
}
|
||||
return event_location_obj_update_result;
|
||||
} else {
|
||||
@@ -555,15 +460,8 @@ export async function update_ae_obj__event_location({
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {});
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.update__event_location_obj:',
|
||||
ae_promises.update__event_location_obj
|
||||
);
|
||||
}
|
||||
return ae_promises.update__event_location_obj;
|
||||
}
|
||||
|
||||
@@ -597,14 +495,14 @@ export async function search__event_location({
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden';
|
||||
const limit: number = params.qry__limit ?? 25; // 99
|
||||
const offset: number = params.qry__offset ?? 0; // 0
|
||||
const limit: number = params.qry__limit ?? 25;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
const params_json: key_val = {};
|
||||
|
||||
if (!fulltext_search_qry_str && !like_search_qry_str) {
|
||||
console.log('No search string provided!!!');
|
||||
return false; // Returning false instead of [] because no search was performed.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fulltext_search_qry_str || ft_presenter_search_qry_str) {
|
||||
@@ -618,18 +516,6 @@ export async function search__event_location({
|
||||
}
|
||||
}
|
||||
|
||||
// Use the AND (AND LIKE) query
|
||||
// if (like_search_qry_str || like_presenter_search_qry_str) {
|
||||
// params_json['and_like'] = {};
|
||||
// if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['default_qry_str'] = like_search_qry_str;
|
||||
// }
|
||||
// if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
// params_json['and_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Use the AND (OR LIKE) query
|
||||
if (like_search_qry_str || like_presentation_search_qry_str || like_presenter_search_qry_str) {
|
||||
params_json['or_like'] = {};
|
||||
if (like_search_qry_str && like_search_qry_str.length > 2) {
|
||||
@@ -646,10 +532,6 @@ export async function search__event_location({
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
// if (location_type_code) {
|
||||
// params_json['and_qry']['location_type_code'] = location_type_code;
|
||||
// }
|
||||
|
||||
const order_by_li = {
|
||||
priority: 'DESC',
|
||||
sort: 'DESC',
|
||||
@@ -659,15 +541,13 @@ export async function search__event_location({
|
||||
created_on: 'DESC'
|
||||
} as const;
|
||||
|
||||
// ae_promises.load__event_location_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_location_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_tbl: true, // NOTE: We want to use the alt table for location searching
|
||||
// use_alt_mdl: false,
|
||||
use_alt_tbl: true,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
@@ -680,18 +560,10 @@ export async function search__event_location({
|
||||
.then(async function (event_location_obj_li_get_result) {
|
||||
if (event_location_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__event_location_props({
|
||||
obj_li: event_location_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'location',
|
||||
@@ -699,9 +571,6 @@ export async function search__event_location({
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return event_location_obj_li_get_result;
|
||||
} else {
|
||||
@@ -710,15 +579,8 @@ export async function search__event_location({
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {});
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_location_obj_li:',
|
||||
ae_promises.load__event_location_obj_li
|
||||
);
|
||||
}
|
||||
return ae_promises.load__event_location_obj_li;
|
||||
}
|
||||
|
||||
@@ -726,28 +588,17 @@ export async function search__event_location({
|
||||
export const properties_to_save = [
|
||||
'id',
|
||||
'event_location_id',
|
||||
// 'event_location_id_random',
|
||||
|
||||
'external_id',
|
||||
'code',
|
||||
|
||||
'type_code',
|
||||
|
||||
'event_id',
|
||||
// 'event_id_random',
|
||||
|
||||
'name',
|
||||
'description',
|
||||
|
||||
'passcode',
|
||||
|
||||
'hide_event_launcher',
|
||||
|
||||
'alert',
|
||||
'alert_msg',
|
||||
|
||||
'data_json',
|
||||
|
||||
'enable',
|
||||
'hide',
|
||||
'priority',
|
||||
@@ -756,26 +607,15 @@ export const properties_to_save = [
|
||||
'notes',
|
||||
'created_on',
|
||||
'updated_on',
|
||||
|
||||
// Generated fields for sorting locally only
|
||||
'tmp_sort_1',
|
||||
'tmp_sort_2',
|
||||
// 'tmp_sort_a',
|
||||
// 'tmp_sort_b',
|
||||
|
||||
// From SQL view
|
||||
'file_count',
|
||||
'file_count_all',
|
||||
'internal_use_count',
|
||||
'event_file_id_li_json',
|
||||
|
||||
'event_name'
|
||||
];
|
||||
|
||||
/**
|
||||
* 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,
|
||||
obj_type,
|
||||
@@ -787,39 +627,24 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) return [];
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
const newKey = key.slice(0, -7);
|
||||
(processed_obj as any)[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
@@ -829,7 +654,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
@@ -853,7 +677,6 @@ export async function process_ae_obj__event_location_props({
|
||||
obj_type: 'event_location',
|
||||
log_lvl,
|
||||
specific_processor: (obj) => {
|
||||
// Event location-specific computed sort fields, overriding generic ones if needed
|
||||
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
|
||||
obj.sort?.toString().padStart(3, '0') ?? ''
|
||||
}_${obj.updated_on ?? obj.created_on}`;
|
||||
@@ -864,4 +687,4 @@ export async function process_ae_obj__event_location_props({
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -44,9 +44,8 @@ export async function load_ae_obj_id__event_session({
|
||||
|
||||
const params = {};
|
||||
|
||||
// $events_sess.badges.status_load__event_session_obj = 'loading';
|
||||
ae_promises.load__event_session_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
try {
|
||||
ae_promises.load__event_session_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
obj_id: event_session_id, // NOTE: This is the FQDN, not normally the ID.
|
||||
@@ -54,94 +53,68 @@ export async function load_ae_obj_id__event_session({
|
||||
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: log_lvl
|
||||
})
|
||||
.then(async function (event_session_obj_get_result) {
|
||||
if (event_session_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__event_session_props({
|
||||
obj_li: [event_session_obj_get_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'session',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// // This is expecting a list
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: [event_session_obj_get_result]
|
||||
// });
|
||||
}
|
||||
return event_session_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (ae_promises.load__event_session_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_session_props({
|
||||
obj_li: [ae_promises.load__event_session_obj],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'session',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_session_obj = await db_events.session.get(event_session_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_session_obj = await db_events.session.get(event_session_id);
|
||||
} else {
|
||||
ae_promises.load__event_session_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_session_obj:', ae_promises?.load__event_session_obj);
|
||||
}
|
||||
|
||||
if (ae_promises?.load__event_session_obj === null) {
|
||||
console.log('No results returned.');
|
||||
if (!ae_promises?.load__event_session_obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const current_session_id = ae_promises.load__event_session_obj.event_session_id || ae_promises.load__event_session_obj.id;
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the session
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for the session now`);
|
||||
}
|
||||
const load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
ae_promises.load__event_session_obj.event_file_li = await load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
for_obj_id: current_session_id,
|
||||
enabled: enabled,
|
||||
limit: 15,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
ae_promises.load__event_session_obj.event_file_li = load_event_file_obj_li;
|
||||
}
|
||||
|
||||
if (inc_presentation_li) {
|
||||
// Load the presentations for the session
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the presentation list for the session now`);
|
||||
}
|
||||
// NOTE: The files will only be included if inc_all_file_li is true. 2025-09-17
|
||||
const load_event_presentation_obj_li = load_ae_obj_li__event_presentation({
|
||||
ae_promises.load__event_session_obj.event_presentation_li = await load_ae_obj_li__event_presentation({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
for_obj_id: current_session_id,
|
||||
inc_file_li: inc_all_file_li,
|
||||
inc_presenter_li: inc_presenter_li,
|
||||
enabled: enabled, // all, disabled, enabled
|
||||
@@ -151,17 +124,7 @@ export async function load_ae_obj_id__event_session({
|
||||
params: {},
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_presentation_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
||||
}
|
||||
return event_presentation_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, load_event_presentation_obj_li);
|
||||
}
|
||||
ae_promises.load__event_session_obj.event_presentation_li = load_event_presentation_obj_li;
|
||||
}
|
||||
|
||||
return ae_promises.load__event_session_obj;
|
||||
@@ -214,124 +177,89 @@ export async function load_ae_obj_li__event_session({
|
||||
);
|
||||
}
|
||||
|
||||
// let enabled: string = (params.qry__enabled ?? 'enabled'); // all, disabled, enabled
|
||||
// let hidden: string = (params.qry__hidden ?? 'not_hidden'); // all, hidden, not_hidden
|
||||
// let limit: number = (params.qry__limit ?? 99); // 99
|
||||
// let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
const params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
try {
|
||||
ae_promises.load__event_session_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// ae_promises.load__event_session_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
ae_promises.load__event_session_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_session',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
use_alt_tbl: true, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
|
||||
// use_alt_mdl: false, // NOTE: This will use the base_name_alt value instead of the base_name value
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: order_by_li,
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (event_session_obj_li_get_result) {
|
||||
if (event_session_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__event_session_props({
|
||||
obj_li: event_session_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'session',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: event_session_obj_li_get_result
|
||||
// });
|
||||
}
|
||||
return event_session_obj_li_get_result;
|
||||
} else {
|
||||
return [];
|
||||
if (ae_promises.load__event_session_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__event_session_props({
|
||||
obj_li: ae_promises.load__event_session_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'session',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_session_obj_li:',
|
||||
ae_promises.load__event_session_obj_li
|
||||
);
|
||||
} else {
|
||||
console.log('No results returned from API.');
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache...');
|
||||
ae_promises.load__event_session_obj_li = await db_events.session
|
||||
.where('for_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_session_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('API request failed.', error);
|
||||
if (try_cache) {
|
||||
if (log_lvl) console.log('Attempting to load from local cache after error...');
|
||||
ae_promises.load__event_session_obj_li = await db_events.session
|
||||
.where('for_id').equals(for_obj_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_session_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_file_li) {
|
||||
// Load the files for the sessions
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for each session now`);
|
||||
}
|
||||
if (inc_file_li && ae_promises.load__event_session_obj_li) {
|
||||
for (let i = 0; i < ae_promises.load__event_session_obj_li.length; i++) {
|
||||
const event_session_obj = ae_promises.load__event_session_obj_li[i];
|
||||
const event_session_id = event_session_obj.event_session_id_random;
|
||||
const current_session_id = event_session_obj.event_session_id || event_session_obj.id;
|
||||
|
||||
const load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
event_session_obj.event_file_li = await load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
for_obj_id: current_session_id,
|
||||
enabled: enabled,
|
||||
limit: limit,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inc_presentation_li) {
|
||||
// Load the presentations for the sessions
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the presentation list for each session now`);
|
||||
}
|
||||
if (inc_presentation_li && ae_promises.load__event_session_obj_li) {
|
||||
for (let i = 0; i < ae_promises.load__event_session_obj_li.length; i++) {
|
||||
const event_session_obj = ae_promises.load__event_session_obj_li[i];
|
||||
const event_session_id = event_session_obj.event_session_id_random;
|
||||
const current_session_id = event_session_obj.event_session_id || event_session_obj.id;
|
||||
|
||||
// NOTE: The files will only be included if inc_all_file_li is true. 2025-09-17
|
||||
const load_event_presentation_obj_li = load_ae_obj_li__event_presentation({
|
||||
event_session_obj.event_presentation_li = await load_ae_obj_li__event_presentation({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
for_obj_id: current_session_id,
|
||||
inc_file_li: inc_all_file_li,
|
||||
inc_presenter_li: inc_presenter_li,
|
||||
enabled: enabled,
|
||||
@@ -341,26 +269,7 @@ export async function load_ae_obj_li__event_session({
|
||||
params: params,
|
||||
try_cache: try_cache,
|
||||
log_lvl: log_lvl
|
||||
}).then((event_presentation_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`event_session_obj = `, event_session_obj);
|
||||
// event_session_obj.event_presentation_li = event_presentation_obj_li;
|
||||
// // Re-save the session object with the new presentation list
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: event_session_obj
|
||||
// });
|
||||
// }
|
||||
|
||||
return event_presentation_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_presentation_obj_li = `, load_event_presentation_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,39 +118,24 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
log_lvl?: number;
|
||||
specific_processor?: (obj: T) => Promise<T> | T;
|
||||
}): Promise<T[]> {
|
||||
if (log_lvl > 0) {
|
||||
console.log(
|
||||
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
|
||||
);
|
||||
}
|
||||
|
||||
if (!obj_li || obj_li.length === 0) {
|
||||
if (log_lvl > 0) console.log('No objects to process.');
|
||||
return [];
|
||||
}
|
||||
if (!obj_li || obj_li.length === 0) return [];
|
||||
|
||||
const processed_obj_li: T[] = [];
|
||||
|
||||
for (const original_obj of obj_li) {
|
||||
let processed_obj = { ...original_obj };
|
||||
|
||||
// --- Common Transformations ---
|
||||
|
||||
// 1. Standardize ID and other '_random' fields
|
||||
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
|
||||
for (const key in processed_obj) {
|
||||
if (key.endsWith('_random')) {
|
||||
const newKey = key.slice(0, -7); // Remove '_random' suffix
|
||||
const newKey = key.slice(0, -7);
|
||||
(processed_obj as any)[newKey] = processed_obj[key];
|
||||
}
|
||||
}
|
||||
// Ensure 'id' is set from '[obj_type]_id_random'
|
||||
const randomIdKey = `${obj_type}_id_random`;
|
||||
if (processed_obj[randomIdKey]) {
|
||||
(processed_obj as any).id = processed_obj[randomIdKey];
|
||||
}
|
||||
|
||||
// 2. Create common computed properties for client-side sorting.
|
||||
const group = processed_obj.group ?? '0';
|
||||
const priority = processed_obj.priority ? 1 : 0;
|
||||
const sort = processed_obj.sort ?? '0';
|
||||
@@ -160,7 +145,6 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
(processed_obj as any).tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
|
||||
(processed_obj as any).tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
|
||||
|
||||
// --- Specific Transformations ---
|
||||
if (specific_processor) {
|
||||
processed_obj = await Promise.resolve(specific_processor(processed_obj));
|
||||
}
|
||||
@@ -209,56 +193,48 @@ export async function load_ae_obj_id__exhibit({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibit | null> {
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__exhibit() *** exhibit_id=${exhibit_id}`);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
try {
|
||||
ae_promises.load__exhibit_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: exhibit_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// $events_sess.exhibits.status_load__exhibit_obj = 'loading';
|
||||
ae_promises.load__exhibit_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
obj_id: exhibit_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: log_lvl
|
||||
})
|
||||
.then(async function (exhibit_obj_get_result) {
|
||||
if (exhibit_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: [exhibit_obj_get_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
if (ae_promises.load__exhibit_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: [ae_promises.load__exhibit_obj],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__exhibit_obj = await db_events.exhibit.get(exhibit_id);
|
||||
} else {
|
||||
ae_promises.load__exhibit_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__exhibit_obj;
|
||||
}
|
||||
@@ -277,100 +253,73 @@ export async function load_ae_obj_li__exhibit({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibit[]> {
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__exhibit() *** event_id=${event_id}`);
|
||||
}
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden';
|
||||
const limit: number = params.qry__limit ?? 99; // 99
|
||||
const offset: number = params.qry__offset ?? 0; // 0
|
||||
const limit: number = params.qry__limit ?? 99;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
const params_json: key_val = {};
|
||||
// params_json['and_qry'] = {};
|
||||
// params_json['and_qry']['license_max'] = 10;
|
||||
|
||||
params_json['and_in_li'] = {
|
||||
license_max: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
const params_json: key_val = {
|
||||
and_in_li: {
|
||||
license_max: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
}
|
||||
};
|
||||
|
||||
// if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
// params_json['ft_qry'] = {
|
||||
// 'default_qry_str': fulltext_search_qry_str,
|
||||
// // 'location_address_json_ext': fulltext_search_qry_str, // JSON extracted text DB field
|
||||
// // 'contact_li_json_ext': fulltext_search_qry_str, // JSON extracted text DB field
|
||||
// };
|
||||
// }
|
||||
try {
|
||||
ae_promises.load__event_exhibit_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
// console.log(params_json);
|
||||
|
||||
// $events_sess.exhibits.status_qry__search = 'loading';
|
||||
ae_promises.load__event_exhibit_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_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.
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
// order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'created_on': 'DESC', 'updated_on': 'DESC'},
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(async function (exhibit_obj_li_get_result) {
|
||||
// console.log('Badge list:', exhibit_obj_li_get_result);
|
||||
if (exhibit_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: exhibit_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_obj_li_get_result;
|
||||
} else {
|
||||
// $slct.exhibit_obj_li = [];
|
||||
return [];
|
||||
if (ae_promises.load__event_exhibit_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_props({
|
||||
obj_li: ae_promises.load__event_exhibit_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
// $events_sess.exhibits.status_qry__search = 'done';
|
||||
// console.log('Badge list:', exhibit_obj_li_get_result);
|
||||
// return exhibit_obj_li_get_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_exhibit_obj_li:',
|
||||
ae_promises.load__event_exhibit_obj_li
|
||||
);
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_obj_li = await db_events.exhibit
|
||||
.where('event_id').equals(event_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_obj_li;
|
||||
}
|
||||
|
||||
@@ -382,62 +331,53 @@ export async function load_ae_obj_id__exhibit_tracking({
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
console.log(
|
||||
`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`*** load_ae_obj_id__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
}
|
||||
|
||||
const params = {};
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
params: {},
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
// $events_sess.exhibits.status_load__exhibit_tracking_obj = 'loading';
|
||||
ae_promises.load__event_exhibit_tracking_obj = await api
|
||||
.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
obj_id: exhibit_tracking_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: log_lvl
|
||||
})
|
||||
.then(async function (exhibit_tracking_obj_get_result) {
|
||||
if (exhibit_tracking_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [exhibit_tracking_obj_get_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_get_result;
|
||||
} else {
|
||||
console.log('No results returned.');
|
||||
return null;
|
||||
if (ae_promises.load__event_exhibit_tracking_obj) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [ae_promises.load__event_exhibit_tracking_obj],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj = await db_events.exhibit_tracking.get(exhibit_tracking_id);
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj = null;
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj;
|
||||
}
|
||||
@@ -456,80 +396,67 @@ export async function load_ae_obj_li__exhibit_tracking({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking[]> {
|
||||
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_li__exhibit_tracking() *** exhibit_id=${exhibit_id}`);
|
||||
}
|
||||
|
||||
const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled';
|
||||
const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'all';
|
||||
const limit: number = params.qry__limit ?? 99; // 99
|
||||
const offset: number = params.qry__offset ?? 0; // 0
|
||||
const limit: number = params.qry__limit ?? 99;
|
||||
const offset: number = params.qry__offset ?? 0;
|
||||
|
||||
const params_json: key_val = {};
|
||||
try {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_id,
|
||||
use_alt_table: false,
|
||||
use_alt_base: false,
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: {},
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await api
|
||||
.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_exhibit_tracking',
|
||||
for_obj_type: 'event_exhibit',
|
||||
for_obj_id: exhibit_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.
|
||||
enabled: enabled,
|
||||
hidden: hidden,
|
||||
order_by_li: { priority: 'DESC', sort: 'DESC', updated_on: 'DESC', created_on: 'DESC' },
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(async function (exhibit_tracking_obj_li_get_result) {
|
||||
// console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result);
|
||||
if (exhibit_tracking_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: exhibit_tracking_obj_li_get_result,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_li_get_result;
|
||||
} else {
|
||||
// $slct.exhibit_tracking_obj_li = [];
|
||||
return [];
|
||||
if (ae_promises.load__event_exhibit_tracking_obj_li) {
|
||||
if (try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: ae_promises.load__event_exhibit_tracking_obj_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
// console.log('Exhibit tracking list:', exhibit_tracking_obj_li_get_result);
|
||||
// return exhibit_tracking_obj_li_get_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.load__event_exhibit_tracking_obj_li:',
|
||||
ae_promises.load__event_exhibit_tracking_obj_li
|
||||
);
|
||||
} else {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = [];
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (try_cache) {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = await db_events.exhibit_tracking
|
||||
.where('event_exhibit_id').equals(exhibit_id)
|
||||
.toArray();
|
||||
} else {
|
||||
ae_promises.load__event_exhibit_tracking_obj_li = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_exhibit_tracking_obj_li;
|
||||
}
|
||||
|
||||
@@ -551,13 +478,6 @@ export async function create_ae_obj__exhibit_tracking({
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
console.log(
|
||||
`*** handle_create_ae_obj__exhibit_tracking() *** exhibit_id=${exhibit_id}, event_badge_id=${event_badge_id}`
|
||||
);
|
||||
|
||||
const params_json: key_val = {};
|
||||
|
||||
// $events_sess.exhibits.status_create__exhibit_tracking = 'loading';
|
||||
ae_promises.create__event_exhibit_tracking = await api
|
||||
.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -572,54 +492,23 @@ export async function create_ae_obj__exhibit_tracking({
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
|
||||
.then(async function (exhibit_tracking_obj_create_result) {
|
||||
// console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result);
|
||||
if (exhibit_tracking_obj_create_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [exhibit_tracking_obj_create_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_create_result;
|
||||
} else {
|
||||
// $slct.exhibit_tracking_obj = [];
|
||||
return null;
|
||||
.then(async function (obj_create_result) {
|
||||
if (obj_create_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [obj_create_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
// console.log('Exhibit tracking create:', exhibit_tracking_obj_create_result);
|
||||
// return exhibit_tracking_obj_create_result;
|
||||
return obj_create_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.create__event_exhibit_tracking:',
|
||||
ae_promises.create__event_exhibit_tracking
|
||||
);
|
||||
}
|
||||
return ae_promises.create__event_exhibit_tracking;
|
||||
}
|
||||
|
||||
@@ -629,18 +518,16 @@ export async function update_ae_obj__exhibit_tracking({
|
||||
exhibit_tracking_id,
|
||||
data,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
exhibit_tracking_id: string;
|
||||
data: any;
|
||||
params: key_val;
|
||||
log_lvl: number;
|
||||
params?: key_val;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}): Promise<ae_EventExhibitTracking | null> {
|
||||
console.log(
|
||||
`*** handle_update_ae_obj__exhibit_tracking() *** exhibit_tracking_id=${exhibit_tracking_id}`
|
||||
);
|
||||
|
||||
ae_promises.update__event_exhibit_tracking = await api
|
||||
.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
@@ -652,48 +539,23 @@ export async function update_ae_obj__exhibit_tracking({
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(async function (exhibit_tracking_obj_update_result) {
|
||||
if (exhibit_tracking_obj_update_result) {
|
||||
if (try_cache) {
|
||||
// Process the results first
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [exhibit_tracking_obj_update_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('Processed object list:', processed_obj_li);
|
||||
}
|
||||
// Save the updated results list to the database
|
||||
if (log_lvl) {
|
||||
console.log('Saving to DB...');
|
||||
}
|
||||
db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log('DB save completed.');
|
||||
}
|
||||
}
|
||||
return exhibit_tracking_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
.then(async function (obj_update_result) {
|
||||
if (obj_update_result && try_cache) {
|
||||
const processed_obj_li = await process_ae_obj__exhibit_tracking_props({
|
||||
obj_li: [obj_update_result],
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'exhibit_tracking',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save_exhibit_tracking,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function (error: any) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {});
|
||||
return obj_update_result;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
'ae_promises.update__event_exhibit_tracking:',
|
||||
ae_promises.update__event_exhibit_tracking
|
||||
);
|
||||
}
|
||||
return ae_promises.update__event_exhibit_tracking;
|
||||
}
|
||||
|
||||
@@ -741,4 +603,4 @@ export async function download_export__event_exhibit_tracking({
|
||||
);
|
||||
}
|
||||
return ae_promises.download__event_exhibit_tracking_export_file;
|
||||
}
|
||||
}
|
||||
@@ -421,6 +421,7 @@ export interface ae_Event extends ae_BaseObj {
|
||||
// Joined view fields
|
||||
event_location_obj_li?: ae_EventLocation[];
|
||||
event_session_obj_li?: ae_EventSession[];
|
||||
event_badge_template_obj_li?: ae_EventBadgeTemplate[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { ae_api } from '$lib/stores/ae_stores';
|
||||
import { events_slct } from '$lib/stores/ae_events_stores';
|
||||
import Comp_badge_obj_view from '../[badge_id]/ae_comp__badge_obj_view.svelte';
|
||||
import type { ae_EventBadge } from '$lib/types/ae_types';
|
||||
|
||||
interface Props {
|
||||
data: any; // PageData from SvelteKit
|
||||
@@ -17,8 +18,8 @@
|
||||
|
||||
let lq__filtered_badges = $derived(
|
||||
liveQuery(async () => {
|
||||
const filters: { printed_status?: string; type_code?: string } = {};
|
||||
if (printed_status_filter) filters.printed_status = printed_status_filter;
|
||||
const filters: { printed_status?: "all" | "printed" | "not_printed"; type_code?: string } = {};
|
||||
if (printed_status_filter) filters.printed_status = printed_status_filter as any;
|
||||
if (badge_type_code_filter) filters.type_code = badge_type_code_filter;
|
||||
|
||||
// Fetch badges using the search function, with a high limit for bulk printing
|
||||
@@ -29,7 +30,7 @@
|
||||
...filters,
|
||||
log_lvl: 0
|
||||
});
|
||||
return result || [];
|
||||
return (result || []) as ae_EventBadge[];
|
||||
})
|
||||
);
|
||||
|
||||
@@ -76,12 +77,10 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{#await lq__filtered_badges}
|
||||
<p>Loading badges for printing...</p>
|
||||
{:then badges_to_print}
|
||||
{#if badges_to_print.length > 0}
|
||||
{#if $lq__filtered_badges}
|
||||
{#if $lq__filtered_badges.length > 0}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{#each badges_to_print as badge_obj (badge_obj.event_badge_id_random)}
|
||||
{#each $lq__filtered_badges as badge_obj (badge_obj.event_badge_id_random)}
|
||||
<div class="badge-print-container">
|
||||
<Comp_badge_obj_view
|
||||
{event_id}
|
||||
@@ -96,7 +95,7 @@
|
||||
{:else}
|
||||
<p>No badges found matching your criteria for printing.</p>
|
||||
{/if}
|
||||
{:catch error}
|
||||
<p class="text-error-500">Error loading badges: {error.message}</p>
|
||||
{/await}
|
||||
{:else}
|
||||
<p>Loading badges for printing...</p>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
@@ -30,7 +30,7 @@ export async function load({ params, parent }) {
|
||||
|
||||
if (browser) {
|
||||
// Load event location object
|
||||
const load_event_location_obj = events_func.load_ae_obj_id__event_location({
|
||||
const load_event_location_obj = await events_func.load_ae_obj_id__event_location({
|
||||
api_cfg: ae_acct.api,
|
||||
event_location_id: event_location_id,
|
||||
try_cache: true
|
||||
@@ -39,71 +39,45 @@ export async function load({ params, parent }) {
|
||||
ae_acct.slct.event_location_obj = load_event_location_obj;
|
||||
|
||||
// Load event sessions for the location
|
||||
const load_event_session_obj_li = events_func
|
||||
.load_ae_obj_li__event_session({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: 'all',
|
||||
limit: 50,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_session_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_session_obj_li = `, event_session_obj_li);
|
||||
}
|
||||
for (let index = 0; index < event_session_obj_li.length; index++) {
|
||||
const event_session_obj = event_session_obj_li[index];
|
||||
const event_session_id = event_session_obj.event_session_id_random;
|
||||
const event_session_obj_li = await events_func.load_ae_obj_li__event_session({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: 'all',
|
||||
limit: 50,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
const load_event_presentation_obj_li =
|
||||
events_func.load_ae_obj_li__event_presentation({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
enabled: 'all',
|
||||
limit: 25,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`load_event_presentation_obj_li = `,
|
||||
load_event_presentation_obj_li
|
||||
);
|
||||
}
|
||||
event_session_obj_li[index].event_presentation_li =
|
||||
load_event_presentation_obj_li;
|
||||
}
|
||||
if (event_session_obj_li) {
|
||||
for (let index = 0; index < event_session_obj_li.length; index++) {
|
||||
const event_session_obj = event_session_obj_li[index];
|
||||
const event_session_id = event_session_obj.event_session_id || event_session_obj.id;
|
||||
|
||||
return event_session_obj_li;
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
const load_event_presentation_obj_li = await events_func.load_ae_obj_li__event_presentation({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
enabled: 'all',
|
||||
limit: 25,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
event_session_obj_li[index].event_presentation_li = load_event_presentation_obj_li;
|
||||
}
|
||||
}
|
||||
ae_acct.slct.event_session_obj_li = load_event_session_obj_li;
|
||||
ae_acct.slct.event_session_obj_li = event_session_obj_li;
|
||||
|
||||
const load_event_file_obj_li = await events_func
|
||||
.load_ae_obj_li__event_file({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 50,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
const load_event_file_obj_li = await events_func.load_ae_obj_li__event_file({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 50,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
|
||||
|
||||
const load_event_device_obj_li = events_func.load_ae_obj_li__event_device({
|
||||
const load_event_device_obj_li = await events_func.load_ae_obj_li__event_device({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_location',
|
||||
for_obj_id: event_location_id,
|
||||
|
||||
@@ -47,75 +47,50 @@ export async function load({ params, parent }) {
|
||||
ae_acct.slct.event_session_obj = load_event_session_obj;
|
||||
|
||||
// Load event presentations for the session
|
||||
const load_event_presentation_obj_li = events_func
|
||||
.load_ae_obj_li__event_presentation({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
inc_presenter_li: true,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 19,
|
||||
// params: {},
|
||||
try_cache: true,
|
||||
log_lvl: 2
|
||||
})
|
||||
.then((event_presentation_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_presentation_obj_li = `, event_presentation_obj_li);
|
||||
}
|
||||
for (let index = 0; index < event_presentation_obj_li?.length; index++) {
|
||||
const event_presentation_obj = event_presentation_obj_li[index];
|
||||
const event_presentation_id =
|
||||
event_presentation_obj.event_presentation_id_random;
|
||||
const event_presentation_obj_li = await events_func.load_ae_obj_li__event_presentation({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
inc_presenter_li: true,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 19,
|
||||
// params: {},
|
||||
try_cache: true,
|
||||
log_lvl: 2
|
||||
});
|
||||
|
||||
const load_event_presenter_obj_li = events_func.load_ae_obj_li__event_presenter(
|
||||
{
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_presentation',
|
||||
for_obj_id: event_presentation_id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 19,
|
||||
params: {},
|
||||
try_cache: true,
|
||||
log_lvl: 2
|
||||
}
|
||||
);
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_presenter_obj_li = `, load_event_presenter_obj_li);
|
||||
}
|
||||
event_presentation_obj_li[index].event_presenter_li =
|
||||
load_event_presenter_obj_li;
|
||||
}
|
||||
if (event_presentation_obj_li) {
|
||||
for (let index = 0; index < event_presentation_obj_li.length; index++) {
|
||||
const event_presentation_obj = event_presentation_obj_li[index];
|
||||
const event_presentation_id = event_presentation_obj.event_presentation_id || event_presentation_obj.id;
|
||||
|
||||
return event_presentation_obj_li;
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_presentation_obj_li = `, load_event_presentation_obj_li);
|
||||
const load_event_presenter_obj_li = await events_func.load_ae_obj_li__event_presenter({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_presentation',
|
||||
for_obj_id: event_presentation_id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 19,
|
||||
params: {},
|
||||
try_cache: true,
|
||||
log_lvl: 2
|
||||
});
|
||||
event_presentation_obj_li[index].event_presenter_li = load_event_presenter_obj_li;
|
||||
}
|
||||
}
|
||||
ae_acct.slct.event_presentation_obj_li = load_event_presentation_obj_li;
|
||||
ae_acct.slct.event_presentation_obj_li = event_presentation_obj_li;
|
||||
|
||||
// Load event files for the session
|
||||
const load_event_file_obj_li = await events_func
|
||||
.load_ae_obj_li__event_file({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 50,
|
||||
try_cache: true
|
||||
})
|
||||
.then((event_file_obj_li) => {
|
||||
if (log_lvl) {
|
||||
console.log(`event_file_obj_li = `, event_file_obj_li);
|
||||
}
|
||||
return event_file_obj_li;
|
||||
});
|
||||
if (log_lvl) {
|
||||
console.log(`load_event_file_obj_li = `, load_event_file_obj_li);
|
||||
}
|
||||
const load_event_file_obj_li = await events_func.load_ae_obj_li__event_file({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: 'event_session',
|
||||
for_obj_id: event_session_id,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
limit: 50,
|
||||
try_cache: true
|
||||
});
|
||||
ae_acct.slct.event_file_obj_li = load_event_file_obj_li;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user