| 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 <task-list> | 9 <task-list> |
| 10 | 10 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 }, | 325 }, |
| 326 | 326 |
| 327 _cancelTask: function(e) { | 327 _cancelTask: function(e) { |
| 328 var task = e.model.task; | 328 var task = e.model.task; |
| 329 if (!task || !task.task_id) { | 329 if (!task || !task.task_id) { |
| 330 console.log("Missing task info", task); | 330 console.log("Missing task info", task); |
| 331 return | 331 return |
| 332 } | 332 } |
| 333 var id = task.task_id | 333 var id = task.task_id |
| 334 | 334 |
| 335 // Keep toast displayed until we hear back from the cancel. | |
| 336 this.$.toast.duration = 0; | |
| 337 this.$.toast.text="Canceling task " + id; | 335 this.$.toast.text="Canceling task " + id; |
| 338 this.$.toast.open(); | |
| 339 var url = "/_ah/api/swarming/v1/task/" + id +"/cancel"; | 336 var url = "/_ah/api/swarming/v1/task/" + id +"/cancel"; |
| 340 sk.request("POST", url, undefined, this._auth_headers).then(function(res
ponse) { | 337 this._postWithToast(url, this.$.toast, this._auth_headers); |
| 341 this.$.toast.close(); | |
| 342 this.$.toast.show({ | |
| 343 text: "Request sent. Response: "+response, | |
| 344 duration: 3000, | |
| 345 }); | |
| 346 }.bind(this)).catch(function(reason) { | |
| 347 console.log("Cancellation failed", reason); | |
| 348 this.$.toast.close(); | |
| 349 this.$.toast.show({ | |
| 350 text: "Request failed. Reason: "+reason, | |
| 351 duration: 3000, | |
| 352 }); | |
| 353 }.bind(this)); | |
| 354 }, | 338 }, |
| 355 | 339 |
| 356 _tag: function(task, col) { | 340 _tag: function(task, col) { |
| 357 if (!task || !task.tagMap) { | 341 if (!task || !task.tagMap) { |
| 358 return undefined; | 342 return undefined; |
| 359 } | 343 } |
| 360 return task.tagMap[col]; | 344 return task.tagMap[col]; |
| 361 }, | 345 }, |
| 362 | 346 |
| 363 _taskLink: function(taskId) { | 347 _taskLink: function(taskId) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 382 if (state === "RUNNING" || state === "PENDING") { | 366 if (state === "RUNNING" || state === "PENDING") { |
| 383 return "pending"; | 367 return "pending"; |
| 384 } | 368 } |
| 385 return ""; | 369 return ""; |
| 386 } | 370 } |
| 387 | 371 |
| 388 }); | 372 }); |
| 389 })(); | 373 })(); |
| 390 </script> | 374 </script> |
| 391 </dom-module> | 375 </dom-module> |
| OLD | NEW |