Add ip sort functionality to dhcp config panel datatable

pull/25799/head
Bastian 2025-06-16 10:46:05 +02:00
parent 9c5803e340
commit e2788d75a1
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { expose } from "comlink"; import { expose } from "comlink";
import { stringCompare } from "../../common/string/compare"; import { stringCompare, ipCompare } from "../../common/string/compare";
import { stripDiacritics } from "../../common/string/strip-diacritics"; import { stripDiacritics } from "../../common/string/strip-diacritics";
import type { import type {
ClonedDataTableColumnData, ClonedDataTableColumnData,
@ -57,6 +57,8 @@ const sortData = (
if (column.type === "numeric") { if (column.type === "numeric") {
valA = isNaN(valA) ? undefined : Number(valA); valA = isNaN(valA) ? undefined : Number(valA);
valB = isNaN(valB) ? undefined : Number(valB); valB = isNaN(valB) ? undefined : Number(valB);
} else if (column.type === "ip") {
return sort * ipCompare(valA, valB);
} else if (typeof valA === "string" && typeof valB === "string") { } else if (typeof valA === "string" && typeof valB === "string") {
return sort * stringCompare(valA, valB, language); return sort * stringCompare(valA, valB, language);
} }

View File

@ -60,6 +60,7 @@ export class DHCPConfigPanel extends SubscribeMixin(LitElement) {
title: localize("ui.panel.config.dhcp.ip_address"), title: localize("ui.panel.config.dhcp.ip_address"),
filterable: true, filterable: true,
sortable: true, sortable: true,
type: "ip",
}, },
}; };