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

Side by Side Diff: appengine/swarming/elements/res/js/common.js

Issue 2302973002: Refactor post requests, implement bot cancel/terminate (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@basic-layout
Patch Set: Address nits Created 4 years, 3 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
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 this.swarming = this.swarming || function() { 5 this.swarming = this.swarming || function() {
6 6
7 var swarming = {}; 7 var swarming = {};
8 8
9 swarming.stableSort = function(arr, comp) { 9 swarming.stableSort = function(arr, comp) {
10 if (!arr || !comp) { 10 if (!arr || !comp) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 swarming.naturalCompare = function(a, b) { 43 swarming.naturalCompare = function(a, b) {
44 // Try numeric, aka "natural" sort and use it if ns is not NaN. 44 // Try numeric, aka "natural" sort and use it if ns is not NaN.
45 // Javascript will try to corece these to numbers or return NaN. 45 // Javascript will try to corece these to numbers or return NaN.
46 var ns = a - b; 46 var ns = a - b;
47 if (!isNaN(ns)) { 47 if (!isNaN(ns)) {
48 return ns; 48 return ns;
49 } 49 }
50 return String(a).localeCompare(b); 50 return String(a).localeCompare(b);
51 }; 51 };
52 52
53 // postWithToast makes a post request and updates the error-toast
54 // element with the response, regardless of failure. See error-toast.html
55 // for more information.
56 swarming.postWithToast = function(url, msg, auth_headers) {
57 // Keep toast displayed until we hear back from the request.
58 sk.errorMessage(msg, 0);
59
60 sk.request("POST", url, undefined, auth_headers).then(function(response) {
61 sk.errorMessage("Request sent. Response: "+response, 3000);
62 }).catch(function(reason) {
63 console.log("Request failed", reason);
64 sk.errorMessage("Request failed. Reason: "+reason, 5000);
65 });
66 }
67
53 return swarming; 68 return swarming;
54 }(); 69 }();
OLDNEW
« no previous file with comments | « appengine/swarming/elements/res/imp/tasklist/task-list.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698