Making progress with the new locations page and devices related.
This commit is contained in:
539
src/lib/ae_events__event_device.ts
Normal file
539
src/lib/ae_events__event_device.ts
Normal file
@@ -0,0 +1,539 @@
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { api } from '$lib/api';
|
||||
|
||||
import { db_events } from "$lib/db_events";
|
||||
|
||||
import { load_ae_obj_id__event_location } from './ae_events__event_location';
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
export async function load_ae_obj_id__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_device_id,
|
||||
inc_location_id = false,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_device_id: string,
|
||||
inc_location_id?: boolean,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_device() *** event_device_id=${event_device_id}`);
|
||||
}
|
||||
|
||||
let 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(function (event_device_obj_get_result) {
|
||||
if (event_device_obj_get_result) {
|
||||
if (try_cache) {
|
||||
// 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;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_device_obj:', ae_promises.load__event_device_obj);
|
||||
}
|
||||
|
||||
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`);
|
||||
}
|
||||
let 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;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-24
|
||||
export async function load_ae_obj_li__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
inc_file_li = false,
|
||||
inc_session_li = false,
|
||||
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'code': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
for_obj_type: string,
|
||||
for_obj_id: string,
|
||||
inc_file_li?: boolean,
|
||||
inc_session_li?: boolean,
|
||||
order_by_li?: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_li__event_device() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`);
|
||||
|
||||
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
|
||||
|
||||
let 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({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_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
|
||||
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(function (event_device_obj_li_get_result) {
|
||||
if (event_device_obj_li_get_result) {
|
||||
if (try_cache) {
|
||||
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) {
|
||||
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_file_li) {
|
||||
// Load the files for the devices
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the file list for each device now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_device_obj_li.length; i++) {
|
||||
let event_device_obj = ae_promises.load__event_device_obj_li[i];
|
||||
let event_device_id = event_device_obj.event_device_id_random;
|
||||
|
||||
let load_event_file_obj_li = load_ae_obj_li__event_file({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_device',
|
||||
for_obj_id: event_device_id,
|
||||
params: {qry__enabled: enabled, qry__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_session_li) {
|
||||
// Load the sessions for the devices
|
||||
if (log_lvl) {
|
||||
console.log(`Need to load the session list for each device now`);
|
||||
}
|
||||
for (let i = 0; i < ae_promises.load__event_device_obj_li.length; i++) {
|
||||
let event_device_obj = ae_promises.load__event_device_obj_li[i];
|
||||
let event_device_id = event_device_obj.event_device_id_random;
|
||||
|
||||
let load_event_session_obj_li = load_ae_obj_li__event_session({
|
||||
api_cfg: api_cfg,
|
||||
for_obj_type: 'event_device',
|
||||
for_obj_id: event_device_id,
|
||||
params: {qry__enabled: enabled, qry__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 (log_lvl) {
|
||||
console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ae_promises.load__event_device_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-25
|
||||
export async function create_ae_obj__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
data_kv,
|
||||
params={},
|
||||
log_lvl=0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** create_ae_obj__event_device() *** event_id=${event_id}`);
|
||||
|
||||
ae_promises.create__event_device = await api.create_ae_obj_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
fields: {
|
||||
event_id_random: event_id,
|
||||
...data_kv
|
||||
},
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_device_obj_create_result) {
|
||||
if (event_device_obj_create_result) {
|
||||
db_save_ae_obj_li__event_device(
|
||||
{
|
||||
obj_type: 'event_device',
|
||||
obj_li: [event_device_obj_create_result]
|
||||
});
|
||||
return event_device_obj_create_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.create__event_device:', ae_promises.create__event_device);
|
||||
}
|
||||
return ae_promises.create__event_device;
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-09-25
|
||||
export async function update_ae_obj__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_device_id,
|
||||
data_kv,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_device_id: string,
|
||||
data_kv: key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** update_ae_obj__event_device() *** event_device_id=${event_device_id}`, data_kv);
|
||||
}
|
||||
ae_promises.update__event_device_obj = await api.update_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
obj_id: event_device_id,
|
||||
fields: data_kv,
|
||||
key: api_cfg.api_crud_super_key,
|
||||
params: params,
|
||||
return_obj: true,
|
||||
log_lvl: log_lvl
|
||||
})
|
||||
.then(function (event_device_obj_update_result) {
|
||||
if (event_device_obj_update_result) {
|
||||
if (try_cache) {
|
||||
db_save_ae_obj_li__event_device({
|
||||
obj_type: 'event_device', obj_li: [event_device_obj_update_result]
|
||||
});
|
||||
}
|
||||
return event_device_obj_update_result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.update__event_device_obj:', ae_promises.update__event_device_obj);
|
||||
}
|
||||
return ae_promises.update__event_device_obj;
|
||||
}
|
||||
|
||||
|
||||
export async function search__event_device(
|
||||
{
|
||||
api_cfg,
|
||||
event_id,
|
||||
fulltext_search_qry_str,
|
||||
ft_presenter_search_qry_str,
|
||||
like_search_qry_str = null,
|
||||
like_presentation_search_qry_str = null,
|
||||
like_presenter_search_qry_str = null,
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any,
|
||||
event_id: any,
|
||||
fulltext_search_qry_str?: null|string,
|
||||
ft_presenter_search_qry_str?: null|string,
|
||||
like_search_qry_str?: null|string,
|
||||
like_presentation_search_qry_str?: null|string,
|
||||
like_presenter_search_qry_str?: null|string,
|
||||
params?: any,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** search__event_device() *** event_id=${event_id}`);
|
||||
|
||||
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 ?? 25); // 99
|
||||
let offset: number = (params.qry__offset ?? 0); // 0
|
||||
|
||||
let 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.
|
||||
}
|
||||
|
||||
if (fulltext_search_qry_str || ft_presenter_search_qry_str) {
|
||||
params_json['ft_qry'] = {};
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['default_qry_str'] = fulltext_search_qry_str;
|
||||
}
|
||||
|
||||
if (ft_presenter_search_qry_str && ft_presenter_search_qry_str.length > 2) {
|
||||
params_json['ft_qry']['event_presenter_li_qry_str'] = ft_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
params_json['or_like']['default_qry_str'] = like_search_qry_str;
|
||||
}
|
||||
if (like_presentation_search_qry_str && like_presentation_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presentation_li_qry_str'] = like_presentation_search_qry_str;
|
||||
}
|
||||
if (like_presenter_search_qry_str && like_presenter_search_qry_str.length > 2) {
|
||||
params_json['or_like']['event_presenter_li_qry_str'] = like_presenter_search_qry_str;
|
||||
}
|
||||
}
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
|
||||
// if (device_type_code) {
|
||||
// params_json['and_qry']['device_type_code'] = device_type_code;
|
||||
// }
|
||||
|
||||
let order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'start_datetime': 'ASC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'};
|
||||
|
||||
ae_promises.load__event_device_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_device',
|
||||
for_obj_type: 'event',
|
||||
for_obj_id: event_id,
|
||||
use_alt_table: true, // NOTE: We want to use the alt table for device searching
|
||||
use_alt_base: 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(function (event_device_obj_li_get_result) {
|
||||
if (event_device_obj_li_get_result) {
|
||||
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) {
|
||||
console.log('No results returned or failed.', error);
|
||||
})
|
||||
.finally(function () {
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log('ae_promises.load__event_device_obj_li:', ae_promises.load__event_device_obj_li);
|
||||
}
|
||||
return ae_promises.load__event_device_obj_li;
|
||||
}
|
||||
|
||||
|
||||
// This function will loop through the event_device_obj_li and save each one to the DB.
|
||||
// Updated 2024-06-25
|
||||
export function db_save_ae_obj_li__event_device(
|
||||
{
|
||||
obj_type,
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
obj_type: string,
|
||||
obj_li: any,
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
if (log_lvl) {
|
||||
console.log(`*** db_save_ae_obj_li__event_device() ***`);
|
||||
}
|
||||
|
||||
if (obj_li && obj_li.length) {
|
||||
obj_li.forEach(async function (obj: any) {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_obj ${obj_type}:`, obj);
|
||||
}
|
||||
|
||||
try {
|
||||
const id_random = await db_events.devices.put({
|
||||
id: obj.event_device_id_random,
|
||||
event_device_id: obj.event_device_id_random,
|
||||
event_device_id_random: obj.event_device_id_random,
|
||||
|
||||
external_id: obj.external_id,
|
||||
code: obj.code,
|
||||
|
||||
type_code: obj.type_code,
|
||||
|
||||
event_id: obj.event_id_random,
|
||||
event_id_random: obj.event_id_random,
|
||||
|
||||
name: obj.name,
|
||||
description: obj.description,
|
||||
|
||||
passcode: obj.passcode,
|
||||
|
||||
hide_event_launcher: obj.hide_event_launcher,
|
||||
|
||||
alert: obj.alert,
|
||||
alert_msg: obj.alert_msg,
|
||||
|
||||
data_json: obj.data_json,
|
||||
|
||||
enable: obj.enable,
|
||||
hide: obj.hide,
|
||||
priority: obj.priority,
|
||||
sort: obj.sort,
|
||||
group: obj.group,
|
||||
notes: obj.notes,
|
||||
created_on: obj.created_on,
|
||||
updated_on: obj.updated_on,
|
||||
|
||||
// From SQL view
|
||||
file_count: obj.file_count,
|
||||
file_count_all: obj.file_count_all,
|
||||
internal_use_count: obj.internal_use_count,
|
||||
event_file_id_li_json: obj.event_file_id_li_json,
|
||||
|
||||
// poc_person_given_name: obj.poc_person_given_name,
|
||||
// poc_person_family_name: obj.poc_person_family_name,
|
||||
// poc_person_full_name: obj.poc_person_full_name,
|
||||
// poc_person_primary_email: obj.poc_person_primary_email,
|
||||
// poc_person_passcode: obj.poc_person_passcode,
|
||||
// poc_kv_json: obj.poc_kv_json,
|
||||
|
||||
event_name: obj.event_name,
|
||||
});
|
||||
// console.log(`Put obj with ID: ${obj.event_device_id_random} or ${id_random}`);
|
||||
} catch (error) {
|
||||
let status = `Failed to put ${obj.event_device_id_random}: ${error}`;
|
||||
console.log(status);
|
||||
}
|
||||
|
||||
// const id_random = await db_events.devices.put(obj);
|
||||
// console.log(`Put obj with ID: ${obj.event_device_id_random}`);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -27,11 +27,12 @@ export async function load_ae_obj_id__event_location(
|
||||
log_lvl?: number
|
||||
}
|
||||
) {
|
||||
console.log(`*** load_ae_obj_id__event_location() *** event_location_id=${event_location_id}`);
|
||||
if (log_lvl) {
|
||||
console.log(`*** load_ae_obj_id__event_location() *** event_location_id=${event_location_id}`);
|
||||
}
|
||||
|
||||
let params = {};
|
||||
|
||||
// $events_sess.badges.status_load__event_location_obj = 'loading';
|
||||
ae_promises.load__event_location_obj = await api.get_ae_obj_id_crud({
|
||||
api_cfg: api_cfg,
|
||||
obj_type: 'event_location',
|
||||
@@ -102,21 +103,6 @@ export async function load_ae_obj_id__event_location(
|
||||
params: {qry__enabled: 'all', qry__limit: 15},
|
||||
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);
|
||||
}
|
||||
// if (try_cache) {
|
||||
// console.log(`ae_promises.load__event_session_obj = `, ae_promises.load__event_session_obj);
|
||||
// ae_promises.load__event_session_obj.event_session_li = event_session_obj_li;
|
||||
// // Re-save the session object with the new session list
|
||||
// db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: [ae_promises.load__event_session_obj]
|
||||
// });
|
||||
// }
|
||||
return event_session_obj_li;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { key_val } from './ae_stores';
|
||||
// li = list
|
||||
// kv = key value list
|
||||
|
||||
// Updated 2024-10-16
|
||||
export interface Event {
|
||||
id: string;
|
||||
// id_random: string;
|
||||
@@ -68,11 +69,14 @@ export interface Event {
|
||||
|
||||
|
||||
export interface Badge {
|
||||
// id?: number;
|
||||
id?: number;
|
||||
id_random: string;
|
||||
event_badge_id: string;
|
||||
event_badge_id_random: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
|
||||
pronouns: null|string;
|
||||
informal_name: null|string;
|
||||
title_names: null|string;
|
||||
@@ -128,12 +132,48 @@ export interface Badge {
|
||||
}
|
||||
|
||||
|
||||
export interface Exhibit {
|
||||
// Updated 2024-10-16
|
||||
export interface Device {
|
||||
// id?: number;
|
||||
id_random: string;
|
||||
event_exhibit_id_random: string;
|
||||
event_device_id_random: string;
|
||||
|
||||
event_id_random: string;
|
||||
event_location_id_random: string;
|
||||
|
||||
code: string;
|
||||
name: string;
|
||||
|
||||
for_type: null|string;
|
||||
for_id: null|string;
|
||||
for_id_random: null|string;
|
||||
|
||||
alert: null|boolean;
|
||||
|
||||
enable: null|boolean;
|
||||
hide: null|boolean;
|
||||
priority: null|boolean
|
||||
sort: null|number;
|
||||
group: null|string;
|
||||
notes: null|string;
|
||||
created_on: Date;
|
||||
updated_on: null|Date;
|
||||
|
||||
// Additional fields for convenience (database views)
|
||||
event_location_code: string;
|
||||
event_location_name: string;
|
||||
}
|
||||
|
||||
|
||||
export interface Exhibit {
|
||||
id?: number;
|
||||
id_random: string;
|
||||
event_exhibit_id: string;
|
||||
event_exhibit_id_random: string;
|
||||
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
|
||||
code: string;
|
||||
name: string;
|
||||
// tagline: null|string;
|
||||
@@ -161,12 +201,16 @@ export interface Exhibit {
|
||||
|
||||
|
||||
export interface Exhibit_tracking {
|
||||
// id?: number;
|
||||
id?: number;
|
||||
id_random: string;
|
||||
event_exhibit_tracking_id: string
|
||||
event_exhibit_tracking_id_random: string;
|
||||
|
||||
event_exhibit_id: string;
|
||||
event_exhibit_id_random: string;
|
||||
event_badge_id: string;
|
||||
event_badge_id_random: string;
|
||||
event_person_id: string;
|
||||
event_person_id_random: null|string; // Is this needed?
|
||||
|
||||
external_person_id: null|string; // This is an email address
|
||||
@@ -555,19 +599,20 @@ export interface Session {
|
||||
}
|
||||
|
||||
|
||||
// Updated 2024-06-10
|
||||
// Updated 2024-10-16
|
||||
export class MySubClassedDexie extends Dexie {
|
||||
// 'badges' is added by dexie when declaring the stores()
|
||||
// We just tell the typing system this is the case
|
||||
events!: Table<Event>;
|
||||
badges!: Table<Badge>;
|
||||
devices!: Table<Device>;
|
||||
exhibits!: Table<Exhibit>;
|
||||
exhibit_tracking!: Table<Exhibit_tracking>;
|
||||
files!: Table<File>;
|
||||
locations!: Table<Location>;
|
||||
sessions!: Table<Session>;
|
||||
presentations!: Table<Presentation>;
|
||||
presenters!: Table<Presenter>;
|
||||
sessions!: Table<Session>;
|
||||
|
||||
constructor() {
|
||||
super('ae_events_db');
|
||||
@@ -585,21 +630,33 @@ export class MySubClassedDexie extends Dexie {
|
||||
|
||||
// badges: '++id, full_name, email' // Primary key and indexed props
|
||||
badges: `
|
||||
id_random, event_badge_id_random, event_id_random,
|
||||
id, id_random, event_badge_id, event_badge_id_random,
|
||||
event_id, event_id_random,
|
||||
full_name, full_name_override, email, email_override,
|
||||
affiliations, affiliations_override,
|
||||
badge_type, badge_type_code, badge_type_code_override, badge_type_override,
|
||||
external_event_id, external_id, external_person_id,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
|
||||
devices: `
|
||||
id, id_random, event_device_id_random, event_device_id,
|
||||
event_id, event_id_random, event_location_id, event_location_id_random,
|
||||
code, name,
|
||||
for_type, for_id, for_id_random,
|
||||
alert,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
|
||||
exhibits: `
|
||||
id_random, event_exhibit_id_random,
|
||||
id, id_random, event_exhibit_id, event_exhibit_id_random,
|
||||
event_id, event_id_random,
|
||||
code, name, description, staff_passcode,
|
||||
data_json, license_max, license_li_json, cfg_json,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on, [priority+name]`,
|
||||
|
||||
exhibit_tracking: `
|
||||
id_random, event_exhibit_tracking_id_random, event_exhibit_id_random, event_badge_id_random, event_person_id_random,
|
||||
id, id_random, event_exhibit_tracking_id, event_exhibit_tracking_id_random,
|
||||
event_exhibit_id, event_exhibit_id_random,
|
||||
event_badge_id, event_badge_id_random, event_person_id, event_person_id_random,
|
||||
exhibitor_notes, responses_json, data_json,
|
||||
event_badge_full_name, event_badge_email,
|
||||
enable, hide, priority, sort, group, notes, created_on, updated_on`,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl = 0;
|
||||
import { onMount } from 'svelte';
|
||||
import { clipboard } from '@skeletonlabs/skeleton';
|
||||
// import { liveQuery } from "dexie";
|
||||
@@ -33,9 +34,10 @@ ae_tmp.show__direct_download = false;
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
onMount(() => {
|
||||
// console.log('Element - Manage Event File List');
|
||||
console.log(`link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`);
|
||||
console.log(`allow_basic: ${allow_basic}; allow_moderator: ${allow_moderator}`);
|
||||
if (log_lvl) {
|
||||
console.log(`Element - Manage Event File List: link_to_type: ${link_to_type}; link_to_id: ${link_to_id}`);
|
||||
console.log(`allow_basic: ${allow_basic}; allow_moderator: ${allow_moderator}`);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
// import { onMount } from 'svelte';
|
||||
// import { clipboard } from '@skeletonlabs/skeleton';
|
||||
export let log_lvl = 0;
|
||||
import { liveQuery } from "dexie";
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
@@ -11,7 +10,7 @@ import type { key_val } from '$lib/ae_stores';
|
||||
import Element_manage_event_file_li from '$lib/element_manage_event_file_li.svelte';
|
||||
|
||||
// import { core_func } from '$lib/ae_core_functions';
|
||||
import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
// import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { db_events } from "$lib/db_events";
|
||||
// import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
// import { events_func } from '$lib/ae_events_functions';
|
||||
@@ -22,10 +21,8 @@ export let link_to_id: string;
|
||||
export let allow_basic: boolean = false;
|
||||
export let allow_moderator: boolean = false;
|
||||
export let display_mode: string = 'default'; // 'default', 'compact', 'minimal', 'launcher'
|
||||
|
||||
// export let show_convert_btn: null|boolean = null;
|
||||
|
||||
// let ae_placeholder_li: key_val = {};
|
||||
// let ae_promises: key_val = {};
|
||||
let ae_tmp: key_val = {};
|
||||
ae_tmp.show__file_li = true;
|
||||
@@ -38,15 +35,17 @@ let dq__where_for_id_eq_val: string = link_to_id;
|
||||
|
||||
// This should only include files that are directly linked to an object (event, location, session, presenter, etc.).
|
||||
// I am not sure why, but doing reverse() and then sortBy() seems to sort in descending order.
|
||||
let lq__event_file_obj_li = liveQuery(
|
||||
async () => await db_events.files
|
||||
.where(dq__where_val)
|
||||
.equals(dq__where_eq_val)
|
||||
.and(file => file.for_id_random == dq__where_for_id_eq_val)
|
||||
.reverse()
|
||||
.sortBy('created_on')
|
||||
// .toArray()
|
||||
);
|
||||
$: lq__event_file_obj_li = liveQuery(async () => {
|
||||
let results = await db_events.files
|
||||
.where(dq__where_val)
|
||||
.equals(dq__where_eq_val)
|
||||
.and(file => file.for_id_random == dq__where_for_id_eq_val)
|
||||
.reverse()
|
||||
.sortBy('created_on')
|
||||
// .toArray()
|
||||
;
|
||||
return results;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -63,6 +62,7 @@ let lq__event_file_obj_li = liveQuery(
|
||||
allow_moderator={allow_moderator}
|
||||
container_class_li={container_class_li}
|
||||
display_mode={display_mode}
|
||||
log_lvl={log_lvl}
|
||||
/>
|
||||
{:catch error}
|
||||
<p style="color: red;">{error.message}</p>
|
||||
|
||||
Reference in New Issue
Block a user