query views, router and store

This commit is contained in:
Julian Krauser 2024-12-12 16:34:03 +01:00
parent 8849d3e273
commit 0508e40494
8 changed files with 208 additions and 14 deletions

View file

@ -90,6 +90,7 @@ export const useNavigationStore = defineStore("navigation", {
...(abilityStore.can("read", "club", "calendar") ? [{ key: "calendar", title: "Kalender" }] : []),
...(abilityStore.can("read", "club", "protocol") ? [{ key: "protocol", title: "Protokolle" }] : []),
...(abilityStore.can("read", "club", "newsletter") ? [{ key: "newsletter", title: "Newsletter" }] : []),
...(abilityStore.can("read", "club", "query") ? [{ key: "query_builder", title: "Query Builder" }] : []),
],
},
settings: {
@ -102,8 +103,8 @@ export const useNavigationStore = defineStore("navigation", {
...(abilityStore.can("read", "settings", "executive_position")
? [{ key: "executive_position", title: "Vereinsämter" }]
: []),
...(abilityStore.can("read", "settings", "communication")
? [{ key: "communication", title: "Kommunikationsarten" }]
...(abilityStore.can("read", "settings", "communication_type")
? [{ key: "communication_type", title: "Kommunikationsarten" }]
: []),
...(abilityStore.can("read", "settings", "membership_status")
? [{ key: "membership_status", title: "Mitgliedsstatus" }]
@ -111,6 +112,7 @@ export const useNavigationStore = defineStore("navigation", {
...(abilityStore.can("read", "settings", "calendar_type")
? [{ key: "calendar_type", title: "Terminarten" }]
: []),
...(abilityStore.can("read", "settings", "query") ? [{ key: "query_store", title: "Query Store" }] : []),
],
},
user: {

View file

@ -0,0 +1,50 @@
import { defineStore } from "pinia";
import type { CreateAwardViewModel, UpdateAwardViewModel, AwardViewModel } from "@/viewmodels/admin/award.models";
import { http } from "@/serverCom";
import type { AxiosResponse } from "axios";
import type { TableMeta } from "../../viewmodels/admin/query.models";
import type { DynamicQueryStructure } from "../../types/dynamicQueries";
export const useQueryBuilderStore = defineStore("queryBuilder", {
state: () => {
return {
tableMetas: [] as Array<TableMeta>,
loading: "loading" as "loading" | "fetched" | "failed",
data: [] as Array<{ id: number; [key: string]: any }>,
totalLength: 0 as number,
loadingData: "failed" as "loading" | "fetched" | "failed",
query: undefined as undefined | DynamicQueryStructure,
isLoadedQuery: undefined as undefined | number,
};
},
actions: {
fetchTableMetas() {
this.loading = "loading";
http
.get("/admin/querybuilder/tables")
.then((result) => {
this.tableMetas = result.data;
this.loading = "fetched";
})
.catch((err) => {
this.loading = "failed";
});
},
sendQuery(offset = 0, count = 25) {
if (this.query == undefined) return;
this.loadingData = "loading";
http
.post(`/admin/querybuilder/query$offset=${offset}&count=${count}`, {
query: this.query,
})
.then((result) => {
this.data = result.data.rows;
this.totalLength = result.data.count;
this.loadingData = "fetched";
})
.catch((err) => {
this.loadingData = "failed";
});
},
},
});