diff src/main.ts @ 1:42a494b8ee1a

show report time
author drewp@bigasterisk.com
date Sun, 28 Jan 2024 15:43:54 -0800
parents 5a77696c6dab
children c04563fc8616
line wrap: on
line diff
--- a/src/main.ts	Sun Jan 28 15:32:18 2024 -0800
+++ b/src/main.ts	Sun Jan 28 15:43:54 2024 -0800
@@ -29,12 +29,15 @@
     `,
   ];
   @state() lights: object[] = [];
+  @state() reportTime: Date;
 
   connectedCallback(): void {
     super.connectedCallback();
     const es = new EventSource("api/table");
     es.onmessage = (ev) => {
-      this.lights = JSON.parse(ev.data).lights;
+      const body = JSON.parse(ev.data);
+      this.lights = body.lights;
+      this.reportTime = new Date(body.now * 1000);
     };
   }
   render() {
@@ -68,6 +71,7 @@
           `
         )}
       </table>
+      <p>Updated ${this.reportTime.toLocaleString("sv")}</p>
       <p>
         <a href="metrics">metrics</a> |
         <a href="api/graph">graph</a>