diff --git a/internal/index/manager/manager.go b/internal/index/manager/manager.go index 08bb25ed..52bb0201 100644 --- a/internal/index/manager/manager.go +++ b/internal/index/manager/manager.go @@ -157,7 +157,7 @@ type ( } ClientConfig struct { - AutoPrependLimit bool + AutoInsertLimitToQuery bool } indexReleaser []*index.Reader diff --git a/web/src/apiClient.guard.ts b/web/src/apiClient.guard.ts index bbe0ab17..d84c4853 100644 --- a/web/src/apiClient.guard.ts +++ b/web/src/apiClient.guard.ts @@ -2,7 +2,7 @@ * Generated type guards for "apiClient.ts". * WARNING: Do not manually change this file. */ -import { Error, SearchResult, SearchResponse, StreamData, Statistics, PcapsResponse, ConvertersResponse, ProcessStderr, PcapOverIPResponse, TagsResponse, GraphResponse } from "./apiClient"; +import { Error, SearchResult, SearchResponse, StreamData, Statistics, PcapsResponse, ConvertersResponse, ProcessStderr, PcapOverIPResponse, TagsResponse, GraphResponse, ClientConfig } from "./apiClient"; export function isError(obj: unknown): obj is Error { const typedObj = obj as Error @@ -133,6 +133,16 @@ export function isStatistics(obj: unknown): obj is Statistics { ) } +export function isClientConfig(obj: unknown): obj is ClientConfig { + const typedObj = obj as ClientConfig + return ( + (typedObj !== null && + typeof typedObj === "object" || + typeof typedObj === "function") && + typeof typedObj["AutoInsertLimitToQuery"] === "boolean" + ) +} + export function isPcapsResponse(obj: unknown): obj is PcapsResponse { const typedObj = obj as PcapsResponse return ( diff --git a/web/src/apiClient.ts b/web/src/apiClient.ts index e635097c..259e8675 100644 --- a/web/src/apiClient.ts +++ b/web/src/apiClient.ts @@ -1,6 +1,7 @@ import axios from "axios"; import type { Base64, DateTimeString } from "@/types/common"; import { + isClientConfig, isConvertersResponse, isGraphResponse, isPcapOverIPResponse, @@ -82,6 +83,11 @@ export type Statistics = { ConverterJobRunning: boolean; }; +/** @see {isClientConfig} ts-auto-guard:type-guard */ +export type ClientConfig = { + AutoInsertLimitToQuery: boolean; +}; + export type PcapInfo = { Filename: string; Filesize: number; @@ -179,6 +185,9 @@ const APIClient = { async getStatus() { return this.performGuarded("get", `/status.json`, isStatistics); }, + async getClientConfig() { + return this.performGuarded("get", `/clientconfig.json`, isClientConfig); + }, async getPcaps() { return this.performGuarded("get", `/pcaps.json`, isPcapsResponse); }, diff --git a/web/src/stores/index.ts b/web/src/stores/index.ts index 6dca5e15..33b92ba5 100644 --- a/web/src/stores/index.ts +++ b/web/src/stores/index.ts @@ -9,10 +9,12 @@ import APIClient, { PcapOverIPEndpoint, Statistics, TagInfo, + ClientConfig, } from "@/apiClient"; interface State { status: Statistics | null; + clientConfig: ClientConfig | null; pcaps: PcapInfo[] | null; tags: TagInfo[] | null; converters: ConverterStatistics[] | null; @@ -23,6 +25,7 @@ export const useRootStore = defineStore("root", { state: (): State => { setupWebsocket(); return { + clientConfig: null, status: null, pcaps: null, tags: null, @@ -76,6 +79,11 @@ export const useRootStore = defineStore("root", { } } }, + async updateClientConfig() { + return APIClient.getClientConfig() + .then((data) => (this.clientConfig = data)) + .catch(handleAxiosDefaultError); + }, async updateStatus() { return APIClient.getStatus() .then((data) => (this.status = data))