This commit is contained in:
Emily
2024-10-09 15:30:59 +02:00
parent 126296d28f
commit e953af2c1b
27 changed files with 271 additions and 209 deletions

View File

@@ -4,16 +4,18 @@ import VueMarkdown from 'vue-markdown-render';
definePageMeta({ layout: 'dashboard' });
const { project, isGuest } = useProject();
const { project } = useProject();
const { data: chatsList, refresh: reloadChatsList } = useFetch(`/api/ai/${project.value?._id}/chats_list`, {
...signHeaders()
const { data: chatsList, refresh: reloadChatsList } = useFetch(`/api/ai/chats_list`, {
headers: useComputedHeaders({ useSnapshotDates: false })
});
const viewChatsList = computed(() => (chatsList.value || []).toReversed());
const { data: chatsRemaining, refresh: reloadChatsRemaining } = useFetch(`/api/ai/${project.value?._id}/chats_remaining`, signHeaders());
const { data: chatsRemaining, refresh: reloadChatsRemaining } = useFetch(`/api/ai/chats_remaining`, {
headers: useComputedHeaders({ useSnapshotDates: false })
});
const currentText = ref<string>("");
const loading = ref<boolean>(false);
@@ -41,11 +43,15 @@ async function sendMessage() {
try {
const res = await $fetch(`/api/ai/${project.value._id.toString()}/send_message`, {
const res = await $fetch(`/api/ai/send_message`, {
method: 'POST',
body: JSON.stringify(body),
...signHeaders({ 'Content-Type': 'application/json' })
headers: useComputedHeaders({
useSnapshotDates: false,
custom: { 'Content-Type': 'application/json' }
}).value
});
currentChatMessages.value.push({ role: 'assistant', content: res.content || 'nocontent', charts: res.charts.map(e => JSON.parse(e)) });
await reloadChatsRemaining();
@@ -82,7 +88,9 @@ async function openChat(chat_id?: string) {
return;
}
currentChatId.value = chat_id;
const messages = await $fetch(`/api/ai/${project.value._id}/${chat_id}/get_messages`, signHeaders());
const messages = await $fetch(`/api/ai/${chat_id}/get_messages`, {
headers: useComputedHeaders({useSnapshotDates:false}).value
});
if (!messages) return;
currentChatMessages.value = messages.map(e => ({ ...e, charts: e.charts.map(k => JSON.parse(k)) })) as any;
@@ -123,7 +131,9 @@ async function deleteChat(chat_id: string) {
currentChatId.value = "";
currentChatMessages.value = [];
}
await $fetch(`/api/ai/${project.value._id}/${chat_id}/delete`, signHeaders());
await $fetch(`/api/ai/${chat_id}/delete`, {
headers: useComputedHeaders({useSnapshotDates:false}).value
});
await reloadChatsList();
}
@@ -143,13 +153,10 @@ const { visible: pricingDrawerVisible } = usePricingDrawer()
<div class="w-[7rem] lg:w-[10rem]">
<img :src="'analyst.png'" class="w-full h-full">
</div>
<div v-if="!isGuest" class="poppins text-[1.2rem] text-center">
<div class="poppins text-[1.2rem] text-center">
Ask me anything about your data
</div>
<div v-if="isGuest" class="poppins text-[1.2rem] text-center">
Im not allowed to help guests :c
</div>
<div class="flex flex-col lg:grid lg:grid-cols-2 gap-4 mt-6" v-if="!isGuest">
<div class="flex flex-col lg:grid lg:grid-cols-2 gap-4 mt-6">
<div v-for="prompt of defaultPrompts" @click="currentText = prompt"
class="bg-lyx-widget-light hover:bg-lyx-widget-lighter cursor-pointer p-4 rounded-lg poppins text-center whitespace-pre-wrap flex items-center justify-center text-[.9rem]">
{{ prompt }}
@@ -201,8 +208,7 @@ const { visible: pricingDrawerVisible } = usePricingDrawer()
</div>
<div v-if="!isGuest"
class="flex gap-2 items-center md:absolute fixed bottom-8 left-0 w-full px-10 xl:px-28">
<div class="flex gap-2 items-center md:absolute fixed bottom-8 left-0 w-full px-10 xl:px-28">
<input @keydown="onKeyDown" v-model="currentText"
class="bg-lyx-widget-light w-full focus:outline-none px-4 py-2 rounded-lg" type="text">
<div @click="sendMessage()"

View File

@@ -62,17 +62,22 @@ const eventsData = await useFetch(`/api/data/count`, { headers: useComputedHeade
</div>
<!-- <div class="flex">
<div class="flex">
<EventsFunnelChart :key="refreshKey" class="w-full"></EventsFunnelChart>
</div>
<div class="flex">
<EventsUserFlow :key="refreshKey"></EventsUserFlow>
</div>
<div class="flex">
<EventsMetadataAnalyzer :key="refreshKey"></EventsMetadataAnalyzer>
</div> -->
</div>

View File

@@ -4,10 +4,18 @@ definePageMeta({ layout: 'dashboard' });
const route = useRoute();
const { project, projectList } = useProject();
const { project, projectList, projectId } = useProject();
const justLogged = computed(() => route.query.just_logged);
onMounted(() => {
if (justLogged.value) {
setTimeout(() => {
location.href = '/'
}, 500)
}
})
const firstInteraction = useFetch<boolean>('/api/project/first_interaction', {
lazy: true, headers: useComputedHeaders({ useSnapshotDates: false })
});
@@ -50,7 +58,7 @@ const showDashboard = computed(() => project.value && firstInteraction.data.valu
<div class="flex w-full justify-center mt-6 px-6">
<div class="flex w-full gap-6 flex-col xl:flex-row">
<div class="flex-1">
<BarCardBrowsers :key="refreshKey"></BarCardBrowsers>
<BarCardBrowsers :key="refreshKey"></BarCardBrowsers>
</div>
<div class="flex-1">
<BarCardOperatingSystems :key="refreshKey"></BarCardOperatingSystems>

View File

@@ -78,7 +78,7 @@ const selectLabelsEvents = [
<div class="flex gap-2 md:pt-0 pt-4">
<LyxUiButton link="/" type="primary"
class="poppins font-semibold text-[.9rem] lg:text-[1.2rem] flex items-center !px-14 py-4">
Get started for free
Go to dashboard
</LyxUiButton>
</div>
</div>
@@ -86,13 +86,14 @@ const selectLabelsEvents = [
<div>
<DashboardTopCards></DashboardTopCards>
<DashboardTopCards :key="refreshKey"></DashboardTopCards>
</div>
<div class="mt-6 px-6 flex gap-6 flex-col 2xl:flex-row w-full">
<DashboardActionableChart></DashboardActionableChart>
<DashboardActionableChart :key="refreshKey"></DashboardActionableChart>
</div>
<div class="flex gap-6 flex-col xl:flex-row p-6">
<CardTitled class="p-4 flex-[4] w-full h-full" title="Events" sub="Events stacked bar chart.">
@@ -115,47 +116,35 @@ const selectLabelsEvents = [
</div>
<div class="flex w-full justify-center px-6">
<div class="flex w-full gap-6 flex-col lg:flex-row">
<div class="flex-1">
<DashboardWebsitesBarCard></DashboardWebsitesBarCard>
</div>
<div class="flex-1">
<DashboardEventsBarCard></DashboardEventsBarCard>
</div>
</div>
</div>
<div class="flex w-full justify-center mt-6 px-6">
<div class="flex w-full gap-6 flex-col lg:flex-row">
<div class="flex w-full gap-6 flex-col xl:flex-row">
<div class="flex-1">
<DashboardReferrersBarCard></DashboardReferrersBarCard>
<BarCardWebsites :key="refreshKey"></BarCardWebsites>
</div>
<div class="flex-1">
<DashboardBrowsersBarCard></DashboardBrowsersBarCard>
<BarCardReferrers :key="refreshKey"></BarCardReferrers>
</div>
</div>
</div>
<div class="flex w-full justify-center mt-6 px-6">
<div class="flex w-full gap-6 flex-col lg:flex-row">
<div class="flex-1">
<DashboardOssBarCard></DashboardOssBarCard>
</div>
<div class="flex-1">
<DashboardGeolocationBarCard></DashboardGeolocationBarCard>
</div>
</div>
</div>
<div class="flex w-full justify-center mt-6 px-6">
<div class="flex w-full gap-6 flex-col xl:flex-row">
<div class="flex-1">
<DashboardDevicesBarCard></DashboardDevicesBarCard>
<BarCardBrowsers :key="refreshKey"></BarCardBrowsers>
</div>
<div class="flex-1">
<!-- <DashboardGeolocationBarCard></DashboardGeolocationBarCard> -->
<BarCardOperatingSystems :key="refreshKey"></BarCardOperatingSystems>
</div>
</div>
</div>
<div class="flex w-full justify-center mt-6 px-6">
<div class="flex w-full gap-6 flex-col xl:flex-row">
<div class="flex-1">
<BarCardGeolocations :key="refreshKey"></BarCardGeolocations>
</div>
<div class="flex-1">
<BarCardDevices :key="refreshKey"></BarCardDevices>
</div>
</div>
</div>
@@ -169,22 +158,18 @@ const selectLabelsEvents = [
<div class="text-[1.9rem] lg:text-[2.2rem] text-center lg:text-left px-2 lg:px-0">
<div class="poppins font-semibold text-accent">
Do you want this KPIs for your website ?
Do you want this analytics for your website ?
</div>
<div class="poppins font-semibold text-text-sub">
Start now! It's free.
Start now and discover more.
</div>
</div>
<div class="flex gap-2 flex-col md:flex-row">
<LyxUiButton link="/" type="primary"
class="poppins font-semibold text-[1.1rem] lg:text-[1.6rem] flex items-center !px-14">
Get started
class="poppins font-semibold text-[.9rem] lg:text-[1.2rem] flex items-center !px-14 py-4">
Get started for free
</LyxUiButton>
<NuxtLink target="_blank" to="https://cal.com/litlyx/30min"
class="bg-white hover:bg-white/90 text-black px-14 py-4 poppins font-semibold text-[1.1rem] lg:text-[1.6rem] rounded-lg">
Book a demo
</NuxtLink>
</div>
</div>

View File

@@ -1,16 +1,8 @@
<script setup lang="ts">
definePageMeta({ layout: 'dashboard' });
const activeProjectId = useActiveProjectId();
const headers = computed(() => {
return {
'Authorization': authorizationHeaderComputed.value,
'x-pid': activeProjectId.data.value || ''
}
});
const reportList = useFetch(`/api/security/list`, { headers });
const reportList = useFetch(`/api/security/list`, { headers: useComputedHeaders({ useSnapshotDates: false }) });
const { createAlert } = useAlert();