| OLD | NEW |
| 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 |
| 11 bot-list creats a dynamic table for viewing swarming bots. Columns can be | 11 bot-list creats a dynamic table for viewing swarming bots. Columns can be |
| 12 dynamically filtered and it supports client-side filtering. | 12 dynamically filtered and it supports client-side filtering. |
| 13 | 13 |
| 14 This is a top-level element. | 14 This is a top-level element. |
| 15 | 15 |
| 16 Properties: | 16 Properties: |
| 17 client_id: String, Oauth 2.0 client id. It will be set by server-side | 17 client_id: String, Oauth 2.0 client id. It will be set by server-side |
| 18 template evaluation. | 18 template evaluation. |
| 19 | 19 |
| 20 Methods: | 20 Methods: |
| 21 None. | 21 None. |
| 22 | 22 |
| 23 Events: | 23 Events: |
| 24 None. | 24 None. |
| 25 --> | 25 --> |
| 26 | 26 |
| 27 <link rel="import" href="/res/imp/bower_components/iron-flex-layout/iron-flex-la
yout-classes.html"> | 27 <link rel="import" href="/res/imp/bower_components/iron-flex-layout/iron-flex-la
yout-classes.html"> |
| 28 <link rel="import" href="/res/imp/bower_components/paper-dialog/paper-dialog.htm
l"> |
| 28 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html"> | 29 <link rel="import" href="/res/imp/bower_components/polymer/polymer.html"> |
| 29 | 30 |
| 30 <link rel="import" href="/res/imp/common/dynamic-table-behavior.html"> | 31 <link rel="import" href="/res/imp/common/dynamic-table-behavior.html"> |
| 31 <link rel="import" href="/res/imp/common/sort-toggle.html"> | 32 <link rel="import" href="/res/imp/common/sort-toggle.html"> |
| 32 <link rel="import" href="/res/imp/common/swarming-app.html"> | 33 <link rel="import" href="/res/imp/common/swarming-app.html"> |
| 33 <link rel="import" href="/res/imp/common/url-param.html"> | 34 <link rel="import" href="/res/imp/common/url-param.html"> |
| 34 <link rel="import" href="/res/imp/common/pageable-data.html"> | 35 <link rel="import" href="/res/imp/common/pageable-data.html"> |
| 35 | 36 |
| 36 <link rel="import" href="bot-filters.html"> | 37 <link rel="import" href="bot-filters.html"> |
| 37 <link rel="import" href="bot-list-data.html"> | 38 <link rel="import" href="bot-list-data.html"> |
| 38 <link rel="import" href="bot-list-shared-behavior.html"> | 39 <link rel="import" href="bot-list-shared-behavior.html"> |
| 39 <link rel="import" href="bot-list-summary.html"> | 40 <link rel="import" href="bot-list-summary.html"> |
| 41 <link rel="import" href="bot-mass-delete.html"> |
| 40 | 42 |
| 41 <dom-module id="bot-list"> | 43 <dom-module id="bot-list"> |
| 42 <template> | 44 <template> |
| 43 <style include="iron-flex iron-flex-alignment iron-positioning swarming-app-
style dynamic-table-style"> | 45 <style include="iron-flex iron-flex-alignment iron-positioning swarming-app-
style dynamic-table-style"> |
| 44 bot-filters, bot-list-summary { | 46 bot-filters, bot-list-summary { |
| 45 margin-bottom: 8px; | 47 margin-bottom: 8px; |
| 46 margin-right: 10px; | 48 margin-right: 10px; |
| 47 } | 49 } |
| 48 .old_version { | 50 .old_version { |
| 49 background-color: #ffffdd; | 51 background-color: #ffffdd; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 </style> | 66 </style> |
| 65 | 67 |
| 66 <url-param name="s" | 68 <url-param name="s" |
| 67 value="{{_sortstr}}" | 69 value="{{_sortstr}}" |
| 68 default_value="id:asc"> | 70 default_value="id:asc"> |
| 69 </url-param> | 71 </url-param> |
| 70 | 72 |
| 71 <swarming-app | 73 <swarming-app |
| 72 client_id="[[client_id]]" | 74 client_id="[[client_id]]" |
| 73 auth_headers="{{_auth_headers}}" | 75 auth_headers="{{_auth_headers}}" |
| 76 permissions="{{_permissions}}" |
| 74 signed_in="{{_signed_in}}" | 77 signed_in="{{_signed_in}}" |
| 75 server_details="{{_server_details}}" | 78 server_details="{{_server_details}}" |
| 76 | 79 |
| 77 busy="[[_or(_busy1,_busy2,_busy3)]]" | 80 busy="[[_or(_busy1,_busy2,_busy3)]]" |
| 78 name="Swarming Bot List"> | 81 name="Swarming Bot List"> |
| 79 | 82 |
| 80 <h2 hidden$="[[_signed_in]]">You must sign in to see anything useful.</h2> | 83 <h2 hidden$="[[_signed_in]]">You must sign in to see anything useful.</h2> |
| 81 | 84 |
| 82 <div hidden$="[[_not(_signed_in)]]"> | 85 <div hidden$="[[_not(_signed_in)]]"> |
| 83 | 86 |
| 84 <div class="horizontal layout"> | 87 <div class="horizontal layout"> |
| 85 | 88 |
| 86 <bot-filters | 89 <bot-filters |
| 87 dimensions="[[_dimensions]]" | 90 dimensions="[[_dimensions]]" |
| 88 primary_map="[[_primary_map]]" | 91 primary_map="[[_primary_map]]" |
| 89 primary_arr="[[_primary_arr]]" | 92 primary_arr="[[_primary_arr]]" |
| 90 special_columns="[[_specialColumns]]" | 93 special_columns="[[_specialColumns]]" |
| 94 permissions="[[_permissions]]" |
| 91 | 95 |
| 92 columns="{{_columns}}" | 96 columns="{{_columns}}" |
| 93 query_params="{{_query_params}}" | 97 query_params="{{_query_params}}" |
| 94 filter="{{_filter}}" | 98 filter="{{_filter}}" |
| 95 verbose="{{_verbose}}"> | 99 verbose="{{_verbose}}" |
| 100 |
| 101 on-delete-all="_promptDeleteAll"> |
| 96 </bot-filters> | 102 </bot-filters> |
| 97 | 103 |
| 98 <bot-list-summary | 104 <bot-list-summary |
| 99 auth_headers="[[_auth_headers]]" | 105 auth_headers="[[_auth_headers]]" |
| 100 columns="[[_columns]]" | 106 columns="[[_columns]]" |
| 101 count_params="[[_query_params]]" | 107 count_params="[[_query_params]]" |
| 102 fleet="[[_fleet]]" | 108 fleet="[[_fleet]]" |
| 103 num_bots="[[_filteredSortedItems.length]]" | 109 num_bots="[[_filteredSortedItems.length]]" |
| 104 sort="[[_sortstr]]" | 110 sort="[[_sortstr]]" |
| 105 verbose="[[_verbose]]" | 111 verbose="[[_verbose]]" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 id="page_bots" | 242 id="page_bots" |
| 237 busy="{{_busy2}}" | 243 busy="{{_busy2}}" |
| 238 label="Show more bots" | 244 label="Show more bots" |
| 239 output="{{_items}}" | 245 output="{{_items}}" |
| 240 parse="[[_parseBots]]"> | 246 parse="[[_parseBots]]"> |
| 241 </pageable-data> | 247 </pageable-data> |
| 242 </div> | 248 </div> |
| 243 | 249 |
| 244 </swarming-app> | 250 </swarming-app> |
| 245 | 251 |
| 252 <!-- Paper dialogs must be on the "outside" of the DOM, that is, not inside
of other elements, otherwise the shadow backdrop is weird.--> |
| 253 <paper-dialog id="delete_all_dialog" modal> |
| 254 <bot-mass-delete |
| 255 id="mass_delete" |
| 256 auth_headers="[[_auth_headers]]" |
| 257 started_deleting="{{_started_deleting}}" |
| 258 finished_deleting="{{_finished_deleting}}"> |
| 259 </bot-mass-delete> |
| 260 <div class="buttons" > |
| 261 <paper-button dialog-dismiss autofocus hidden$="[[_started_deleting]]"> |
| 262 Go Back - Don't Delete Anything |
| 263 </paper-button> |
| 264 <paper-button dialog-dismiss autofocus hidden$="[[!_finished_deleting]]"
on-tap="_reload"> |
| 265 Done |
| 266 </paper-button> |
| 267 </div> |
| 268 </paper-dialog> |
| 246 </template> | 269 </template> |
| 247 <script> | 270 <script> |
| 248 (function(){ | 271 (function(){ |
| 249 var UNKNOWN = "unknown"; | 272 var UNKNOWN = "unknown"; |
| 250 // see dynamic-table for more information on specialColumns, headerMap, | 273 // see dynamic-table for more information on specialColumns, headerMap, |
| 251 // columnMap, and specialSort | 274 // columnMap, and specialSort |
| 252 var specialColumns = ["id", "mp_lease_id", "task"]; | 275 var specialColumns = ["id", "mp_lease_id", "task"]; |
| 253 | 276 |
| 254 var deviceColumns = ["battery_health", "battery_level", "battery_status", "b
attery_temperature", "battery_voltage", "device_temperature"]; | 277 var deviceColumns = ["battery_health", "battery_level", "battery_status", "b
attery_temperature", "battery_voltage", "device_temperature"]; |
| 255 | 278 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return sk.human.strDuration(u); | 403 return sk.human.strDuration(u); |
| 381 }, | 404 }, |
| 382 status: function(bot) { | 405 status: function(bot) { |
| 383 // If a bot is both dead and quarantined, show the deadness over the | 406 // If a bot is both dead and quarantined, show the deadness over the |
| 384 // quarentinedness. | 407 // quarentinedness. |
| 385 if (bot.is_dead) { | 408 if (bot.is_dead) { |
| 386 return "Dead. Last seen " + sk.human.diffDate(bot.last_seen_ts) + | 409 return "Dead. Last seen " + sk.human.diffDate(bot.last_seen_ts) + |
| 387 " ago"; | 410 " ago"; |
| 388 } | 411 } |
| 389 if (bot.quarantined) { | 412 if (bot.quarantined) { |
| 390 var msg = this._state(bot, "quarantined")[0]; | 413 var msg = this._state(bot, "quarantined"); |
| 414 if (msg) { |
| 415 msg = msg[0]; |
| 416 }; |
| 391 // Sometimes, the quarantined message is actually in "error". This | 417 // Sometimes, the quarantined message is actually in "error". This |
| 392 // happens when the bot code has thrown an exception. | 418 // happens when the bot code has thrown an exception. |
| 393 if (msg === UNKNOWN || msg === "true" || msg === true) { | 419 if (!msg || msg === "true" || msg === true) { |
| 394 msg = this._attribute(bot, "error"); | 420 msg = this._attribute(bot, "error")[0]; |
| 421 } |
| 422 // Othertimes, the bot has reported it is quarantined by setting the |
| 423 // dimension "quarantined" to be something. |
| 424 if (msg === UNKNOWN) { |
| 425 msg = this._dimension(bot, "quarantined") || UNKNOWN; |
| 395 } | 426 } |
| 396 var errs = []; | 427 var errs = []; |
| 397 // Show all the errors that are active on devices to make it more | 428 // Show all the errors that are active on devices to make it more |
| 398 // clear if this is a transient error (e.g. device is too hot) | 429 // clear if this is a transient error (e.g. device is too hot) |
| 399 // or if it is requires human interaction (e.g. device is unauthorized
) | 430 // or if it is requires human interaction (e.g. device is unauthorized
) |
| 400 this._devices(bot).forEach(function(d){ | 431 this._devices(bot).forEach(function(d){ |
| 401 if (d.state !== "available") { | 432 if (d.state !== "available") { |
| 402 errs.push(d.state); | 433 errs.push(d.state); |
| 403 } | 434 } |
| 404 }); | 435 }); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 return ""; | 691 return ""; |
| 661 }, | 692 }, |
| 662 | 693 |
| 663 _mpLink: function(bot, template) { | 694 _mpLink: function(bot, template) { |
| 664 if (!bot || !bot.lease_id || !template) { | 695 if (!bot || !bot.lease_id || !template) { |
| 665 return false; | 696 return false; |
| 666 } | 697 } |
| 667 return template.replace("%s", bot.lease_id); | 698 return template.replace("%s", bot.lease_id); |
| 668 }, | 699 }, |
| 669 | 700 |
| 701 _promptDeleteAll: function(e) { |
| 702 this.$.mass_delete.dimensions = e.detail.dimensions; |
| 703 this.$.mass_delete.prompt(); |
| 704 this.$.delete_all_dialog.open(); |
| 705 }, |
| 706 |
| 670 _reload: function() { | 707 _reload: function() { |
| 671 if (!this._auth_headers || !this._query_params) { | 708 if (!this._auth_headers || !this._query_params) { |
| 672 return; | 709 return; |
| 673 } | 710 } |
| 674 var url = "/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this._qu
ery_params); | 711 var url = "/api/swarming/v1/bots/list?" + sk.query.fromParamSet(this._qu
ery_params); |
| 675 this.$.page_bots.load(url,this._auth_headers); | 712 this.$.page_bots.load(url,this._auth_headers); |
| 676 } | 713 } |
| 677 | 714 |
| 678 }); | 715 }); |
| 679 })(); | 716 })(); |
| 680 </script> | 717 </script> |
| 681 </dom-module> | 718 </dom-module> |
| OLD | NEW |