) {
+ const slug = ev.detail.id;
+ showHassioSnapshotDialog(this, {
+ slug,
+ supervisor: this.supervisor,
+ onDelete: () => this.fetchSnapshots(),
+ });
+ }
+
+ private _createSnapshot() {
+ if (this.supervisor!.info.state !== "running") {
+ showAlertDialog(this, {
+ title: this.supervisor!.localize("snapshot.could_not_create"),
+ text: this.supervisor!.localize(
+ "snapshot.create_blocked_not_running",
+ "state",
+ this.supervisor!.info.state
+ ),
+ });
+ return;
+ }
+ showHassioCreateSnapshotDialog(this, {
+ supervisor: this.supervisor!,
+ onCreate: () => this.fetchSnapshots(),
+ });
+ }
+
static get styles(): CSSResultGroup {
- return [
- haStyle,
- hassioStyle,
- css`
- paper-radio-group {
- display: block;
- }
- paper-radio-button {
- padding: 0 0 2px 2px;
- }
- paper-radio-button,
- paper-checkbox,
- paper-input[type="password"] {
- display: block;
- margin: 4px 0 4px 48px;
- }
- .pointer {
- cursor: pointer;
- }
- `,
- ];
+ return [haStyle, hassioStyle];
}
}
diff --git a/src/components/data-table/ha-data-table.ts b/src/components/data-table/ha-data-table.ts
index 639849eb7a..6a495afa9f 100644
--- a/src/components/data-table/ha-data-table.ts
+++ b/src/components/data-table/ha-data-table.ts
@@ -22,6 +22,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import "../../common/search/search-input";
import { debounce } from "../../common/util/debounce";
import { nextRender } from "../../common/util/render-status";
+import { haStyleScrollbar } from "../../resources/styles";
import "../ha-checkbox";
import type { HaCheckbox } from "../ha-checkbox";
import "../ha-icon";
@@ -327,7 +328,7 @@ export class HaDataTable extends LitElement {
`
: html`
${scroll({
@@ -574,354 +575,358 @@ export class HaDataTable extends LitElement {
}
static get styles(): CSSResultGroup {
- return css`
- /* default mdc styles, colors changed, without checkbox styles */
- :host {
- height: 100%;
- }
- .mdc-data-table__content {
- font-family: Roboto, sans-serif;
- -moz-osx-font-smoothing: grayscale;
- -webkit-font-smoothing: antialiased;
- font-size: 0.875rem;
- line-height: 1.25rem;
- font-weight: 400;
- letter-spacing: 0.0178571429em;
- text-decoration: inherit;
- text-transform: inherit;
- }
+ return [
+ haStyleScrollbar,
+ css`
+ /* default mdc styles, colors changed, without checkbox styles */
+ :host {
+ height: 100%;
+ }
+ .mdc-data-table__content {
+ font-family: Roboto, sans-serif;
+ -moz-osx-font-smoothing: grayscale;
+ -webkit-font-smoothing: antialiased;
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ font-weight: 400;
+ letter-spacing: 0.0178571429em;
+ text-decoration: inherit;
+ text-transform: inherit;
+ }
- .mdc-data-table {
- background-color: var(--data-table-background-color);
- border-radius: 4px;
- border-width: 1px;
- border-style: solid;
- border-color: var(--divider-color);
- display: inline-flex;
- flex-direction: column;
- box-sizing: border-box;
- overflow: hidden;
- }
+ .mdc-data-table {
+ background-color: var(--data-table-background-color);
+ border-radius: 4px;
+ border-width: 1px;
+ border-style: solid;
+ border-color: var(--divider-color);
+ display: inline-flex;
+ flex-direction: column;
+ box-sizing: border-box;
+ overflow: hidden;
+ }
- .mdc-data-table__row--selected {
- background-color: rgba(var(--rgb-primary-color), 0.04);
- }
+ .mdc-data-table__row--selected {
+ background-color: rgba(var(--rgb-primary-color), 0.04);
+ }
- .mdc-data-table__row {
- display: flex;
- width: 100%;
- height: 52px;
- }
+ .mdc-data-table__row {
+ display: flex;
+ width: 100%;
+ height: 52px;
+ }
- .mdc-data-table__row ~ .mdc-data-table__row {
- border-top: 1px solid var(--divider-color);
- }
+ .mdc-data-table__row ~ .mdc-data-table__row {
+ border-top: 1px solid var(--divider-color);
+ }
- .mdc-data-table__row:not(.mdc-data-table__row--selected):hover {
- background-color: rgba(var(--rgb-primary-text-color), 0.04);
- }
+ .mdc-data-table__row:not(.mdc-data-table__row--selected):hover {
+ background-color: rgba(var(--rgb-primary-text-color), 0.04);
+ }
- .mdc-data-table__header-cell {
- color: var(--primary-text-color);
- }
+ .mdc-data-table__header-cell {
+ color: var(--primary-text-color);
+ }
- .mdc-data-table__cell {
- color: var(--primary-text-color);
- }
+ .mdc-data-table__cell {
+ color: var(--primary-text-color);
+ }
- .mdc-data-table__header-row {
- height: 56px;
- display: flex;
- width: 100%;
- border-bottom: 1px solid var(--divider-color);
- overflow-x: auto;
- }
+ .mdc-data-table__header-row {
+ height: 56px;
+ display: flex;
+ width: 100%;
+ border-bottom: 1px solid var(--divider-color);
+ overflow-x: auto;
+ }
- .mdc-data-table__header-row::-webkit-scrollbar {
- display: none;
- }
+ .mdc-data-table__header-row::-webkit-scrollbar {
+ display: none;
+ }
- .mdc-data-table__cell,
- .mdc-data-table__header-cell {
- padding-right: 16px;
- padding-left: 16px;
- align-self: center;
- overflow: hidden;
- text-overflow: ellipsis;
- flex-shrink: 0;
- box-sizing: border-box;
- }
+ .mdc-data-table__cell,
+ .mdc-data-table__header-cell {
+ padding-right: 16px;
+ padding-left: 16px;
+ align-self: center;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ flex-shrink: 0;
+ box-sizing: border-box;
+ }
- .mdc-data-table__cell.mdc-data-table__cell--icon {
- overflow: initial;
- }
+ .mdc-data-table__cell.mdc-data-table__cell--icon {
+ overflow: initial;
+ }
- .mdc-data-table__header-cell--checkbox,
- .mdc-data-table__cell--checkbox {
- /* @noflip */
- padding-left: 16px;
- /* @noflip */
- padding-right: 0;
- width: 56px;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell--checkbox,
- :host([dir="rtl"]) .mdc-data-table__cell--checkbox {
- /* @noflip */
- padding-left: 0;
- /* @noflip */
- padding-right: 16px;
- }
+ .mdc-data-table__header-cell--checkbox,
+ .mdc-data-table__cell--checkbox {
+ /* @noflip */
+ padding-left: 16px;
+ /* @noflip */
+ padding-right: 0;
+ width: 56px;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell--checkbox,
+ :host([dir="rtl"]) .mdc-data-table__cell--checkbox {
+ /* @noflip */
+ padding-left: 0;
+ /* @noflip */
+ padding-right: 16px;
+ }
- .mdc-data-table__table {
- height: 100%;
- width: 100%;
- border: 0;
- white-space: nowrap;
- }
+ .mdc-data-table__table {
+ height: 100%;
+ width: 100%;
+ border: 0;
+ white-space: nowrap;
+ }
- .mdc-data-table__cell {
- font-family: Roboto, sans-serif;
- -moz-osx-font-smoothing: grayscale;
- -webkit-font-smoothing: antialiased;
- font-size: 0.875rem;
- line-height: 1.25rem;
- font-weight: 400;
- letter-spacing: 0.0178571429em;
- text-decoration: inherit;
- text-transform: inherit;
- }
+ .mdc-data-table__cell {
+ font-family: Roboto, sans-serif;
+ -moz-osx-font-smoothing: grayscale;
+ -webkit-font-smoothing: antialiased;
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ font-weight: 400;
+ letter-spacing: 0.0178571429em;
+ text-decoration: inherit;
+ text-transform: inherit;
+ }
- .mdc-data-table__cell a {
- color: inherit;
- text-decoration: none;
- }
+ .mdc-data-table__cell a {
+ color: inherit;
+ text-decoration: none;
+ }
- .mdc-data-table__cell--numeric {
- text-align: right;
- }
- :host([dir="rtl"]) .mdc-data-table__cell--numeric {
- /* @noflip */
- text-align: left;
- }
+ .mdc-data-table__cell--numeric {
+ text-align: right;
+ }
+ :host([dir="rtl"]) .mdc-data-table__cell--numeric {
+ /* @noflip */
+ text-align: left;
+ }
- .mdc-data-table__cell--icon {
- color: var(--secondary-text-color);
- text-align: center;
- }
+ .mdc-data-table__cell--icon {
+ color: var(--secondary-text-color);
+ text-align: center;
+ }
- .mdc-data-table__header-cell--icon,
- .mdc-data-table__cell--icon {
- width: 54px;
- }
+ .mdc-data-table__header-cell--icon,
+ .mdc-data-table__cell--icon {
+ width: 54px;
+ }
- .mdc-data-table__header-cell.mdc-data-table__header-cell--icon {
- text-align: center;
- }
+ .mdc-data-table__header-cell.mdc-data-table__header-cell--icon {
+ text-align: center;
+ }
- .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:hover,
- .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not(.not-sorted) {
- text-align: left;
- }
- :host([dir="rtl"])
.mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:hover,
- :host([dir="rtl"])
.mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not(.not-sorted) {
- text-align: right;
- }
+ text-align: left;
+ }
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:hover,
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell.sortable.mdc-data-table__header-cell--icon:not(.not-sorted) {
+ text-align: right;
+ }
- .mdc-data-table__cell--icon:first-child ha-icon {
- margin-left: 8px;
- }
- :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child ha-icon {
- margin-left: auto;
- margin-right: 8px;
- }
+ .mdc-data-table__cell--icon:first-child ha-icon {
+ margin-left: 8px;
+ }
+ :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child ha-icon {
+ margin-left: auto;
+ margin-right: 8px;
+ }
- .mdc-data-table__cell--icon:first-child state-badge {
- margin-right: -8px;
- }
- :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child state-badge {
- margin-right: auto;
- margin-left: -8px;
- }
+ .mdc-data-table__cell--icon:first-child state-badge {
+ margin-right: -8px;
+ }
+ :host([dir="rtl"]) .mdc-data-table__cell--icon:first-child state-badge {
+ margin-right: auto;
+ margin-left: -8px;
+ }
- .mdc-data-table__header-cell--icon-button,
- .mdc-data-table__cell--icon-button {
- width: 56px;
- padding: 8px;
- }
+ .mdc-data-table__header-cell--icon-button,
+ .mdc-data-table__cell--icon-button {
+ width: 56px;
+ padding: 8px;
+ }
- .mdc-data-table__cell--icon-button {
- color: var(--secondary-text-color);
- text-overflow: clip;
- }
+ .mdc-data-table__cell--icon-button {
+ color: var(--secondary-text-color);
+ text-overflow: clip;
+ }
- .mdc-data-table__header-cell--icon-button:first-child,
- .mdc-data-table__cell--icon-button:first-child {
- width: 64px;
- padding-left: 16px;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell--icon-button:first-child,
- :host([dir="rtl"]) .mdc-data-table__cell--icon-button:first-child {
- padding-left: auto;
- padding-right: 16px;
- }
+ .mdc-data-table__header-cell--icon-button:first-child,
+ .mdc-data-table__cell--icon-button:first-child {
+ width: 64px;
+ padding-left: 16px;
+ }
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell--icon-button:first-child,
+ :host([dir="rtl"]) .mdc-data-table__cell--icon-button:first-child {
+ padding-left: auto;
+ padding-right: 16px;
+ }
- .mdc-data-table__header-cell--icon-button:last-child,
- .mdc-data-table__cell--icon-button:last-child {
- width: 64px;
- padding-right: 16px;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell--icon-button:last-child,
- :host([dir="rtl"]) .mdc-data-table__cell--icon-button:last-child {
- padding-right: auto;
- padding-left: 16px;
- }
+ .mdc-data-table__header-cell--icon-button:last-child,
+ .mdc-data-table__cell--icon-button:last-child {
+ width: 64px;
+ padding-right: 16px;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell--icon-button:last-child,
+ :host([dir="rtl"]) .mdc-data-table__cell--icon-button:last-child {
+ padding-right: auto;
+ padding-left: 16px;
+ }
- .mdc-data-table__cell--icon-button a {
- color: var(--secondary-text-color);
- }
+ .mdc-data-table__cell--icon-button a {
+ color: var(--secondary-text-color);
+ }
- .mdc-data-table__header-cell {
- font-family: Roboto, sans-serif;
- -moz-osx-font-smoothing: grayscale;
- -webkit-font-smoothing: antialiased;
- font-size: 0.875rem;
- line-height: 1.375rem;
- font-weight: 500;
- letter-spacing: 0.0071428571em;
- text-decoration: inherit;
- text-transform: inherit;
- text-align: left;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell {
- /* @noflip */
- text-align: right;
- }
+ .mdc-data-table__header-cell {
+ font-family: Roboto, sans-serif;
+ -moz-osx-font-smoothing: grayscale;
+ -webkit-font-smoothing: antialiased;
+ font-size: 0.875rem;
+ line-height: 1.375rem;
+ font-weight: 500;
+ letter-spacing: 0.0071428571em;
+ text-decoration: inherit;
+ text-transform: inherit;
+ text-align: left;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell {
+ /* @noflip */
+ text-align: right;
+ }
- .mdc-data-table__header-cell--numeric {
- text-align: right;
- }
- .mdc-data-table__header-cell--numeric.sortable:hover,
- .mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) {
- text-align: left;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell--numeric {
- /* @noflip */
- text-align: left;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell--numeric.sortable:hover,
- :host([dir="rtl"])
+ .mdc-data-table__header-cell--numeric {
+ text-align: right;
+ }
+ .mdc-data-table__header-cell--numeric.sortable:hover,
.mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) {
- text-align: right;
- }
+ text-align: left;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell--numeric {
+ /* @noflip */
+ text-align: left;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell--numeric.sortable:hover,
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell--numeric.sortable:not(.not-sorted) {
+ text-align: right;
+ }
- /* custom from here */
+ /* custom from here */
- :host {
- display: block;
- }
+ :host {
+ display: block;
+ }
- .mdc-data-table {
- display: block;
- border-width: var(--data-table-border-width, 1px);
- height: 100%;
- }
- .mdc-data-table__header-cell {
- overflow: hidden;
- position: relative;
- }
- .mdc-data-table__header-cell span {
- position: relative;
- left: 0px;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell span {
- left: auto;
- right: 0px;
- }
+ .mdc-data-table {
+ display: block;
+ border-width: var(--data-table-border-width, 1px);
+ height: 100%;
+ }
+ .mdc-data-table__header-cell {
+ overflow: hidden;
+ position: relative;
+ }
+ .mdc-data-table__header-cell span {
+ position: relative;
+ left: 0px;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell span {
+ left: auto;
+ right: 0px;
+ }
- .mdc-data-table__header-cell.sortable {
- cursor: pointer;
- }
- .mdc-data-table__header-cell > * {
- transition: left 0.2s ease;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell > * {
- transition: right 0.2s ease;
- }
- .mdc-data-table__header-cell ha-icon {
- top: -3px;
- position: absolute;
- }
- .mdc-data-table__header-cell.not-sorted ha-icon {
- left: -20px;
- }
- :host([dir="rtl"]) .mdc-data-table__header-cell.not-sorted ha-icon {
- right: -20px;
- }
- .mdc-data-table__header-cell.sortable:not(.not-sorted) span,
- .mdc-data-table__header-cell.sortable.not-sorted:hover span {
- left: 24px;
- }
- :host([dir="rtl"])
- .mdc-data-table__header-cell.sortable:not(.not-sorted)
- span,
- :host([dir="rtl"])
- .mdc-data-table__header-cell.sortable.not-sorted:hover
- span {
- left: auto;
- right: 24px;
- }
- .mdc-data-table__header-cell.sortable:not(.not-sorted) ha-icon,
- .mdc-data-table__header-cell.sortable:hover.not-sorted ha-icon {
- left: 12px;
- }
- :host([dir="rtl"])
- .mdc-data-table__header-cell.sortable:not(.not-sorted)
- ha-icon,
- :host([dir="rtl"])
- .mdc-data-table__header-cell.sortable:hover.not-sorted
- ha-icon {
- left: auto;
- right: 12px;
- }
- .table-header {
- border-bottom: 1px solid var(--divider-color);
- padding: 0 16px;
- }
- search-input {
- position: relative;
- top: 2px;
- }
- slot[name="header"] {
- display: block;
- }
- .center {
- text-align: center;
- }
- .secondary {
- color: var(--secondary-text-color);
- }
- .scroller {
- display: flex;
- position: relative;
- contain: strict;
- height: calc(100% - 57px);
- }
- .mdc-data-table__table:not(.auto-height) .scroller {
- overflow: auto;
- }
- .grows {
- flex-grow: 1;
- flex-shrink: 1;
- }
- .forceLTR {
- direction: ltr;
- }
- .clickable {
- cursor: pointer;
- }
- `;
+ .mdc-data-table__header-cell.sortable {
+ cursor: pointer;
+ }
+ .mdc-data-table__header-cell > * {
+ transition: left 0.2s ease;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell > * {
+ transition: right 0.2s ease;
+ }
+ .mdc-data-table__header-cell ha-icon {
+ top: -3px;
+ position: absolute;
+ }
+ .mdc-data-table__header-cell.not-sorted ha-icon {
+ left: -20px;
+ }
+ :host([dir="rtl"]) .mdc-data-table__header-cell.not-sorted ha-icon {
+ right: -20px;
+ }
+ .mdc-data-table__header-cell.sortable:not(.not-sorted) span,
+ .mdc-data-table__header-cell.sortable.not-sorted:hover span {
+ left: 24px;
+ }
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell.sortable:not(.not-sorted)
+ span,
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell.sortable.not-sorted:hover
+ span {
+ left: auto;
+ right: 24px;
+ }
+ .mdc-data-table__header-cell.sortable:not(.not-sorted) ha-icon,
+ .mdc-data-table__header-cell.sortable:hover.not-sorted ha-icon {
+ left: 12px;
+ }
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell.sortable:not(.not-sorted)
+ ha-icon,
+ :host([dir="rtl"])
+ .mdc-data-table__header-cell.sortable:hover.not-sorted
+ ha-icon {
+ left: auto;
+ right: 12px;
+ }
+ .table-header {
+ border-bottom: 1px solid var(--divider-color);
+ padding: 0 16px;
+ }
+ search-input {
+ position: relative;
+ top: 2px;
+ }
+ slot[name="header"] {
+ display: block;
+ }
+ .center {
+ text-align: center;
+ }
+ .secondary {
+ color: var(--secondary-text-color);
+ }
+ .scroller {
+ display: flex;
+ position: relative;
+ contain: strict;
+ height: calc(100% - 57px);
+ }
+ .mdc-data-table__table:not(.auto-height) .scroller {
+ overflow: auto;
+ }
+ .grows {
+ flex-grow: 1;
+ flex-shrink: 1;
+ }
+ .forceLTR {
+ direction: ltr;
+ }
+ .clickable {
+ cursor: pointer;
+ }
+ `,
+ ];
}
}
diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts
index 2b9687b20d..179b221515 100644
--- a/src/layouts/hass-tabs-subpage-data-table.ts
+++ b/src/layouts/hass-tabs-subpage-data-table.ts
@@ -11,6 +11,7 @@ import {
query,
TemplateResult,
} from "lit-element";
+import { LocalizeFunc } from "../common/translations/localize";
import { fireEvent } from "../common/dom/fire_event";
import { computeRTLDirection } from "../common/util/compute_rtl";
import "../components/data-table/ha-data-table";
@@ -35,6 +36,8 @@ declare global {
export class HaTabsSubpageDataTable extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
+ @property({ attribute: false }) public localizeFunc?: LocalizeFunc;
+
@property({ type: Boolean }) public isWide = false;
@property({ type: Boolean, reflect: true }) public narrow = false;
@@ -185,6 +188,7 @@ export class HaTabsSubpageDataTable extends LitElement {
return html`