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

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: Build using new skia-common-js 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..f5478e09ebda6c8892889edc19c1a2ef3eeed2ff
--- /dev/null
+++ b/appengine/swarming/elements/res/imp/common/error-toast.html
@@ -0,0 +1,49 @@
+<!--
+ 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.",
jcgregorio 2016/09/06 20:40:56 Document duration in the example.
kjlubick 2016/09/07 12:00:20 Done.
+ }
+
+ Attributes:
+ None
+ Events:
+ Methods:
+-->
+<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