| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 This in an HTML Import-able file that contains the definition |
| 3 of the following elements: |
| 4 |
| 5 <task-disambiguation> |
| 6 |
| 7 This element shows a table with all runs of a given task id. |
| 8 |
| 9 It assumes that a task id ends with an integer, where 0 represents |
| 10 a task summary and non-zero integers represent attempts at a task. |
| 11 |
| 12 For example, task "abc" might have had its host die (BOT_DIED), and thus |
| 13 was silently retried. The task id "abc1" would represent the first attempt |
| 14 (BOT_DIED), "abc2" represents the second attempt (SUCCESS) and "abc0" |
| 15 repreesents the summary of these two tasks. |
| 16 |
| 17 This element assumes the client made a request for a task summary (ending in |
| 18 0) and has passed in the task id and the object containing the task.result |
| 19 API call pertaining to that task summary. From this object, the "try_number" |
| 20 is used to infer the total number of silent retires. |
| 21 |
| 22 A number of XHR requests equal to the number of attempts, minus one (the one |
| 23 passed in), is made and the state and bot id of those is displayed. |
| 24 |
| 25 Properties: |
| 26 // input |
| 27 auth_headers: Object, the OAuth2 header to include in the request. This |
| 28 should come from swarming-app. |
| 29 summary_result: Object, the result of the task.result API call pertaining |
| 30 to task_id; |
| 31 task_id: String, the id of the task summary. Should end in 0. |
| 32 |
| 33 // output |
| 34 busy: A boolean represneting if any XHR requests are in flight. |
| 35 |
| 36 Methods: |
| 37 None. |
| 38 |
| 39 Events: |
| 40 None. |
| 41 --> |
| 42 |
| 43 <link rel="import" href="/res/imp/common/single-page-style.html"> |
| 44 <link rel="import" href="/res/imp/common/swarming-app.html"> |
| 45 <link rel="import" href="/res/imp/common/task-behavior.html"> |
| 46 |
| 47 <link rel="import" href="/res/imp/common/common-behavior.html"> |
| 48 |
| 49 <dom-module id="task-disambiguation"> |
| 50 <template> |
| 51 <style include="swarming-app-style single-page-style task-style"> |
| 52 </style> |
| 53 |
| 54 <table> |
| 55 <thead> |
| 56 <tr> |
| 57 <th>Try ID</th> |
| 58 <th>Bot ID</th> |
| 59 <th>Status</th> |
| 60 </tr> |
| 61 </thead> |
| 62 <tbody> |
| 63 <template id="result_list" is="dom-repeat" |
| 64 items="[[_results]]" as="result" observe="task_id bot_id state"> |
| 65 <tr> |
| 66 <td> |
| 67 <a href$="[[_taskLink(result.task_id,'true')]]"> |
| 68 [[result.task_id]] |
| 69 </a> |
| 70 </td> |
| 71 <td> |
| 72 <a href$="[[_botLink(result.bot_id)]]"> |
| 73 [[result.bot_id]] |
| 74 </a> |
| 75 </td> |
| 76 <td class$="[[_stateClass(result)]]">[[state(result)]]</td> |
| 77 </tr> |
| 78 </template> |
| 79 </tbody> |
| 80 </table> |
| 81 |
| 82 </template> |
| 83 <script> |
| 84 Polymer({ |
| 85 is: 'task-disambiguation', |
| 86 |
| 87 behaviors: [ |
| 88 SwarmingBehaviors.CommonBehavior, |
| 89 SwarmingBehaviors.TaskBehavior, |
| 90 ], |
| 91 |
| 92 properties: { |
| 93 auth_headers: { |
| 94 type: Object, |
| 95 }, |
| 96 summary_result: { |
| 97 type: Object, |
| 98 }, |
| 99 task_id: { |
| 100 type: String, |
| 101 }, |
| 102 |
| 103 busy: { |
| 104 type: Boolean, |
| 105 value: false, |
| 106 notify: true, |
| 107 }, |
| 108 |
| 109 |
| 110 _busyArr: { |
| 111 type: Array, |
| 112 value: function() { |
| 113 return []; |
| 114 }, |
| 115 }, |
| 116 |
| 117 _results: { |
| 118 type: Array, |
| 119 value: function(){ |
| 120 return []; |
| 121 } |
| 122 } |
| 123 }, |
| 124 |
| 125 observers: [ |
| 126 "_fetchRest(auth_headers,task_id,summary_result)", |
| 127 "_computeBusy(_busyArr.*)", |
| 128 ], |
| 129 |
| 130 _computeBusy: function() { |
| 131 for (var i = 0; i< this._busyArr.length; i++){ |
| 132 if (this._busyArr[i].status) { |
| 133 return true; |
| 134 } |
| 135 } |
| 136 return false; |
| 137 }, |
| 138 |
| 139 _fetchRest: function(authHeaders, taskId, summaryResult) { |
| 140 if (!authHeaders || !taskId || !summaryResult) { |
| 141 return; |
| 142 } |
| 143 var numTries = summaryResult.try_number; |
| 144 |
| 145 // reset all previous info |
| 146 this.set("_busyArr", []); |
| 147 this.set("_results", []); |
| 148 var baseTaskId = taskId.substring(0, taskId.length - 1); |
| 149 var baseUrl = "/api/swarming/v1/task/"; |
| 150 |
| 151 for (var i = 0; i < numTries -1; i++) { |
| 152 var id = baseTaskId + (i + 1); |
| 153 this.splice("_busyArr", i , 0, {}); |
| 154 this.splice("_results", i , 0, {task_id:id}); |
| 155 this._getJsonAsyncArr(i, "_results", baseUrl + id +"/result", "_busyAr
r", authHeaders); |
| 156 } |
| 157 summaryResult.task_id = baseTaskId+numTries; |
| 158 this.splice("_results", numTries -1 , 1, summaryResult); |
| 159 } |
| 160 |
| 161 }); |
| 162 </script> |
| 163 </dom-module> |
| OLD | NEW |