Skip to content

Commit

Permalink
Clients Page orderby
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Garbato committed Aug 21, 2022
1 parent 32cc656 commit 1b8dfe3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 4 additions & 2 deletions app/client_mgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 10 additions & 0 deletions app/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 5 additions & 5 deletions app/templates/clients.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<th></th><th><a href="/clients/mgt"><img width="48" height="48" title="Manage" src="/static/images/settings.png"></a></th></table>
<table id="rowtable">
<tr>
<th>Client</th>
<th>Status</th>
<th>Last Seen</th>
<th>Join Date</th>
<th>Sync Status</th>
<th>Client&nbsp;&nbsp;<a class="navlink" title="Order By Client Name" href="/clients?orderby=name">&#8595;</a></th>
<th>Status&nbsp;&nbsp;<a class="navlink" title="Order By Status" href="/clients?orderby=status">&#8595;</a></th>
<th>Last Seen&nbsp;&nbsp;<a class="navlink" title="Order By Last Seen" href="/clients?orderby=lastseen">&#8595;</a></th>
<th>Join Date&nbsp;&nbsp;<a class="navlink" title="Order By Joindate" href="/clients?orderby=joindate">&#8595;</a></th>
<th>Sync Status&nbsp;&nbsp;<a class="navlink" title="Order By Joindate" href="/clients?orderby=sync_status">&#8595;</a></th>
</tr>
{% set red = "#ff0000" %}
{% set green = "#008000" %}
Expand Down

0 comments on commit 1b8dfe3

Please sign in to comment.