From 67b01c5884d9fd19033aad1b146c796d7859c282 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 17 Oct 2024 12:56:10 -0400 Subject: [PATCH] Now with status updates for devices. --- src/lib/ae_events__event.ts | 2 +- src/lib/ae_events__event_device.ts | 4 +++ src/lib/ae_events__event_location.ts | 33 +++++++++++++++++++ src/lib/db_events.ts | 4 +++ .../ae_comp__event_device_obj_li.svelte | 25 +++++++++++++- 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/lib/ae_events__event.ts b/src/lib/ae_events__event.ts index b8cdff19..a6b20353 100644 --- a/src/lib/ae_events__event.ts +++ b/src/lib/ae_events__event.ts @@ -80,7 +80,7 @@ export async function load_ae_obj_id__event( api_cfg: api_cfg, for_obj_type: 'event', for_obj_id: event_id, - params: {qry__enabled: 'all', qry__limit: 15}, + params: {qry__enabled: 'all', qry__limit: 50}, try_cache: try_cache, log_lvl: log_lvl }); diff --git a/src/lib/ae_events__event_device.ts b/src/lib/ae_events__event_device.ts index 02e3f1aa..8d4d2282 100644 --- a/src/lib/ae_events__event_device.ts +++ b/src/lib/ae_events__event_device.ts @@ -475,6 +475,10 @@ export function db_save_ae_obj_li__event_device( alert: obj.alert, alert_msg: obj.alert_msg, + status: obj.status, + status_msg: obj.status_msg, + record_status: obj.record_status, + record_status_msg: obj.record_status_msg, info_hostname: obj.info_hostname, info_ip_list: obj.info_ip_list, diff --git a/src/lib/ae_events__event_location.ts b/src/lib/ae_events__event_location.ts index ee636fd4..c69477ba 100644 --- a/src/lib/ae_events__event_location.ts +++ b/src/lib/ae_events__event_location.ts @@ -3,6 +3,7 @@ import { api } from '$lib/api'; import { db_events } from "$lib/db_events"; +import { load_ae_obj_li__event_device } from "$lib/ae_events__event_device"; import { load_ae_obj_li__event_file } from "$lib/ae_events__event_file"; import { load_ae_obj_li__event_session } from './ae_events__event_session'; @@ -121,6 +122,7 @@ export async function load_ae_obj_li__event_location( api_cfg, for_obj_type, for_obj_id, + inc_device_li = false, 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'}, @@ -131,6 +133,7 @@ export async function load_ae_obj_li__event_location( api_cfg: any, for_obj_type: string, for_obj_id: string, + inc_device_li?: boolean, inc_file_li?: boolean, inc_session_li?: boolean, order_by_li?: key_val, @@ -187,6 +190,36 @@ export async function load_ae_obj_li__event_location( 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++) { + let event_location_obj = ae_promises.load__event_location_obj_li[i]; + let event_location_id = event_location_obj.event_location_id_random; + + let 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); + } + } + } + if (inc_file_li) { // Load the files for the locations if (log_lvl) { diff --git a/src/lib/db_events.ts b/src/lib/db_events.ts index a3fb7584..64c25fe7 100644 --- a/src/lib/db_events.ts +++ b/src/lib/db_events.ts @@ -167,6 +167,10 @@ export interface Device { alert?: null|boolean; alert_msg?: null|string; + status?: null|string; + status_msg?: null|string; + record_status?: null|string; + record_status_msg?: null|string; info_hostname?: null|string; info_ip_list?: null|string; // Semi-colon separated list of IP addresses diff --git a/src/routes/events/[event_id]/device/ae_comp__event_device_obj_li.svelte b/src/routes/events/[event_id]/device/ae_comp__event_device_obj_li.svelte index 8107fd62..6c3e56b2 100644 --- a/src/routes/events/[event_id]/device/ae_comp__event_device_obj_li.svelte +++ b/src/routes/events/[event_id]/device/ae_comp__event_device_obj_li.svelte @@ -166,8 +166,31 @@ if (!$events_loc.pres_mgmt?.device_kv) { {event_device_obj?.alert ? 'Alert' : 'No Alert'}
- {event_device_obj?.alert_msg ?? 'No Alert Message'} + {event_device_obj?.alert_msg ?? 'No message'} + +
+ + {event_device_obj?.status ? 'Status' : 'No Status'} + +
+ {event_device_obj?.status_msg ?? 'No message'} +
+ +
+ + {event_device_obj?.record_status ? 'Recording Status' : 'No Recording Status'} + +
+ {event_device_obj?.record_status_msg ?? 'No message'} +
+
hostname: