| 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;
|
| }();
|
|
|