Skip to content

Commit

Permalink
Merge pull request #29 from agarbato/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
agarbato authored Aug 21, 2022
2 parents 32cc656 + 88c238a commit 590895b
Show file tree
Hide file tree
Showing 4 changed files with 22 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", order="asc"):
self.orderby = orderby
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
4 changes: 3 additions & 1 deletion app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ def status():
@app.route("/clients", methods=['GET'])
@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()
res = client.list_clients_page(orderby, order)
#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>&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 590895b

Please sign in to comment.