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

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

Issue 2404883002: Add links to MP and resolve minor fixes (Closed)
Patch Set: Add more generic approach to revision Created 4 years, 2 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 Copyright 2016 The LUCI Authors. All rights reserved. 2 Copyright 2016 The LUCI Authors. All rights reserved.
3 Use of this source code is governed under the Apache License, Version 2.0 3 Use of this source code is governed under the Apache License, Version 2.0
4 that can be found in the LICENSE file. 4 that can be found in the LICENSE file.
5 5
6 This in an HTML Import-able file that contains the definition 6 This in an HTML Import-able file that contains the definition
7 of the following elements: 7 of the following elements:
8 8
9 <bot-list> 9 <bot-list>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 <url-param name="s" 61 <url-param name="s"
62 value="{{_sortstr}}" 62 value="{{_sortstr}}"
63 default_value="id:asc"> 63 default_value="id:asc">
64 </url-param> 64 </url-param>
65 65
66 <swarming-app 66 <swarming-app
67 client_id="[[client_id]]" 67 client_id="[[client_id]]"
68 auth_headers="{{_auth_headers}}" 68 auth_headers="{{_auth_headers}}"
69 signed_in="{{_signed_in}}" 69 signed_in="{{_signed_in}}"
70 server_details="{{_server_details}}"
70 71
71 busy="[[_or(_busy1,_busy2)]]" 72 busy="[[_or(_busy1,_busy2)]]"
72 name="Swarming Bot List"> 73 name="Swarming Bot List">
73 74
74 <h2 hidden$="[[_signed_in]]">You must sign in to see anything useful.</h2> 75 <h2 hidden$="[[_signed_in]]">You must sign in to see anything useful.</h2>
75 76
76 <div hidden$="[[_not(_signed_in)]]"> 77 <div hidden$="[[_not(_signed_in)]]">
77 78
78 <div class="horizontal layout"> 79 <div class="horizontal layout">
79 80
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 array (we are listening to all subproperties). The element returne d is 133 array (we are listening to all subproperties). The element returne d is
133 not of much use, so we'll ignore it in _hide() and use this._colum ns. 134 not of much use, so we'll ignore it in _hide() and use this._colum ns.
134 --> 135 -->
135 <th hidden$="[[_hide('cloud_console_link', _columns.*)]]"> 136 <th hidden$="[[_hide('cloud_console_link', _columns.*)]]">
136 <span>Bot in Cloud Console</span> 137 <span>Bot in Cloud Console</span>
137 <sort-toggle 138 <sort-toggle
138 name="cloud_console_link" 139 name="cloud_console_link"
139 current="[[_sort]]"> 140 current="[[_sort]]">
140 </sort-toggle> 141 </sort-toggle>
141 </th> 142 </th>
143 <th hidden$="[[_hide('mp_lease_id', _columns.*)]]">
144 <span>Machine Provider Lease Id</span>
145 <sort-toggle
146 name="mp_lease_id"
147 current="[[_sort]]">
148 </sort-toggle>
149 </th>
142 <th hidden$="[[_hide('task', _columns.*)]]"> 150 <th hidden$="[[_hide('task', _columns.*)]]">
143 <span>Current Task</span> 151 <span>Current Task</span>
144 <sort-toggle 152 <sort-toggle
145 name="task" 153 name="task"
146 current="[[_sort]]"> 154 current="[[_sort]]">
147 </sort-toggle> 155 </sort-toggle>
148 </th> 156 </th>
149 157
150 <template 158 <template
151 is="dom-repeat" 159 is="dom-repeat"
(...skipping 23 matching lines...) Expand all
175 class="center" 183 class="center"
176 href$="[[_botLink(bot.bot_id)]]" 184 href$="[[_botLink(bot.bot_id)]]"
177 target="_blank" 185 target="_blank"
178 rel="noopener"> 186 rel="noopener">
179 [[bot.bot_id]] 187 [[bot.bot_id]]
180 </a> 188 </a>
181 </td> 189 </td>
182 <td hidden$="[[_hide('cloud_console_link', _columns.*)]]"> 190 <td hidden$="[[_hide('cloud_console_link', _columns.*)]]">
183 <a href$="[[_ccLink(bot)]]">[[_ccText(bot)]]</a> 191 <a href$="[[_ccLink(bot)]]">[[_ccText(bot)]]</a>
184 </td> 192 </td>
193 <td hidden$="[[_hide('mp_lease_id', _columns.*)]]">
194 <a href$="[[_mpLink(bot,_server_details.machine_provider_templ ate)]]">
jcgregorio 2016/10/13 12:03:46 Need space after comma, not consistent with rest o
kjlubick 2016/10/13 12:26:49 Done.
195 [[_column('mp_lease_id',bot,_verbose)]]
196 </a>
197 </td>
185 <td hidden$="[[_hide('task', _columns.*)]]"> 198 <td hidden$="[[_hide('task', _columns.*)]]">
186 <a href$="[[_taskLink(bot.task_id)]]">[[_taskId(bot)]]</a> 199 <a href$="[[_taskLink(bot.task_id)]]">[[_taskId(bot)]]</a>
187 </td> 200 </td>
188 201
189 <template 202 <template
190 is="dom-repeat" 203 is="dom-repeat"
191 items="[[_plainColumns]]" 204 items="[[_plainColumns]]"
192 as="c"> 205 as="c">
193 <td hidden$="[[_hide(c)]]"> 206 <td hidden$="[[_hide(c)]]">
194 [[_column(c, bot, _verbose)]] 207 [[_column(c, bot, _verbose)]]
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 242
230 <error-toast></error-toast> 243 <error-toast></error-toast>
231 </swarming-app> 244 </swarming-app>
232 245
233 </template> 246 </template>
234 <script> 247 <script>
235 (function(){ 248 (function(){
236 var UNKNOWN = "unknown"; 249 var UNKNOWN = "unknown";
237 // see dynamic-table for more information on specialColumns, headerMap, 250 // see dynamic-table for more information on specialColumns, headerMap,
238 // columnMap, and specialSort 251 // columnMap, and specialSort
239 var specialColumns = ["id", "task"]; 252 var specialColumns = ["id", "task", "cloud_console_link", "mp_lease_id"];
240 253
241 var headerMap = { 254 var headerMap = {
242 // "id" and "task" are special, so they don't go here. They have their 255 // "id" and "task" are special, so they don't go here. They have their
243 // headers hard-coded above. 256 // headers hard-coded above.
244 "android_devices": "Android Devices", 257 "android_devices": "Android Devices",
245 "battery_health": "Battery Health", 258 "battery_health": "Battery Health",
246 "battery_level": "Battery Level (%)", 259 "battery_level": "Battery Level (%)",
247 "battery_status": "Battery Status", 260 "battery_status": "Battery Status",
248 "battery_temperature": "Battery Temp (°C)", 261 "battery_temperature": "Battery Temp (°C)",
249 "battery_voltage": "Battery Voltage (mV)", 262 "battery_voltage": "Battery Voltage (mV)",
250 "bot_temperature": "Bot Temp (°C)", 263 "bot_temperature": "Bot Temp (°C)",
251 "cores": "Cores", 264 "cores": "Cores",
252 "cpu": "CPU", 265 "cpu": "CPU",
253 "device": "Non-android Device", 266 "device": "Non-android Device",
254 "device_os": "Device OS", 267 "device_os": "Device OS",
255 "device_temperature": "Device Temp (°C)", 268 "device_temperature": "Device Temp (°C)",
256 "device_type": "Device Type", 269 "device_type": "Device Type",
257 "disk_space": "Free Space (MB)", 270 "disk_space": "Free Space (MB)",
258 "first_seen": "First Seen", 271 "first_seen": "First Seen",
259 "gpu": "GPU", 272 "gpu": "GPU",
260 "last_seen": "Last Seen", 273 "last_seen": "Last Seen",
274 "mp_lease_expires": "Machine Provider Lease Expires",
261 "os": "OS", 275 "os": "OS",
262 "pool": "Pool", 276 "pool": "Pool",
263 "running_time": "Swarming Uptime", 277 "running_time": "Swarming Uptime",
264 "status": "Status", 278 "status": "Status",
265 "uptime": "Bot Uptime", 279 "uptime": "Bot Uptime",
266 "xcode_version": "XCode Version", 280 "xcode_version": "XCode Version",
267 }; 281 };
268 282
269 var columnMap = { 283 var columnMap = {
270 android_devices: function(bot) { 284 android_devices: function(bot) {
(...skipping 24 matching lines...) Expand all
295 return bot.state.temp.zones || UNKNOWN; 309 return bot.state.temp.zones || UNKNOWN;
296 } 310 }
297 return bot.state.temp.average || UNKNOWN; 311 return bot.state.temp.average || UNKNOWN;
298 }, 312 },
299 device_temperature: function(){ 313 device_temperature: function(){
300 return ""; 314 return "";
301 }, 315 },
302 disk_space: function(bot) { 316 disk_space: function(bot) {
303 var aliased = []; 317 var aliased = [];
304 bot.disks.forEach(function(disk){ 318 bot.disks.forEach(function(disk){
305 var alias = sk.human.bytes(disk.mb, swarming.MB); 319 var alias = sk.human.bytes(disk.mb, sk.MB);
306 aliased.push(swarming.alias.apply(disk.mb, disk.id + " "+ alias)); 320 aliased.push(swarming.alias.apply(disk.mb, disk.id + " "+ alias));
307 }.bind(this)); 321 }.bind(this));
308 if (this._verbose) { 322 if (this._verbose) {
309 return aliased.join(" | "); 323 return aliased.join(" | ");
310 } 324 }
311 return aliased[0]; 325 return aliased[0];
312 }, 326 },
313 327
jcgregorio 2016/10/13 12:03:46 why blank line here?
kjlubick 2016/10/13 12:26:49 Sometimes, the code just needs to breathe. jk, re
314 external_ip: function(bot) { 328 external_ip: function(bot) {
315 return bot.external_ip || "none"; 329 return bot.external_ip || "none";
316 }, 330 },
317 first_seen: function(bot) { 331 first_seen: function(bot) {
318 return sk.human.localeTime(bot.first_seen_ts) 332 return sk.human.localeTime(bot.first_seen_ts)
319 }, 333 },
320 id: function(bot) { 334 id: function(bot) {
321 return bot.bot_id; 335 return bot.bot_id;
322 }, 336 },
323 last_seen: function(bot) { 337 last_seen: function(bot) {
324 if (this._verbose) { 338 if (this._verbose) {
325 return sk.human.localeTime(bot.last_seen_ts); 339 return sk.human.localeTime(bot.last_seen_ts);
326 } 340 }
327 return this._timeDiffApprox(bot.last_seen_ts) + " ago"; 341 return this._timeDiffApprox(bot.last_seen_ts) + " ago";
328 }, 342 },
343 mp_lease_id: function(bot) {
344 var id = bot.lease_id || "none";
345 if (this._verbose) {
346 return id;
347 }
348 return id.substring(0, 10);
349 },
350 mp_lease_expires: function(bot) {
351 if (!bot.lease_expiration_ts) {
352 return "N/A";
353 }
354 if (this._verbose) {
355 return sk.human.localeTime(bot.lease_expiration_ts);
356 }
357 if (bot.lease_expiration_ts < new Date()) {
jcgregorio 2016/10/13 12:03:46 lease_expiration_ts is in seconds but new Date() i
kjlubick 2016/10/13 12:26:49 At this point, lease_expiration_ts is now a parsed
358 return this._timeDiffApprox(bot.lease_expiration_ts) + " ago";
359 }
360 return "in " + this._timeDiffApprox(bot.lease_expiration_ts);
361 },
329 running_time: function(bot) { 362 running_time: function(bot) {
330 var u = this._state(bot, "running_time"); 363 var u = this._state(bot, "running_time");
331 if (!u) { 364 if (!u) {
332 return "unknown"; 365 return "unknown";
333 } 366 }
334 return sk.human.strDuration(u); 367 return sk.human.strDuration(u);
335 }, 368 },
336 status: function(bot) { 369 status: function(bot) {
337 // If a bot is both dead and quarantined, show the deadness over the 370 // If a bot is both dead and quarantined, show the deadness over the
338 // quarentinedness. 371 // quarentinedness.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 value: specialColumns, 569 value: specialColumns,
537 }, 570 },
538 _specialSort: { 571 _specialSort: {
539 type: Object, 572 type: Object,
540 value: specialSort, 573 value: specialSort,
541 }, 574 },
542 }, 575 },
543 576
544 observers:["_reload(_query_params,_auth_headers)"], 577 observers:["_reload(_query_params,_auth_headers)"],
545 578
579 _androidAliasDevice: function(device) {
580 if (device.notReady) {
581 return UNAUTHENTICATED.toUpperCase();
582 }
583 return swarming.alias.android(this._deviceType(device));
584 },
585
546 _botClass: function(bot) { 586 _botClass: function(bot) {
547 if (bot.is_dead) { 587 if (bot.is_dead) {
548 return "dead"; 588 return "dead";
549 } 589 }
550 if (bot.quarantined) { 590 if (bot.quarantined) {
551 return "quarantined"; 591 return "quarantined";
552 } 592 }
553 return ""; 593 return "";
554 }, 594 },
555 595
556 _ccLink: function(bot){ 596 _ccLink: function(bot){
557 var z = this._attribute(bot, "zone")[0]; 597 var z = this._attribute(bot, "zone")[0];
558 if (z === "unknown") { 598 if (z === "unknown") {
559 return undefined; 599 return undefined;
560 } 600 }
561 return this._cloudConsoleLink(z, bot.bot_id); 601 return this._cloudConsoleLink(z, bot.bot_id);
562 }, 602 },
563 603
564 _ccText: function(bot){ 604 _ccText: function(bot){
565 var z = this._attribute(bot, "zone")[0]; 605 var z = this._attribute(bot, "zone")[0];
566 if (z === "unknown") { 606 if (z === "unknown") {
567 return "Not on GCE"; 607 return "Not on GCE";
568 } 608 }
569 return "View Bot"; 609 return "View Bot";
570 }, 610 },
571 611
572 _androidAliasDevice: function(device) {
573 if (device.notReady) {
574 return UNAUTHENTICATED.toUpperCase();
575 }
576 return swarming.alias.android(this._deviceType(device));
577 },
578
579 _deviceColumn: function(col, device) { 612 _deviceColumn: function(col, device) {
580 var f = deviceColumnMap[col]; 613 var f = deviceColumnMap[col];
581 if (!f || !device) { 614 if (!f || !device) {
582 return ""; 615 return "";
583 } 616 }
584 return f.bind(this)(device); 617 return f.bind(this)(device);
585 }, 618 },
586 619
587 _deviceClass: function(device) { 620 _deviceClass: function(device) {
588 if (!device.okay) { 621 if (!device.okay) {
589 return "bad-device"; 622 return "bad-device";
590 } 623 }
591 return ""; 624 return "";
592 }, 625 },
593 626
627 _mpLink: function(bot, template) {
628 if (!bot || !bot.lease_id || !template) {
629 return false;
630 }
631 return template.replace("%s", bot.lease_id);
632 },
633
594 _reload: function() { 634 _reload: function() {
595 if (!this._auth_headers || !this._query_params) { 635 if (!this._auth_headers || !this._query_params) {
596 return; 636 return;
597 } 637 }
598 var url = "/_ah/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this ._query_params); 638 var url = "/_ah/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this ._query_params);
599 this.$.page_bots.load(url,this._auth_headers); 639 this.$.page_bots.load(url,this._auth_headers);
600 } 640 }
601 641
602 }); 642 });
603 })(); 643 })();
604 </script> 644 </script>
605 </dom-module> 645 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698