Now with status updates for devices.

This commit is contained in:
Scott Idem
2024-10-17 12:56:10 -04:00
parent a0d5a97d48
commit 67b01c5884
5 changed files with 66 additions and 2 deletions

View File

@@ -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
});

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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

View File

@@ -166,8 +166,31 @@ if (!$events_loc.pres_mgmt?.device_kv) {
{event_device_obj?.alert ? 'Alert' : 'No Alert'}
<span class="fas fa-exclamation-triangle mx-1" />
<br>
{event_device_obj?.alert_msg ?? 'No Alert Message'}
{event_device_obj?.alert_msg ?? 'No message'}
</div>
<div
class="text-red-500 bg-red-200 p-1 rounded-md border border-red-200 text-center"
class:hidden={!event_device_obj?.status && !event_device_obj?.status_msg}
>
<span class="fas fa-exclamation-triangle mx-1" />
{event_device_obj?.status ? 'Status' : 'No Status'}
<span class="fas fa-exclamation-triangle mx-1" />
<br>
{event_device_obj?.status_msg ?? 'No message'}
</div>
<div
class="text-red-500 bg-red-200 p-1 rounded-md border border-red-200 text-center"
class:hidden={!event_device_obj?.record_status && !event_device_obj?.record_status_msg}
>
<span class="fas fa-exclamation-triangle mx-1" />
{event_device_obj?.record_status ? 'Recording Status' : 'No Recording Status'}
<span class="fas fa-exclamation-triangle mx-1" />
<br>
{event_device_obj?.record_status_msg ?? 'No message'}
</div>
<div class="flex flex-col gap-1">
<span>
<strong class="text-sm">hostname:</strong>