data structure

This commit is contained in:
Julian Krauser 2024-12-18 14:29:33 +01:00
parent 8f4731e08a
commit a01764e471
5 changed files with 58 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 10 MiB

View file

@ -34,6 +34,14 @@
</div> </div>
<div class="grow"></div> <div class="grow"></div>
<div class="flex flex-row overflow-hidden border border-gray-400 rounded-md"> <div class="flex flex-row overflow-hidden border border-gray-400 rounded-md">
<div
class="p-1"
:class="queryMode == 'structure' ? 'bg-gray-200' : ''"
title="Schema-Struktur"
@click="queryMode = 'structure'"
>
<SparklesIcon class="text-gray-500 h-6 w-6 cursor-pointer" />
</div>
<div <div
class="p-1" class="p-1"
:class="queryMode == 'builder' ? 'bg-gray-200' : ''" :class="queryMode == 'builder' ? 'bg-gray-200' : ''"
@ -53,14 +61,17 @@
</div> </div>
</div> </div>
<div class="p-2 h-44 md:h-60 w-full overflow-y-auto"> <div class="p-2 h-44 md:h-60 w-full overflow-y-auto">
<textarea v-if="typeof value == 'string'" v-model="value" placeholder="SQL Query" class="h-full w-full" /> <div v-if="queryMode == 'structure'">
<img src="/administration-db.png" class="h-full w-full cursor-pointer" @click="showStructure" />
</div>
<textarea v-else-if="typeof value == 'string'" v-model="value" placeholder="SQL Query" class="h-full w-full" />
<Table v-else v-model="value" /> <Table v-else v-model="value" />
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineComponent, type PropType } from "vue"; import { defineAsyncComponent, defineComponent, markRaw, type PropType } from "vue";
import { mapActions, mapState } from "pinia"; import { mapActions, mapState } from "pinia";
import type { DynamicQueryStructure } from "../../types/dynamicQueries"; import type { DynamicQueryStructure } from "../../types/dynamicQueries";
import { import {
@ -71,8 +82,10 @@ import {
PlayIcon, PlayIcon,
RectangleGroupIcon, RectangleGroupIcon,
TrashIcon, TrashIcon,
SparklesIcon,
} from "@heroicons/vue/24/outline"; } from "@heroicons/vue/24/outline";
import { useQueryBuilderStore } from "../../stores/admin/queryBuilder"; import { useQueryBuilderStore } from "../../stores/admin/queryBuilder";
import { useModalStore } from "../../stores/modal";
import Table from "./Table.vue"; import Table from "./Table.vue";
</script> </script>
@ -108,7 +121,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
queryMode: "builder" as "builder" | "editor", queryMode: "builder" as "builder" | "editor" | "structure",
}; };
}, },
computed: { computed: {
@ -126,6 +139,7 @@ export default defineComponent({
this.fetchTableMetas(); this.fetchTableMetas();
}, },
methods: { methods: {
...mapActions(useModalStore, ["openModal"]),
...mapActions(useQueryBuilderStore, ["fetchTableMetas"]), ...mapActions(useQueryBuilderStore, ["fetchTableMetas"]),
clearQuery() { clearQuery() {
this.$emit("update:model-value", undefined); this.$emit("update:model-value", undefined);
@ -141,6 +155,9 @@ export default defineComponent({
this.value = ""; this.value = "";
} }
}, },
showStructure() {
this.openModal(markRaw(defineAsyncComponent(() => import("@/components/queryBuilder/StructureModal.vue"))));
},
}, },
}); });
</script> </script>

View file

@ -0,0 +1,32 @@
<template>
<div class="flex flex-col w-full h-full overflow-hidden">
<div class="flex flex-col items-center">
<p class="text-xl font-medium">Datenstruktur</p>
</div>
<br />
<div class="grow w-full overflow-hidden">
<img src="/administration-db.png" class="max-h-full max-w-full h-auto w-auto mx-auto" />
</div>
<div class="flex flex-row justify-end">
<div class="flex flex-row gap-4 py-2">
<button primary-outline @click="closeModal">schnließen</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapState, mapActions } from "pinia";
import { useModalStore } from "@/stores/modal";
</script>
<script lang="ts">
export default defineComponent({
methods: {
...mapActions(useModalStore, ["closeModal"]),
},
});
</script>

View file

@ -30,7 +30,11 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
}); });
}, },
sendQuery(offset = 0, count = 25) { sendQuery(offset = 0, count = 25) {
if (this.query == undefined) return; this.queryError = "";
this.data = [];
this.totalLength = 0;
if (this.query == undefined || this.query == "" || (typeof this.query != "string" && this.query.table == ""))
return;
this.loadingData = "loading"; this.loadingData = "loading";
http http
.post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, { .post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, {