Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: appengine/swarming/elements/res/imp/taskpage/task-page-data.html

Issue 2350853004: Make the buttons on task-page work (Closed) Base URL: git@github.com:luci/luci-py@task-page2
Patch Set: Fix promses Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <task-page-data> 9 <task-page-data>
10 10
(...skipping 11 matching lines...) Expand all
22 name, id, created_ts, tags, and dimensions. See the sample data in 22 name, id, created_ts, tags, and dimensions. See the sample data in
23 task-request-demo.json for a full rundown. 23 task-request-demo.json for a full rundown.
24 result: Object, the result or progress of the task. This contains informatio n such as the 24 result: Object, the result or progress of the task. This contains informatio n such as the
25 modified_ts, duration, exit_code, information about the bot that picked 25 modified_ts, duration, exit_code, information about the bot that picked
26 up the task, etc. See the sample data in task-result-demo.json for a 26 up the task, etc. See the sample data in task-result-demo.json for a
27 full rundown. 27 full rundown.
28 stdout: String, the raw output of the task, if any. See 28 stdout: String, the raw output of the task, if any. See
29 task-stdout-demo.json for a full rundown. 29 task-stdout-demo.json for a full rundown.
30 30
31 Methods: 31 Methods:
32 request(): Force a fetch of the data. This happens automatically when 32 reload(): Force a fetch of the data. This happens automatically when
33 auth_headers is set or task_id is changed. 33 auth_headers is set or task_id is changed.
34 reloadStdout(): Force a fetch of just the stdout
34 35
35 Events: 36 Events:
36 None. 37 None.
37 --> 38 -->
38 39
39 40
40 <link rel="import" href="/res/imp/common/common-behavior.html"> 41 <link rel="import" href="/res/imp/common/common-behavior.html">
41 <link rel="import" href="/res/imp/common/task-behavior.html"> 42 <link rel="import" href="/res/imp/common/task-behavior.html">
42 43
43 <dom-module id="task-page-data"> 44 <dom-module id="task-page-data">
(...skipping 13 matching lines...) Expand all
57 behaviors: [ 58 behaviors: [
58 SwarmingBehaviors.CommonBehavior, 59 SwarmingBehaviors.CommonBehavior,
59 SwarmingBehaviors.TaskBehavior, 60 SwarmingBehaviors.TaskBehavior,
60 ], 61 ],
61 62
62 properties: { 63 properties: {
63 // inputs 64 // inputs
64 auth_headers: { 65 auth_headers: {
65 type: Object, 66 type: Object,
66 }, 67 },
68
67 task_id: { 69 task_id: {
68 type: String, 70 type: String,
69 }, 71 },
70 72
71 // outputs 73 // outputs
72 busy: { 74 busy: {
73 type: Boolean, 75 type: Boolean,
74 computed: "_or(_busy1,_busy2,_busy3)", 76 computed: "_or(_busy1,_busy2,_busy3)",
75 notify: true, 77 notify: true,
76 }, 78 },
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 122
121 reload: function(){ 123 reload: function(){
122 if (!this.task_id || !this.auth_headers) { 124 if (!this.task_id || !this.auth_headers) {
123 console.log("task_id and auth_headers can't be empty"); 125 console.log("task_id and auth_headers can't be empty");
124 return; 126 return;
125 } 127 }
126 if (lastRequest) { 128 if (lastRequest) {
127 this.cancelAsync(lastRequest); 129 this.cancelAsync(lastRequest);
128 } 130 }
129 131
132 var baseUrl = "/_ah/api/swarming/v1/task/" + this.task_id;
130 lastRequest = this.async(function(){ 133 lastRequest = this.async(function(){
131 lastRequest = undefined; 134 lastRequest = undefined;
132 var baseUrl = "/_ah/api/swarming/v1/task/"+this.task_id;
133 this._getJsonAsync("_request", baseUrl + "/request", 135 this._getJsonAsync("_request", baseUrl + "/request",
134 "_busy1", this.auth_headers); 136 "_busy1", this.auth_headers);
135 this._getJsonAsync("_result", 137 this._getJsonAsync("_result",
136 baseUrl + "/result?include_performance_stats=true", 138 baseUrl + "/result?include_performance_stats=true",
137 "_busy2", this.auth_headers); 139 "_busy2", this.auth_headers);
138 this._getJsonAsync("_stdout", baseUrl + "/stdout", 140 this.reloadStdout();
139 "_busy3", this.auth_headers);
140 }, TASK_ID_DEBOUNCE_MS); 141 }, TASK_ID_DEBOUNCE_MS);
141 }, 142 },
142 143
143 _parseRequest: function(request) { 144 _parseRequest: function(request) {
144 if (!request) { 145 if (!request) {
145 return {}; 146 return {};
146 } 147 }
147 request.tagMap = {}; 148 request.tagMap = {};
148 request.tags = request.tags || []; 149 request.tags = request.tags || [];
149 request.tags.forEach(function(tag) { 150 request.tags.forEach(function(tag) {
150 var split = tag.split(":", 1) 151 var split = tag.split(":", 1)
151 var key = split[0]; 152 var key = split[0];
152 var rest = tag.substring(key.length + 1); 153 var rest = tag.substring(key.length + 1);
153 request.tagMap[key] = rest; 154 request.tagMap[key] = rest;
154 }); 155 });
155 156
156 TIMES.forEach(function(time) { 157 TIMES.forEach(function(time) {
157 if (request[time]) { 158 if (request[time]) {
158 request[time] = new Date(request[time]); 159 request[time] = new Date(request[time]);
159 request["human_"+time] = sk.human.localeTime(request[time]); 160 request["human_"+time] = sk.human.localeTime(request[time]);
160 } 161 }
161 }); 162 });
162 // request.properties.dimensions
163 request.properties = request.properties || {};
164 if (request.properties.dimensions) {
165 request.properties.dimensions.forEach(function(dim){
166 if (swarming.alias.has(dim.key)) {
167 dim.value = swarming.alias.apply(dim.value, dim.key);
168 }
169 })
170 }
171 return request; 163 return request;
172 }, 164 },
173 165
174 _parseResult: function(result) { 166 _parseResult: function(result) {
175 if (!result) { 167 if (!result) {
176 return {}; 168 return {};
177 } 169 }
178 var now = new Date(); 170 var now = new Date();
179 TIMES.forEach(function(time) { 171 TIMES.forEach(function(time) {
180 if (result[time]) { 172 if (result[time]) {
181 result[time] = new Date(result[time]); 173 result[time] = new Date(result[time]);
182 result["human_"+time] = sk.human.localeTime(result[time]); 174 result["human_"+time] = sk.human.localeTime(result[time]);
183 } 175 }
184 }); 176 });
185 // Running tasks have no duration set, so we can figure it out. 177 // Running tasks have no duration set, so we can figure it out.
186 if (!result.duration && result.state === this.RUNNING && result.started_ ts){ 178 if (!result.duration && result.state === this.RUNNING && result.started_ ts){
187 result.duration = (now - result.started_ts) / 1000; 179 result.duration = (now - result.started_ts) / 1000;
188 } 180 }
189 // Make the duration human readable 181 // Make the duration human readable
190 if (result.duration){ 182 if (result.duration){
191 result.human_duration = this._humanDuration(result.duration); 183 result.human_duration = this._humanDuration(result.duration);
192 } 184 }
193 // result.bot_dimensions
194 if (result.bot_dimensions) {
195 result.bot_dimensions.forEach(function(dim){
196 if (swarming.alias.has(dim.key)) {
197 // dim.value is an array
198 dim.value.forEach(function(v, i){
199 dim.value[i] = swarming.alias.apply(v, dim.key);
200 });
201 }
202 })
203 }
204 return result; 185 return result;
205 }, 186 },
206 187
207 _parseStdout: function(stdout) { 188 _parseStdout: function(stdout) {
208 if (!stdout || !stdout.output) { 189 if (!stdout || !stdout.output) {
209 return ""; 190 return "[No output yet]";
210 } 191 }
211 return stdout.output; 192 return stdout.output;
212 } 193 },
194
195 reloadStdout: function() {
196 this._getJsonAsync("_stdout", "/_ah/api/swarming/v1/task/" +
197 this.task_id + "/stdout", "_busy3", this.auth_headers);
198 },
213 199
214 }); 200 });
215 })(); 201 })();
216 </script> 202 </script>
217 </dom-module> 203 </dom-module>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698