Merge lp:~robru/bileto/colorize-statuses into lp:bileto

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 238
Merged at revision: 234
Proposed branch: lp:~robru/bileto/colorize-statuses
Merge into: lp:bileto
Diff against target: 143 lines (+71/-6)
4 files modified
tickets/static/app.js (+37/-1)
tickets/static/index.html (+1/-1)
tickets/static/style.css (+26/-0)
tickets/v1.py (+7/-4)
To merge this branch: bzr merge lp:~robru/bileto/colorize-statuses
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+269441@code.launchpad.net

Commit message

Colorize statuses like the dashboard.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

Looking great in staging.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:238
http://jenkins.qa.ubuntu.com/job/bileto-ci/44/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/bileto-ci/44/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tickets/static/app.js'
2--- tickets/static/app.js 2015-08-27 01:47:49 +0000
3+++ tickets/static/app.js 2015-08-27 21:25:34 +0000
4@@ -10,6 +10,38 @@
5
6 var app = angular.module('Bileto', ['ngSanitize']);
7
8+var COLORS = {
9+ 'red': ['caught', 'exception', 'fail', 'can\'t', 'error', 'unacceptable'],
10+ 'green': ['landed', 'merging', 'migrating'],
11+ 'grey': ['abandoned'],
12+ 'purple': ['ready'],
13+ 'olive': ['dirty'],
14+ 'blue': ['needs'],
15+};
16+
17+function colorize(text, qa) {
18+ text = (text || '').toLowerCase();
19+ qa = (qa || '').toLowerCase();
20+ if (qa == 'publish without qa' || qa == 'qa granted') {
21+ if (text.indexOf('packages built') > -1) {
22+ return 'blue';
23+ }
24+ } else if (qa == 'qa failed') {
25+ return 'red';
26+ }
27+ for (var color in COLORS) {
28+ if (COLORS.hasOwnProperty(color)) {
29+ var keywords = COLORS[color];
30+ for (var i=0; i < keywords.length; i++) {
31+ if (text.indexOf(keywords[i]) > -1) {
32+ return color;
33+ }
34+ }
35+ }
36+ }
37+ return 'black';
38+}
39+
40 function a(href, text) {
41 return '<a target="_blank" href="' + href + '">' + text + '</a> ';
42 }
43@@ -42,6 +74,9 @@
44 if (text) {
45 var words = text.split(/[\s,]+/);
46 switch (field) {
47+ case 'status':
48+ text = linkify(text);
49+ break;
50 case 'siloname':
51 // TODO: Make PPA link link to correct staging/production PPA team
52 text = a('https://launchpad.net/~ci-train-ppa-service/+archive/' + text, text)
53@@ -73,12 +108,13 @@
54 $scope.short_fields = ['siloname', 'status', 'landers', 'sync_request', 'dest', 'sources'];
55 $scope.dropdowns = ['distribution', 'series', 'qa_signoff'];
56
57+ $scope.colorize = colorize;
58 $scope.linkify = linkify;
59 $scope.process = process;
60 $scope.editing = null;
61 $scope.commenting = null;
62
63- $scope.data = {'requests': {}};
64+ $scope.data = {'requests': {}, 'assigned': 0};
65
66 $http.get('/v1/metadata').success(function(data, status, headers, config) {
67 $scope.docs = data.docs;
68
69=== modified file 'tickets/static/index.html'
70--- tickets/static/index.html 2015-08-27 18:55:39 +0000
71+++ tickets/static/index.html 2015-08-27 21:25:34 +0000
72@@ -68,7 +68,7 @@
73 </td>
74 </tr>
75 <tr ng-hide="display_this(req)">
76-<td ng-repeat="field in short_fields"><p ng-bind-html="process(req[field], field)"></p></td>
77+<td ng-repeat="field in short_fields"><p class="{{colorize(req.status, req.qa_signoff)}}" ng-bind-html="process(req[field], field)"></p></td>
78 <td ng-repeat="field in dropdowns"><p ng-bind-html="process(req[field], field)"></p></td>
79 <td class="nowrap"><p><strong><a href="#/ticket/{{req.request_id}}">{{req.request_id}}.&nbsp;{{req.date | date:'yyyy-MM-dd'}}</a></strong></p></td>
80 </tr>
81
82=== modified file 'tickets/static/style.css'
83--- tickets/static/style.css 2015-08-26 23:32:40 +0000
84+++ tickets/static/style.css 2015-08-27 21:25:34 +0000
85@@ -152,3 +152,29 @@
86 tbody:hover ul {
87 display: block;
88 }
89+
90+.red {
91+ color: red;
92+ font-weight: bold;
93+}
94+
95+.green {
96+ color: green;
97+}
98+
99+.olive {
100+ color: olive;
101+ font-weight: bold;
102+}
103+
104+.blue {
105+ color: blue;
106+}
107+
108+.purple {
109+ color: purple;
110+}
111+
112+.grey {
113+ color: #888;
114+}
115
116=== modified file 'tickets/v1.py'
117--- tickets/v1.py 2015-08-27 19:47:38 +0000
118+++ tickets/v1.py 2015-08-27 21:25:34 +0000
119@@ -30,6 +30,8 @@
120 PUBLISHABLE = ('Publish without QA', 'QA Granted')
121 HID = [Request.status != hide for hide in HIDDEN]
122 LC = func.lower
123+FAILURES = ('can\'t', 'caught', 'error', 'exception',
124+ 'fail', 'needs', 'unacceptable')
125
126
127 def assert_json():
128@@ -141,10 +143,11 @@
129 @app.route('/v1/failures', methods=['GET'])
130 def list_requests_in_failed_states():
131 """Show requests that are in failure states."""
132- cant = Request.query.filter(LC(Request.status).contains("can't")).all()
133- fail = Request.query.filter(LC(Request.status).contains('fail')).all()
134- err = Request.query.filter(LC(Request.status).contains('error')).all()
135- return return_reqs(sorted(set(cant + fail + err)))
136+ reqs = set()
137+ for word in FAILURES:
138+ reqs.update(Request.query.filter(
139+ LC(Request.status).contains(word)).all())
140+ return return_reqs(sorted(reqs))
141
142
143 @app.route('/v1/user/<nickname>', methods=['GET'])

Subscribers

People subscribed via source and target branches