Polymer .9: Notifications
parent
5baf16ad6e
commit
de243855c4
|
@ -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
|
|
@ -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}}'>
|
||||
|
|
Loading…
Reference in New Issue