ff-admin/src/views/admin/club/query/Builder.vue

85 lines
2.6 KiB
Vue
Raw Normal View History

2024-12-12 16:34:03 +01:00
<template>
<MainTemplate>
<template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
<h1 class="font-bold text-xl h-8">Query Builder</h1>
</div>
</template>
<template #diffMain>
2024-12-16 17:49:18 +01:00
<div class="flex flex-col w-full h-full gap-2 px-7 overflow-y-auto">
2024-12-16 13:56:06 +01:00
<BuilderHost
v-model="query"
2024-12-18 22:27:44 +01:00
allow-predefined-select
@query:run="sendQuery"
@query:save="triggerSave"
@results:clear="clearResults"
@results:export="exportData"
2024-12-16 13:56:06 +01:00
/>
2024-12-14 17:02:34 +01:00
<p>Ergebnisse:</p>
2024-12-16 17:49:18 +01:00
<div
v-if="loadingData == 'failed'"
class="flex flex-col p-2 border border-red-600 bg-red-200 rounded-md select-none"
>
<p v-if="typeof queryError == 'string'">
{{ queryError }}
</p>
<div v-else>
<p>
CODE: <br />
{{ queryError.code }}
</p>
<br />
<p>
MSG: <br />
{{ queryError.msg }}
</p>
<br />
<p>
RESULTING SQL: <br />
{{ queryError.sql }}
</p>
</div>
</div>
2024-12-12 16:34:03 +01:00
<Pagination
2024-12-16 17:49:18 +01:00
v-else
2024-12-12 16:34:03 +01:00
:items="data"
:totalCount="totalLength"
:indicateLoading="loadingData == 'loading'"
@load-data="(offset, count) => sendQuery(offset, count)"
>
<template #pageRow="{ row }: { row: { id: FieldType; [key: string]: FieldType } }">
2024-12-12 16:34:03 +01:00
<p>{{ row }}</p>
</template>
</Pagination>
</div>
</template>
</MainTemplate>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
2024-12-16 13:56:06 +01:00
import { mapActions, mapState, mapWritableState } from "pinia";
2024-12-12 16:34:03 +01:00
import MainTemplate from "@/templates/Main.vue";
import Pagination from "@/components/Pagination.vue";
2025-01-02 18:28:13 +01:00
import { useQueryBuilderStore } from "@/stores/admin/club/queryBuilder";
2024-12-26 12:34:36 +01:00
import BuilderHost from "@/components/queryBuilder/BuilderHost.vue";
import type { DynamicQueryStructure, FieldType } from "@/types/dynamicQueries";
2025-01-02 18:28:13 +01:00
import { useQueryStoreStore } from "@/stores/admin/settings/queryStore";
2024-12-12 16:34:03 +01:00
</script>
<script lang="ts">
export default defineComponent({
computed: {
2024-12-16 17:49:18 +01:00
...mapState(useQueryBuilderStore, ["loading", "loadingData", "tableMetas", "data", "totalLength", "queryError"]),
2024-12-16 13:56:06 +01:00
...mapWritableState(useQueryBuilderStore, ["query"]),
2024-12-12 16:34:03 +01:00
},
mounted() {
this.fetchTableMetas();
},
methods: {
...mapActions(useQueryBuilderStore, ["fetchTableMetas", "sendQuery", "clearResults", "exportData"]),
2024-12-18 22:27:44 +01:00
...mapActions(useQueryStoreStore, ["triggerSave"]),
2024-12-12 16:34:03 +01:00
},
});
</script>