From 1b8dfe31da83acf1f19d9681eb5ee455b414b6ee Mon Sep 17 00:00:00 2001 From: Andrea Garbato Date: Sun, 21 Aug 2022 21:30:25 +0200 Subject: [PATCH] Clients Page orderby --- app/client_mgt.py | 6 ++++-- app/routes.py | 3 ++- app/static/style.css | 10 ++++++++++ app/templates/clients.html | 10 +++++----- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/client_mgt.py b/app/client_mgt.py index 3eb7a27..6a60acb 100644 --- a/app/client_mgt.py +++ b/app/client_mgt.py @@ -182,8 +182,10 @@ def list_clients_threshold(self): clientlist = query_db(query) return clientlist - def list_clients_page(self): - query = ("SELECT name,status,joindate,threshold,ssh_key,lastseen from clients;") + def list_clients_page(self, orderby="id"): + self.orderby = orderby + query = (f"SELECT name,status,joindate,threshold,ssh_key,lastseen from clients order by {orderby};") + print(query) res = query_db(query) return res diff --git a/app/routes.py b/app/routes.py index b632d0d..ac57cdf 100644 --- a/app/routes.py +++ b/app/routes.py @@ -154,8 +154,9 @@ def status(): @app.route("/clients", methods=['GET']) @basic_auth.required def clients(): + orderby = request.args.get('orderby', 'id') client = ClientMgt("all-clients-page") - res = client.list_clients_page() + res = client.list_clients_page(orderby) #print (res) return render_template("clients.html", clients=res) diff --git a/app/static/style.css b/app/static/style.css index dcdfa78..4b245da 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -150,4 +150,14 @@ .topnav_autoindex a.active { background-color: #4CAF50; color: white; +} + +a.navlink:link { + color: white; + text-decoration: none; +} + +a.navlink:visited { + color: white; + text-decoration: none; } \ No newline at end of file diff --git a/app/templates/clients.html b/app/templates/clients.html index b65bc15..6698d5f 100644 --- a/app/templates/clients.html +++ b/app/templates/clients.html @@ -6,11 +6,11 @@ - - - - - + + + + + {% set red = "#ff0000" %} {% set green = "#008000" %}
ClientStatusLast SeenJoin DateSync StatusClient  Status  Last Seen  Join Date  Sync Status