summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-15 13:34:35 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-15 13:34:51 +0100
commit49d6566b043fb6d02186dd0d7b6cfdf01b0beb17 (patch)
tree405190bb14fb9021e4ec8c3f56ebf18d7c56eb02
parent2fe88b678392344d7042d6ebb375d1d6179537ec (diff)
downloadmorph-cache-server-49d6566b043fb6d02186dd0d7b6cfdf01b0beb17.tar.gz
Colour in the rows.
Red for "there are mismatches", yellow for "there is only one build", green for "all the builds match."
-rw-r--r--morphcacheserver/frontend.py18
-rw-r--r--morphcacheserver/style.css4
2 files changed, 16 insertions, 6 deletions
diff --git a/morphcacheserver/frontend.py b/morphcacheserver/frontend.py
index 52c9db5..5d2bca1 100644
--- a/morphcacheserver/frontend.py
+++ b/morphcacheserver/frontend.py
@@ -18,7 +18,7 @@ from bottle import Bottle, request, static_file, template
import math
-def make_table(data, heading_ids, heading_titles):
+def make_table(data, heading_ids, heading_titles, row_class_cb=None):
'''Render 'data' as a HTML table.'''
table_template = """
@@ -29,7 +29,7 @@ def make_table(data, heading_ids, heading_titles):
%end
</tr>
%for row in rows:
- <tr>
+ <tr class="{{ row_class_cb(row) }}" >
%for col in heading_ids:
<td>{{row[col]}}</td>
%end
@@ -38,7 +38,8 @@ def make_table(data, heading_ids, heading_titles):
</table>
"""
return template(table_template, heading_ids=heading_ids,
- heading_titles=heading_titles, rows=data)
+ heading_titles=heading_titles, rows=data,
+ row_class_cb=row_class_cb)
def web_frontend(db):
@@ -55,12 +56,21 @@ def web_frontend(db):
content = '<p>Artifacts:</p>'
+ def row_style_class_cb(row):
+ if row['n_different_builds'] > 0:
+ return 'fail'
+ elif row['n_builds'] <= 1:
+ return 'noinfo'
+ else:
+ return 'pass'
+
artifacts = db.view_artifact_statistics(
start=(page-1)*page_size, page_size=page_size)
content += make_table(
artifacts,
['cache_name', 'n_builds', 'n_different_builds'],
- ['Artifact', 'Total builds', 'Mismatching builds'])
+ ['Artifact', 'Total builds', 'Mismatching builds'],
+ row_class_cb=row_style_class_cb)
n_artifacts = db.count_artifacts()
n_pages = int(math.ceil(n_artifacts / float(page_size)))
diff --git a/morphcacheserver/style.css b/morphcacheserver/style.css
index 0a296b9..0a6e00f 100644
--- a/morphcacheserver/style.css
+++ b/morphcacheserver/style.css
@@ -42,10 +42,10 @@ table tr.fail {
table tr.fail:hover {
background: #ffbbbb;
}
-table tr.nonet {
+table tr.noinfo {
background: #ffdd99;
}
-table tr.nonet:hover {
+table tr.noinfo:hover {
background: #ffeeaa;
}
table tr.headings th {