Skip to content

Commit

Permalink
Backend/Frontend Gluecode, load config on component load
Browse files Browse the repository at this point in the history
  • Loading branch information
findus committed Nov 12, 2024
1 parent 4295fa0 commit c18d7df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
12 changes: 9 additions & 3 deletions internal/index/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,16 @@ func (mgr *Manager) getIndexesCopy(start int) ([]*index.Reader, indexReleaser) {

func (mgr *Manager) ClientConfig() ClientConfig {
c := make(chan ClientConfig)
c <- ClientConfig{
AutoInsertLimitToQuery: true,
mgr.jobs <- func() {
locks := uint(0)
for _, n := range mgr.usedIndexes {
locks += n
}
c <- ClientConfig{
AutoInsertLimitToQuery: true,
}
close(c)
}
close(c)
res := <-c
return res
}
Expand Down
3 changes: 3 additions & 0 deletions web/src/components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ watch(
);
onMounted(() => {
store.getClientConfig().catch((err: string) => {
EventBus.emit("showError", `Failed to get clientconfig: ${err}`);
});
store.updateConverters().catch((err: string) => {
EventBus.emit("showError", `Failed to update converters: ${err}`);
});
Expand Down
14 changes: 7 additions & 7 deletions web/src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ import APIClient, {

interface State {
status: Statistics | null;
clientConfig: ClientConfig | null;
pcaps: PcapInfo[] | null;
tags: TagInfo[] | null;
converters: ConverterStatistics[] | null;
clientConfig: ClientConfig | null;
pcapOverIPEndpoints: PcapOverIPEndpoint[] | null;
}

export const useRootStore = defineStore("root", {
state: (): State => {
setupWebsocket();
return {
clientConfig: null,
status: null,
pcaps: null,
tags: null,
converters: null,
pcapOverIPEndpoints: null,
clientConfig: null,
};
},
getters: {
Expand Down Expand Up @@ -79,11 +79,6 @@ 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))
Expand Down Expand Up @@ -118,6 +113,11 @@ export const useRootStore = defineStore("root", {
.then((data) => (this.converters = data))
.catch(handleAxiosDefaultError);
},
async getClientConfig() {
return APIClient.getClientConfig()
.then((data) => (this.clientConfig = data))
.catch(handleAxiosDefaultError);
},
async updatePcaps() {
return APIClient.getPcaps()
.then((data) => (this.pcaps = data))
Expand Down

0 comments on commit c18d7df

Please sign in to comment.