aboutsummaryrefslogtreecommitdiffstats
path: root/snag/dashboard.py
diff options
context:
space:
mode:
authorMatt Kohls <mattkohls13@gmail.com>2023-09-04 15:36:33 -0400
committerMatt Kohls <mattkohls13@gmail.com>2023-09-04 15:36:33 -0400
commitc8ef8843aaaf28bc38b544ae8ac72accf233aead (patch)
tree53e846d7480814040bbebe11dd6e290f5d366589 /snag/dashboard.py
downloadsensor-aggregator-c8ef8843aaaf28bc38b544ae8ac72accf233aead.tar.gz
sensor-aggregator-c8ef8843aaaf28bc38b544ae8ac72accf233aead.tar.bz2
sensor-aggregator-c8ef8843aaaf28bc38b544ae8ac72accf233aead.zip
Revamped project init
New repo for larger structural changes from Sensor-Server. Currently doing most all the same stuff but hopefully better. Still have to clean out some of the older templates for the new interface
Diffstat (limited to 'snag/dashboard.py')
-rw-r--r--snag/dashboard.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/snag/dashboard.py b/snag/dashboard.py
new file mode 100644
index 0000000..7e77124
--- /dev/null
+++ b/snag/dashboard.py
@@ -0,0 +1,26 @@
+# snag
+# Matt Kohls
+# (c) 2023
+
+from flask import (
+ Blueprint, flash, g, redirect, render_template, request, url_for
+)
+from werkzeug.exceptions import abort
+from datetime import datetime
+from snag.db import get_db
+
+bp = Blueprint('dashboard', __name__)
+
+@bp.route('/')
+def dashboard():
+ db = get_db()
+
+ rows = db.execute(
+ 'SELECT de.deviceId, de.environment, d.deviceName'
+ ' FROM device_env de JOIN devices d ON de.deviceId = d.deviceId'
+ ' ORDER BY entry DESC'
+ ).fetchall()
+
+ deviceList = [dict(deviceId=row['deviceId'], location=row['environment'], name=row['deviceName']) for row in rows]
+ return render_template('dashboard/dashboard.html', deviceList=deviceList, generatedAt=datetime.now())
+