Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/dialogs/notifications/notification-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class HuiNotificationDrawer extends EventsMixin(
padding: 0 16px 16px;
}

.notification-actions {
padding: 0 16px 16px;
text-align: center;
}

.empty {
padding: 16px;
text-align: center;
Expand All @@ -69,6 +74,13 @@ export class HuiNotificationDrawer extends EventsMixin(
</div>
</template>
</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 is="dom-if" if="[[_empty(notifications)]]">
<div class="empty">[[localize('ui.notification_drawer.empty')]]<div>
Expand Down Expand Up @@ -111,10 +123,23 @@ export class HuiNotificationDrawer extends EventsMixin(
this.open = false;
}

_dismissAll() {
this.notifications.forEach((notification) => {
this.hass.callService("persistent_notification", "dismiss", {
notification_id: notification.notification_id,
});
});
this.open = false;
}

_empty(notifications) {
return notifications.length === 0;
}

_moreThanOne(notifications) {
return notifications.length > 1;
}

_openChanged(open) {
if (open) {
// Render closed then animate open
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@
"click_to_configure": "Click button to configure {entity}",
"empty": "No Notifications",
"title": "Notifications",
"close": "Close"
"close": "Close",
"dismiss_all": "Dismiss all"
},
"notification_toast": {
"service_call_failed": "Failed to call service {service}.",
Expand Down