Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: appengine/swarming/elements/res/imp/botlist/bot-list-summary.html

Issue 2227803002: Mirror filters and sort preferences to url-params (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@use-dimensions
Patch Set: Tweak docs Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!-- 1 <!--
2 This in an HTML Import-able file that contains the definition 2 This in an HTML Import-able file that contains the definition
3 of the following elements: 3 of the following elements:
4 4
5 <bot-list-summary> 5 <bot-list-summary>
6 6
7 7
8 Usage: 8 Usage:
9 9
10 <bot-list-summary></bot-list-summary> 10 <bot-list-summary></bot-list-summary>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 .right { 45 .right {
46 text-align: right; 46 text-align: right;
47 } 47 }
48 .left { 48 .left {
49 text-align: left; 49 text-align: left;
50 } 50 }
51 </style> 51 </style>
52 52
53 <div class="header">Fleet</div> 53 <div class="header">Fleet</div>
54 <!-- TODO(kjlubick) Once url params have been implemented, have these
55 properly link to the botlist with the given features preloaded.-->
56 <table> 54 <table>
57 <tr> 55 <tr>
58 <td class="right"><a href="/newui/botlist?alive">Alive</a>:</td> 56 <td class="right">
57 <a href$="[[_makeURL('','',columns.*,filtered_bots.*,sort,verbose)]]"> All</a>:
58 </td>
59 <td class="left">[[fleet.all]]</td>
60 </tr>
61 <tr>
62 <td class="right">
63 <a href$="[[_makeURL('alive','',columns.*,filtered_bots.*,sort,verbose )]]">Alive</a>:
64 </td>
59 <td class="left">[[fleet.alive]]</td> 65 <td class="left">[[fleet.alive]]</td>
60 </tr> 66 </tr>
61 <tr> 67 <tr>
62 <td class="right"><a href="/newui/botlist?busy">Busy</a>:</td> 68 <td class="right">
69 <a href$="[[_makeURL('busy','',columns.*,filtered_bots.*,sort,verbose) ]]">Busy</a>:
70 </td>
63 <td class="left">[[fleet.busy]]</td> 71 <td class="left">[[fleet.busy]]</td>
64 </tr> 72 </tr>
65 <tr> 73 <tr>
66 <td class="right"><a href="/newui/botlist?idle">Idle</a>:</td> 74 <td class="right">
75 <a href$="[[_makeURL('idle','',columns.*,filtered_bots.*,sort,verbose) ]]">Idle</a>:
76 </td>
67 <td class="left">[[fleet.idle]]</td> 77 <td class="left">[[fleet.idle]]</td>
68 </tr> 78 </tr>
69 <tr> 79 <tr>
70 <td class="right"><a href="/newui/botlist?dead">Dead</a>:</td> 80 <td class="right">
81 <a href$="[[_makeURL('dead','',columns.*,filtered_bots.*,sort,verbose) ]]">Dead</a>:
82 </td>
71 <td class="left">[[fleet.dead]]</td> 83 <td class="left">[[fleet.dead]]</td>
72 </tr> 84 </tr>
73 <tr> 85 <tr>
74 <td class="right"><a href="/newui/botlist?quaren">Quarantined</a>:</td> 86 <td class="right">
87 <a href$="[[_makeURL('quarantined','',columns.*,filtered_bots.*,sort,v erbose)]]">Quarantined</a>:
88 </td>
75 <td class="left">[[fleet.quarantined]]</td> 89 <td class="left">[[fleet.quarantined]]</td>
76 </tr> 90 </tr>
77 </table> 91 </table>
78 92
79 <div class="header">Displayed</div> 93 <div class="header">Displayed</div>
80 <table> 94 <table>
81 <tr> 95 <tr>
82 <td class="right"><a href="/newui/botlist?alive2">Alive</a>:</td> 96 <td class="right">
97 All:
98 </td>
99 <td class="left">[[_currently_showing.all]]</td>
100 </tr>
101 <tr>
102 <td class="right">
103 <a href$="[[_makeURL('alive','true',columns.*,filtered_bots.*,sort,ver bose)]]">Alive</a>:
104 </td>
83 <td class="left">[[_currently_showing.alive]]</td> 105 <td class="left">[[_currently_showing.alive]]</td>
84 </tr> 106 </tr>
85 <tr> 107 <tr>
86 <td class="right"><a href="/newui/botlist?busy2">Busy</a>:</td> 108 <td class="right">
109 <a href$="[[_makeURL('busy','true',columns.*,filtered_bots.*,sort,verb ose)]]">Busy</a>:
110 </td>
87 <td class="left">[[_currently_showing.busy]]</td> 111 <td class="left">[[_currently_showing.busy]]</td>
88 </tr> 112 </tr>
89 <tr> 113 <tr>
90 <td class="right"><a href="/newui/botlist?idle2">Idle</a>:</td> 114 <td class="right">
115 <a href$="[[_makeURL('idle','true',columns.*,filtered_bots.*,sort,verb ose)]]">Idle</a>:
116 </td>
91 <td class="left">[[_currently_showing.idle]]</td> 117 <td class="left">[[_currently_showing.idle]]</td>
92 </tr> 118 </tr>
93 <tr> 119 <tr>
94 <td class="right"><a href="/newui/botlist?dead2">Dead</a>:</td> 120 <td class="right">
121 <a href$="[[_makeURL('dead','true',columns.*,filtered_bots.*,sort,verb ose)]]">Dead</a>:
122 </td>
95 <td class="left">[[_currently_showing.dead]]</td> 123 <td class="left">[[_currently_showing.dead]]</td>
96 </tr> 124 </tr>
97 <tr> 125 <tr>
98 <td class="right"><a href="/newui/botlist?quaren2">Quarantined</a>:</td> 126 <td class="right">
127 <a href$="[[_makeURL('quarantined','true',columns.*,filtered_bots.*,so rt,verbose)]]">Quarantined</a>:
128 </td>
99 <td class="left">[[_currently_showing.quarantined]]</td> 129 <td class="left">[[_currently_showing.quarantined]]</td>
100 </tr> 130 </tr>
101 </table> 131 </table>
102 132
103 </template> 133 </template>
104 <script> 134 <script>
105 Polymer({ 135 Polymer({
106 is: 'bot-list-summary', 136 is: 'bot-list-summary',
107 137
108 behaviors: [SwarmingBehaviors.BotListBehavior], 138 behaviors: [SwarmingBehaviors.BotListBehavior],
109 139
110 properties: { 140 properties: {
141 columns: {
142 type: Array,
143 },
111 filtered_bots: { 144 filtered_bots: {
112 type: Array, 145 type: Array,
113 }, 146 },
114 fleet: { 147 fleet: {
115 type: Object, 148 type: Object,
116 }, 149 },
150 sort: {
151 type: String,
152 },
153 verbose: {
154 type: Boolean,
155 },
117 156
118 _currently_showing: { 157 _currently_showing: {
119 type: Object, 158 type: Object,
120 value: function() { 159 value: function() {
121 return { 160 return {
161 all: -1,
122 alive: -1, 162 alive: -1,
123 busy: -1, 163 busy: -1,
124 idle: -1, 164 idle: -1,
125 dead: -1, 165 dead: -1,
126 quarantined: -1, 166 quarantined: -1,
127 }; 167 };
128 }, 168 },
129 }, 169 },
130 }, 170 },
131 171
132 // Do this because Array changes in Polymer don't always trigger normal 172 // Do this because Array changes in Polymer don't always trigger normal
133 // property observers 173 // property observers
134 observers: ["_recount(filtered_bots.*)"], 174 observers: ["_recount(filtered_bots.*)"],
135 175
176 _getFilterStr: function(filter) {
177 if (!filter) {
178 return "";
179 }
180 if (filter === "alive" || filter === "dead" ||
181 filter === "quarantined") {
182 return "status:" + filter;
183 } else {
184 return "task:" + filter;
185 }
186 },
187
188 _makeURL: function(filter, preserveOthers) {
189 if (preserveOthers) {
190 var fstr = encodeURIComponent(this._getFilterStr(filter));
191 if (window.location.href.indexOf(fstr) === -1) {
192 return window.location.href + "&filters=" + fstr;
193 }
194 // The filter is already on the list.
195 return undefined;
196 }
197 var params = {
198 sort: [this.sort],
199 columns: this.columns,
200 verbose: [this.verbose],
201 }
202 if (filter) {
203 params["filters"] = [this._getFilterStr(filter)];
204 }
205
206 return window.location.href.split('?')[0] + '?' + sk.query.fromParamSet( params);
207 },
208
136 _recount: function() { 209 _recount: function() {
137 var curr = { 210 var curr = {
211 all: 0,
138 alive: 0, 212 alive: 0,
139 busy: 0, 213 busy: 0,
140 idle: 0, 214 idle: 0,
141 dead: 0, 215 dead: 0,
142 quarantined: 0, 216 quarantined: 0,
143 }; 217 };
144 if (!this.filtered_bots) { 218 if (!this.filtered_bots) {
145 return curr; 219 return curr;
146 } 220 }
147 this.filtered_bots.forEach(function(bot) { 221 this.filtered_bots.forEach(function(bot) {
148 if (this._taskId(bot) === "idle") { 222 if (this._taskId(bot) === "idle") {
149 curr.idle++; 223 curr.idle++;
150 } else { 224 } else {
151 curr.busy++; 225 curr.busy++;
152 } 226 }
153 if (bot.quarantined) { 227 if (bot.quarantined) {
154 curr.quarantined++; 228 curr.quarantined++;
155 } 229 }
156 if (bot.is_dead) { 230 if (bot.is_dead) {
157 curr.dead++; 231 curr.dead++;
158 } else { 232 } else {
159 curr.alive++; 233 curr.alive++;
160 } 234 }
235 curr.all++;
161 }.bind(this)); 236 }.bind(this));
162 this.set("_currently_showing", curr); 237 this.set("_currently_showing", curr);
163 } 238 }
164 }); 239 });
165 </script> 240 </script>
166 </dom-module> 241 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698