| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 This in an HTML Import-able file that contains the definition | |
| 3 of the following elements: | |
| 4 | |
| 5 <bot-list-summary> | |
| 6 | |
| 7 | |
| 8 Usage: | |
| 9 | |
| 10 <bot-list-summary></bot-list-summary> | |
| 11 | |
| 12 This element summarizes and displays the results of the current query. | |
| 13 | |
| 14 Properties: | |
| 15 filtered_bots: Array<Object>, The bot list that is currently being shown | |
| 16 (after filtering). The alive, dead, etc bots in this will be counted up | |
| 17 for the summary. See bot-list-data for a description of this data type. | |
| 18 fleet: Object, counts of all bots in the fleet. Contains "alive", "busy", | |
| 19 "idle", "dead", and "quarantined". | |
| 20 Methods: | |
| 21 None. | |
| 22 | |
| 23 Events: | |
| 24 None. | |
| 25 --> | |
| 26 | |
| 27 | |
| 28 <link rel="import" href="/res/imp/common/swarming-app.html"> | |
| 29 | |
| 30 <link rel="import" href="bot-list-shared-behavior.html"> | |
| 31 | |
| 32 <dom-module id="bot-list-summary"> | |
| 33 <template> | |
| 34 <style include="swarming-app-style"> | |
| 35 :host { | |
| 36 display: block; | |
| 37 border-left: 1px solid black; | |
| 38 padding: 5px 5px; | |
| 39 font-family: sans-serif; | |
| 40 } | |
| 41 .header { | |
| 42 font-size: 1.2em; | |
| 43 font-weight: bold; | |
| 44 } | |
| 45 .right { | |
| 46 text-align: right; | |
| 47 } | |
| 48 .left { | |
| 49 text-align: left; | |
| 50 } | |
| 51 </style> | |
| 52 | |
| 53 <div class="header">Fleet</div> | |
| 54 <table> | |
| 55 <tr> | |
| 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> | |
| 65 <td class="left">[[fleet.alive]]</td> | |
| 66 </tr> | |
| 67 <tr> | |
| 68 <td class="right"> | |
| 69 <a href$="[[_makeURL('busy','',columns.*,filtered_bots.*,sort,verbose)
]]">Busy</a>: | |
| 70 </td> | |
| 71 <td class="left">[[fleet.busy]]</td> | |
| 72 </tr> | |
| 73 <tr> | |
| 74 <td class="right"> | |
| 75 <a href$="[[_makeURL('idle','',columns.*,filtered_bots.*,sort,verbose)
]]">Idle</a>: | |
| 76 </td> | |
| 77 <td class="left">[[fleet.idle]]</td> | |
| 78 </tr> | |
| 79 <tr> | |
| 80 <td class="right"> | |
| 81 <a href$="[[_makeURL('dead','',columns.*,filtered_bots.*,sort,verbose)
]]">Dead</a>: | |
| 82 </td> | |
| 83 <td class="left">[[fleet.dead]]</td> | |
| 84 </tr> | |
| 85 <tr> | |
| 86 <td class="right"> | |
| 87 <a href$="[[_makeURL('quarantined','',columns.*,filtered_bots.*,sort,v
erbose)]]">Quarantined</a>: | |
| 88 </td> | |
| 89 <td class="left">[[fleet.quarantined]]</td> | |
| 90 </tr> | |
| 91 </table> | |
| 92 | |
| 93 <div class="header">Displayed</div> | |
| 94 <table> | |
| 95 <tr> | |
| 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> | |
| 105 <td class="left">[[_currently_showing.alive]]</td> | |
| 106 </tr> | |
| 107 <tr> | |
| 108 <td class="right"> | |
| 109 <a href$="[[_makeURL('busy','true',columns.*,filtered_bots.*,sort,verb
ose)]]">Busy</a>: | |
| 110 </td> | |
| 111 <td class="left">[[_currently_showing.busy]]</td> | |
| 112 </tr> | |
| 113 <tr> | |
| 114 <td class="right"> | |
| 115 <a href$="[[_makeURL('idle','true',columns.*,filtered_bots.*,sort,verb
ose)]]">Idle</a>: | |
| 116 </td> | |
| 117 <td class="left">[[_currently_showing.idle]]</td> | |
| 118 </tr> | |
| 119 <tr> | |
| 120 <td class="right"> | |
| 121 <a href$="[[_makeURL('dead','true',columns.*,filtered_bots.*,sort,verb
ose)]]">Dead</a>: | |
| 122 </td> | |
| 123 <td class="left">[[_currently_showing.dead]]</td> | |
| 124 </tr> | |
| 125 <tr> | |
| 126 <td class="right"> | |
| 127 <a href$="[[_makeURL('quarantined','true',columns.*,filtered_bots.*,so
rt,verbose)]]">Quarantined</a>: | |
| 128 </td> | |
| 129 <td class="left">[[_currently_showing.quarantined]]</td> | |
| 130 </tr> | |
| 131 </table> | |
| 132 | |
| 133 </template> | |
| 134 <script> | |
| 135 Polymer({ | |
| 136 is: 'bot-list-summary', | |
| 137 | |
| 138 behaviors: [SwarmingBehaviors.BotListBehavior], | |
| 139 | |
| 140 properties: { | |
| 141 columns: { | |
| 142 type: Array, | |
| 143 }, | |
| 144 filtered_bots: { | |
| 145 type: Array, | |
| 146 }, | |
| 147 fleet: { | |
| 148 type: Object, | |
| 149 }, | |
| 150 sort: { | |
| 151 type: String, | |
| 152 }, | |
| 153 verbose: { | |
| 154 type: Boolean, | |
| 155 }, | |
| 156 | |
| 157 _currently_showing: { | |
| 158 type: Object, | |
| 159 value: function() { | |
| 160 return { | |
| 161 all: -1, | |
| 162 alive: -1, | |
| 163 busy: -1, | |
| 164 idle: -1, | |
| 165 dead: -1, | |
| 166 quarantined: -1, | |
| 167 }; | |
| 168 }, | |
| 169 }, | |
| 170 }, | |
| 171 | |
| 172 // Do this because Array changes in Polymer don't always trigger normal | |
| 173 // property observers | |
| 174 observers: ["_recount(filtered_bots.*)"], | |
| 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 + "&f=" + fstr; | |
| 193 } | |
| 194 // The filter is already on the list. | |
| 195 return undefined; | |
| 196 } | |
| 197 var params = { | |
| 198 s: [this.sort], | |
| 199 c: this.columns, | |
| 200 v: [this.verbose], | |
| 201 } | |
| 202 if (filter) { | |
| 203 params["f"] = [this._getFilterStr(filter)]; | |
| 204 } | |
| 205 | |
| 206 return window.location.href.split('?')[0] + '?' + sk.query.fromParamSet(
params); | |
| 207 }, | |
| 208 | |
| 209 _recount: function() { | |
| 210 var curr = { | |
| 211 all: 0, | |
| 212 alive: 0, | |
| 213 busy: 0, | |
| 214 idle: 0, | |
| 215 dead: 0, | |
| 216 quarantined: 0, | |
| 217 }; | |
| 218 if (!this.filtered_bots) { | |
| 219 return curr; | |
| 220 } | |
| 221 this.filtered_bots.forEach(function(bot) { | |
| 222 if (this._taskId(bot) === "idle") { | |
| 223 curr.idle++; | |
| 224 } else { | |
| 225 curr.busy++; | |
| 226 } | |
| 227 if (bot.quarantined) { | |
| 228 curr.quarantined++; | |
| 229 } | |
| 230 if (bot.is_dead) { | |
| 231 curr.dead++; | |
| 232 } else { | |
| 233 curr.alive++; | |
| 234 } | |
| 235 curr.all++; | |
| 236 }.bind(this)); | |
| 237 this.set("_currently_showing", curr); | |
| 238 } | |
| 239 }); | |
| 240 </script> | |
| 241 </dom-module> | |
| OLD | NEW |