Skip to content

Commit 9511d65

Browse files
committed
preen
1 parent db6d0ec commit 9511d65

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

src/components/ha-data-table-wrapper.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export class HaDataTable extends LitElement {
4242
@state() private _filteredData: DataTableRowData[] = [];
4343

4444
private _sortData = memoizeOne(
45-
(data: DataTableRowData[], sortColumn?: string, sortDirection?: SortingDirection) => {
45+
(
46+
data: DataTableRowData[],
47+
sortColumn?: string,
48+
sortDirection?: SortingDirection,
49+
) => {
4650
if (!sortColumn || !sortDirection) {
4751
return data;
4852
}
@@ -63,11 +67,15 @@ export class HaDataTable extends LitElement {
6367
});
6468

6569
return sorted;
66-
}
70+
},
6771
);
6872

6973
private _filterData = memoizeOne(
70-
(data: DataTableRowData[], filter: string, columns: DataTableColumnContainer) => {
74+
(
75+
data: DataTableRowData[],
76+
filter: string,
77+
columns: DataTableColumnContainer,
78+
) => {
7179
if (!filter) {
7280
return data;
7381
}
@@ -81,12 +89,16 @@ export class HaDataTable extends LitElement {
8189
return String(value).toLowerCase().includes(filterLower);
8290
});
8391
});
84-
}
92+
},
8593
);
8694

8795
protected willUpdate() {
8896
const filtered = this._filterData(this.data, this.filter, this.columns);
89-
this._filteredData = this._sortData(filtered, this.sortColumn, this.sortDirection);
97+
this._filteredData = this._sortData(
98+
filtered,
99+
this.sortColumn,
100+
this.sortDirection,
101+
);
90102
}
91103

92104
private _handleHeaderClick(columnKey: string) {
@@ -111,7 +123,7 @@ export class HaDataTable extends LitElement {
111123
detail: { column: this.sortColumn, direction: this.sortDirection },
112124
bubbles: true,
113125
composed: true,
114-
})
126+
}),
115127
);
116128
}
117129

@@ -121,7 +133,7 @@ export class HaDataTable extends LitElement {
121133
detail: { index, data: this._filteredData[index] },
122134
bubbles: true,
123135
composed: true,
124-
})
136+
}),
125137
);
126138
}
127139

@@ -131,7 +143,7 @@ export class HaDataTable extends LitElement {
131143
}
132144

133145
const columnKeys = Object.keys(this.columns).filter(
134-
(key) => !this.columns[key].hidden
146+
(key) => !this.columns[key].hidden,
135147
);
136148

137149
return html`
@@ -176,18 +188,20 @@ export class HaDataTable extends LitElement {
176188
</tr>
177189
</thead>
178190
<tbody>
179-
${this._filteredData.map((row, index) => html`
180-
<tr @click=${() => this._handleRowClick(index)}>
181-
${columnKeys.map((key) => {
182-
const column = this.columns[key];
183-
const cellContent = column.template
184-
? column.template(row)
185-
: row[key];
186-
187-
return html`<td>${cellContent}</td>`;
188-
})}
189-
</tr>
190-
`)}
191+
${this._filteredData.map(
192+
(row, index) => html`
193+
<tr @click=${() => this._handleRowClick(index)}>
194+
${columnKeys.map((key) => {
195+
const column = this.columns[key];
196+
const cellContent = column.template
197+
? column.template(row)
198+
: row[key];
199+
200+
return html`<td>${cellContent}</td>`;
201+
})}
202+
</tr>
203+
`,
204+
)}
191205
</tbody>
192206
</table>
193207
</div>
@@ -383,4 +397,4 @@ declare global {
383397
interface HTMLElementTagNameMap {
384398
"ha-data-table": HaDataTable;
385399
}
386-
}
400+
}

src/devices/devices-list.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,42 +122,33 @@ class ESPHomeDevicesList extends LitElement {
122122

123123
private _getTableColumns(): DataTableColumnContainer {
124124
return {
125-
status_indicator: {
125+
icon: {
126126
title: "",
127127
sortable: false,
128-
minWidth: "24px",
129-
maxWidth: "24px",
130-
template: (row: DataTableRowData) =>
131-
this._renderStatusIndicator(row),
128+
minWidth: "48px",
129+
maxWidth: "48px",
130+
template: (row: DataTableRowData) => this._renderDeviceIcon(row),
132131
},
133132
name: {
134133
title: "Name",
135134
sortable: true,
136135
filterable: true,
137-
template: (row: DataTableRowData) =>
138-
this._renderDeviceName(row),
136+
template: (row: DataTableRowData) => this._renderDeviceInfo(row),
139137
},
140138
status: {
141139
title: "Status",
142140
sortable: true,
143141
template: (row: DataTableRowData) => this._renderStatus(row),
144142
},
145-
ip_address: {
146-
title: "IP Address",
143+
filename: {
144+
title: "File name",
147145
sortable: true,
148-
template: (row: DataTableRowData) =>
149-
this._renderIPAddress(row),
150-
},
151-
mdns: {
152-
title: "mDNS",
153-
sortable: false,
154-
template: (row: DataTableRowData) => this._renderMDNS(row),
146+
template: (row: DataTableRowData) => this._renderFileName(row),
155147
},
156148
actions: {
157-
title: "Actions",
149+
title: "",
158150
sortable: false,
159-
template: (row: DataTableRowData) =>
160-
this._renderActions(row),
151+
template: (row: DataTableRowData) => this._renderActions(row),
161152
},
162153
};
163154
}

0 commit comments

Comments
 (0)