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

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

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, 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/imp/taskpage/task-page-demo.html ('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 64296f8d578a330d7b478700263b4a106d7118f0..61f4a34dd605e5181a5faf6917ee4fbae1238e16 100644
--- a/appengine/swarming/elements/res/js/common.js
+++ b/appengine/swarming/elements/res/js/common.js
@@ -53,16 +53,23 @@ this.swarming = this.swarming || function() {
// 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) {
+ // for more information. The body param should be an object or undefined.
+ swarming.postWithToast = function(url, msg, auth_headers, body) {
// Keep toast displayed until we hear back from the request.
sk.errorMessage(msg, 0);
- sk.request("POST", url, undefined, auth_headers).then(function(response) {
+ auth_headers["content-type"] = "application/json; charset=UTF-8";
+ if (body) {
+ body = JSON.stringify(body);
+ }
+
+ return sk.request("POST", url, body, auth_headers).then(function(response) {
sk.errorMessage("Request sent. Response: "+response, 3000);
+ return response;
}).catch(function(reason) {
console.log("Request failed", reason);
sk.errorMessage("Request failed. Reason: "+reason, 5000);
+ return Promise.reject(reason);
});
}
« no previous file with comments | « appengine/swarming/elements/res/imp/taskpage/task-page-demo.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698