mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Polymer .9: Notifications
This commit is contained in:
parent
5baf16ad6e
commit
de243855c4
@ -1,37 +1,47 @@
|
|||||||
<link rel="import" href="../bower_components/polymer/polymer.html">
|
<link rel="import" href="../bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
<link rel="import" href="../bower_components/paper-toast/paper-toast.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>
|
<template>
|
||||||
<paper-toast id="toast" role="alert" text=""></paper-toast>
|
<paper-toast id="toast" text='{{text}}'></paper-toast>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
</dom-module>
|
||||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
|
||||||
|
|
||||||
Polymer(Polymer.mixin({
|
<script>
|
||||||
lastId: null,
|
(function() {
|
||||||
|
Polymer({
|
||||||
|
is: 'ha-notifications',
|
||||||
|
|
||||||
attached: function() {
|
behaviors: [StoreListenerBehavior],
|
||||||
this.listenToStores(true);
|
|
||||||
|
properties: {
|
||||||
|
text: {
|
||||||
|
type: String,
|
||||||
|
value: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
detached: function() {
|
lastId: {
|
||||||
this.stopListeningToStores();
|
type: Number,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
notificationStoreChanged: function(notificationStore) {
|
notificationStoreChanged: function(notificationStore) {
|
||||||
if (notificationStore.hasNewNotifications(this.lastId)) {
|
if (notificationStore.hasNewNotifications(this.lastId)) {
|
||||||
var toast = this.$.toast;
|
|
||||||
var notification = notificationStore.lastNotification;
|
var notification = notificationStore.lastNotification;
|
||||||
|
|
||||||
if (notification) {
|
|
||||||
this.lastId = notification.id;
|
this.lastId = notification.id;
|
||||||
toast.text = notification.message;
|
this.text = notification.message;
|
||||||
toast.show();
|
|
||||||
}
|
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-fire-event.html">
|
||||||
<link rel="import" href="../layouts/partial-dev-set-state.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-notifications.html">
|
||||||
<link rel="import" href="../components/ha-modals.html"> -->
|
<!--<link rel="import" href="../components/ha-modals.html"> -->
|
||||||
<link rel="import" href="../components/stream-status.html">
|
<link rel="import" href="../components/stream-status.html">
|
||||||
|
|
||||||
<dom-module is="home-assistant-main">
|
<dom-module is="home-assistant-main">
|
||||||
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- <ha-notifications></ha-notifications> -->
|
<ha-notifications></ha-notifications>
|
||||||
<!-- <ha-modals></ha-modals> -->
|
<!-- <ha-modals></ha-modals> -->
|
||||||
|
|
||||||
<paper-drawer-panel id="drawer" narrow='{{narrow}}'>
|
<paper-drawer-panel id="drawer" narrow='{{narrow}}'>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user