OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <polymer-element name="ct-tree-status"> | 7 <polymer-element name="ct-tree-status"> |
8 <template> | 8 <template> |
9 <template if="{{ message }}"> | |
10 <style> | 9 <style> |
11 :host { | 10 :host { |
12 display: block; | 11 display: block; |
13 whitespace: nowrap; | |
14 overflow: hidden; | |
15 text-overflow: ellispis; | |
16 } | 12 } |
17 | 13 |
18 :host([status=throttled]) { | 14 :host([status=throttled]) { |
19 background-color: khaki; | 15 background-color: #fffc6c; |
20 } | 16 } |
21 | 17 |
22 :host([status=closed]) { | 18 :host([status=closed]) { |
23 color: white; | 19 color: white; |
24 background-color: tomato; | 20 background-color: #e98080; |
25 } | 21 } |
26 </style> | 22 </style> |
| 23 <template if="{{ message }}"> |
27 {{ project }}: {{ message }} | 24 {{ project }}: {{ message }} |
28 </template> | 25 </template> |
29 </template> | 26 </template> |
30 <script> | 27 <script> |
31 Polymer({ | 28 Polymer({ |
32 publish: { | 29 publish: { |
33 project: '', | 30 project: '', |
34 message: '', | 31 message: '', |
35 status: { | 32 status: { |
36 value: 'open', | 33 value: '', |
37 reflect: true, | 34 reflect: true, |
38 }, | 35 }, |
39 }, | 36 }, |
40 | 37 |
41 update: function() { | 38 update: function() { |
| 39 // FIXME: Show a link to *-status.appspot.com. |
42 var url = treestatus.urlByName(this.project); | 40 var url = treestatus.urlByName(this.project); |
43 return net.json(url).then(function(response) { | 41 return net.json(url).then(function(response) { |
44 this.updateStatus(response); | 42 this.updateStatus(response); |
45 }.bind(this)); | 43 }.bind(this)); |
46 }, | 44 }, |
47 | 45 |
48 updateStatus: function(status) { | 46 updateStatus: function(status) { |
49 if (status.can_commit_freely) { | 47 if (status.can_commit_freely) { |
50 this.message = null; | 48 this.message = null; |
51 this.status = 'open'; | 49 this.status = 'open'; |
52 return; | 50 return; |
53 } | 51 } |
54 | 52 |
55 this.message = status.message + ' by ' + status.username; | 53 this.message = status.message + ' by ' + status.username; |
56 var responseLowerCase = status.message.toLowerCase(); | 54 var responseLowerCase = status.message.toLowerCase(); |
57 if (responseLowerCase.indexOf('throttled') != -1) { | 55 if (responseLowerCase.indexOf('throttled') != -1) { |
58 this.status = 'throttled'; | 56 this.status = 'throttled'; |
59 } else if (responseLowerCase.indexOf("closed") != -1) { | 57 } else if (responseLowerCase.indexOf("closed") != -1) { |
60 this.status = 'closed'; | 58 this.status = 'closed'; |
61 } else { | 59 } else { |
62 this.status = 'unknown'; | 60 this.status = 'unknown'; |
63 } | 61 } |
64 }, | 62 }, |
65 }); | 63 }); |
66 </script> | 64 </script> |
67 </polymer-element> | 65 </polymer-element> |
OLD | NEW |