mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
fix csv endpoint
This commit is contained in:
@@ -4,7 +4,7 @@ import type { MetricsCounts } from '~/server/api/metrics/[project_id]/counts';
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const {project} = useProject();
|
||||
const { project } = useProject();
|
||||
|
||||
const isPremium = computed(() => (project.value?.premium_type || 0) > 0);
|
||||
|
||||
@@ -28,9 +28,9 @@ const itemsPerPage = 50;
|
||||
const totalItems = computed(() => metricsInfo.value);
|
||||
|
||||
|
||||
const { data: tableData, pending: loadingData } = await useLazyFetch<any[]>(() =>
|
||||
const { data: tableData, pending: loadingData } = await useFetch<any[]>(() =>
|
||||
`/api/metrics/${project.value?._id}/query?type=1&orderBy=${sort.value.column}&order=${sort.value.direction}&page=${page.value}&limit=${itemsPerPage}`, {
|
||||
...signHeaders(),
|
||||
...signHeaders(), lazy: true
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -42,7 +42,9 @@ const creatingCsv = ref<boolean>(false);
|
||||
|
||||
async function downloadCSV() {
|
||||
creatingCsv.value = true;
|
||||
const result = await $fetch(`/api/project/generate_csv?mode=events&slice=${options.indexOf(selectedTimeFrom.value)}`, signHeaders());
|
||||
const result = await $fetch(`/api/project/generate_csv?mode=events&slice=${options.indexOf(selectedTimeFrom.value)}`, {
|
||||
headers: useComputedHeaders({ useSnapshotDates: false }).value
|
||||
});
|
||||
const blob = new Blob([result as any], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const activeProject = useActiveProject();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const newProjectName = ref<string>(activeProject.value?.name || "");
|
||||
|
||||
async function deleteProject(projectId: string, projectName: string) {
|
||||
const sure = confirm(`Are you sure to delete the project ${projectName} ?`);
|
||||
if (!sure) return;
|
||||
|
||||
try {
|
||||
await $fetch('/api/project/delete', {
|
||||
method: 'DELETE',
|
||||
...signHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ project_id: projectId })
|
||||
});
|
||||
// await refresh();
|
||||
// setActiveProject(0);
|
||||
router.push('/')
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<div class="settings w-full">
|
||||
|
||||
<div class="flex flex-col justify-center mt-16 gap-10 px-10">
|
||||
|
||||
<div class="text-text font-bold text-[1.5rem]"> Settings </div>
|
||||
|
||||
<div class="flex gap-4 items-center text-[1.2rem] text-text-sub">
|
||||
<div class="font-semibold"> Name: </div>
|
||||
<div>
|
||||
<input v-model="newProjectName" type="text" class="px-4 py-1 rounded-lg">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex mt-10">
|
||||
<div @click="deleteProject(((activeProject?._id || '') as string), (activeProject?.name || ''))"
|
||||
class="bg-[#bd4747] hover:bg-[#c94b4b] rounded-lg px-6 py-2 text-white text-[.9rem] font-semibold inter cursor-pointer">
|
||||
Delete
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
<style scoped lang="scss">
|
||||
input:focus {
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
@@ -4,7 +4,7 @@ import type { MetricsCounts } from '~/server/api/metrics/[project_id]/counts';
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const {project} = useProject();
|
||||
const { project } = useProject();
|
||||
|
||||
const isPremium = computed(() => (project.value?.premium_type || 0) > 0);
|
||||
|
||||
@@ -34,9 +34,9 @@ const itemsPerPage = 50;
|
||||
const totalItems = computed(() => metricsInfo.value);
|
||||
|
||||
|
||||
const { data: tableData, pending: loadingData } = await useLazyFetch<any[]>(() =>
|
||||
const { data: tableData, pending: loadingData } = await useFetch<any[]>(() =>
|
||||
`/api/metrics/${project.value?._id}/query?type=0&orderBy=${sort.value.column}&order=${sort.value.direction}&page=${page.value}&limit=${itemsPerPage}`, {
|
||||
...signHeaders(),
|
||||
...signHeaders(), lazy: true
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -49,7 +49,9 @@ const creatingCsv = ref<boolean>(false);
|
||||
|
||||
async function downloadCSV() {
|
||||
creatingCsv.value = true;
|
||||
const result = await $fetch(`/api/project/generate_csv?mode=visits&slice=${options.indexOf(selectedTimeFrom.value)}`, signHeaders());
|
||||
const result = await $fetch(`/api/project/generate_csv?mode=visits&slice=${options.indexOf(selectedTimeFrom.value)}`, {
|
||||
headers: useComputedHeaders({ useSnapshotDates: false }).value
|
||||
});
|
||||
const blob = new Blob([result as any], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
@@ -105,12 +107,12 @@ function goToUpgrade() {
|
||||
class="bg-[#57c78fc0] hover:bg-[#57c78fab] cursor-pointer text-text poppins font-semibold px-8 py-2 rounded-lg">
|
||||
Download CSV
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="!isPremium" @click="goToUpgrade()"
|
||||
class="bg-[#57c78f46] hover:bg-[#57c78f42] flex gap-4 items-center cursor-pointer text-text poppins font-semibold px-8 py-2 rounded-lg">
|
||||
<i class="far fa-lock"></i>
|
||||
Upgrade plan for CSV
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ const showDashboard = computed(() => project.value && firstInteraction.data.valu
|
||||
<FirstInteraction v-if="!justLogged" :refresh-interaction="firstInteraction.refresh"
|
||||
:first-interaction="(firstInteraction.data.value || false)"></FirstInteraction>
|
||||
|
||||
<div class="text-text/85 mt-8 ml-8 poppis text-[1.2rem]" v-if="projectList && projectList.length == 0 && !justLogged">
|
||||
<div class="text-text/85 mt-8 ml-8 poppis text-[1.2rem]"
|
||||
v-if="projectList && projectList.length == 0 && !justLogged">
|
||||
Create your first project...
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user