Wrapping up for the night. Better alerts and things with the correct timezone...

This commit is contained in:
Scott Idem
2024-10-17 20:46:39 -04:00
parent 172763bc26
commit de24f0dc80
4 changed files with 25 additions and 6 deletions

View File

@@ -483,6 +483,8 @@ export function db_save_ae_obj_li__event_device(
record_status: obj.record_status,
record_status_msg: obj.record_status_msg,
record_status_on: obj.record_status_on,
// These are timestamps that are in UTC but missing the 'Z' at the end
heartbeat: obj.heartbeat ? obj.heartbeat+'Z' : null,
info_hostname: obj.info_hostname,
info_ip_list: obj.info_ip_list,

View File

@@ -174,6 +174,7 @@ export interface Device {
record_status?: null|string;
record_status_msg?: null|string;
record_status_on?: null|Date;
heartbeat?: null|string;
info_hostname?: null|string;
info_ip_list?: null|string; // Semi-colon separated list of IP addresses

View File

@@ -247,7 +247,8 @@ if (auto_refresh) {
</strong>
<span class="fas fa-exclamation-triangle mx-1" />
</div>
<div>
<div class="font-mono">
<span class="fas fa-comment-dots mx-1"></span>
{@html event_device_obj?.alert_msg ?? 'No message'}
</div>
{#if event_device_obj?.alert_on}
@@ -268,7 +269,8 @@ if (auto_refresh) {
</strong>
<span class="fas fa-laptop-code mx-1" />
</div>
<div>
<div class="font-mono">
<span class="fas fa-comment-dots mx-1"></span>
{@html event_device_obj?.status_msg ?? 'No message'}
</div>
{#if event_device_obj?.status_on}
@@ -296,7 +298,8 @@ if (auto_refresh) {
{/if}
<span class="fas fa-camera mx-1" />
</div>
<div>
<div class="font-mono text-black">
<span class="fas fa-comment-dots mx-1"></span>
{@html event_device_obj?.record_status_msg ?? 'No message'}
</div>
{#if event_device_obj?.record_status_on}
@@ -306,7 +309,7 @@ if (auto_refresh) {
{/if}
</div>
<div class="flex flex-col gap-1">
<div class="flex flex-col gap-1 text-gray-500 bg-gray-100">
<span>
<strong class="text-sm">hostname:</strong>
{event_device_obj?.info_hostname}
@@ -337,6 +340,19 @@ if (auto_refresh) {
>
{ae_util.iso_datetime_formatter(event_device_obj?.updated_on, 'time_iso_12_tz')}
</span>
{#if event_device_obj?.heartbeat}
<span class="fas fa-heartbeat mx-1"></span>
Heartbeat:
<span
class="px-1"
class:bg-yellow-200={ae_util.is_datetime_recent({datetime: event_device_obj?.heartbeat, minutes: 30})}
class:bg-green-200={ae_util.is_datetime_recent({datetime: event_device_obj?.heartbeat, minutes: 240})}
class:bg-blue-200={ae_util.is_datetime_recent({datetime: event_device_obj?.heartbeat, minutes: 2880})}
>
{ae_util.iso_datetime_formatter(event_device_obj?.heartbeat, 'time_iso_12_tz')}
</span>
{/if}
</div>
</div>

View File

@@ -131,8 +131,8 @@ async function handle_qry__event_file(
// It is very important to know that all of the created_on and updated_on timestamps are in ET timezone. Sorry...?
let for_et_tz_datetime = new Date(current_datetime.toLocaleString('en-US', {timeZone: 'America/New_York'}));
const offset_minutes = for_et_tz_datetime.getTimezoneOffset();
const adjusted_for_et_tz_datetime = new Date(for_et_tz_datetime.getTime() - offset_minutes * 60 * 1000);
const adjust_minutes = for_et_tz_datetime.getTimezoneOffset(); // Usually 240 minutes for ET.
const adjusted_for_et_tz_datetime = new Date(for_et_tz_datetime.getTime() - adjust_minutes * 60 * 1000);
const adjusted_for_et_tz_datetime_iso_str = adjusted_for_et_tz_datetime.toISOString().slice(0, -1);
console.log(`Adjusted for ET TZ time:`, adjusted_for_et_tz_datetime_iso_str);