Add search / filter box (#2170)

* feat: Add search client based on #1978

* moved the filtering to the DB level using zod and tidied up some imports.

* minor fix

* minor fix

* fix typo

---------

Co-authored-by: Bernd Storath <999999bst@gmail.com>
This commit is contained in:
YuWorm
2025-10-20 14:04:21 +08:00
committed by GitHub
parent 76d5944726
commit 2b42b639ea
14 changed files with 225 additions and 15 deletions
+16 -4
View File
@@ -61,10 +61,15 @@ class WireGuard {
WG_DEBUG('Config synced successfully.');
}
async getClientsForUser(userId: ID) {
async getClientsForUser(userId: ID, filter?: string) {
const wgInterface = await Database.interfaces.get();
const dbClients = await Database.clients.getForUser(userId);
let dbClients;
if (filter?.trim()) {
dbClients = await Database.clients.getForUserFiltered(userId, filter);
} else {
dbClients = await Database.clients.getForUser(userId);
}
const clients = dbClients.map((client) => ({
...client,
@@ -104,9 +109,16 @@ class WireGuard {
return clientDump;
}
async getAllClients() {
async getAllClients(filter?: string) {
const wgInterface = await Database.interfaces.get();
const dbClients = await Database.clients.getAllPublic();
let dbClients;
if (filter?.trim()) {
dbClients = await Database.clients.getAllPublicFiltered(filter);
} else {
dbClients = await Database.clients.getAllPublic();
}
const clients = dbClients.map((client) => ({
...client,
latestHandshakeAt: null as Date | null,