Skip to content

Commit

Permalink
Fix backup and gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Sep 5, 2023
1 parent 760e509 commit 31aed6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions gallery/src/pages/misc/entity-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export class DemoEntityState extends LitElement {
const columns: DataTableColumnContainer<EntityRowData> = {
icon: {
title: "Icon",
template: (_, entry) => html`
template: (entry) => html`
<state-badge
.stateObj=${entry.stateObj}
.stateColor=${true}
Expand All @@ -360,7 +360,7 @@ export class DemoEntityState extends LitElement {
title: "State",
width: "20%",
sortable: true,
template: (_, entry) =>
template: (entry) =>
html`${computeStateDisplay(
hass.localize,
entry.stateObj,
Expand All @@ -371,14 +371,14 @@ export class DemoEntityState extends LitElement {
},
device_class: {
title: "Device class",
template: (dc) => html`${dc ?? "-"}`,
template: (entry) => html`${entry.device_class ?? "-"}`,
width: "20%",
filterable: true,
sortable: true,
},
domain: {
title: "Domain",
template: (_, entry) => html`${computeDomain(entry.entity_id)}`,
template: (entry) => html`${computeDomain(entry.entity_id)}`,
width: "20%",
filterable: true,
sortable: true,
Expand Down
22 changes: 13 additions & 9 deletions hassio/src/backups/hassio-backups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ import { showHassioCreateBackupDialog } from "../dialogs/backup/show-dialog-hass
import { supervisorTabs } from "../hassio-tabs";
import { hassioStyle } from "../resources/hassio-style";

type BackupItem = HassioBackup & {
secondary: string;
};

@customElement("hassio-backups")
export class HassioBackups extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
Expand Down Expand Up @@ -117,15 +121,15 @@ export class HassioBackups extends LitElement {
}

private _columns = memoizeOne(
(narrow: boolean): DataTableColumnContainer => ({
(narrow: boolean): DataTableColumnContainer<BackupItem> => ({
name: {
title: this.supervisor.localize("backup.name"),
main: true,
sortable: true,
filterable: true,
grows: true,
template: (entry: string, backup: any) =>
html`${entry || backup.slug}
template: (backup) =>
html`${backup.name || backup.slug}
<div class="secondary">${backup.secondary}</div>`,
},
size: {
Expand All @@ -134,16 +138,16 @@ export class HassioBackups extends LitElement {
hidden: narrow,
filterable: true,
sortable: true,
template: (entry: number) => Math.ceil(entry * 10) / 10 + " MB",
template: (backup) => Math.ceil(backup.size * 10) / 10 + " MB",
},
location: {
title: this.supervisor.localize("backup.location"),
width: "15%",
hidden: narrow,
filterable: true,
sortable: true,
template: (entry: string | null) =>
entry || this.supervisor.localize("backup.data_disk"),
template: (backup) =>
backup.location || this.supervisor.localize("backup.data_disk"),
},
date: {
title: this.supervisor.localize("backup.created"),
Expand All @@ -152,8 +156,8 @@ export class HassioBackups extends LitElement {
hidden: narrow,
filterable: true,
sortable: true,
template: (entry: string) =>
relativeTime(new Date(entry), this.hass.locale),
template: (backup) =>
relativeTime(new Date(backup.date), this.hass.locale),
},
secondary: {
title: "",
Expand All @@ -163,7 +167,7 @@ export class HassioBackups extends LitElement {
})
);

private _backupData = memoizeOne((backups: HassioBackup[]) =>
private _backupData = memoizeOne((backups: HassioBackup[]): BackupItem[] =>
backups.map((backup) => ({
...backup,
secondary: this._computeBackupContent(backup),
Expand Down

0 comments on commit 31aed6e

Please sign in to comment.