Polymer .9: Notifications

pull/132/head
Paulus Schoutsen 2015-05-20 22:41:58 -07:00
parent 5baf16ad6e
commit de243855c4
3 changed files with 34 additions and 24 deletions

View File

@ -1,37 +1,47 @@
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/paper-toast/paper-toast.html">
<polymer-element name="ha-notifications">
<dom-module id="ha-notifications">
<style>
paper-toast {
z-index: 1;
}
</style>
<template>
<paper-toast id="toast" role="alert" text=""></paper-toast>
<paper-toast id="toast" text='{{text}}'></paper-toast>
</template>
<script>
var storeListenerMixIn = window.hass.storeListenerMixIn;
</dom-module>
Polymer(Polymer.mixin({
lastId: null,
<script>
(function() {
Polymer({
is: 'ha-notifications',
attached: function() {
this.listenToStores(true);
},
behaviors: [StoreListenerBehavior],
detached: function() {
this.stopListeningToStores();
properties: {
text: {
type: String,
value: '',
},
lastId: {
type: Number,
},
},
notificationStoreChanged: function(notificationStore) {
if (notificationStore.hasNewNotifications(this.lastId)) {
var toast = this.$.toast;
var notification = notificationStore.lastNotification;
if (notification) {
this.lastId = notification.id;
toast.text = notification.message;
toast.show();
}
this.lastId = notification.id;
this.text = notification.message;
this.$.toast.show();
}
},
}, storeListenerMixIn));
</script>
</polymer-element>
});
})();
</script>

@ -1 +1 @@
Subproject commit dd4cefc7af348dd9a9cfbc99094b73a7ed128621
Subproject commit 015edf9c28a63122aa8f6bc153f0c0ddfaad1caa

View File

@ -16,8 +16,8 @@
<link rel="import" href="../layouts/partial-dev-fire-event.html">
<link rel="import" href="../layouts/partial-dev-set-state.html">
<!--<link rel="import" href="../components/ha-notifications.html">
<link rel="import" href="../components/ha-modals.html"> -->
<link rel="import" href="../components/ha-notifications.html">
<!--<link rel="import" href="../components/ha-modals.html"> -->
<link rel="import" href="../components/stream-status.html">
<dom-module is="home-assistant-main">
@ -56,7 +56,7 @@
<template>
<!-- <ha-notifications></ha-notifications> -->
<ha-notifications></ha-notifications>
<!-- <ha-modals></ha-modals> -->
<paper-drawer-panel id="drawer" narrow='{{narrow}}'>