summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
authorDaniel GarcĂ­a Moreno <danigm@soleta.eu>2021-07-07 10:27:59 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-07-07 11:27:28 +0200
commit4e519590af6484cc05a91f102a0a3765408b5e72 (patch)
treefcd40d47e79beb94f1e1602d37ba8cbd6585e664 /ogcp/views.py
parentaf938c328011f942258091276a150c6810970dd4 (diff)
Update scopes tree dynamically
This patch adds a javascript function to update the scope tree (on/off) state. This javacript function is called every second, does a call to the new backend endpoint `/scopes/status` and updates the tree classes depending on the current data. The new `/scopes/status` endpoint just returns the scopes tree as json. This patch also adds an icon in the tree leafs, a filled green circle when the state is `on`, and a empty red circle when the state is `off`. There's also a new javascript function to unfold all collapses in the scope tree.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 1221478..ad5a8cb 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -113,7 +113,7 @@ def add_state_and_ips(scope, clients, ips):
if client:
scope['state'] = client['state']
else:
- scope['state'] = 'OFF'
+ scope['state'] = 'off'
scope['ip'] = [scope['ip']]
scope['selected'] = set(scope['ip']).issubset(ips)
else:
@@ -191,6 +191,12 @@ def logout():
logout_user()
return redirect(url_for('index'))
+@app.route('/scopes/status')
+@login_required
+def scopes_status():
+ scopes, _clients = get_scopes()
+ return jsonify(scopes)
+
@app.route('/scopes/')
@login_required
def scopes():