mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Notifications are now done via the new store
This commit is contained in:
parent
dcffd102cc
commit
3be8a1ad02
@ -0,0 +1,35 @@
|
||||
<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">
|
||||
<template>
|
||||
<paper-toast id="toast" role="alert" text=""></paper-toast>
|
||||
</template>
|
||||
<script>
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
lastId: null,
|
||||
|
||||
ready: function() {
|
||||
this.listenToStores(true);
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
this.stopListeningToStores();
|
||||
},
|
||||
|
||||
notificationStoreChanged: function(notificationStore) {
|
||||
if (notificationStore.hasNewNotifications(this.lastId)) {
|
||||
var toast = this.$.toast;
|
||||
var notification = notificationStore.getLastNotification();
|
||||
|
||||
this.lastId = notification.id;
|
||||
toast.text = notification.message;
|
||||
toast.show();
|
||||
}
|
||||
},
|
||||
|
||||
}, storeListenerMixIn));
|
||||
</script>
|
||||
</polymer-element>
|
@ -1,4 +1,4 @@
|
||||
<link rel="import" href="./bower_components/paper-toast/paper-toast.html">
|
||||
<link rel="import" href="./bower_components/polymer/polymer.html">
|
||||
|
||||
<link rel="import" href="./dialogs/more-info-dialog.html">
|
||||
|
||||
@ -78,7 +78,6 @@
|
||||
|
||||
<polymer-element name="home-assistant-api" attributes="auth">
|
||||
<template>
|
||||
<paper-toast id="toast" role="alert" text=""></paper-toast>
|
||||
<more-info-dialog id="moreInfoDialog"></more-info-dialog>
|
||||
</template>
|
||||
<script>
|
||||
@ -88,11 +87,6 @@
|
||||
|
||||
dispatcher.register(function(payload) {
|
||||
switch (payload.actionType) {
|
||||
case constants.ACTION_SHOW_TOAST:
|
||||
this.$.toast.text = payload.message;
|
||||
this.$.toast.show();
|
||||
break;
|
||||
|
||||
case uiActions.ACTION_SHOW_DIALOG_MORE_INFO:
|
||||
state = getState(payload.entityId);
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
<link rel="import" href="../layouts/partial-dev-call-service.html">
|
||||
<link rel="import" href="../layouts/partial-dev-set-state.html">
|
||||
|
||||
<link rel="import" href="../components/ha-notifications.html">
|
||||
<link rel="import" href="../components/stream-status.html">
|
||||
|
||||
<polymer-element name="home-assistant-main">
|
||||
@ -64,6 +65,8 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<ha-notifications></ha-notifications>
|
||||
|
||||
<core-drawer-panel id="drawer" on-core-responsive-change="{{responsiveChanged}}">
|
||||
<core-header-panel mode="scroll" drawer>
|
||||
<core-toolbar>
|
||||
@ -141,8 +144,6 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
var componentStore = window.hass.componentStore;
|
||||
var streamStore = window.hass.streamStore;
|
||||
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||
|
||||
Polymer(Polymer.mixin({
|
||||
@ -163,11 +164,11 @@ Polymer(Polymer.mixin({
|
||||
this.stopListeningToStores();
|
||||
},
|
||||
|
||||
componentStoreChanged: function() {
|
||||
componentStoreChanged: function(componentStore) {
|
||||
this.hasHistoryComponent = componentStore.isLoaded('history');
|
||||
},
|
||||
|
||||
streamStoreChanged: function() {
|
||||
streamStoreChanged: function(streamStore) {
|
||||
var state = streamStore.getState();
|
||||
|
||||
this.isStreaming = state === streamStore.STATE_CONNECTED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user