| OLD | NEW |
| 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 <task-list-summary> | 5 <task-list-summary> |
| 6 | 6 |
| 7 Usage: | 7 Usage: |
| 8 | 8 |
| 9 <task-list-summary></task-list-summary> | 9 <task-list-summary></task-list-summary> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 .left { | 62 .left { |
| 63 text-align: left; | 63 text-align: left; |
| 64 } | 64 } |
| 65 </style> | 65 </style> |
| 66 | 66 |
| 67 <div class="horizontal layout"> | 67 <div class="horizontal layout"> |
| 68 | 68 |
| 69 <div class="column"> | 69 <div class="column"> |
| 70 <table> | 70 <table> |
| 71 <thead> | 71 <thead> |
| 72 <th class="header right" colspan=2>Selected</th> | 72 <th class="header right" colspan=2>Selected Tasks</th> |
| 73 </thead> | 73 </thead> |
| 74 <tr> | 74 <tr> |
| 75 <td class="right"> | 75 <td class="right"> |
| 76 Displayed: | 76 Displayed: |
| 77 </td> | 77 </td> |
| 78 <td class="left">[[num_tasks]]</td> | 78 <td class="left">[[num_tasks]]</td> |
| 79 </tr> | 79 </tr> |
| 80 <tr title="These counts reflect the time period selected"> | 80 <tr title="These counts reflect the time period selected"> |
| 81 <td class="right" > | 81 <td class="right" > |
| 82 Total: | 82 Total: |
| 83 </td> | 83 </td> |
| 84 <td class="left">[[_selected_exact.count]]</td> | 84 <td class="left">[[_selected_exact.count]]</td> |
| 85 </tr> | 85 </tr> |
| 86 <template is="dom-repeat" items="[[_selected_summary]]" as="item" inde
x-as="idx"> | 86 <template is="dom-repeat" items="[[_selected_summary]]" as="item" inde
x-as="idx"> |
| 87 <tr title="These counts reflect the time period selected"> | 87 <tr title="These counts reflect the time period selected"> |
| 88 <td class="right"> | 88 <td class="right"> |
| 89 <a href$="[[_makeURL(item.name,'true',columns.*,sort,count_param
s.*)]]">[[item.human]]</a>: | 89 <a href$="[[_makeURL(item.name,'true',columns.*,sort,count_param
s.*)]]">[[item.human]]</a>: |
| 90 </td> | 90 </td> |
| 91 <td class="left">[[_idx(_selected_counts, idx, _selected_counts.*)
]]</td> | 91 <td class="left">[[_idx(_selected_counts, idx, _selected_counts.*)
]]</td> |
| 92 </tr> | 92 </tr> |
| 93 </template> | 93 </template> |
| 94 </table> | 94 </table> |
| 95 </div> | 95 </div> |
| 96 | 96 |
| 97 <div class="left column"> | |
| 98 <table> | |
| 99 <thead> | |
| 100 <th class="header right" colspan=2>All Tasks in last 24h</th> | |
| 101 </thead> | |
| 102 <template is="dom-repeat" items="[[_all_summary]]" as="item" index-as=
"idx"> | |
| 103 <tr title="These counts are all from the last 24 hours"> | |
| 104 <td class="right"> | |
| 105 <a href$="[[_makeURL(item.name,'',columns.*,sort)]]">[[item.huma
n]]</a>: | |
| 106 </td> | |
| 107 <td class="left">[[_idx(_all_counts, idx, _all_counts.*)]]</td> | |
| 108 </tr> | |
| 109 </template> | |
| 110 </table> | |
| 111 </div> | |
| 112 | |
| 113 </div> | 97 </div> |
| 114 | 98 |
| 115 </template> | 99 </template> |
| 116 <script> | 100 <script> |
| 117 (function(){ | 101 (function(){ |
| 118 var ALL_TASKS_SUMMARY = [ | |
| 119 {name:"ALL", human:"All"}, | |
| 120 {name:"BOT_DIED", human:"Bot Died"}, | |
| 121 {name:"CANCELED", human:"Canceled"}, | |
| 122 {name:"COMPLETED_SUCCESS", human:"Completed (Success)"}, | |
| 123 {name:"COMPLETED_FAILURE", human:"Completed (Failure)"}, | |
| 124 {name:"DEDUPED", human:"Deduplicated"}, | |
| 125 {name:"EXPIRED", human:"Expired"}, | |
| 126 {name:"PENDING", human:"Pending"}, | |
| 127 {name:"RUNNING", human:"Running"}, | |
| 128 {name:"TIMED_OUT", human:"Timed Out"}, | |
| 129 ]; | |
| 130 var SELECTED_TASKS_SUMMARY = [ | 102 var SELECTED_TASKS_SUMMARY = [ |
| 131 {name:"BOT_DIED", human:"Bot Died"}, | 103 {name:"BOT_DIED", human:"Bot Died"}, |
| 132 {name:"CANCELED", human:"Canceled"}, | 104 {name:"CANCELED", human:"Canceled"}, |
| 133 {name:"COMPLETED_SUCCESS", human:"Completed (Success)"}, | 105 {name:"COMPLETED_SUCCESS", human:"Completed (Success)"}, |
| 134 {name:"COMPLETED_FAILURE", human:"Completed (Failure)"}, | 106 {name:"COMPLETED_FAILURE", human:"Completed (Failure)"}, |
| 135 {name:"DEDUPED", human:"Deduplicated"}, | 107 {name:"DEDUPED", human:"Deduplicated"}, |
| 136 {name:"EXPIRED", human:"Expired"}, | 108 {name:"EXPIRED", human:"Expired"}, |
| 137 {name:"PENDING", human:"Pending"}, | 109 {name:"PENDING", human:"Pending"}, |
| 138 {name:"RUNNING", human:"Running"}, | 110 {name:"RUNNING", human:"Running"}, |
| 139 {name:"TIMED_OUT", human:"Timed Out"}, | 111 {name:"TIMED_OUT", human:"Timed Out"}, |
| 140 ]; | 112 ]; |
| 141 Polymer({ | 113 Polymer({ |
| 142 is: 'task-list-summary', | 114 is: 'task-list-summary', |
| 143 | 115 |
| 144 behaviors: [SwarmingBehaviors.CommonBehavior], | 116 behaviors: [SwarmingBehaviors.CommonBehavior], |
| 145 | 117 |
| 146 properties: { | 118 properties: { |
| 147 auth_headers: { | 119 auth_headers: { |
| 148 type: Object, | 120 type: Object, |
| 149 }, | 121 }, |
| 150 busy: { | 122 busy: { |
| 151 type: Boolean, | 123 type: Boolean, |
| 152 computed: "_anyBusy(_busyArr1.*,_busyArr2.*,_busy3)", | 124 computed: "_anyBusy(_busyArr1.*,_busy3)", |
| 153 notify: true, | 125 notify: true, |
| 154 }, | 126 }, |
| 155 count_params: { | 127 count_params: { |
| 156 type: Object, | 128 type: Object, |
| 157 }, | 129 }, |
| 158 columns: { | 130 columns: { |
| 159 type: Array, | 131 type: Array, |
| 160 }, | 132 }, |
| 161 num_tasks: { | 133 num_tasks: { |
| 162 type: Number, | 134 type: Number, |
| 163 }, | 135 }, |
| 164 sort: { | 136 sort: { |
| 165 type: String, | 137 type: String, |
| 166 }, | 138 }, |
| 167 | 139 |
| 168 _busyArr1: { | 140 _busyArr1: { |
| 169 type:Array, | 141 type:Array, |
| 170 value: function() { | 142 value: function() { |
| 171 return []; | 143 return []; |
| 172 } | 144 } |
| 173 }, | 145 }, |
| 174 _busyArr2: { | |
| 175 type:Array, | |
| 176 value: function() { | |
| 177 return []; | |
| 178 } | |
| 179 }, | |
| 180 _busy3: { | 146 _busy3: { |
| 181 type: Boolean, | 147 type: Boolean, |
| 182 value: false, | 148 value: false, |
| 183 }, | 149 }, |
| 184 _all_counts: { | |
| 185 type: Array, | |
| 186 value: function() { | |
| 187 return []; | |
| 188 } | |
| 189 }, | |
| 190 _all_summary: { | |
| 191 type: Array, | |
| 192 value: function() { | |
| 193 return ALL_TASKS_SUMMARY; | |
| 194 } | |
| 195 }, | |
| 196 _selected_counts: { | 150 _selected_counts: { |
| 197 type: Array, | 151 type: Array, |
| 198 value: function() { | 152 value: function() { |
| 199 return []; | 153 return []; |
| 200 } | 154 } |
| 201 }, | 155 }, |
| 202 _selected_exact: { | 156 _selected_exact: { |
| 203 type: Object, | 157 type: Object, |
| 204 }, | 158 }, |
| 205 _selected_summary: { | 159 _selected_summary: { |
| 206 type: Array, | 160 type: Array, |
| 207 value: function() { | 161 value: function() { |
| 208 return SELECTED_TASKS_SUMMARY; | 162 return SELECTED_TASKS_SUMMARY; |
| 209 } | 163 } |
| 210 }, | 164 }, |
| 211 | 165 |
| 212 }, | 166 }, |
| 213 | 167 |
| 214 observers: [ | 168 observers: [ |
| 215 "_recountEverything(auth_headers.*,count_params.*)" | 169 "_recountEverything(auth_headers.*,count_params.*)" |
| 216 ], | 170 ], |
| 217 | 171 |
| 218 // Returns true if any of the busy signals are true. | 172 // Returns true if any of the busy signals are true. |
| 219 _anyBusy: function() { | 173 _anyBusy: function() { |
| 220 for (var i = 0; i<this._busyArr1.length; i++) { | 174 for (var i = 0; i<this._busyArr1.length; i++) { |
| 221 if (this._busyArr1[i].status) { | 175 if (this._busyArr1[i].status) { |
| 222 return true; | 176 return true; |
| 223 } | 177 } |
| 224 } | 178 } |
| 225 for (var i = 0; i<this._busyArr2.length; i++) { | |
| 226 if (this._busyArr2[i].status) { | |
| 227 return true; | |
| 228 } | |
| 229 } | |
| 230 return this._busy3; | 179 return this._busy3; |
| 231 }, | 180 }, |
| 232 | 181 |
| 233 // Returns the idx'th count of obj. | 182 // Returns the idx'th count of obj. |
| 234 _idx: function(obj, idx) { | 183 _idx: function(obj, idx) { |
| 235 return obj && obj[idx] && obj[idx].count; | 184 return obj && obj[idx] && obj[idx].count; |
| 236 }, | 185 }, |
| 237 | 186 |
| 238 // Recount all the task counts. This will make use of _getJsonAsyncArr bec
ause | 187 // Recount all the task counts. This will make use of _getJsonAsyncArr bec
ause |
| 239 // the results will be generated in a dom-repeat. | 188 // the results will be generated in a dom-repeat. |
| 240 _recountEverything: function() { | 189 _recountEverything: function() { |
| 241 if (!this.auth_headers || !this.count_params) { | 190 if (!this.auth_headers || !this.count_params) { |
| 242 return; | 191 return; |
| 243 } | 192 } |
| 244 // We round 24 hours ago down to the nearest minute to mirror what | |
| 245 // the UI can select. Additionally, this may allow for easier | |
| 246 // server-side caching. | |
| 247 var now = new Date(); | |
| 248 now.setSeconds(0); | |
| 249 now.setMilliseconds(0); | |
| 250 // convert to seconds because API uses seconds. | |
| 251 var last24hrs = now.getTime()/1000 - 24 * 60 * 60; | |
| 252 | 193 |
| 253 var queryObj = { | 194 var queryObj = JSON.parse(JSON.stringify(this.count_params)); |
| 254 start: [last24hrs], | |
| 255 }; | |
| 256 // ALL_TASKS summary is always the last 24 hours | |
| 257 for (var i = 0; i < ALL_TASKS_SUMMARY.length; i++) { | |
| 258 if (this._all_counts.length < ALL_TASKS_SUMMARY.length) { | |
| 259 this.push("_all_counts", {}); | |
| 260 } | |
| 261 queryObj.state = [ALL_TASKS_SUMMARY[i].name]; | |
| 262 this._getJsonAsyncArr(i, "_all_counts","/api/swarming/v1/tasks/count",
"_busyArr1", | |
| 263 this.auth_headers, queryObj); | |
| 264 } | |
| 265 | |
| 266 queryObj = JSON.parse(JSON.stringify(this.count_params)); | |
| 267 this._getJsonAsync("_selected_exact","/api/swarming/v1/tasks/count","_bu
sy3", | 195 this._getJsonAsync("_selected_exact","/api/swarming/v1/tasks/count","_bu
sy3", |
| 268 this.auth_headers, queryObj); | 196 this.auth_headers, queryObj); |
| 269 | 197 |
| 270 for (var j = 0; j < SELECTED_TASKS_SUMMARY.length; j++) { | 198 for (var j = 0; j < SELECTED_TASKS_SUMMARY.length; j++) { |
| 271 if (this._selected_counts.length < SELECTED_TASKS_SUMMARY.length) { | 199 if (this._selected_counts.length < SELECTED_TASKS_SUMMARY.length) { |
| 272 this.push("_selected_counts", {}); | 200 this.push("_selected_counts", {}); |
| 273 } | 201 } |
| 274 queryObj.state = [SELECTED_TASKS_SUMMARY[j].name]; | 202 queryObj.state = [SELECTED_TASKS_SUMMARY[j].name]; |
| 275 this._getJsonAsyncArr(j, "_selected_counts","/api/swarming/v1/tasks/co
unt","_busyArr2", | 203 this._getJsonAsyncArr(j, "_selected_counts","/api/swarming/v1/tasks/co
unt","_busyArr1", |
| 276 this.auth_headers, queryObj); | 204 this.auth_headers, queryObj); |
| 277 } | 205 } |
| 278 }, | 206 }, |
| 279 | 207 |
| 280 // _makeURL creates a task-list url that keeps the columns and sort requir
ements the same | 208 // _makeURL creates a task-list url that keeps the columns and sort requir
ements the same |
| 281 // while changing which state is represented. The preserveOthers signifies
if other | 209 // while changing which state is represented. |
| 282 // filtering parameters (e.g. tags) should be kept as well. | 210 _makeURL: function(state) { |
| 283 _makeURL: function(state, preserveOthers) { | |
| 284 var fstr = "state:"+state; | 211 var fstr = "state:"+state; |
| 285 var cp = this.count_params; | 212 var cp = this.count_params; |
| 286 var params = { | 213 var params = { |
| 287 s: [this.sort], | 214 s: [this.sort], |
| 288 c: this.columns, | 215 c: this.columns, |
| 289 f: [], | 216 f: [], |
| 290 } | 217 } |
| 291 if (cp.start && cp.start[0]) { | 218 if (cp.start && cp.start[0]) { |
| 292 // timestamps gleaned from count_params are in seconds, so we convert
back to ms. | 219 // timestamps gleaned from count_params are in seconds, so we convert
back to ms. |
| 293 params.st = [cp.start[0] + "000"]; | 220 params.st = [cp.start[0] + "000"]; |
| 294 } | 221 } |
| 295 if (cp.end && cp.end[0]) { | 222 if (cp.end && cp.end[0]) { |
| 296 // timestamps gleaned from count_params are in seconds, so we convert
back to ms. | 223 // timestamps gleaned from count_params are in seconds, so we convert
back to ms. |
| 297 params.et = [cp.end[0] + "000"]; | 224 params.et = [cp.end[0] + "000"]; |
| 298 } else { | 225 } else { |
| 299 params.n = [true]; | 226 params.n = [true]; |
| 300 } | 227 } |
| 301 if (state) { | 228 if (state) { |
| 302 params.f.push(fstr); | 229 params.f.push(fstr); |
| 303 } | 230 } |
| 304 if (preserveOthers && cp.tags) { | 231 if (cp.tags) { |
| 305 cp.tags.forEach(function(t){ | 232 cp.tags.forEach(function(t){ |
| 306 params.f.push(t); | 233 params.f.push(t); |
| 307 }); | 234 }); |
| 308 } | 235 } |
| 309 if (!preserveOthers) { | |
| 310 params.n = [true]; | |
| 311 } | |
| 312 | |
| 313 return window.location.href.split('?')[0] + '?' + sk.query.fromParamSet(
params); | 236 return window.location.href.split('?')[0] + '?' + sk.query.fromParamSet(
params); |
| 314 }, | 237 }, |
| 315 | 238 |
| 316 }); | 239 }); |
| 317 })(); | 240 })(); |
| 318 </script> | 241 </script> |
| 319 </dom-module> | 242 </dom-module> |
| OLD | NEW |