| 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-page-data> | 9     <bot-page-data> | 
| 10 | 10 | 
| 11   This makes calls authenticated with Oauth 2 to the swarming apis.  It parses | 11   This makes calls authenticated with Oauth 2 to the swarming apis.  It parses | 
| 12   that data into usable data structures. | 12   that data into usable data structures. | 
| 13 | 13 | 
| 14   Properties: | 14   Properties: | 
| 15     busy: Boolean, if we are fetching any data from the server. | 15     // input | 
|  | 16     auth_headers: Object, the OAuth2 header to include in the request.  This | 
|  | 17         should come from swarming-app. | 
|  | 18     bot_id: String, the id of the bot to fetch data on. | 
|  | 19     // output | 
| 16     bot: Object, The information about the bot. See swarming_rpcs.py#BotInfo | 20     bot: Object, The information about the bot. See swarming_rpcs.py#BotInfo | 
| 17         for all relevent fields. | 21         for all relevent fields. | 
|  | 22     busy: Boolean, if we are fetching any data from the server. | 
| 18     events: Array<Object>, The most recent events that pertain to this bot. | 23     events: Array<Object>, The most recent events that pertain to this bot. | 
| 19         Contains the following fields: "event_type", "message", "ts" (timestamp)
     , | 24         Contains the following fields: "event_type", "message", "ts" (timestamp)
     , | 
| 20         "quarantined", "version". | 25         "quarantined", "version". | 
| 21     tasks: Array<Object>, The most recent tasks done by this bot. | 26     tasks: Array<Object>, The most recent tasks done by this bot. | 
| 22         Contains the following fields: "abandoned_ts", "bot_version", "duration"
     , | 27         Contains the following fields: "abandoned_ts", "bot_version", "duration"
     , | 
| 23         "failure", "internal_failure", "modified_ts", "name", "started_ts", | 28         "failure", "internal_failure", "modified_ts", "name", "started_ts", | 
| 24         "state", "task_id", "try_number". | 29         "state", "task_id", "try_number". | 
| 25 | 30 | 
| 26   Methods: | 31   Methods: | 
| 27     request(): Force a fetch of the data. This happens automatically when | 32     request(): Force a fetch of the data. This happens automatically when | 
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 220         tasks.forEach(function(task){ | 225         tasks.forEach(function(task){ | 
| 221           // Do any preprocessing here | 226           // Do any preprocessing here | 
| 222           TASK_TIMES.forEach(function(time) { | 227           TASK_TIMES.forEach(function(time) { | 
| 223             if (task[time]) { | 228             if (task[time]) { | 
| 224               task[time] = new Date(task[time]); | 229               task[time] = new Date(task[time]); | 
| 225               task["human_"+time] = formatDate(task[time]); | 230               task["human_"+time] = formatDate(task[time]); | 
| 226             } | 231             } | 
| 227           }); | 232           }); | 
| 228 | 233 | 
| 229           if (task.duration) { | 234           if (task.duration) { | 
| 230             task.human_duration = sk.human.strDuration(task.duration) || "0s"; | 235             task.human_duration = this._humanDuration(task.duration); | 
| 231           } else { | 236           } else { | 
| 232             var end = task.completed_ts || task.abandoned_ts || task.modified_ts
      || new Date(); | 237             var end = task.completed_ts || task.abandoned_ts || task.modified_ts
      || new Date(); | 
| 233             task.human_duration = this._timeDiffExact(task.started_ts, end); | 238             task.human_duration = this._timeDiffExact(task.started_ts, end); | 
| 234           } | 239           } | 
| 235 | 240 | 
| 236           task.state = task.state || "UNKNOWN"; | 241           task.state = task.state || "UNKNOWN"; | 
| 237           if (task.state === "COMPLETED") { | 242           if (task.state === "COMPLETED") { | 
| 238             if (task.failure) { | 243             if (task.failure) { | 
| 239               task.state = "FAILURE"; | 244               task.state = "FAILURE"; | 
| 240             } else { | 245             } else { | 
| 241               task.state = "SUCCESS"; | 246               task.state = "SUCCESS"; | 
| 242             } | 247             } | 
| 243           } | 248           } | 
| 244 | 249 | 
| 245         }.bind(this)); | 250         }.bind(this)); | 
| 246 | 251 | 
| 247         // Sort the most recent tasks first. | 252         // Sort the most recent tasks first. | 
| 248         tasks.sort(function(a,b) { | 253         tasks.sort(function(a,b) { | 
| 249           return b.started_ts - a.started_ts; | 254           return b.started_ts - a.started_ts; | 
| 250         }); | 255         }); | 
| 251 | 256 | 
| 252         return tasks; | 257         return tasks; | 
| 253       } | 258       } | 
| 254 | 259 | 
| 255     }); | 260     }); | 
| 256   })(); | 261   })(); | 
| 257   </script> | 262   </script> | 
| 258 </dom-module> | 263 </dom-module> | 
| OLD | NEW | 
|---|