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

Unified Diff: appengine/swarming/elements/res/imp/common/common-behavior.html

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: rebase 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
Index: appengine/swarming/elements/res/imp/common/common-behavior.html
diff --git a/appengine/swarming/elements/res/imp/common/common-behavior.html b/appengine/swarming/elements/res/imp/common/common-behavior.html
index 76254a1ab1d51fec135169bf19aacd8bab98a269..2c9b21f82291ccd40e65e5b7dcecf1ab33d05574 100644
--- a/appengine/swarming/elements/res/imp/common/common-behavior.html
+++ b/appengine/swarming/elements/res/imp/common/common-behavior.html
@@ -68,6 +68,28 @@
}
return result;
},
+
jcgregorio 2016/09/02 18:31:22 So there's already a similar solution that we have
kjlubick 2016/09/06 13:06:31 I considered using sk.errorMessage, but it doesn't
jcgregorio 2016/09/06 15:16:53 I don't understand, why are you keeping it open?
kjlubick 2016/09/06 15:26:50 It just feels like a better way to communicate wit
jcgregorio 2016/09/06 15:33:32 Yes, or add a parameter to error-toast-sk, either
+ // _postWithToast makes a post request and updates the provided paper-toast
+ // element with the response, regardless of failure.
+ _postWithToast: function(url, toast, auth_headers) {
+ // Keep toast displayed until we hear back from the request.
+ toast.duration = 0;
+ toast.open();
+ sk.request("POST", url, undefined, auth_headers).then(function(response) {
+ toast.close();
+ toast.show({
+ text: "Request sent. Response: "+response,
+ duration: 3000,
+ });
+ }.bind(this)).catch(function(reason) {
+ console.log("Request failed", reason);
+ toast.close();
+ toast.show({
+ text: "Request failed. Reason: "+reason,
+ duration: 3000,
+ });
+ }.bind(this));
+ }
};
})();
</script>

Powered by Google App Engine
This is Rietveld 408576698