From 611454ba82fe446b2216efe010b2efaae3149194 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Wed, 24 Aug 2016 18:00:05 +0200 Subject: [PATCH] Added color in web-index reprenting modules states. --- var/www/Flask_server.py | 18 ++++++++++++++++-- var/www/static/js/indexjavascript.js | 8 +++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 45efd8f1..8b6e05e3 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -81,8 +81,22 @@ def event_stream(): def get_queues(r): # We may want to put the llen in a pipeline to do only one query. - return [(queue, int(card)) for queue, card in - r.hgetall("queues").iteritems()] + data = [(queue, int(card)) for queue, card in r.hgetall("queues").iteritems()] + newData = [] + for queue, card in data: + key = "MODULE_" + queue + value = r.get(key) + if value is not None: + timestamp, path = value.split(", ") + if timestamp is not None: + startTime_readable = datetime.datetime.fromtimestamp(int(timestamp)) + processed_time_readable = str((datetime.datetime.now() - startTime_readable)).split('.')[0] + seconds = int((datetime.datetime.now() - startTime_readable).total_seconds()) + newData.append( (queue, card, seconds) ) + else: + newData.append( (queue, cards, 0) ) + + return newData def list_len(s): diff --git a/var/www/static/js/indexjavascript.js b/var/www/static/js/indexjavascript.js index f0cd101f..d50e098a 100644 --- a/var/www/static/js/indexjavascript.js +++ b/var/www/static/js/indexjavascript.js @@ -221,11 +221,17 @@ function create_queue_table() { for(i = 0; i < (glob_tabvar.row1).length;i++){ var tr = document.createElement('TR') - for(j = 0; j < (glob_tabvar.row1[i]).length; j++){ + for(j = 0; j < 2; j++){ var td = document.createElement('TD') td.appendChild(document.createTextNode(glob_tabvar.row1[i][j])); tr.appendChild(td) } + if (parseInt(glob_tabvar.row1[i][2]) > 60*1 && parseInt(glob_tabvar.row1[i][1]) > 2) + tr.className += " danger"; + else if (parseInt(glob_tabvar.row1[i][2]) > 60*1) + tr.className += " warning"; + else + tr.className += " success"; tableBody.appendChild(tr); } Tablediv.appendChild(table);