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

Unified Diff: appengine/swarming/elements/res/js/common.js

Issue 2306103002: Add aliases to bot-page and refactor duplicated code (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@fix-buttons
Patch Set: rebase again 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/elements/res/js/alias.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/elements/res/js/common.js
diff --git a/appengine/swarming/elements/res/js/common.js b/appengine/swarming/elements/res/js/common.js
index f0639e6f525523c2cad3df582871e665e0b824c8..5789dac0d74e85c5570a03ba0ff48c5e5e0b9c35 100644
--- a/appengine/swarming/elements/res/js/common.js
+++ b/appengine/swarming/elements/res/js/common.js
@@ -50,5 +50,20 @@ this.swarming = this.swarming || function() {
return String(a).localeCompare(b);
};
+ // postWithToast makes a post request and updates the error-toast
+ // element with the response, regardless of failure. See error-toast.html
+ // for more information.
+ swarming.postWithToast = function(url, msg, auth_headers) {
+ // Keep toast displayed until we hear back from the request.
+ sk.errorMessage(msg, 0);
+
+ sk.request("POST", url, undefined, auth_headers).then(function(response) {
+ sk.errorMessage("Request sent. Response: "+response, 3000);
+ }).catch(function(reason) {
+ console.log("Request failed", reason);
+ sk.errorMessage("Request failed. Reason: "+reason, 5000);
+ });
+ }
+
return swarming;
}();
« no previous file with comments | « appengine/swarming/elements/res/js/alias.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698