mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-29 18:16:43 +00:00
Merge pull request #385 from Vaso73/fix/lxc-ip-search
fix(monitor): include all LXC IPs in VM search
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
export interface VMSearchable {
|
||||
vmid: number
|
||||
name: string
|
||||
type: string
|
||||
tags?: string
|
||||
description?: string
|
||||
ip?: string
|
||||
ips?: string[]
|
||||
app_watches?: Array<{ name?: string | null }>
|
||||
}
|
||||
|
||||
export interface VMTypeSynonyms {
|
||||
lxc: string
|
||||
qemu: string
|
||||
}
|
||||
|
||||
export function normalizeVmSearchValue(value: unknown): string {
|
||||
return String(value ?? "")
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.toLocaleLowerCase()
|
||||
}
|
||||
|
||||
export function matchesVmSearch(
|
||||
vm: VMSearchable,
|
||||
terms: string[],
|
||||
typeSynonyms: VMTypeSynonyms,
|
||||
): boolean {
|
||||
if (terms.length === 0) return true
|
||||
const searchable = normalizeVmSearchValue([
|
||||
vm.name,
|
||||
vm.vmid,
|
||||
vm.type,
|
||||
vm.type === "lxc" ? typeSynonyms.lxc : typeSynonyms.qemu,
|
||||
vm.tags,
|
||||
vm.description,
|
||||
vm.ip,
|
||||
...(vm.ips || []),
|
||||
...(vm.app_watches || []).map((app) => app.name || ""),
|
||||
].join(" "))
|
||||
return terms.every((term) => searchable.includes(term))
|
||||
}
|
||||
Reference in New Issue
Block a user