More work on making the locations and devices more useful.

This commit is contained in:
Scott Idem
2024-10-16 15:27:25 -04:00
parent 3c957692c3
commit deac7bd574
10 changed files with 212 additions and 227 deletions

View File

@@ -3,14 +3,17 @@ import { api } from '$lib/api';
import { db_events } from "$lib/db_events";
import { load_ae_obj_li__event_device } from './ae_events__event_device';
let ae_promises: key_val = {};
// Updated 2024-09-25
// Updated 2024-10-16
export async function load_ae_obj_id__event(
{
api_cfg,
event_id,
inc_device_li = false,
inc_file_li = false,
inc_location_li = false,
inc_presentation_li = false,
@@ -21,6 +24,7 @@ export async function load_ae_obj_id__event(
}: {
api_cfg: any,
event_id: string,
inc_device_li?: boolean,
inc_file_li?: boolean,
inc_location_li?: boolean,
inc_presentation_li?: boolean,
@@ -63,6 +67,30 @@ export async function load_ae_obj_id__event(
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__event_obj:', ae_promises.load__event_obj);
}
if (inc_device_li) {
// Load the devices for the
if (log_lvl) {
console.log(`Need to load the device list for the now`);
}
let load_event_device_obj_li = load_ae_obj_li__event_device({
api_cfg: api_cfg,
for_obj_type: 'event',
for_obj_id: event_id,
params: {qry__enabled: 'all', qry__limit: 15},
try_cache: try_cache,
log_lvl: log_lvl
});
if (log_lvl) {
console.log(`load_event_device_obj_li = `, load_event_device_obj_li);
}
ae_promises.load__event_obj.event_device_li = load_event_device_obj_li;
}
return ae_promises.load__event_obj;
}

View File

@@ -8,7 +8,7 @@ import { load_ae_obj_id__event_location } from './ae_events__event_location';
let ae_promises: key_val = {};
// Updated 2024-06-10
// Updated 2024-10-16
export async function load_ae_obj_id__event_device(
{
api_cfg,
@@ -84,14 +84,13 @@ export async function load_ae_obj_id__event_device(
}
// Updated 2024-09-24
// Updated 2024-10-16
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,
inc_location_id = false,
order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'code': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
params = {},
try_cache = true,
@@ -100,8 +99,7 @@ export async function load_ae_obj_li__event_device(
api_cfg: any,
for_obj_type: string,
for_obj_id: string,
inc_file_li?: boolean,
inc_session_li?: boolean,
inc_location_id?: boolean,
order_by_li?: key_val,
params?: key_val,
try_cache?: boolean,
@@ -119,13 +117,14 @@ export async function load_ae_obj_li__event_device(
// console.log('params_json:', params_json);
ae_promises.load__event_device_obj_li = await api.get_ae_obj_li_for_obj_id_crud({
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_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
use_alt_tbl: true,
use_alt_mdl: false,
use_alt_exp: false,
enabled: enabled,
hidden: hidden,
order_by_li: order_by_li,
@@ -156,62 +155,29 @@ export async function load_ae_obj_li__event_device(
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 (inc_location_id) {
// Load the location for the devices
if (log_lvl) {
console.log(`Need to load the file list for each device now`);
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++) {
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({
let load_event_location_obj_li = load_ae_obj_id__event_location({
api_cfg: api_cfg,
for_obj_type: 'event_device',
for_obj_id: event_device_id,
params: {qry__enabled: enabled, qry__limit: limit},
event_location_id: event_device_obj.event_location_id,
try_cache: try_cache,
log_lvl: log_lvl
})
.then((event_file_obj_li) => {
.then((event_location_obj_li) => {
if (log_lvl) {
console.log(`event_file_obj_li = `, event_file_obj_li);
console.log(`event_location_obj_li = `, event_location_obj_li);
}
return event_file_obj_li;
return event_location_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);
console.log(`load_event_location_obj_li = `, load_event_location_obj_li);
}
}
}
@@ -220,7 +186,7 @@ export async function load_ae_obj_li__event_device(
}
// Updated 2024-06-25
// Updated 2024-10-16
export async function create_ae_obj__event_device(
{
api_cfg,
@@ -275,7 +241,7 @@ export async function create_ae_obj__event_device(
}
// Updated 2024-09-25
// Updated 2024-10-16
export async function update_ae_obj__event_device(
{
api_cfg,
@@ -331,6 +297,7 @@ export async function update_ae_obj__event_device(
}
// Updated 2024-10-16
export async function search__event_device(
{
api_cfg,
@@ -452,7 +419,7 @@ export async function search__event_device(
// This function will loop through the event_device_obj_li and save each one to the DB.
// Updated 2024-06-25
// Updated 2024-10-16
export function db_save_ae_obj_li__event_device(
{
obj_type,
@@ -478,27 +445,42 @@ export function db_save_ae_obj_li__event_device(
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_device_id_random: obj.event_device_id_random,
event_id: obj.event_id_random,
event_id_random: obj.event_id_random,
// event_id_random: obj.event_id_random,
event_location_id: obj.event_location_id_random,
// event_location_id_random: obj.event_location_id_random,
code: obj.code,
name: obj.name,
description: obj.description,
passcode: obj.passcode,
hide_event_launcher: obj.hide_event_launcher,
local_file_cache_path: obj.local_file_cache_path,
host_file_temp_path: obj.host_file_temp_path,
recording_path: obj.recording_path,
record_audio: obj.record_audio,
record_video: obj.record_video,
trigger_open_file_id: obj.trigger_open_file_id,
trigger_open_session_id: obj.trigger_open_session_id,
trigger_recording_start: obj.trigger_recording_start,
trigger_recording_stop: obj.trigger_recording_stop,
trigger_reset: obj.trigger_reset,
trigger_show_admin: obj.trigger_show_admin,
trigger_show_hidden: obj.trigger_show_hidden,
alert: obj.alert,
alert_msg: obj.alert_msg,
data_json: obj.data_json,
info_hostname: obj.info_hostname,
info_ip_list: obj.info_ip_list,
meta_json: obj.meta_json,
other_json: obj.other_json,
enable: obj.enable,
hide: obj.hide,
@@ -510,19 +492,9 @@ export function db_save_ae_obj_li__event_device(
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,
event_location_code: obj.event_location_code,
event_location_name: obj.event_location_name,
});
// console.log(`Put obj with ID: ${obj.event_device_id_random} or ${id_random}`);
} catch (error) {

View File

@@ -552,10 +552,12 @@ export async function qry__event_session(
})
.then(function (event_session_obj_li_get_result) {
if (event_session_obj_li_get_result) {
db_save_ae_obj_li__event_session({
obj_type: 'event_session',
obj_li: event_session_obj_li_get_result
});
if (try_cache) {
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 [];

View File

@@ -21,7 +21,7 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
// datetime_iso 'YYYY-MM-DD HH:mm:ss'
// datetime_iso_12 'YYYY-MM-DD hh:mm:ss A'
// datetime_iso_12_short 'YY-MM-DD hh:mm A'
// datetime_iso_tz 'YYYY-MM-DD HH:mm:ss'
// datetime_iso_tz 'YYYY-MM-DD HH:mm:ss Z'
// datetime_12_no_seconds 'YYYY-MM-DD hh:mm A'
@@ -37,6 +37,8 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
// time_iso 'HH:mm:ss'
// time_iso_12 'hh:mm:ss A'
// time_iso_tz 'HH:mm:ss Z'
// time_iso_12_tz 'hh:mm:ss A Z'
// time_long 'hh:mm:ss A'
// time_medium 'h:m:s A'
@@ -63,6 +65,9 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
case 'datetime_iso_12_short_month':
datetime_string = dayjs(raw_datetime).format('MM-DD hh:mm A');
break;
case 'datetime_iso_tz':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD HH:mm:ss Z');
break;
case 'datetime_12_no_seconds':
datetime_string = dayjs(raw_datetime).format('YYYY-MM-DD hh:mm A');
break;
@@ -117,6 +122,9 @@ export let iso_datetime_formatter = function iso_datetime_formatter(
case 'time_iso':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss');
break;
case 'time_iso_12_tz':
datetime_string = dayjs(raw_datetime).format('hh:mm:ss A Z');
break;
case 'time_long':
datetime_string = dayjs(raw_datetime).format('HH:mm:ss A');
break;

View File

@@ -35,13 +35,13 @@ export interface Event {
cfg_json?: null|key_val;
enable: null|boolean;
hide: null|boolean;
priority: null|boolean
sort: null|number;
group: null|string;
notes: null|string;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on: null|Date;
updated_on?: null|Date;
// IDAA Recovery Meetings
contact_li_json?: null|string[]; // full_name, email, phone_mobile, phone_home, phone_office, other_text
@@ -122,46 +122,71 @@ export interface Badge {
external_person_id: string;
enable: null|boolean;
hide: null|boolean;
priority: null|boolean
sort: null|number;
group: null|string;
notes: null|string;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on: null|Date;
updated_on?: null|Date;
}
// Updated 2024-10-16
export interface Device {
// id?: number;
id_random: string;
event_device_id_random: string;
id: number;
// id_random: string;
event_device_id: string;
// event_device_id_random: string;
event_id_random: string;
event_location_id_random: string;
event_id: string;
// event_id_random: string;
event_location_id?: string;
// event_location_id_random?: string;
code: string;
code?: string;
name: string;
description?: null|string;
for_type: null|string;
for_id: null|string;
for_id_random: null|string;
passcode?: null|string;
alert: null|boolean;
local_file_cache_path?: null|string;
host_file_temp_path?: null|string;
recording_path?: null|string;
record_audio?: null|boolean;
record_video?: null|boolean;
trigger_open_file_id?: null|string;
trigger_open_session_id?: null|string;
trigger_recording_start?: null|boolean;
trigger_recording_stop?: null|boolean;
trigger_reset?: null|boolean;
trigger_show_admin?: null|boolean;
trigger_show_hidden?: null|boolean;
alert?: null|boolean;
alert_msg?: null|string;
info_hostname?: null|string;
info_ip_list?: null|string; // Semi-colon separated list of IP addresses
meta_json?: null|string;
other_json?: null|string;
enable: null|boolean;
hide: null|boolean;
priority: null|boolean
sort: null|number;
group: null|string;
notes: null|string;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on: null|Date;
updated_on?: null|Date;
// Additional fields for convenience (database views)
event_location_code: string;
event_location_name: string;
event_name?: string;
event_location_code?: string;
event_location_name?: string;
}