diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2021-03-29 14:49:27 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2021-05-20 18:44:23 +0200 |
commit | 7f0d1ab287285e3903ff5507d68565aa393de3a0 (patch) | |
tree | d2429343e7c4faf57eecd8656e30d48a567d00d5 | |
parent | 411189e6ecb41b209b48993090bc5b8c8a14aa3b (diff) |
Add latest images to the dashboard
Users want to know latest created/modified images to manage new images
or changes made on existing images.
This commit adds a list with the 10 latest created or modified images.
-rw-r--r-- | ogcp/templates/dashboard.html | 15 | ||||
-rw-r--r-- | ogcp/views.py | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/ogcp/templates/dashboard.html b/ogcp/templates/dashboard.html index 9c34768..518ae20 100644 --- a/ogcp/templates/dashboard.html +++ b/ogcp/templates/dashboard.html @@ -18,5 +18,20 @@ <p class="card-text">{{ images | length }}</p> </div> </div> + <div class="m-4 w-25 card text-center"> + <div class="card-header"> + Latest images + </div> + {% for image in images[:10] %} + <ul class="list-group list-group-horizontal"> + <li class="list-group-item w-50"> + {{ image['name'] }} + </li> + <li class="list-group-item w-50"> + {{ image['modified'] }} + </li> + </ul> + {% endfor %} + </div> </div> {% endblock %} diff --git a/ogcp/views.py b/ogcp/views.py index 44e9a6e..09454f7 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -17,6 +17,7 @@ from ogcp.og_server import OGServer from flask_babel import _ from ogcp import app import requests +import datetime FS_CODES = { 0: 'DISK', @@ -112,6 +113,9 @@ def page_not_found(error): def server_error(error): return render_template('error.html', message=error), 500 +def image_modified_date_from_str(image): + return datetime.datetime.strptime(image['modified'], '%a %b %d %H:%M:%S %Y') + @app.route('/') def index(): clients = None @@ -119,6 +123,7 @@ def index(): clients = get_clients() images_response = g.server.get('/images') images = images_response.json()['images'] + images.sort(key=image_modified_date_from_str, reverse=True) return render_template('dashboard.html', clients=clients, images=images) return render_template('base.html') |