Skip to content

Commit

Permalink
Clients Page orderby asc/desc
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Garbato committed Aug 21, 2022
1 parent 1b8dfe3 commit 88c238a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/client_mgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def list_clients_threshold(self):
clientlist = query_db(query)
return clientlist

def list_clients_page(self, orderby="id"):
def list_clients_page(self, orderby="id", order="asc"):
self.orderby = orderby
query = (f"SELECT name,status,joindate,threshold,ssh_key,lastseen from clients order by {orderby};")
print(query)
self.order = order
query = (f"SELECT name,status,joindate,threshold,ssh_key,lastseen from clients order by {orderby} {order};")
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 @@ -155,8 +155,9 @@ def status():
@basic_auth.required
def clients():
orderby = request.args.get('orderby', 'id')
order = request.args.get('order', 'asc')
client = ClientMgt("all-clients-page")
res = client.list_clients_page(orderby)
res = client.list_clients_page(orderby, order)
#print (res)
return render_template("clients.html", clients=res)

Expand Down
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&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>
<th>Client&nbsp;&nbsp;<a class="navlink" title="Order By Client Name" href="/clients?orderby=name">&#8595;</a>&nbsp;<a class="navlink" href="/clients?orderby=name&order=desc">&#8593;</a></th>
<th>Status&nbsp;&nbsp;<a class="navlink" title="Order By Status" href="/clients?orderby=status">&#8595;</a>&nbsp;<a class="navlink" href="/clients?orderby=status&order=desc">&#8593;</a></th>
<th>Last Seen&nbsp;&nbsp;<a class="navlink" title="Order By Last Seen" href="/clients?orderby=lastseen">&#8595;</a>&nbsp;<a class="navlink" href="/clients?orderby=lastseen&order=desc">&#8593;</a></th>
<th>Join Date&nbsp;&nbsp;<a class="navlink" title="Order By Joindate" href="/clients?orderby=joindate">&#8595;</a>&nbsp;<a class="navlink" href="/clients?orderby=joindate&order=desc">&#8593;</a></th>
<th>Sync Status&nbsp;&nbsp;<a class="navlink" title="Order By Joindate" href="/clients?orderby=sync_status">&#8595;</a>&nbsp;<a class="navlink" href="/clients?orderby=sync_status&order=desc">&#8593;</a></th>
</tr>
{% set red = "#ff0000" %}
{% set green = "#008000" %}
Expand Down

0 comments on commit 88c238a

Please sign in to comment.