mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +00:00
Add button that dismisses all notifications (#7223)
This commit is contained in:
parent
2dd7f292b1
commit
5b1a2d10c2
@ -50,6 +50,11 @@ export class HuiNotificationDrawer extends EventsMixin(
|
|||||||
padding: 0 16px 16px;
|
padding: 0 16px 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notification-actions {
|
||||||
|
padding: 0 16px 16px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -69,6 +74,13 @@ export class HuiNotificationDrawer extends EventsMixin(
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</dom-repeat>
|
</dom-repeat>
|
||||||
|
<template is="dom-if" if="[[_moreThanOne(notifications)]]">
|
||||||
|
<div class="notification-actions">
|
||||||
|
<mwc-button raised on-click="_dismissAll">
|
||||||
|
[[localize('ui.notification_drawer.dismiss_all')]]
|
||||||
|
</mwc-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template is="dom-if" if="[[_empty(notifications)]]">
|
<template is="dom-if" if="[[_empty(notifications)]]">
|
||||||
<div class="empty">[[localize('ui.notification_drawer.empty')]]<div>
|
<div class="empty">[[localize('ui.notification_drawer.empty')]]<div>
|
||||||
@ -112,10 +124,23 @@ export class HuiNotificationDrawer extends EventsMixin(
|
|||||||
this.open = false;
|
this.open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_dismissAll() {
|
||||||
|
this.notifications.forEach((notification) => {
|
||||||
|
this.hass.callService("persistent_notification", "dismiss", {
|
||||||
|
notification_id: notification.notification_id,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.open = false;
|
||||||
|
}
|
||||||
|
|
||||||
_empty(notifications) {
|
_empty(notifications) {
|
||||||
return notifications.length === 0;
|
return notifications.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_moreThanOne(notifications) {
|
||||||
|
return notifications.length > 1;
|
||||||
|
}
|
||||||
|
|
||||||
_openChanged(open) {
|
_openChanged(open) {
|
||||||
if (open) {
|
if (open) {
|
||||||
// Render closed then animate open
|
// Render closed then animate open
|
||||||
|
@ -677,7 +677,8 @@
|
|||||||
"click_to_configure": "Click button to configure {entity}",
|
"click_to_configure": "Click button to configure {entity}",
|
||||||
"empty": "No Notifications",
|
"empty": "No Notifications",
|
||||||
"title": "Notifications",
|
"title": "Notifications",
|
||||||
"close": "Close"
|
"close": "Close",
|
||||||
|
"dismiss_all": "Dismiss all"
|
||||||
},
|
},
|
||||||
"notification_toast": {
|
"notification_toast": {
|
||||||
"service_call_failed": "Failed to call service {service}.",
|
"service_call_failed": "Failed to call service {service}.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user