Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!-- | |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | |
| 4 that can be found in the LICENSE file. | |
| 5 | |
| 6 This in an HTML Import-able file that contains the definition | |
| 7 of the following elements: | |
| 8 | |
| 9 <bot-page-data> | |
| 10 | |
| 11 This makes calls authenticated with Oauth 2 to the swarming apis. It parses | |
|
stephana
2016/09/01 13:25:39
Based on our recent discussion about JS convention
kjlubick
2016/09/01 14:32:29
The Skia element status-sk originally had everythi
stephana
2016/09/01 14:48:35
Acknowledged.
| |
| 12 that data into usable data structures. | |
| 13 | |
| 14 Properties: | |
| 15 busy: Boolean, if we are fetching any data from the server. | |
| 16 bot: Object, The information about the bot. See swarming_rpcs.py#BotInfo | |
| 17 for all relevent fields. | |
| 18 events: Array<Object>, The most recent events that pertain to this bot. | |
| 19 Contains the following fields: "event_type", "message", "ts" (timestamp) , | |
|
stephana
2016/09/01 13:25:39
If it's easily available, it would be helpful to j
kjlubick
2016/09/01 14:32:29
I think they are a bit long to inline. If you run
stephana
2016/09/01 14:48:35
Acknowledged.
| |
| 20 "quarantined", "version". | |
| 21 tasks: Array<Object>, The most recent tasks done by this bot. | |
| 22 Contains the following fields: "abandoned_ts", "bot_version", "duration" , | |
| 23 "failure", "internal_failure", "modified_ts", "name", "started_ts", | |
| 24 "state", "task_id", "try_number". | |
| 25 | |
| 26 Methods: | |
| 27 request(): Force a fetch of the data. This happens automatically when | |
| 28 auth_headers is set or bot_id is changed. | |
| 29 | |
| 30 Events: | |
| 31 None. | |
| 32 --> | |
| 33 | |
| 34 | |
| 35 <link rel="import" href="/res/imp/common/common-behavior.html"> | |
| 36 | |
| 37 <dom-module id="bot-page-data"> | |
| 38 <script> | |
| 39 (function(){ | |
| 40 | |
| 41 Polymer({ | |
| 42 is: 'bot-page-data', | |
| 43 | |
| 44 behaviors: [ | |
| 45 SwarmingBehaviors.CommonBehavior, | |
| 46 ], | |
| 47 | |
| 48 properties: { | |
| 49 // inputs | |
| 50 auth_headers: { | |
| 51 type: Object, | |
| 52 }, | |
| 53 bot_id: { | |
| 54 type: String, | |
| 55 }, | |
| 56 | |
| 57 // outputs | |
| 58 busy: { | |
| 59 type: Boolean, | |
| 60 computed: "_or(_busy1,_busy2,_busy3)", | |
| 61 notify: true, | |
| 62 }, | |
| 63 bot: { | |
| 64 type: Object, | |
| 65 computed: "_parseBot(_bot)", | |
| 66 notify: true, | |
| 67 }, | |
| 68 events: { | |
| 69 type: Array, | |
| 70 computed: "_parseEvents(_events)", | |
| 71 notify: true, | |
| 72 }, | |
| 73 tasks: { | |
| 74 type: Array, | |
| 75 computed: "_parseTasks(_tasks)", | |
| 76 notify: true, | |
| 77 }, | |
| 78 | |
| 79 // private | |
| 80 _busy1: { | |
| 81 type: Boolean, | |
| 82 value: false | |
| 83 }, | |
| 84 _busy2: { | |
| 85 type: Boolean, | |
| 86 value: false | |
| 87 }, | |
| 88 _busy3: { | |
| 89 type: Boolean, | |
| 90 value: false | |
| 91 }, | |
| 92 _bot: { | |
| 93 type: Object, | |
| 94 }, | |
| 95 _events: { | |
| 96 type: Object, | |
| 97 }, | |
| 98 _tasks: { | |
| 99 type: Object, | |
| 100 }, | |
| 101 }, | |
| 102 | |
| 103 observers: [ | |
| 104 "request(auth_headers,bot_id)", | |
| 105 ], | |
| 106 | |
| 107 request: function(){ | |
| 108 if (!this.bot_id || !this.auth_headers) { | |
| 109 console.log("bot_id and auth_headers can't be empty"); | |
| 110 return; | |
| 111 } | |
| 112 var baseUrl = "/_ah/api/swarming/v1/bot/"+this.bot_id; | |
| 113 this._getJsonAsync("_bot", baseUrl + "/get", | |
| 114 "_busy1", this.auth_headers); | |
| 115 // We limit the fields on these two queries to make them faster. | |
| 116 this._getJsonAsync("_events", | |
| 117 baseUrl + "/events?fields=items(event_type%2Cmessage%2Cquarantined%2Ct ask_id%2Cts%2Cversion)", | |
| 118 "_busy2", this.auth_headers); | |
| 119 this._getJsonAsync("_tasks", | |
| 120 baseUrl + "/tasks?fields=items(abandoned_ts%2Cbot_version%2Ccompleted_ ts%2Cduration%2Cexit_code%2Cfailure%2Cinternal_failure%2Cmodified_ts%2Cname%2Cst arted_ts%2Cstate%2Ctask_id%2Ctry_number)", | |
| 121 "_busy3", this.auth_headers); | |
| 122 }, | |
| 123 | |
| 124 _parseBot: function(bot) { | |
| 125 if (!bot) { | |
| 126 return {}; | |
| 127 } | |
| 128 return bot; | |
| 129 }, | |
| 130 | |
| 131 _parseEvents: function(events) { | |
| 132 if (!events || !events.items) { | |
| 133 return []; | |
| 134 } | |
| 135 return events.items; | |
| 136 }, | |
| 137 | |
| 138 _parseTasks: function(tasks) { | |
| 139 if (!tasks || !tasks.items) { | |
| 140 return []; | |
| 141 } | |
| 142 return tasks.items; | |
| 143 } | |
| 144 | |
| 145 }); | |
| 146 })(); | |
| 147 </script> | |
| 148 </dom-module> | |
| OLD | NEW |