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

Unified Diff: appengine/swarming/elements/res/imp/common/error-toast.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: 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/res/imp/common/error-toast.html
diff --git a/appengine/swarming/elements/res/imp/common/error-toast.html b/appengine/swarming/elements/res/imp/common/error-toast.html
new file mode 100644
index 0000000000000000000000000000000000000000..5abd0eaef24340b1b56ec0fe93a5e5cd023095c1
--- /dev/null
+++ b/appengine/swarming/elements/res/imp/common/error-toast.html
@@ -0,0 +1,56 @@
+<!--
+ Copyright 2016 The LUCI Authors. All rights reserved.
+ Use of this source code is governed under the Apache License, Version 2.0
+ that can be found in the LICENSE file.
+
+ Listens for 'error-sk' events that bubble up to the document
+ and displays them.
+
+ The 'error-sk' event should have 'detail' of the form:
+
+ {
+ message: "The error message to display goes here.",
+ duration: Integer, the number of ms to display or 0 for indefinitely.
+ Defaults to 10000 (10s)
+ }
+
+ Attributes:
+ None
+
+ Events:
+ None
+
+ Methods:
+ None
+-->
+<link rel="import" href="/res/imp/bower_components/paper-toast/paper-toast.html" />
+
+<dom-module id="error-toast">
+ <template>
+ <paper-toast id=toast></paper-toast>
+ </template>
+</dom-module>
+
+<script>
+ Polymer({
+ is: "error-toast",
+
+ ready: function() {
+ document.addEventListener('error-sk', function(e) {
+ this.$.toast.close();
+ if (e.detail.message) {
+ this.$.toast.text = e.detail.message;
+ var duration = 10000;
+ // duration = 0 is a valid input for "keep open indefinitely".
+ if (e.detail.duration !== undefined) {
+ duration = e.detail.duration;
+ }
+ this.$.toast.duration = duration;
+ this.$.toast.show();
+ } else {
+ console.log("Empty message?", e);
+ }
+ }.bind(this));
+ },
+ });
+</script>

Powered by Google App Engine
This is Rietveld 408576698