Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1917b74c32 | ||
|
|
b709ad285a | ||
|
|
6a157b81c9 | ||
|
|
82b0f6aac4 | ||
|
|
407c84f59c | ||
|
|
e8f8600df4 | ||
|
|
eb954cac6c | ||
|
|
a9bbc58ad1 | ||
|
|
f631c29fb2 | ||
|
|
946f9d4d32 | ||
|
|
1d5dad44fa | ||
|
|
1187cafd07 | ||
|
|
475512711b | ||
|
|
8f7f89e0bd | ||
|
|
4d51676a2e | ||
|
|
72ceb7971d | ||
|
|
10d4a9f1bc | ||
|
|
70c15238a0 | ||
|
|
7e093251fa | ||
|
|
7658dbe85c | ||
|
|
1f9ef5d18c | ||
|
|
94a28b31d3 | ||
|
|
87c9aca5c4 | ||
|
|
afda29997d | ||
|
|
d1b3e997c1 | ||
|
|
be82f7046f | ||
|
|
45e9a9c6a7 | ||
|
|
942d074f99 | ||
|
|
63fa3995c5 | ||
|
|
76e5e07f79 | ||
|
|
b8f9e598a7 | ||
|
|
0ee4895e1a | ||
|
|
72d6b97383 | ||
|
|
3f22c655a5 | ||
|
|
4fea549a5a |
8
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"github.copilot.enable": {
|
||||
"*": false,
|
||||
"plaintext": false,
|
||||
"markdown": true,
|
||||
"scminput": false
|
||||
}
|
||||
}
|
||||
BIN
assets/agent.png
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 42 KiB |
BIN
assets/tech.png
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 7.7 KiB |
@@ -2,77 +2,56 @@ import { ProjectModel } from "./shared/schema/project/ProjectSchema";
|
||||
import { UserModel } from "./shared/schema/UserSchema";
|
||||
import { LimitNotifyModel } from "./shared/schema/broker/LimitNotifySchema";
|
||||
import { EmailService } from './shared/services/EmailService';
|
||||
import { TProjectLimit } from "./shared/schema/project/ProjectsLimits";
|
||||
import { EmailServiceHelper } from "./EmailServiceHelper";
|
||||
import { TUserLimit } from "./shared/schema/UserLimitSchema";
|
||||
|
||||
|
||||
export async function checkLimitsForEmail(projectCounts: TProjectLimit) {
|
||||
export async function checkLimitsForEmail(projectCounts: TUserLimit) {
|
||||
|
||||
const project_id = projectCounts.project_id;
|
||||
const hasNotifyEntry = await LimitNotifyModel.findOne({ project_id });
|
||||
const user_id = projectCounts.user_id;
|
||||
|
||||
const hasNotifyEntry = await LimitNotifyModel.findOne({ user_id });
|
||||
if (!hasNotifyEntry) {
|
||||
await LimitNotifyModel.create({ project_id, limit1: false, limit2: false, limit3: false })
|
||||
await LimitNotifyModel.create({ user_id, limit1: false, limit2: false, limit3: false })
|
||||
}
|
||||
|
||||
const owner = await UserModel.findById(user_id);
|
||||
if (!owner) return;
|
||||
|
||||
const userName = owner.given_name || owner.name || 'no_name';
|
||||
|
||||
if ((projectCounts.visits + projectCounts.events) >= (projectCounts.limit)) {
|
||||
|
||||
if (hasNotifyEntry.limit3 === true) return;
|
||||
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
if (!project) return;
|
||||
|
||||
const owner = await UserModel.findById(project.owner);
|
||||
if (!owner) return;
|
||||
|
||||
setImmediate(() => {
|
||||
const emailData = EmailService.getEmailServerInfo('limit_max', {
|
||||
target: owner.email,
|
||||
projectName: project.name
|
||||
});
|
||||
const emailData = EmailService.getEmailServerInfo('limit_max', { target: owner.email });
|
||||
EmailServiceHelper.sendEmail(emailData);
|
||||
});
|
||||
|
||||
await LimitNotifyModel.updateOne({ project_id: projectCounts.project_id }, { limit1: true, limit2: true, limit3: true });
|
||||
await LimitNotifyModel.updateOne({ user_id }, { limit1: true, limit2: true, limit3: true });
|
||||
|
||||
} else if ((projectCounts.visits + projectCounts.events) >= (projectCounts.limit * 0.9)) {
|
||||
|
||||
if (hasNotifyEntry.limit2 === true) return;
|
||||
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
if (!project) return;
|
||||
|
||||
const owner = await UserModel.findById(project.owner);
|
||||
if (!owner) return;
|
||||
|
||||
setImmediate(() => {
|
||||
const emailData = EmailService.getEmailServerInfo('limit_90', {
|
||||
target: owner.email,
|
||||
projectName: project.name
|
||||
});
|
||||
const emailData = EmailService.getEmailServerInfo('limit_90', { target: owner.email });
|
||||
EmailServiceHelper.sendEmail(emailData);
|
||||
});
|
||||
|
||||
await LimitNotifyModel.updateOne({ project_id: projectCounts.project_id }, { limit1: true, limit2: true, limit3: false });
|
||||
await LimitNotifyModel.updateOne({ user_id }, { limit1: true, limit2: true, limit3: false });
|
||||
|
||||
} else if ((projectCounts.visits + projectCounts.events) >= (projectCounts.limit * 0.5)) {
|
||||
|
||||
if (hasNotifyEntry.limit1 === true) return;
|
||||
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
if (!project) return;
|
||||
|
||||
const owner = await UserModel.findById(project.owner);
|
||||
if (!owner) return;
|
||||
|
||||
setImmediate(() => {
|
||||
const emailData = EmailService.getEmailServerInfo('limit_50', {
|
||||
target: owner.email,
|
||||
projectName: project.name
|
||||
});
|
||||
const emailData = EmailService.getEmailServerInfo('limit_50', { target: owner.email });
|
||||
EmailServiceHelper.sendEmail(emailData);
|
||||
});
|
||||
|
||||
await LimitNotifyModel.updateOne({ project_id: projectCounts.project_id }, { limit1: true, limit2: false, limit3: false });
|
||||
|
||||
await LimitNotifyModel.updateOne({ user_id }, { limit1: true, limit2: false, limit3: false });
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
|
||||
|
||||
import { ProjectLimitModel } from './shared/schema/project/ProjectsLimits';
|
||||
import { MAX_LOG_LIMIT_PERCENT } from './shared/data/broker/Limits';
|
||||
import { checkLimitsForEmail } from './EmailController';
|
||||
import { UserLimitModel } from './shared/schema/UserLimitSchema';
|
||||
|
||||
export async function checkLimits(project_id: string) {
|
||||
const projectLimits = await ProjectLimitModel.findOne({ project_id });
|
||||
if (!projectLimits) return false;
|
||||
const TOTAL_COUNT = projectLimits.events + projectLimits.visits;
|
||||
const COUNT_LIMIT = projectLimits.limit;
|
||||
export async function checkLimits(user_id: string) {
|
||||
const userLimits = await UserLimitModel.findOne({ user_id });
|
||||
if (!userLimits) return false;
|
||||
const TOTAL_COUNT = userLimits.events + userLimits.visits;
|
||||
const COUNT_LIMIT = userLimits.limit;
|
||||
if ((TOTAL_COUNT) > COUNT_LIMIT * MAX_LOG_LIMIT_PERCENT) return false;
|
||||
await checkLimitsForEmail(projectLimits);
|
||||
await checkLimitsForEmail(userLimits);
|
||||
return true;
|
||||
}
|
||||
@@ -11,10 +11,9 @@ import { UAParser } from 'ua-parser-js';
|
||||
import { checkLimits } from './LimitChecker';
|
||||
import express from 'express';
|
||||
|
||||
import { ProjectLimitModel } from './shared/schema/project/ProjectsLimits';
|
||||
import { ProjectCountModel } from './shared/schema/project/ProjectsCounts';
|
||||
import { metricsRouter } from './Metrics';
|
||||
|
||||
import { UserLimitModel } from './shared/schema/UserLimitSchema';
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -27,6 +26,12 @@ main();
|
||||
|
||||
const CONSUMER_NAME = `CONSUMER_${process.env.NODE_APP_INSTANCE || 'DEFAULT'}`
|
||||
|
||||
|
||||
async function getProjectOwner(pid: string) {
|
||||
const ownerData = await ProjectModel.findOne({ _id: pid }, { owner: 1 });
|
||||
return ownerData.owner;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
await RedisStreamService.connect();
|
||||
@@ -51,18 +56,18 @@ async function processStreamEntry(data: Record<string, string>) {
|
||||
|
||||
const { pid, sessionHash } = data;
|
||||
|
||||
const project = await ProjectModel.exists({ _id: pid });
|
||||
if (!project) return;
|
||||
const owner = await getProjectOwner(pid);
|
||||
if (!owner) return;
|
||||
|
||||
const canLog = await checkLimits(pid);
|
||||
const canLog = await checkLimits(owner.toString());
|
||||
if (!canLog) return;
|
||||
|
||||
if (eventType === 'event') {
|
||||
await process_event(data, sessionHash);
|
||||
await process_event(data, sessionHash, owner.toString());
|
||||
} else if (eventType === 'keep_alive') {
|
||||
await process_keep_alive(data, sessionHash);
|
||||
await process_keep_alive(data, sessionHash, owner.toString());
|
||||
} else if (eventType === 'visit') {
|
||||
await process_visit(data, sessionHash);
|
||||
await process_visit(data, sessionHash, owner.toString());
|
||||
}
|
||||
|
||||
} catch (ex: any) {
|
||||
@@ -75,7 +80,7 @@ async function processStreamEntry(data: Record<string, string>) {
|
||||
|
||||
}
|
||||
|
||||
async function process_visit(data: Record<string, string>, sessionHash: string) {
|
||||
async function process_visit(data: Record<string, string>, sessionHash: string, user_id: string) {
|
||||
|
||||
const { pid, ip, website, page, referrer, userAgent, flowHash, timestamp } = data;
|
||||
|
||||
@@ -105,14 +110,14 @@ async function process_visit(data: Record<string, string>, sessionHash: string)
|
||||
created_at: new Date(parseInt(timestamp))
|
||||
}),
|
||||
ProjectCountModel.updateOne({ project_id: pid }, { $inc: { 'visits': 1 } }, { upsert: true }),
|
||||
ProjectLimitModel.updateOne({ project_id: pid }, { $inc: { 'visits': 1 } })
|
||||
UserLimitModel.updateOne({ user_id }, { $inc: { 'visits': 1 } })
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
async function process_keep_alive(data: Record<string, string>, sessionHash: string) {
|
||||
async function process_keep_alive(data: Record<string, string>, sessionHash: string, user_id: string) {
|
||||
|
||||
const { pid, instant, flowHash, timestamp } = data;
|
||||
const { pid, instant, flowHash, timestamp, website } = data;
|
||||
|
||||
const existingSession = await SessionModel.findOne({ project_id: pid, session: sessionHash }, { _id: 1 });
|
||||
if (!existingSession) {
|
||||
@@ -123,21 +128,23 @@ async function process_keep_alive(data: Record<string, string>, sessionHash: str
|
||||
await SessionModel.updateOne({ project_id: pid, session: sessionHash, }, {
|
||||
$inc: { duration: 0 },
|
||||
flowHash,
|
||||
updated_at: Date.now()
|
||||
website,
|
||||
updated_at: new Date(parseInt(timestamp))
|
||||
}, { upsert: true });
|
||||
} else {
|
||||
await SessionModel.updateOne({ project_id: pid, session: sessionHash, }, {
|
||||
$inc: { duration: 1 },
|
||||
flowHash,
|
||||
updated_at: Date.now()
|
||||
website,
|
||||
updated_at: new Date(parseInt(timestamp))
|
||||
}, { upsert: true });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function process_event(data: Record<string, string>, sessionHash: string) {
|
||||
async function process_event(data: Record<string, string>, sessionHash: string, user_id: string) {
|
||||
|
||||
const { name, metadata, pid, flowHash, timestamp } = data;
|
||||
const { name, metadata, pid, flowHash, timestamp, website } = data;
|
||||
|
||||
let metadataObject;
|
||||
try {
|
||||
@@ -149,10 +156,11 @@ async function process_event(data: Record<string, string>, sessionHash: string)
|
||||
await Promise.all([
|
||||
EventModel.create({
|
||||
project_id: pid, name, flowHash, metadata: metadataObject, session: sessionHash,
|
||||
website,
|
||||
created_at: new Date(parseInt(timestamp))
|
||||
}),
|
||||
ProjectCountModel.updateOne({ project_id: pid }, { $inc: { 'events': 1 } }, { upsert: true }),
|
||||
ProjectLimitModel.updateOne({ project_id: pid }, { $inc: { 'events': 1 } })
|
||||
UserLimitModel.updateOne({ user_id }, { $inc: { 'events': 1 } })
|
||||
]);
|
||||
|
||||
|
||||
|
||||
9
dashboard/app.config.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
export default defineAppConfig({
|
||||
ui: {
|
||||
notifications: {
|
||||
position: 'top-0 bottom-[unset]'
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -69,6 +69,7 @@ const { drawerVisible, hideDrawer, drawerClasses } = useDrawer();
|
||||
|
||||
|
||||
<UModals />
|
||||
<UNotifications />
|
||||
|
||||
<LazyOnboarding> </LazyOnboarding>
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
@import './font-awesome/css/all.css';
|
||||
/* Are these many fonts required? For the time being switching to privacy friendly bunny.net for Google fonts. NOTE: No variable font support in bunnet.net yet. */
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;0,1000;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900;1,1000&display=swap');
|
||||
@import url('https://fonts.bunny.net/css?family=nunito:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i');
|
||||
@import url('https://fonts.cdnfonts.com/css/brockmann');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
|
||||
@import url('https://fonts.bunny.net/css?family=inter:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i');
|
||||
|
||||
|
||||
@import url('https://fonts.cdnfonts.com/css/geometric-sans-serif-v1');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
|
||||
@import url('https://fonts.bunny.net/css?family=manrope:300,400,500,600,700,800');
|
||||
@import url('https://fonts.bunny.net/css?family=lato:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i');
|
||||
@import url('https://fonts.bunny.net/css?family=poppins:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i');
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');
|
||||
@import url('https://cdn.jsdelivr.net/npm/material-symbols@0.28.2/index.css');
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
@use './utilities.scss';
|
||||
@use './colors.scss';
|
||||
|
||||
:root{
|
||||
--font-sans: "SF Pro Text","SF Pro Icons", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "Google Sans", "Helvetica Neue", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol"
|
||||
}
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: "Geist";
|
||||
src: url("../fonts/GeistVF.ttf");
|
||||
}
|
||||
|
||||
|
||||
.actionable-visits-color-checkbox {
|
||||
color: #5655d7;
|
||||
}
|
||||
@@ -19,7 +23,7 @@
|
||||
}
|
||||
|
||||
.geist {
|
||||
font-family: "Geist";
|
||||
font-family: "Geist", var(--font-sans);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,38 +38,38 @@
|
||||
}
|
||||
|
||||
.brockmann {
|
||||
font-family: "Brockmann" !important;
|
||||
font-family: "Brockmann", var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.nunito {
|
||||
font-family: "Nunito" !important;
|
||||
font-family: "Nunito",var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.inter {
|
||||
font-family: "Inter" !important;
|
||||
font-family: "Inter", var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.geometric {
|
||||
font-family: 'Geometric Sans Serif v1' !important;
|
||||
font-family: "Geometric Sans Serif v1", var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.manrope {
|
||||
font-family: 'Manrope' !important;
|
||||
font-family: "Manrope", var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.lato {
|
||||
font-family: 'Lato' !important;
|
||||
font-family: "Lato", var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.poppins {
|
||||
font-family: 'Poppins' !important;
|
||||
font-family: "Poppins", var(--font-sans)!important;
|
||||
}
|
||||
|
||||
.poppins-childs {
|
||||
font-family: 'Poppins' !important;
|
||||
font-family: "Poppins", var(--font-sans)!important;
|
||||
|
||||
* {
|
||||
font-family: 'Poppins' !important;
|
||||
font-family: "Poppins", var(--font-sans)!important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,5 +109,13 @@ body {
|
||||
}
|
||||
|
||||
* {
|
||||
font-family: 'Nunito';
|
||||
font-family: 'Nunito', var(--font-sans);
|
||||
}
|
||||
|
||||
.rotating-thing {
|
||||
height: 100%;
|
||||
aspect-ratio: 1 / 1;
|
||||
opacity: 0.15;
|
||||
background: radial-gradient(51.24% 31.29% at 50% 50%, rgb(51, 58, 232) 0%, rgba(51, 58, 232, 0) 100%);
|
||||
animation: 12s linear 0s infinite normal none running spin;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ registerChartComponents();
|
||||
const props = defineProps<{
|
||||
datasets: any[],
|
||||
labels: string[],
|
||||
legendPosition?: "left" | "top" | "right" | "bottom" | "center" | "chartArea"
|
||||
}>();
|
||||
|
||||
const chartOptions = ref<ChartOptions<'bar'>>({
|
||||
@@ -40,7 +41,7 @@ const chartOptions = ref<ChartOptions<'bar'>>({
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'right',
|
||||
position: props.legendPosition ?? 'right',
|
||||
},
|
||||
title: { display: false },
|
||||
tooltip: {
|
||||
|
||||
@@ -54,7 +54,7 @@ onMounted(() => {
|
||||
<div class="flex overflow-x-auto hide-scrollbars">
|
||||
<div class="flex">
|
||||
<div v-for="(tab, index) of items" @click="onChangeTab(index)"
|
||||
class="px-6 pb-3 poppins font-medium text-lyx-lightmode-text dark:text-lyx-text-darker border-b-[1px] border-lyx-text-darker"
|
||||
class="px-6 whitespace-nowrap pb-3 poppins font-medium text-lyx-lightmode-text dark:text-lyx-text-darker border-b-[1px] border-lyx-text-darker"
|
||||
:class="{
|
||||
'dark:!border-[#FFFFFF] dark:!text-[#FFFFFF] !border-lyx-primary !text-lyx-primary': activeTabIndex === index,
|
||||
'hover:border-lyx-lightmode-text-dark hover:text-lyx-lightmode-text-dark/60 dark:hover:border-lyx-text-dark dark:hover:text-lyx-text-dark cursor-pointer': activeTabIndex !== index
|
||||
|
||||
@@ -79,28 +79,13 @@ function reloadPage() {
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex items-center justify-center mt-10">
|
||||
<div class="flex items-center justify-center mt-10 w-full px-10">
|
||||
<div class="flex flex-col gap-6">
|
||||
|
||||
<div class="flex gap-6 xl:flex-row flex-col">
|
||||
|
||||
<div class="h-full w-full">
|
||||
<CardTitled class="h-full w-full xl:min-w-[500px] xl:h-[35rem]" title="Quick setup tutorial"
|
||||
sub="Quickly Set Up Litlyx in 30 Seconds!">
|
||||
|
||||
<div class="flex items-center justify-center h-full w-full">
|
||||
|
||||
<iframe class="w-full h-full min-h-[400px]"
|
||||
src="https://www.youtube.com/embed/LInFoNLJ-CI?si=a97HVXpXFDgFg2Yp" title="Litlyx"
|
||||
frameborder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
|
||||
</div>
|
||||
|
||||
</CardTitled>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<div class="flex gap-4">
|
||||
|
||||
<div class="w-full">
|
||||
<CardTitled title="Quick Integration"
|
||||
@@ -147,28 +132,36 @@ function reloadPage() {
|
||||
<div class="flex flex-col items-end">
|
||||
<div class="justify-center w-full hidden xl:flex gap-3">
|
||||
<a href="https://docs.litlyx.com/techs/js" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/js.png'" alt="Litlyx-Javascript-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/js.png'"
|
||||
alt="Litlyx-Javascript-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/nuxt" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/nuxt.png'" alt="Litlyx-Nuxt-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/nuxt.png'"
|
||||
alt="Litlyx-Nuxt-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/next" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/next.png'" alt="Litlyx-Next-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/next.png'"
|
||||
alt="Litlyx-Next-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/react" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/react.png'" alt="Litlyx-React-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/react.png'"
|
||||
alt="Litlyx-React-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/vue" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/vue.png'" alt="Litlyx-Vue-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/vue.png'"
|
||||
alt="Litlyx-Vue-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/angular" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/angular.png'" alt="Litlyx-Angular-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/angular.png'"
|
||||
alt="Litlyx-Angular-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/python" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/py.png'" alt="Litlyx-Python-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/py.png'"
|
||||
alt="Litlyx-Python-Analytics">
|
||||
</a>
|
||||
<a href="https://docs.litlyx.com/techs/serverless" target="_blank">
|
||||
<img class="cursor-pointer" :src="'tech-icons/serverless.png'" alt="Litlyx-Serverless-Analytics">
|
||||
<img class="cursor-pointer" :src="'tech-icons/serverless.png'"
|
||||
alt="Litlyx-Serverless-Analytics">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -176,6 +169,48 @@ function reloadPage() {
|
||||
</CardTitled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4 w-full">
|
||||
|
||||
|
||||
<CardTitled class="w-full h-full" title="Start with Wordpress."
|
||||
sub="Setup Litlyx analytics in 30 seconds on Wordpress.">
|
||||
<!-- <template #header>
|
||||
<LyxUiButton @click="Lit.event('no_visit_goto_docs')" type="secondary"
|
||||
to="https://docs.litlyx.com/techs/wordpress">
|
||||
Visit documentation
|
||||
</LyxUiButton>
|
||||
</template> -->
|
||||
|
||||
<div class="flex flex-col items-end">
|
||||
<div class="justify-center w-full hidden xl:flex gap-3">
|
||||
<a href="https://docs.litlyx.com/techs/wordpress">
|
||||
<img class="cursor-pointer" :src="'tech-icons/wpel.png'"
|
||||
alt="Litlyx-Wordpress-Elementor">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</CardTitled>
|
||||
|
||||
<CardTitled class="w-full h-full" title="Start with Shopify."
|
||||
sub="Setup Litlyx analytics in 30 seconds on Shopify.">
|
||||
<!-- <template #header>
|
||||
<LyxUiButton @click="Lit.event('no_visit_goto_docs')" type="secondary"
|
||||
to="https://docs.litlyx.com/techs/shopify">
|
||||
Visit documentation
|
||||
</LyxUiButton>
|
||||
</template> -->
|
||||
|
||||
<div class="flex flex-col items-end">
|
||||
<div class="justify-center w-full hidden xl:flex gap-3">
|
||||
<a href="https://docs.litlyx.com/techs/shopify">
|
||||
<img class="cursor-pointer" :src="'tech-icons/shopify.png'" alt="Litlyx-Shopify">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</CardTitled>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ const widgetStyle = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :style="widgetStyle" class="bg-lyx-widget-light"></div>
|
||||
<div :style="widgetStyle" class="dark:bg-lyx-widget-light bg-lyx-lightmode-widget"></div>
|
||||
</template>
|
||||
@@ -9,7 +9,23 @@ const avgDuration = computed(() => {
|
||||
return (backendData.value.durations.durations.reduce((a: any, e: any) => a + parseInt(e[1]), 0) / backendData.value.durations.durations.length);
|
||||
})
|
||||
|
||||
const labels = new Array(650).fill('-');
|
||||
const labels = computed(() => {
|
||||
if (!backendData?.value?.durations) return [];
|
||||
|
||||
const sizes = new Map<string, number>();
|
||||
|
||||
for (const e of backendData.value.durations.durations) {
|
||||
if (!sizes.has(e[0])) {
|
||||
sizes.set(e[0], 0);
|
||||
} else {
|
||||
const data = sizes.get(e[0]) ?? 0;
|
||||
sizes.set(e[0], data + 1);
|
||||
}
|
||||
}
|
||||
|
||||
const max = Array.from(sizes.values()).reduce((a, e) => a > e ? a : e, 0);
|
||||
return new Array(max).fill('-');
|
||||
});
|
||||
|
||||
const durationsDatasets = computed(() => {
|
||||
if (!backendData?.value?.durations) return [];
|
||||
@@ -26,7 +42,7 @@ const durationsDatasets = computed(() => {
|
||||
|
||||
datasets.push({
|
||||
points: consumerDurations.map((e: any) => {
|
||||
return 1000 / parseInt(e[1])
|
||||
return 1000 / parseInt(e[1])
|
||||
}),
|
||||
color: colors[i],
|
||||
chartType: 'line',
|
||||
@@ -45,7 +61,7 @@ const durationsDatasets = computed(() => {
|
||||
|
||||
<div class="cursor-default flex justify-center w-full">
|
||||
|
||||
<div v-if="backendData" class="flex flex-col mt-8 gap-6 px-20 items-center w-full">
|
||||
<div v-if="backendData && !backendPending" class="flex flex-col mt-8 gap-6 px-20 items-center w-full">
|
||||
|
||||
<div class="flex gap-8">
|
||||
<div> Queue size: {{ backendData.queue?.size || 'ERROR' }} </div>
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const { data: feedbacks, pending: pendingFeedbacks } = useFetch<any[]>(() => `/api/admin/feedbacks`, signHeaders());
|
||||
const { data: feedbacks, pending: pendingFeedbacks, refresh } = useFetch<any[]>(() => `/api/admin/feedbacks`, signHeaders());
|
||||
|
||||
|
||||
async function deleteFeedback(id: string) {
|
||||
await $fetch('/api/admin/delete_feedback', {
|
||||
method: 'DELETE',
|
||||
headers: useComputedHeaders({ custom: { 'Content-Type': 'application/json' } }).value,
|
||||
body: JSON.stringify({ id })
|
||||
});
|
||||
refresh();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -13,11 +23,19 @@ const { data: feedbacks, pending: pendingFeedbacks } = useFetch<any[]>(() => `/a
|
||||
<div v-if="feedbacks" class="flex flex-col-reverse gap-4 px-20">
|
||||
<div class="flex flex-col text-center outline outline-[1px] outline-lyx-widget-lighter p-4 gap-2"
|
||||
v-for="feedback of feedbacks">
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="text-lyx-text-dark"> {{ feedback.user[0]?.email || 'DELETED USER' }} </div>
|
||||
<div class="text-lyx-text-dark"> {{ feedback.project[0]?.name || 'DELETED PROJECT' }} </div>
|
||||
<div>
|
||||
<div class="flex flex-col gap-1 items-center">
|
||||
<div class="text-lyx-text-dark"> {{ feedback.user[0]?.email || 'DELETED USER' }} </div>
|
||||
<div class="text-lyx-text-dark flex gap-2 items-center">
|
||||
<div>{{ feedback.project[0]?.name || 'DELETED PROJECT' }}</div>
|
||||
<div @click="deleteFeedback(feedback._id.toString())" class="hover:text-red-200"><i
|
||||
class="fas fa-trash"></i></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{ feedback.text }}
|
||||
</div>
|
||||
{{ feedback.text }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { TAdminProject } from '~/server/api/admin/projects';
|
||||
|
||||
import { PREMIUM_PLAN, getPlanFromId } from '@data/PREMIUM'
|
||||
import { PREMIUM_PLAN, getPlanFromId } from '@data/PLANS'
|
||||
import { useSelectMenuStyle } from '~/composables/ui/useSelectMenuStyle';
|
||||
|
||||
import { sub, format, isSameDay, type Duration, startOfDay, endOfDay } from 'date-fns'
|
||||
@@ -10,35 +10,17 @@ import { sub, format, isSameDay, type Duration, startOfDay, endOfDay } from 'dat
|
||||
const page = ref<number>(1);
|
||||
|
||||
const ordersList = [
|
||||
{ label: 'created_at -->', id: '{ "created_at": 1 }' },
|
||||
{ label: 'created_at <--', id: '{ "created_at": -1 }' },
|
||||
{ label: 'Older', id: '{ "created_at": 1 }' },
|
||||
{ label: 'Newer', id: '{ "created_at": -1 }' },
|
||||
|
||||
{ label: 'active -->', id: '{ "last_log_at": 1 }' },
|
||||
{ label: 'active <--', id: '{ "last_log_at": -1 }' },
|
||||
{ label: 'Less active', id: '{ "last_log_at": 1 }' },
|
||||
{ label: 'More active', id: '{ "last_log_at": -1 }' },
|
||||
|
||||
{ label: 'visits -->', id: '{ "visits": 1 }' },
|
||||
{ label: 'visits <--', id: '{ "visits": -1 }' },
|
||||
{ label: 'Less usage', id: '{ "limit_total": 1 }' },
|
||||
{ label: 'More usage', id: '{ "limit_total": -1 }' },
|
||||
|
||||
{ label: 'events -->', id: '{ "events": 1 }' },
|
||||
{ label: 'events <--', id: '{ "events": -1 }' },
|
||||
|
||||
{ label: 'sessions -->', id: '{ "sessions": 1 }' },
|
||||
{ label: 'sessions <--', id: '{ "sessions": -1 }' },
|
||||
|
||||
{ label: 'usage total -->', id: '{ "limit_total": 1 }' },
|
||||
{ label: 'usage total <--', id: '{ "limit_total": -1 }' },
|
||||
|
||||
{ label: 'usage visits -->', id: '{ "limit_visits": 1 }' },
|
||||
{ label: 'usage visits <--', id: '{ "limit_visits": -1 }' },
|
||||
|
||||
{ label: 'usage events -->', id: '{ "limit_events": 1 }' },
|
||||
{ label: 'usage events <--', id: '{ "limit_events": -1 }' },
|
||||
|
||||
{ label: 'usage ai -->', id: '{ "limit_ai_messages": 1 }' },
|
||||
{ label: 'usage ai <--', id: '{ "limit_ai_messages": -1 }' },
|
||||
|
||||
{ label: 'plan -->', id: '{ "premium_type": 1 }' },
|
||||
{ label: 'plan <--', id: '{ "premium_type": -1 }' },
|
||||
{ label: 'Smaller plan', id: '{ "premium_type": 1 }' },
|
||||
{ label: 'Bigger plan', id: '{ "premium_type": -1 }' },
|
||||
|
||||
]
|
||||
|
||||
@@ -88,12 +70,15 @@ onMounted(() => {
|
||||
|
||||
const filter = ref<string>('{}');
|
||||
|
||||
const { data: projectsInfo, pending: pendingProjects } = await useFetch<{ count: number, projects: TAdminProject[] }>(
|
||||
const { data: projectsInfo, pending: pendingProjects } = useFetch<{ count: number, projects: TAdminProject[] }>(
|
||||
() => `/api/admin/projects?page=${page.value - 1}&limit=${limit.value}&sortQuery=${order.value}&filterQuery=${filter.value}&filterFrom=${selected.value.start.toISOString()}&filterTo=${selected.value.end.toISOString()}`,
|
||||
signHeaders()
|
||||
);
|
||||
|
||||
|
||||
const { data: metrics, pending: pendingMetrics } = useFetch(
|
||||
() => `/api/admin/metrics?filterFrom=${selected.value.start.toISOString()}&filterTo=${selected.value.end.toISOString()}`,
|
||||
signHeaders()
|
||||
);
|
||||
|
||||
const { uiMenu } = useSelectMenuStyle();
|
||||
|
||||
@@ -136,7 +121,7 @@ const { uiMenu } = useSelectMenuStyle();
|
||||
<div class="flex gap-2 items-center shrink-0">
|
||||
<div>Page {{ page }} </div>
|
||||
<div> {{ Math.min(limit, projectsInfo?.count || 0) }} of {{ projectsInfo?.count || 0
|
||||
}}</div>
|
||||
}}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -165,12 +150,29 @@ const { uiMenu } = useSelectMenuStyle();
|
||||
</UPopover>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="w-[80%]">
|
||||
<div v-if="pendingMetrics"> Loading... </div>
|
||||
<div class="flex gap-10 flex-wrap" v-if="!pendingMetrics && metrics">
|
||||
<div> Projects: {{ metrics.totalProjects }} ({{ metrics.premiumProjects }} premium) </div>
|
||||
<div>
|
||||
Total visits: {{ formatNumberK(metrics.totalVisits) }}
|
||||
</div>
|
||||
<div>
|
||||
Active: {{ metrics.totalProjects - metrics.deadProjects }} |
|
||||
Dead: {{ metrics.deadProjects }}
|
||||
</div>
|
||||
<div>
|
||||
Total events: {{ formatNumberK(metrics.totalEvents) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div
|
||||
class="cursor-default flex justify-center flex-wrap gap-6 mb-[4rem] mt-4 overflow-auto h-full pt-6 pb-[8rem]">
|
||||
class="cursor-default flex justify-center flex-wrap gap-6 mb-[4rem] mt-4 overflow-auto h-full pt-6 pb-[20rem]">
|
||||
|
||||
<AdminOverviewProjectCard v-if="!pendingProjects" :key="project._id.toString()" :project="project"
|
||||
class="w-[26rem]" v-for="project of projectsInfo?.projects" />
|
||||
|
||||
@@ -2,14 +2,34 @@
|
||||
|
||||
import { useSelectMenuStyle } from '~/composables/ui/useSelectMenuStyle';
|
||||
import type { TAdminUser } from '~/server/api/admin/users';
|
||||
import { sub, format, isSameDay, type Duration, startOfDay, endOfDay } from 'date-fns'
|
||||
|
||||
|
||||
|
||||
const filterText = ref<string>('');
|
||||
|
||||
watch(filterText,()=>{
|
||||
watch(filterText, () => {
|
||||
page.value = 1;
|
||||
})
|
||||
|
||||
function isRangeSelected(duration: Duration) {
|
||||
return isSameDay(selected.value.start, sub(new Date(), duration)) && isSameDay(selected.value.end, new Date())
|
||||
}
|
||||
|
||||
function selectRange(duration: Duration) {
|
||||
selected.value = { start: sub(new Date(), duration), end: new Date() }
|
||||
}
|
||||
|
||||
const ranges = [
|
||||
{ label: 'Last 7 days', duration: { days: 7 } },
|
||||
{ label: 'Last 14 days', duration: { days: 14 } },
|
||||
{ label: 'Last 30 days', duration: { days: 30 } },
|
||||
{ label: 'Last 3 months', duration: { months: 3 } },
|
||||
{ label: 'Last 6 months', duration: { months: 6 } },
|
||||
{ label: 'Last year', duration: { years: 1 } }
|
||||
]
|
||||
const selected = ref<{ start: Date, end: Date }>({ start: sub(new Date(), { days: 14 }), end: new Date() })
|
||||
|
||||
const filter = computed(() => {
|
||||
return JSON.stringify({
|
||||
$or: [
|
||||
@@ -39,7 +59,7 @@ const limitList = [
|
||||
const limit = ref<number>(20);
|
||||
|
||||
const { data: usersInfo, pending: pendingUsers } = await useFetch<{ count: number, users: TAdminUser[] }>(
|
||||
() => `/api/admin/users?page=${page.value - 1}&limit=${limit.value}&sortQuery=${order.value}&filterQuery=${filter.value}`,
|
||||
() => `/api/admin/users?page=${page.value - 1}&limit=${limit.value}&sortQuery=${order.value}&filterQuery=${filter.value}&filterFrom=${selected.value.start.toISOString()}&filterTo=${selected.value.end.toISOString()}`,
|
||||
signHeaders()
|
||||
);
|
||||
|
||||
@@ -51,46 +71,73 @@ const { uiMenu } = useSelectMenuStyle();
|
||||
<div class="mt-6 h-full">
|
||||
|
||||
|
||||
<div class="flex items-center gap-10 px-10">
|
||||
<div class="flex flex-col items-center gap-6">
|
||||
|
||||
<div class="flex gap-2 items-center">
|
||||
<div>Order:</div>
|
||||
<USelectMenu :uiMenu="uiMenu" class="w-[12rem]" placeholder="Order" :options="ordersList"
|
||||
value-attribute="id" option-attribute="label" v-model="order">
|
||||
</USelectMenu>
|
||||
</div>
|
||||
<div class="flex items-center gap-10 px-10">
|
||||
<div class="flex gap-2 items-center">
|
||||
<div>Order:</div>
|
||||
<USelectMenu :uiMenu="uiMenu" class="w-[12rem]" placeholder="Order" :options="ordersList"
|
||||
value-attribute="id" option-attribute="label" v-model="order">
|
||||
</USelectMenu>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex gap-2 items-center">
|
||||
<div>Limit:</div>
|
||||
<USelectMenu :uiMenu="uiMenu" class="w-[12rem]" placeholder="Limit" :options="limitList"
|
||||
value-attribute="id" option-attribute="label" v-model="limit">
|
||||
</USelectMenu>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<div>Limit:</div>
|
||||
<USelectMenu :uiMenu="uiMenu" class="w-[12rem]" placeholder="Limit" :options="limitList"
|
||||
value-attribute="id" option-attribute="label" v-model="limit">
|
||||
</USelectMenu>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 items-center">
|
||||
<LyxUiInput placeholder="Search user" class="px-2 py-1" v-model="filterText"></LyxUiInput>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 items-center">
|
||||
<div>Page {{ page }} </div>
|
||||
<div>
|
||||
{{ Math.min(limit, usersInfo?.count || 0) }}
|
||||
of
|
||||
{{ usersInfo?.count || 0 }}
|
||||
<div class="flex gap-2 items-center">
|
||||
<LyxUiInput placeholder="Search user" class="px-2 py-1" v-model="filterText"></LyxUiInput>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<UPagination v-model="page" :page-count="limit" :total="usersInfo?.count || 0" />
|
||||
<div class="flex items-centet gap-10">
|
||||
<div class="flex gap-2 items-center">
|
||||
<div>Page {{ page }} </div>
|
||||
<div>
|
||||
{{ Math.min(limit, usersInfo?.count || 0) }}
|
||||
of
|
||||
{{ usersInfo?.count || 0 }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<UPagination v-model="page" :page-count="limit" :total="usersInfo?.count || 0" />
|
||||
</div>
|
||||
|
||||
<UPopover class="w-[20rem]" :popper="{ placement: 'bottom' }">
|
||||
<UButton class="w-full" color="primary" variant="solid">
|
||||
<div class="flex items-center justify-center w-full gap-2">
|
||||
<i class="i-heroicons-calendar-days-20-solid"></i>
|
||||
{{ selected.start.toLocaleDateString() }} - {{ selected.end.toLocaleDateString() }}
|
||||
</div>
|
||||
</UButton>
|
||||
<template #panel="{ close }">
|
||||
<div class="flex items-center sm:divide-x divide-gray-200 dark:divide-gray-800">
|
||||
<div class="hidden sm:flex flex-col py-4">
|
||||
<UButton v-for="(range, index) in ranges" :key="index" :label="range.label" color="gray"
|
||||
variant="ghost" class="rounded-none px-6"
|
||||
:class="[isRangeSelected(range.duration) ? 'bg-gray-100 dark:bg-gray-800' : 'hover:bg-gray-50 dark:hover:bg-gray-800/50']"
|
||||
truncate @click="selectRange(range.duration)" />
|
||||
</div>
|
||||
|
||||
<DatePicker v-model="selected" @close="close" />
|
||||
</div>
|
||||
</template>
|
||||
</UPopover>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div
|
||||
class="cursor-default flex justify-center flex-wrap gap-6 mb-[4rem] mt-4 overflow-auto h-full pt-6 pb-[8rem]">
|
||||
class="cursor-default flex justify-center flex-wrap gap-6 mb-[4rem] mt-4 overflow-auto h-full pt-6 pb-[16rem]">
|
||||
|
||||
<AdminUsersUserCard v-if="!pendingUsers" :key="user._id.toString()" :user="user" class="w-[26rem]"
|
||||
v-for="user of usersInfo?.users" />
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { TAdminProject } from '~/server/api/admin/projects';
|
||||
|
||||
const props = defineProps<{ pid: string }>();
|
||||
|
||||
const { data: projectInfo, refresh, pending } = useFetch<{ domains: { _id: string }[], project: TAdminProject }>(
|
||||
() => `/api/admin/project_info?pid=${props.pid}`,
|
||||
signHeaders(),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div class="mt-6 h-full flex flex-col gap-10 w-full" v-if="!pending">
|
||||
|
||||
<div>
|
||||
<LyxUiButton type="secondary" @click="refresh"> Refresh </LyxUiButton>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center gap-10" v-if="projectInfo">
|
||||
|
||||
<AdminOverviewProjectCard :project="projectInfo.project" class="w-[30rem] shrink-0" />
|
||||
|
||||
<AdminMiniChart class="max-w-[40rem]" :pid="pid"></AdminMiniChart>
|
||||
</div>
|
||||
|
||||
<div v-if="projectInfo" class="flex flex-col">
|
||||
|
||||
<div>Domains:</div>
|
||||
|
||||
<div class="flex flex-wrap gap-8 mt-8">
|
||||
|
||||
<div v-for="domain of projectInfo.domains">
|
||||
{{ domain._id }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div v-if="pending">
|
||||
Loading...
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
35
dashboard/components/admin/dialog/UserDetails.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<script lang="ts" setup>
|
||||
import type { TAdminUserInfo } from '~/server/api/admin/user_info';
|
||||
|
||||
|
||||
const props = defineProps<{ user_id: string }>();
|
||||
|
||||
const { data: userInfo, refresh, pending } = useFetch<{ projects: TAdminUserInfo }>(
|
||||
() => `/api/admin/user_info?user_id=${props.user_id}`,
|
||||
signHeaders(),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div class="mt-6 h-full flex flex-col gap-10 w-full overflow-y-auto pb-[10rem]" v-if="!pending">
|
||||
|
||||
<div>
|
||||
<LyxUiButton type="secondary" @click="refresh"> Refresh </LyxUiButton>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center gap-10 flex-wrap" v-if="userInfo">
|
||||
|
||||
<AdminOverviewProjectCard v-for="project of userInfo.projects" :project="project as any"
|
||||
class="w-[30rem] shrink-0" />
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div v-if="pending">
|
||||
Loading...
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,20 +1,19 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
import type { TAdminProject } from '~/server/api/admin/projects';
|
||||
import { getPlanFromId } from '~/shared/data/PREMIUM';
|
||||
import { getPlanFromId } from '~/shared/data/PLANS';
|
||||
|
||||
|
||||
import { AdminDialogProjectDetails } from '#components';
|
||||
import { AdminDialogUserDetails } from '#components';
|
||||
|
||||
const { openDialogEx } = useCustomDialog();
|
||||
|
||||
function showProjectDetails(pid: string) {
|
||||
openDialogEx(AdminDialogProjectDetails, {
|
||||
params: { pid }
|
||||
function showUserDetails(user_id: string) {
|
||||
openDialogEx(AdminDialogUserDetails, {
|
||||
params: { user_id }
|
||||
})
|
||||
}
|
||||
|
||||
const props = defineProps<{ project: TAdminProject }>();
|
||||
const props = defineProps<{ project: TAdminProject & { domains?: string[] } }>();
|
||||
|
||||
|
||||
const logBg = computed(() => {
|
||||
@@ -69,9 +68,9 @@ const usageAiLabel = computed(() => {
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4 justify-center text-[.9rem]">
|
||||
<UTooltip :text="`PRICE_ID: ${project.premium_type}`">
|
||||
<UTooltip :text="`PRICE_ID: ${project.premium[0].premium_type}`">
|
||||
<div class="font-medium text-lyx-text-dark">
|
||||
{{ getPlanFromId(project.premium_type)?.TAG?.replace('APPSUMO', 'AS') ?? 'ERROR' }}
|
||||
{{ getPlanFromId(project.premium[0].premium_type)?.TAG?.replace('APPSUMO', 'AS') ?? 'ERROR' }}
|
||||
</div>
|
||||
</UTooltip>
|
||||
<div class="text-lyx-text-darker">
|
||||
@@ -79,9 +78,11 @@ const usageAiLabel = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-5 justify-center">
|
||||
<div @click="showProjectDetails(project._id.toString())" class="font-medium hover:text-lyx-primary cursor-pointer">
|
||||
{{ project.name }}
|
||||
<div class="flex flex-col items-center py-1">
|
||||
<div class="text-center"> {{ project.name }} </div>
|
||||
<div v-if="project.user" @click="showUserDetails(project.premium[0].user_id.toString())"
|
||||
class="font-medium hover:text-lyx-primary cursor-pointer text-center">
|
||||
{{ project.user[0].email }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -128,6 +129,13 @@ const usageAiLabel = computed(() => {
|
||||
|
||||
</div>
|
||||
|
||||
<LyxUiSeparator class="my-2" />
|
||||
|
||||
<div v-if="project.domains" class="flex flex-wrap gap-4">
|
||||
<div v-for="domain of project.domains" class="hover:text-gray-200 cursor-pointer">
|
||||
{{ domain }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
import type { TAdminProject } from '~/server/api/admin/projects';
|
||||
import type { TAdminUser } from '~/server/api/admin/users';
|
||||
import { getPlanFromId } from '~/shared/data/PREMIUM';
|
||||
import { getPlanFromId } from '~/shared/data/PLANS';
|
||||
|
||||
import { AdminDialogProjectDetails } from '#components';
|
||||
import { AdminDialogUserDetails } from '#components';
|
||||
|
||||
const { openDialogEx } = useCustomDialog();
|
||||
|
||||
function showProjectDetails(pid: string) {
|
||||
openDialogEx(AdminDialogProjectDetails, {
|
||||
params: { pid }
|
||||
function showUserDetails(user_id: string) {
|
||||
openDialogEx(AdminDialogUserDetails, {
|
||||
params: { user_id }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -31,34 +31,11 @@ const props = defineProps<{ user: TAdminUser }>();
|
||||
</div>
|
||||
|
||||
<div class="flex gap-5 justify-center">
|
||||
<div class="font-medium">
|
||||
<div class="font-medium hover:text-blue-400 cursor-pointer" @click="showUserDetails(user._id.toString())">
|
||||
{{ user.email }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LyxUiSeparator class="my-2" />
|
||||
|
||||
<div class="flex flex-col text-[.9rem]">
|
||||
<div class="flex gap-2" v-for="project of user.projects">
|
||||
<div class="text-lyx-text-darker">
|
||||
{{ new Date(project.created_at).toLocaleDateString('it-IT') }}
|
||||
</div>
|
||||
<UTooltip :text="`PRICE_ID: ${project.premium_type}`">
|
||||
<div class="font-medium text-lyx-text-dark">
|
||||
{{ getPlanFromId(project.premium_type)?.TAG?.replace('APPSUMO', 'AS') ?? 'ERROR' }}
|
||||
</div>
|
||||
</UTooltip>
|
||||
|
||||
<div @click="showProjectDetails(project._id.toString())"
|
||||
class="ml-1 hover:text-lyx-primary cursor-pointer">
|
||||
{{ project.name }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- <div class="poppins outline outline-[1px] outline-lyx-widget-lighter p-3 rounded-md relative">
|
||||
|
||||
@@ -7,11 +7,7 @@ function goToUpgrade() {
|
||||
showDrawer('PRICING');
|
||||
}
|
||||
|
||||
const { project } = useProject()
|
||||
|
||||
const isPremium = computed(() => {
|
||||
return project.value?.premium ?? false;
|
||||
});
|
||||
const { isPremium } = useLoggedUser()
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ const chartData = ref<ChartData<'line' | 'bar' | 'bubble'>>({
|
||||
type: 'bubble',
|
||||
stack: 'combined',
|
||||
borderColor: ["#fbbf24"]
|
||||
},
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
@@ -198,11 +198,16 @@ const selectLabelsAvailable = computed<{ label: string, value: Slice, disabled:
|
||||
})
|
||||
|
||||
const selectedSlice = computed<Slice>(() => {
|
||||
console.log({ available: selectLabelsAvailable.value })
|
||||
const targetValue = selectLabelsAvailable.value[selectedLabelIndex.value];
|
||||
if (!targetValue) return 'day';
|
||||
if (targetValue.disabled) {
|
||||
selectedLabelIndex.value = selectLabelsAvailable.value.findIndex(e => !e.disabled);
|
||||
}
|
||||
if (selectedLabelIndex.value === -1) {
|
||||
console.error('ERROR CANNOT FIND CORRECT SLICE')
|
||||
return 'day';
|
||||
}
|
||||
return selectLabelsAvailable.value[selectedLabelIndex.value].value
|
||||
});
|
||||
|
||||
@@ -215,9 +220,14 @@ function transformResponse(input: { _id: string, count: number }[]) {
|
||||
const labels = input.map(e => DateService.getChartLabelFromISO(e._id, new Date().getTimezoneOffset(), selectedSlice.value));
|
||||
if (input.length > 0) allDatesFull.value = input.map(e => e._id.toString());
|
||||
|
||||
const todayIndex = input.findIndex(e => new Date(e._id).getTime() > (Date.now() - new Date().getTimezoneOffset() * 1000 * 60));
|
||||
const current = (Date.now());
|
||||
//console.log(input.map(e => e._id));
|
||||
//console.log(new Date(current));
|
||||
|
||||
return { data, labels, todayIndex }
|
||||
const todayIndex = input.findIndex(e => new Date(e._id).getTime() >= current);
|
||||
|
||||
//console.log({ todayIndex })
|
||||
return { data, labels, todayIndex: todayIndex + 1 }
|
||||
}
|
||||
|
||||
function onResponseError(e: any) {
|
||||
@@ -276,7 +286,6 @@ function onDataReady() {
|
||||
chartData.value.datasets[1].backgroundColor = [createGradient('#4abde8')];
|
||||
chartData.value.datasets[2].backgroundColor = [createGradient('#fbbf24')];
|
||||
|
||||
|
||||
(chartData.value.datasets[1] as any).borderSkipped = sessionsData.data.value.data.map((e, i) => {
|
||||
const todayIndex = eventsData.data.value?.todayIndex || 0;
|
||||
if (i == todayIndex - 1) return true;
|
||||
@@ -362,6 +371,12 @@ const legendClasses = ref<string[]>([
|
||||
{{ (currentTooltipData as any)[tooltipNameIndex[index]] }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 font-normal flex flex-col text-[.9rem] dark:text-lyx-text-dark text-lyx-lightmode-text-dark"
|
||||
v-if="(currentTooltipData as any).sessions > (currentTooltipData as any).visits">
|
||||
<div> Unique visitors are higher than total visits </div>
|
||||
<div> which often means bots (automated scripts or crawlers)</div>
|
||||
<div> are inflating the numbers.</div>
|
||||
</div>
|
||||
<!-- <div class="bg-lyx-background-lighter h-[2px] w-full my-2"> </div> -->
|
||||
</LyxUiCard>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ const { snapshot, safeSnapshotDates, snapshotDuration } = useSnapshot()
|
||||
|
||||
const chartSlice = computed(() => {
|
||||
if (snapshotDuration.value <= 3) return 'hour' as Slice;
|
||||
if (snapshotDuration.value <= 32) return 'day' as Slice;
|
||||
if (snapshotDuration.value <= 31 * 2) return 'day' as Slice;
|
||||
return 'month' as Slice;
|
||||
});
|
||||
|
||||
@@ -68,27 +68,56 @@ const avgBouncingRate = computed(() => {
|
||||
return avg.toFixed(2) + ' %';
|
||||
})
|
||||
|
||||
function weightedAverage(data: number[]): number {
|
||||
if (data.length === 0) return 0;
|
||||
|
||||
// Compute median
|
||||
const sortedData = [...data].sort((a, b) => a - b);
|
||||
const middle = Math.floor(sortedData.length / 2);
|
||||
const median = sortedData.length % 2 === 0
|
||||
? (sortedData[middle - 1] + sortedData[middle]) / 2
|
||||
: sortedData[middle];
|
||||
|
||||
// Define a threshold (e.g., 3 times the median) to filter out extreme values
|
||||
const threshold = median * 3;
|
||||
const filteredData = data.filter(num => num <= threshold);
|
||||
|
||||
if (filteredData.length === 0) return median; // Fallback to median if all are removed
|
||||
|
||||
// Compute weights based on inverse absolute deviation from median
|
||||
const weights = filteredData.map(num => 1 / (1 + Math.abs(num - median)));
|
||||
|
||||
// Compute weighted sum and sum of weights
|
||||
const weightedSum = filteredData.reduce((sum, num, i) => sum + num * weights[i], 0);
|
||||
const sumOfWeights = weights.reduce((sum, weight) => sum + weight, 0);
|
||||
|
||||
return weightedSum / sumOfWeights;
|
||||
}
|
||||
const avgSessionDuration = computed(() => {
|
||||
if (!sessionsDurationData.data.value) return '0.00 %'
|
||||
|
||||
const counts = sessionsDurationData.data.value.data
|
||||
.filter(e => e > 0)
|
||||
// .filter(e => e > 0)
|
||||
.reduce((a, e) => e + a, 0);
|
||||
|
||||
const avg = counts / (Math.max(sessionsDurationData.data.value.data.filter(e => e > 0).length, 1)) / 5;
|
||||
const avg = weightedAverage(sessionsDurationData.data.value.data);
|
||||
// counts / (Math.max(sessionsDurationData.data.value.data.length, 1));
|
||||
|
||||
let hours = 0;
|
||||
let minutes = 0;
|
||||
let seconds = 0;
|
||||
seconds += avg * 60;
|
||||
while (seconds > 60) { seconds -= 60; minutes += 1; }
|
||||
while (minutes > 60) { minutes -= 60; hours += 1; }
|
||||
while (seconds >= 60) { seconds -= 60; minutes += 1; }
|
||||
while (minutes >= 60) { minutes -= 60; hours += 1; }
|
||||
|
||||
|
||||
if (hours == 0 && minutes == 0 && seconds < 10) return `0m ~10s`
|
||||
return `${hours > 0 ? hours + 'h ' : ''}${minutes}m ${seconds.toFixed()}s`
|
||||
});
|
||||
|
||||
const todayIndex = computed(() => {
|
||||
if (!visitsData.data.value) return -1;
|
||||
return visitsData.data.value.input.findIndex(e => new Date(e._id).getTime() > (Date.now() - new Date().getTimezoneOffset() * 1000 * 60));
|
||||
return visitsData.data.value.input.findIndex(e => new Date(e._id).getTime() > (Date.now()));
|
||||
})
|
||||
|
||||
|
||||
|
||||
38
dashboard/components/dialog/ConfirmLogout.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const emit = defineEmits(['success', 'cancel'])
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'dark:bg-lyx-widget bg-lyx-lightmode-widget-light',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="h-full flex flex-col gap-2 p-4">
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
|
||||
<div class="font-medium">
|
||||
Are you sure to logout ?
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<LyxUiButton type="secondary" @click="emit('cancel')">
|
||||
Cancel
|
||||
</LyxUiButton>
|
||||
<LyxUiButton @click="emit('success')" type="danger">
|
||||
Confirm
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
|
||||
</template>
|
||||
@@ -107,7 +107,7 @@ async function confirmSnapshot() {
|
||||
Cancel
|
||||
</LyxUiButton>
|
||||
<LyxUiButton @click="confirmSnapshot()" type="primary" class="w-full text-center"
|
||||
:disabled="snapshotName.length == 0">
|
||||
:disabled="snapshotName.trim().length == 0">
|
||||
Confirm
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
|
||||
86
dashboard/components/dialog/InviteManager.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<script lang="ts" setup>
|
||||
import Accept_invite from '~/pages/accept_invite.vue';
|
||||
|
||||
|
||||
const { createAlert } = useAlert();
|
||||
const { close } = useModal()
|
||||
|
||||
const emit = defineEmits(['success', 'cancel'])
|
||||
|
||||
const props = defineProps<{
|
||||
invites: {
|
||||
project_name: string, project_id: string
|
||||
}[]
|
||||
}>();
|
||||
|
||||
async function acceptInvite(project_id: string) {
|
||||
try {
|
||||
await $fetch('/api/project/members/accept', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ project_id }),
|
||||
headers: useComputedHeaders({
|
||||
custom: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).value
|
||||
});
|
||||
emit('success');
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
alert('Error accepting invite');
|
||||
emit('cancel');
|
||||
}
|
||||
}
|
||||
|
||||
async function declineInvite(project_id: string) {
|
||||
try {
|
||||
await $fetch('/api/project/members/decline', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ project_id }),
|
||||
headers: useComputedHeaders({
|
||||
custom: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).value
|
||||
});
|
||||
emit('success');
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
alert('Error accepting invite');
|
||||
emit('cancel');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'dark:bg-lyx-widget bg-lyx-lightmode-widget-light',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="h-full flex flex-col gap-8 p-6">
|
||||
|
||||
<div class="flex flex-col gap-6" v-for="invite of invites">
|
||||
|
||||
<div class="dark:text-lyx-text text-lyx-lightmode-text">
|
||||
You are invited to join
|
||||
<span class="font-semibold">{{ invite.project_name }}</span>.
|
||||
Do you accept?
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4 w-full justify-end">
|
||||
<LyxUiButton @click="declineInvite(invite.project_id)" type="secondary"> Decline </LyxUiButton>
|
||||
<LyxUiButton @click="acceptInvite(invite.project_id)" type="primary"> Accept </LyxUiButton>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
</template>
|
||||
118
dashboard/components/dialog/PermissionManager.vue
Normal file
@@ -0,0 +1,118 @@
|
||||
<script lang="ts" setup>
|
||||
import { useSelectMenuStyle } from '~/composables/ui/useSelectMenuStyle';
|
||||
import type { TTeamMember } from '~/shared/schema/TeamMemberSchema';
|
||||
|
||||
const emit = defineEmits(['success', 'cancel'])
|
||||
|
||||
const props = defineProps<{ member_id: string }>();
|
||||
|
||||
const { domainList, domain, setActiveDomain, refreshDomains, refreshingDomains } = useDomain();
|
||||
|
||||
const { data: member } = useFetch<TTeamMember>(`/api/project/members/get?member_id=${props.member_id}`, {
|
||||
headers: useComputedHeaders({})
|
||||
})
|
||||
|
||||
const { createAlert } = useAlert()
|
||||
|
||||
async function save(member_id: string) {
|
||||
if (!member.value) return;
|
||||
const res = await $fetch('/api/project/members/edit', {
|
||||
method: 'POST',
|
||||
headers: useComputedHeaders({ custom: { 'Content-Type': 'application/json' } }).value,
|
||||
body: JSON.stringify({
|
||||
member_id,
|
||||
webAnalytics: member.value.permission.webAnalytics,
|
||||
events: member.value.permission.events,
|
||||
ai: member.value.permission.ai,
|
||||
domains: member.value.permission.domains
|
||||
})
|
||||
});
|
||||
createAlert('Saved', 'Permission saved successfully', 'fas fa-check', 2500);
|
||||
emit('success')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'bg-lyx-lightmode-widget dark:bg-lyx-widget',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="p-8">
|
||||
<div v-if="member" class="manage flex flex-col gap-4">
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="poppins text-[1.1rem]"> Manage permissions </div>
|
||||
<div class="poppins text-[.9rem] dark:text-lyx-text-dark"> Choose what this member can do on this project. </div>
|
||||
</div>
|
||||
|
||||
<LyxUiSeparator></LyxUiSeparator>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<div>
|
||||
<div class="mb-1"> Select what domain is allowed to see: </div>
|
||||
<div class="mb-1">
|
||||
<USelectMenu v-model="member.permission.domains" :options="domainList" multiple
|
||||
value-attribute="_id">
|
||||
<template #option="{ option, active, selected }">
|
||||
<div class="flex items-center gap-2">
|
||||
<div>
|
||||
<img class="h-5 bg-black rounded-full" :src="'/logo_32.png'"
|
||||
alt="Litlyx logo">
|
||||
</div>
|
||||
<div> {{ option._id }} </div>
|
||||
</div>
|
||||
</template>
|
||||
<template #label="e">
|
||||
<div class="flex items-center gap-2">
|
||||
<div>
|
||||
<img class="h-5 bg-black rounded-full" :src="'/logo_32.png'"
|
||||
alt="Litlyx logo">
|
||||
</div>
|
||||
<div>
|
||||
{{
|
||||
member.permission.domains.length > 2 ?
|
||||
`${member.permission.domains.length} domains` :
|
||||
(member.permission.domains.map(e => e).join(' & ') || 'No domains')
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<UCheckbox v-model="member.permission.webAnalytics"></UCheckbox>
|
||||
<div> Allow web analytics page </div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<UCheckbox v-model="member.permission.events"></UCheckbox>
|
||||
<div> Allow events page </div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<UCheckbox v-model="member.permission.ai"></UCheckbox>
|
||||
<div> Allow to use AI data analyst </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="flex gap-2 justify-end mt-8">
|
||||
<LyxUiButton class="!w-[6rem] text-center" type="secondary" @click="emit('cancel')"> Cancel </LyxUiButton>
|
||||
<LyxUiButton class="!w-[6rem] text-center" v-if="member?.permission" @click="save(member._id.toString())" type="primary">
|
||||
Save
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
|
||||
</template>
|
||||
80
dashboard/components/dialog/shields/AddAddress.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const emit = defineEmits(['success', 'cancel']);
|
||||
|
||||
const address = ref<string>('');
|
||||
const description = ref<string>('');
|
||||
|
||||
|
||||
const { data: currentIP } = useFetch<any>('https://api.ipify.org/?format=json');
|
||||
|
||||
|
||||
const canAddAddress = computed(() => {
|
||||
return address.value.trim().length > 0;
|
||||
})
|
||||
|
||||
async function addAddress() {
|
||||
if (!canAddAddress.value) return;
|
||||
try {
|
||||
const res = await $fetch('/api/shields/ip/add', {
|
||||
method: 'POST',
|
||||
headers: useComputedHeaders({}).value,
|
||||
body: JSON.stringify({ address: address.value, description: description.value })
|
||||
});
|
||||
address.value = '';
|
||||
emit('success');
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
emit('cancel');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'dark:bg-lyx-widget bg-lyx-lightmode-widget-light',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="h-full flex flex-col gap-2 p-4">
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
|
||||
<div class="font-semibold text-[1.1rem]"> Add IP to Block List </div>
|
||||
|
||||
<div class="flex flex-col gap-2 dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
<div> Your current IP address is: {{ currentIP?.ip || '...' }} </div>
|
||||
<div> Copy and Paste your IP address in the box below or enter a custom address </div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="font-medium"> IP Address </div>
|
||||
<LyxUiInput class="px-2 py-1" v-model="address" placeholder="127.0.0.1"></LyxUiInput>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="font-medium"> Description (optional) </div>
|
||||
<LyxUiInput class="px-2 py-1" v-model="description" placeholder="e.g. localhost or office">
|
||||
</LyxUiInput>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2 dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
<div> Once added, we will start rejecting traffic from this IP within a few minutes.</div>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<LyxUiButton class="w-full text-center" :disabled="!canAddAddress" @click="addAddress()"
|
||||
type="primary">
|
||||
Add IP Address
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
|
||||
</template>
|
||||
67
dashboard/components/dialog/shields/AddDomain.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const emit = defineEmits(['success', 'cancel']);
|
||||
|
||||
const domain = ref<string>('');
|
||||
|
||||
const canAddDomain = computed(() => {
|
||||
return domain.value.trim().length > 0;
|
||||
})
|
||||
|
||||
async function addDomain() {
|
||||
if (!canAddDomain.value) return;
|
||||
try {
|
||||
const res = await $fetch('/api/shields/domains/add', {
|
||||
method: 'POST',
|
||||
headers: useComputedHeaders({}).value,
|
||||
body: JSON.stringify({ domain: domain.value })
|
||||
});
|
||||
domain.value = '';
|
||||
emit('success');
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
emit('cancel');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'dark:bg-lyx-widget bg-lyx-lightmode-widget-light',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="h-full flex flex-col gap-2 p-4">
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
|
||||
<div class="font-semibold text-[1.1rem]"> Add Domain to Allow List </div>
|
||||
|
||||
<LyxUiInput class="px-2 py-1" v-model="domain"></LyxUiInput>
|
||||
|
||||
<div class="flex flex-col gap-2 dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
<div>
|
||||
<div> You can use a wildcard (*) to match multiple hostnames. </div>
|
||||
<div> For example, *.domain.com will only record traffic on the main domain and all the
|
||||
subdomains.
|
||||
</div>
|
||||
</div>
|
||||
<div> NB: Once added, we will start allowing traffic only from matching hostnames within a few
|
||||
minutes.</div>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<LyxUiButton class="w-full text-center" :disabled="!canAddDomain" @click="addDomain()" type="primary">
|
||||
Add domain
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
|
||||
</template>
|
||||
56
dashboard/components/dialog/shields/DeleteAddress.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const emit = defineEmits(['success', 'cancel']);
|
||||
|
||||
const props = defineProps<{ address: string }>();
|
||||
|
||||
async function deleteAddress() {
|
||||
if (!props.address) return;
|
||||
try {
|
||||
const res = await $fetch('/api/shields/ip/delete', {
|
||||
method: 'DELETE',
|
||||
headers: useComputedHeaders({}).value,
|
||||
body: JSON.stringify({ address: props.address })
|
||||
});
|
||||
emit('success');
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
emit('cancel');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'dark:bg-lyx-widget bg-lyx-lightmode-widget-light',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="h-full flex flex-col gap-2 p-4">
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
|
||||
<div class="font-semibold text-[1.1rem]"> IP Address delete </div>
|
||||
|
||||
<div> Are you sure to delete the blacklisted IP Address
|
||||
<span class="font-semibold">{{ props.address }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<LyxUiButton type="secondary" @click="emit('cancel')">
|
||||
Cancel
|
||||
</LyxUiButton>
|
||||
<LyxUiButton @click="deleteAddress()" type="danger">
|
||||
Delete
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
|
||||
</template>
|
||||
56
dashboard/components/dialog/shields/DeleteDomain.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const emit = defineEmits(['success', 'cancel']);
|
||||
|
||||
const props = defineProps<{ domain: string }>();
|
||||
|
||||
async function deleteDomain() {
|
||||
if (!props.domain) return;
|
||||
try {
|
||||
const res = await $fetch('/api/shields/domains/delete', {
|
||||
method: 'DELETE',
|
||||
headers: useComputedHeaders({}).value,
|
||||
body: JSON.stringify({ domain: props.domain })
|
||||
});
|
||||
emit('success');
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
emit('cancel');
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UModal :ui="{
|
||||
strategy: 'override',
|
||||
overlay: {
|
||||
background: 'bg-lyx-background/85'
|
||||
},
|
||||
background: 'dark:bg-lyx-widget bg-lyx-lightmode-widget-light',
|
||||
ring: 'border-solid border-[1px] border-[#262626]'
|
||||
}">
|
||||
<div class="h-full flex flex-col gap-2 p-4">
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
|
||||
<div class="font-semibold text-[1.1rem]"> Domain delete </div>
|
||||
|
||||
<div> Are you sure to delete the whitelisted domain
|
||||
<span class="font-semibold">{{ props.domain }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<LyxUiButton type="secondary" @click="emit('cancel')">
|
||||
Cancel
|
||||
</LyxUiButton>
|
||||
<LyxUiButton @click="deleteDomain()" type="danger">
|
||||
Delete
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</UModal>
|
||||
|
||||
</template>
|
||||
@@ -196,7 +196,7 @@ function getPricingsData() {
|
||||
<div class="flex justify-between items-center mt-10 flex-col xl:flex-row">
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="poppins text-[1.1rem] text-lyx-lightmode-text dark:text-yellow-400 mb-2">
|
||||
*Plan upgrades are applicable exclusively to this project(workspace).
|
||||
*Plan upgrades are applied to account level.
|
||||
</div>
|
||||
<div class="poppins text-[2rem] font-semibold">
|
||||
Do you need help ?
|
||||
|
||||
@@ -72,7 +72,7 @@ const canSearch = computed(() => {
|
||||
<template>
|
||||
|
||||
|
||||
<CardTitled title="Event metadata analyzer" sub="Filter events metadata fields to analyze them" class="w-full p-4">
|
||||
<CardTitled title="Analyze event metadata" sub="Filter events metadata fields to analyze them" class="w-full p-4">
|
||||
|
||||
<div class="">
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<AdvancedStackedBarChart v-if="!eventsStackedData.pending.value && !errorData.errored"
|
||||
:datasets="eventsStackedData.data.value?.datasets || []"
|
||||
:labels="eventsStackedData.data.value?.labels || []">
|
||||
:labels="eventsStackedData.data.value?.labels || []" legendPosition="bottom">
|
||||
</AdvancedStackedBarChart>
|
||||
<div v-if="errorData.errored" class="flex items-center justify-center py-8 h-full">
|
||||
{{ errorData.text }}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { DialogFeedback, DialogHelp } from '#components';
|
||||
const modal = useModal();
|
||||
const selfhosted = useSelfhosted();
|
||||
|
||||
const { domain } = useDomain();
|
||||
|
||||
const colorMode = useColorMode()
|
||||
const isDark = computed({
|
||||
@@ -16,47 +17,41 @@ const isDark = computed({
|
||||
}
|
||||
})
|
||||
|
||||
const {safeSnapshotDates} = useSnapshot();
|
||||
const { safeSnapshotDates } = useSnapshot();
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="w-full overflow-y-auto hide-scrollbars h-[4rem] border-solid border-[#D9D9E0] dark:border-[#202020] border-b-[1px] bg-lyx-lightmode-background dark:bg-lyx-background flex dark:shadow-[1px_0_10px_#000000]">
|
||||
class="w-full hide-scrollbars relative h-[4rem] border-solid border-[#D9D9E0] dark:border-[#202020] border-b-[1px] bg-lyx-lightmode-background dark:bg-lyx-background dark:shadow-[1px_0_10px_#000000]">
|
||||
|
||||
<div class="flex items-center px-6">
|
||||
<SelectorDomainSelector></SelectorDomainSelector>
|
||||
</div>
|
||||
|
||||
<div class="hidden lg:flex pl-[12rem] items-center popping text-[.9rem] dark:text-lyx-text-dark">
|
||||
Timeframe:
|
||||
{{new Date(safeSnapshotDates.from).toLocaleDateString()}}
|
||||
to
|
||||
{{new Date(safeSnapshotDates.to).toLocaleDateString()}}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grow"></div>
|
||||
<div class="flex items-center gap-6 mr-10">
|
||||
|
||||
<div v-if="!selfhosted" @click="modal.open(DialogFeedback, {});"
|
||||
class="flex gap-2 items-center cursor-pointer outline-[1px] outline-lyx-widget-lighter p-1 px-3 rounded-md outline">
|
||||
<i class="far fa-message"></i>
|
||||
Feedback
|
||||
<div class="absolute flex h-full w-full">
|
||||
<div class="flex items-center px-6">
|
||||
<SelectorDomainSelector></SelectorDomainSelector>
|
||||
</div>
|
||||
|
||||
<div @click="modal.open(DialogHelp, {});" class="cursor-pointer"> Help </div>
|
||||
<NuxtLink to="https://docs.litlyx.com" target="_blank" class="cursor-pointer">
|
||||
Docs
|
||||
</NuxtLink>
|
||||
<div class="hidden lg:flex items-center popping text-[.9rem] dark:text-lyx-text-dark">
|
||||
Timeframe:
|
||||
{{ new Date(safeSnapshotDates.from).toLocaleDateString() }}
|
||||
to
|
||||
{{ new Date(safeSnapshotDates.to).toLocaleDateString() }}
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<UTooltip :text="isDark ? 'Toggle light mode' : 'Toggle dark mode'">
|
||||
<i @click="isDark = !isDark"
|
||||
class="cursor-pointer hover:text-lyx-lightmode-text text-lyx-lightmode-text-dark dark:hover:text-lyx-text dark:text-lyx-text-dark"
|
||||
:class="isDark ? 'far fa-moon' : 'far fa-sun'"></i>
|
||||
</UTooltip>
|
||||
<div class="grow"></div>
|
||||
<div class="flex items-center gap-6 mr-10">
|
||||
|
||||
<div v-if="!selfhosted" @click="modal.open(DialogFeedback, {});"
|
||||
class="flex gap-2 items-center cursor-pointer outline-[1px] outline-lyx-widget-lighter p-1 px-3 rounded-md outline">
|
||||
<i class="far fa-message"></i>
|
||||
Feedback
|
||||
</div>
|
||||
|
||||
<div @click="modal.open(DialogHelp, {});" class="cursor-pointer"> Help </div>
|
||||
<NuxtLink to="https://docs.litlyx.com" target="_blank" class="cursor-pointer">
|
||||
Docs
|
||||
</NuxtLink>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
146
dashboard/components/layout/VerticalBottomMenu.vue
Normal file
@@ -0,0 +1,146 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import { DialogConfirmLogout } from '#components';
|
||||
|
||||
const router = useRouter();
|
||||
const { user, isAdmin, setLoggedUser } = useLoggedUser();
|
||||
const { setToken } = useAccessToken();
|
||||
const selfhosted = useSelfhosted();
|
||||
|
||||
const modal = useModal();
|
||||
|
||||
|
||||
function onLogout() {
|
||||
modal.open(DialogConfirmLogout, {
|
||||
onSuccess() {
|
||||
modal.close();
|
||||
console.log('LOGOUT');
|
||||
setToken('');
|
||||
setLoggedUser(undefined);
|
||||
router.push('/login');
|
||||
},
|
||||
onCancel() {
|
||||
modal.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const colorMode = useColorMode()
|
||||
const isDark = computed({
|
||||
get() {
|
||||
return colorMode.value === 'dark'
|
||||
},
|
||||
set() {
|
||||
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const items = computed(() => {
|
||||
|
||||
const slots: any = [];
|
||||
|
||||
if (selfhosted === true) {
|
||||
slots.push([
|
||||
{
|
||||
label: 'Account',
|
||||
icon: 'far fa-user',
|
||||
to: '/account'
|
||||
},
|
||||
]);
|
||||
} else {
|
||||
slots.push([
|
||||
{
|
||||
label: 'Account',
|
||||
icon: 'far fa-user',
|
||||
to: '/account'
|
||||
},
|
||||
{
|
||||
label: 'Billing',
|
||||
icon: 'far fa-wallet',
|
||||
to: '/billing'
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
slots.push([
|
||||
{
|
||||
label: 'Switch theme',
|
||||
icon: isDark.value ? 'far fa-sun' : 'far fa-moon',
|
||||
click: () => {
|
||||
isDark.value = !isDark.value
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
if (isAdmin.value === true) {
|
||||
slots.push([
|
||||
{
|
||||
label: 'Admin',
|
||||
icon: 'far fa-cat',
|
||||
to: '/admin'
|
||||
},
|
||||
{
|
||||
label: 'Logout',
|
||||
icon: 'far fa-arrow-right-from-bracket scale-x-[-100%]',
|
||||
click: () => onLogout()
|
||||
}
|
||||
])
|
||||
} else {
|
||||
slots.push([
|
||||
{
|
||||
label: 'Logout',
|
||||
icon: 'far fa-arrow-right-from-bracket scale-x-[-100%]',
|
||||
click: () => onLogout()
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
return slots;
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDropdown :popper="{ placement: 'top' }" class="w-full" :items="items" :ui="{
|
||||
width: 'w-[14rem]',
|
||||
strategy: 'override',
|
||||
background: 'dark:bg-lyx-background bg-lyx-lightmode-background',
|
||||
ring: 'ring-1 dark:ring-lyx-widget-lighter ring-lyx-lightmode-widget',
|
||||
item: {
|
||||
active: 'dark:text-lyx-text text-lyx-lightmode-text dark:bg-lyx-background-lighter bg-lyx-lightmode-background-light'
|
||||
}
|
||||
}">
|
||||
<div class="dark:hover:bg-lyx-widget-light hover:bg-lyx-lightmode-widget cursor-pointer px-1 py-1 rounded-lg text-lyx-lightmode-text-dark dark:text-lyx-text-dark flex items-center gap-2 w-full"
|
||||
v-if="user && user.logged && user.user">
|
||||
|
||||
<div class="flex">
|
||||
<div
|
||||
class="flex shrink-0 items-center justify-center h-6 w-6 rounded-full border-solid border-[2px] border-lyx-lightmode-widget dark:border-lyx-widget-lighter">
|
||||
<div class="text-[.8rem] font-medium translate-y-[1px]">
|
||||
{{ user.user.name.substring(0, 1).toUpperCase() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-[.9rem] font-medium poppins overflow-hidden text-ellipsis grow">
|
||||
{{ user.user.email }}
|
||||
</div>
|
||||
|
||||
<div class="w-[2rem] text-right pr-1">
|
||||
<i class="fas fa-ellipsis-h brightness-75"></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<template #item="e">
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="text-lyx-text-darker" :class="e.item.icon"></i>
|
||||
<div>{{ e.item.label }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</UDropdown>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
import { DialogConfirmLogout, DialogInviteManager } from '#components';
|
||||
import CreateSnapshot from '../dialog/CreateSnapshot.vue';
|
||||
|
||||
export type Entry = {
|
||||
@@ -27,7 +28,11 @@ type Props = {
|
||||
const route = useRoute();
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const { userRoles, setLoggedUser } = useLoggedUser();
|
||||
const { data: pendingInvites, refresh: refreshInvites } = useFetch('/api/project/members/pending', {
|
||||
headers: useComputedHeaders({})
|
||||
});
|
||||
|
||||
const { userRoles, isPremium } = useLoggedUser();
|
||||
const { projectList } = useProject();
|
||||
|
||||
const debugMode = process.dev;
|
||||
@@ -68,34 +73,13 @@ async function deleteSnapshot(close: () => any) {
|
||||
close();
|
||||
}
|
||||
|
||||
async function generatePDF() {
|
||||
const { actions } = useProject();
|
||||
|
||||
try {
|
||||
const res = await $fetch<Blob>('/api/project/generate_pdf', {
|
||||
headers: useComputedHeaders({ useSnapshotDates: false, custom: { 'x-snapshot-name': snapshot.value.name } }).value,
|
||||
responseType: 'blob'
|
||||
});
|
||||
const { showDrawer } = useDrawer();
|
||||
|
||||
const url = URL.createObjectURL(res);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `Report.pdf`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
const { setToken } = useAccessToken();
|
||||
const router = useRouter();
|
||||
|
||||
function onLogout() {
|
||||
console.log('LOGOUT')
|
||||
setToken('');
|
||||
setLoggedUser(undefined);
|
||||
router.push('/login');
|
||||
}
|
||||
const modal = useModal();
|
||||
|
||||
const { data: maxProjects } = useFetch("/api/user/max_projects", {
|
||||
headers: computed(() => {
|
||||
@@ -106,22 +90,37 @@ const { data: maxProjects } = useFetch("/api/user/max_projects", {
|
||||
});
|
||||
|
||||
|
||||
function openPendingInvites() {
|
||||
if (!pendingInvites.value) return;
|
||||
if (pendingInvites.value.length == 0) return;
|
||||
|
||||
console.log(pendingInvites);
|
||||
modal.open(DialogInviteManager, {
|
||||
invites: pendingInvites.value.map(e => {
|
||||
return { project_id: e.project_id, project_name: e.project_name }
|
||||
}),
|
||||
onSuccess: () => {
|
||||
modal.close();
|
||||
actions.refreshProjectsList();
|
||||
refreshInvites();
|
||||
},
|
||||
onCancel: () => {
|
||||
modal.close();
|
||||
actions.refreshProjectsList();
|
||||
refreshInvites();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="CVerticalNavigation border-solid border-[#D9D9E0] dark:border-[#202020] border-r-[1px] h-full w-[20rem] bg-lyx-lightmode-background dark:bg-lyx-background flex shadow-[1px_0_10px_#000000]"
|
||||
<div class="CVerticalNavigation border-solid border-[#D9D9E0] dark:border-[#202020] border-r-[1px] h-full w-[16rem] bg-lyx-lightmode-background dark:bg-lyx-background flex shadow-[1px_0_10px_#000000]"
|
||||
:class="{
|
||||
'absolute top-0 w-full md:w-[20rem] z-[45] open': isOpen,
|
||||
'hidden lg:flex': !isOpen
|
||||
}">
|
||||
<div class="py-4 px-2 gap-6 flex flex-col w-full">
|
||||
|
||||
<!-- <div class="flex px-2" v-if="!isPremium">
|
||||
<LyxUiButton type="primary" class="w-full text-center text-[.8rem] font-medium" @click="pricingDrawer.visible.value = true;">
|
||||
Upgrade plan
|
||||
</LyxUiButton>
|
||||
</div> -->
|
||||
|
||||
<div class="py-4 pb-2 px-2 gap-6 flex flex-col w-full">
|
||||
|
||||
<div class="flex px-2 flex-col">
|
||||
|
||||
@@ -238,18 +237,11 @@ const { data: maxProjects } = useFetch("/api/user/max_projects", {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-full flex mt-4">
|
||||
<LyxUiButton @click="generatePDF()" type="outline" class="w-full text-center text-[.8rem]">
|
||||
Export report
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="bg-lyx-lightmode-widget dark:bg-[#202020] h-[1px] w-full"></div>
|
||||
|
||||
<div class="flex flex-col h-full">
|
||||
|
||||
<div v-for="section of sections" class="flex flex-col gap-1 h-full pb-6">
|
||||
|
||||
<div v-for="entry of section.entries" :class="{ 'grow flex items-end': entry.grow }">
|
||||
@@ -283,25 +275,41 @@ const { data: maxProjects } = useFetch("/api/user/max_projects", {
|
||||
|
||||
<div class="grow"></div>
|
||||
|
||||
<div class="bg-lyx-lightmode-widget dark:bg-[#202020] h-[1px] w-full px-4 mb-3"></div>
|
||||
|
||||
<div class="flex justify-end px-2">
|
||||
|
||||
<div class="grow flex gap-3">
|
||||
|
||||
<NuxtLink to="/admin" v-if="userRoles.isAdmin.value"
|
||||
class="cursor-pointer hover:text-lyx-lightmode-text text-lyx-lightmode-text-dark dark:hover:text-lyx-text dark:text-lyx-text-dark">
|
||||
<i class="far fa-cat"></i>
|
||||
</NuxtLink>
|
||||
<LyxUiCard class="w-full mb-4" v-if="!isPremium">
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="text-center"> Upgrade to premium </div>
|
||||
<LyxUiButton type="primary" class="w-full text-center text-[.8rem] font-medium"
|
||||
@click="showDrawer('PRICING')">
|
||||
Upgrade
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
</LyxUiCard>
|
||||
|
||||
<UTooltip text="Logout" :popper="{ arrow: true, placement: 'top' }">
|
||||
<div @click="onLogout()" class="cursor-pointer hover:text-lyx-lightmode-text text-lyx-lightmode-text-dark dark:hover:text-lyx-text dark:text-lyx-text-dark">
|
||||
<i class="far fa-arrow-right-from-bracket scale-x-[-100%]"></i>
|
||||
</div>
|
||||
</UTooltip>
|
||||
<div v-if="pendingInvites && pendingInvites.length > 0" @click="openPendingInvites()"
|
||||
class="w-full bg-[#fbbf2422] p-4 rounded-lg text-[.9rem] flex flex-col justify-center cursor-pointer">
|
||||
<div class="poppins font-medium dark:text-lyx-text text-lyx-lightmode-text">
|
||||
Pending invitation
|
||||
</div>
|
||||
<div class="poppins dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
You have {{ pendingInvites.length }}
|
||||
pending invitation{{ pendingInvites.length != 1 ? 's' : '' }}
|
||||
awaiting your response
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <LyxUiSeparator class="px-4 mb-2"></LyxUiSeparator> -->
|
||||
|
||||
<LyxUiCard class="flex py-1 px-1 w-full relative">
|
||||
<div class="absolute top-[-22%] right-0">
|
||||
<div v-if="isPremium" @click="showDrawer('PRICING')"
|
||||
class="flex items-center gap-1 poppins text-[.5rem] bg-[#fbbe244f] outline outline-[1px] outline-[#fbbf24] px-3 py-[.12rem] rounded-sm">
|
||||
<i class="far fa-crown mb-[2px]"></i>
|
||||
<div>Premium</div>
|
||||
</div>
|
||||
</div>
|
||||
<LayoutVerticalBottomMenu></LayoutVerticalBottomMenu>
|
||||
</LyxUiCard>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ function onChange(e: string) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex gap-2 absolute">
|
||||
<div class="flex gap-2">
|
||||
<USelectMenu :uiMenu="{
|
||||
select: 'bg-lyx-lightmode-widget-light !ring-lyx-lightmode-widget dark:!bg-lyx-widget-light !shadow-none focus:!ring-lyx-widget-lighter dark:!ring-lyx-widget-lighter',
|
||||
base: '!bg-lyx-lightmode-widget dark:!bg-lyx-widget w-max',
|
||||
@@ -18,7 +18,7 @@ function onChange(e: string) {
|
||||
},
|
||||
input: 'z-[999] !bg-lyx-lightmode-widget dark:!bg-lyx-widget-light'
|
||||
}" class="w-full" searchable searchable-placeholder="Search domain..." v-if="domainList" @change="onChange"
|
||||
:value="domain" value-attribute="_id" :options="domainList">
|
||||
:value="domain" :loading="refreshingDomains" value-attribute="_id" :options="domainList">
|
||||
|
||||
<template #option="{ option, active, selected }">
|
||||
<div class="flex items-center gap-2">
|
||||
@@ -35,7 +35,7 @@ function onChange(e: string) {
|
||||
<img class="h-5 bg-black rounded-full" :src="'/logo_32.png'" alt="Litlyx logo">
|
||||
</div>
|
||||
<div>
|
||||
{{ domain || '-' }}
|
||||
{{ refreshingDomains ? 'Loading...' : (domain || '-') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
73
dashboard/components/selector/ImageSelector.vue
Normal file
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
|
||||
const emits = defineEmits<{
|
||||
(event: 'file_selected', value: string): void;
|
||||
}>();
|
||||
|
||||
const fileInput = ref<HTMLElement | null>(null)
|
||||
const isDragging = ref(false)
|
||||
|
||||
const triggerFileSelect = () => { (fileInput.value as any).click() }
|
||||
|
||||
const handleFileChange = async (event: any) => {
|
||||
const file = event.target.files[0]
|
||||
if (file) {
|
||||
const b64 = await getBase64FromFile(file);
|
||||
emits('file_selected', b64);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getBase64FromFile(file: File) {
|
||||
return new Promise<string>(resolve => {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onloadend = async function () {
|
||||
const base64String = reader.result;
|
||||
if (!base64String) return alert('Error reading image');
|
||||
resolve(base64String as string);
|
||||
}
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const handleDrop = async (event: any) => {
|
||||
const file = event.dataTransfer.files[0]
|
||||
isDragging.value = false
|
||||
if (file) {
|
||||
const b64 = await getBase64FromFile(file);
|
||||
emits('file_selected', b64);
|
||||
}
|
||||
}
|
||||
|
||||
const handleDragOver = () => {
|
||||
isDragging.value = true
|
||||
}
|
||||
|
||||
const handleDragLeave = () => {
|
||||
isDragging.value = false
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<div id="drop-area"
|
||||
class="w-full select-none max-w-md border-2 border-dashed border-gray-600 rounded-lg p-12 text-center cursor-pointer hover:border-blue-500 transition"
|
||||
@click="triggerFileSelect" @dragover.prevent="handleDragOver" @dragleave="handleDragLeave"
|
||||
@drop.prevent="handleDrop" :class="{ 'border-blue-500': isDragging }">
|
||||
<p class="text-gray-400">
|
||||
Drag & drop an image here
|
||||
<br>
|
||||
or click to select a file
|
||||
</p>
|
||||
<input ref="fileInput" type="file" accept="image/*" class="hidden" @change="handleFileChange" />
|
||||
</div>
|
||||
|
||||
</template>
|
||||
@@ -16,7 +16,6 @@ function isProjectMine(owner?: string) {
|
||||
|
||||
function onChange(e: TProject) {
|
||||
actions.setActiveProject(e._id.toString());
|
||||
setActiveDomain('All domains');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ async function redeemCode() {
|
||||
Redeemed codes: {{ valid_codes.data.value?.count || '0' }}
|
||||
</div>
|
||||
<div class="poppins text-[1.1rem] text-lyx-lightmode-text dark:text-yellow-400 mb-2">
|
||||
*Plan upgrades are applicable exclusively to this project(workspace).
|
||||
*Plan upgrades are applied to account level.
|
||||
</div>
|
||||
</template>
|
||||
</SettingsTemplate>
|
||||
|
||||
@@ -148,7 +148,7 @@ const sessionsLabel = computed(() => {
|
||||
|
||||
<div v-if="!isGuest"
|
||||
class="outline rounded-lg w-full px-8 py-4 flex flex-col gap-4 outline-[1px] outline-[#541c15] bg-lyx-lightmode-widget-light dark:bg-[#1e1412]">
|
||||
<div class="poppins font-semibold"> This operation will reset this project to it's initial state (0
|
||||
<div class="poppins font-semibold"> This operation will reset this project to its initial state (0
|
||||
visits 0 events 0 sessions) </div>
|
||||
<div @click="openDeleteAllDomainDataDialog()"
|
||||
class="text-[#e95b61] poppins font-semibold cursor-pointer hover:text-black hover:bg-red-700 outline rounded-lg w-fit px-8 py-2 outline-[1px] outline-[#532b26] bg-lyx-lightmode-widget-light dark:bg-[#291415]">
|
||||
|
||||
@@ -4,6 +4,8 @@ import type { SettingsTemplateEntry } from './Template.vue';
|
||||
|
||||
const { project, actions, projectList, isGuest, projectId } = useProject();
|
||||
|
||||
const { createErrorAlert, createAlert } = useAlert();
|
||||
|
||||
const entries: SettingsTemplateEntry[] = [
|
||||
{ id: 'pname', title: 'Name', text: 'Project name' },
|
||||
{ id: 'api', title: 'ApiKeys', text: 'Manage your authorization token' },
|
||||
@@ -37,7 +39,7 @@ async function createApiKey() {
|
||||
apiKeys.value.push(res);
|
||||
newApiKeyName.value = '';
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
createErrorAlert('Error', ex.message, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ async function deleteApiKey(api_id: string) {
|
||||
newApiKeyName.value = '';
|
||||
await updateApiKeys();
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
createErrorAlert('Error', ex.message, 10000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,14 +118,12 @@ async function deleteProject() {
|
||||
|
||||
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
createErrorAlert('Error', ex.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const { createAlert } = useAlert()
|
||||
|
||||
function copyScript() {
|
||||
if (!navigator.clipboard) alert('You can\'t copy in HTTP');
|
||||
|
||||
@@ -172,7 +172,7 @@ function copyProjectId() {
|
||||
<LyxUiInput class="grow px-4 py-2" :disabled="isGuest" placeholder="ApiKeyName"
|
||||
v-model="newApiKeyName">
|
||||
</LyxUiInput>
|
||||
<LyxUiButton v-if="!isGuest" @click="createApiKey()" :disabled="newApiKeyName.length < 3"
|
||||
<LyxUiButton v-if="!isGuest" @click="createApiKey()" :disabled="newApiKeyName.trim().length < 3"
|
||||
type="primary">
|
||||
<i class="far fa-plus"></i>
|
||||
</LyxUiButton>
|
||||
@@ -215,7 +215,7 @@ function copyProjectId() {
|
||||
</div>
|
||||
</template>
|
||||
<template #pdelete>
|
||||
<div class="flex lg:justify-end" v-if="!isGuest">
|
||||
<div class="flex lg:justify-end pb-30" v-if="!isGuest">
|
||||
<LyxUiButton type="danger" @click="deleteProject()">
|
||||
Delete project
|
||||
</LyxUiButton>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import dayjs from 'dayjs';
|
||||
import type { SettingsTemplateEntry } from './Template.vue';
|
||||
import { getPlanFromId, PREMIUM_PLAN, type PREMIUM_TAG } from '@data/PREMIUM';
|
||||
import { getPlanFromId, PREMIUM_PLAN, type PLAN_TAG } from '@data/PLANS';
|
||||
|
||||
const { projectId, isGuest } = useProject();
|
||||
|
||||
@@ -53,10 +53,10 @@ function openInvoice(link: string) {
|
||||
window.open(link, '_blank');
|
||||
}
|
||||
|
||||
function getPremiumName(type: number) {
|
||||
function getTagName(type: number) {
|
||||
|
||||
return Object.keys(PREMIUM_PLAN).map(e => ({
|
||||
...PREMIUM_PLAN[e as PREMIUM_TAG], name: e
|
||||
...PREMIUM_PLAN[e as PLAN_TAG], name: e
|
||||
})).find(e => e.ID == type)?.name;
|
||||
|
||||
}
|
||||
@@ -116,7 +116,7 @@ const { showDrawer } = useDrawer();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative">
|
||||
<div class="relative pb-[6rem]">
|
||||
|
||||
<div v-if="invoicesPending || planPending"
|
||||
class="backdrop-blur-[1px] z-[20] mt-20 w-full h-full flex items-center justify-center font-bold">
|
||||
@@ -168,7 +168,7 @@ const { showDrawer } = useDrawer();
|
||||
</div>
|
||||
<div
|
||||
class="flex lato text-[.7rem] bg-transparent border-[#262626] border-[1px] px-[.6rem] rounded-sm">
|
||||
{{ planData.premium ? getPremiumName(planData.premium_type) : 'FREE' }}
|
||||
{{ planData.premium ? getTagName(planData.premium_type) : 'FREE' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -187,9 +187,6 @@ const { showDrawer } = useDrawer();
|
||||
</div>
|
||||
<div class="poppins"> {{ daysLeft }} days left </div>
|
||||
</div>
|
||||
<div class="flex justify-center">
|
||||
Subscription: {{ planData.subscription_status }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="my-4 w-full bg-gray-400/30 h-[1px]">
|
||||
@@ -222,7 +219,7 @@ const { showDrawer } = useDrawer();
|
||||
<div class="poppins"> Usage:</div>
|
||||
<div class="flex items-center gap-2 md:gap-4 flex-col pt-4 md:pt-0 md:flex-row">
|
||||
<div class="grow w-full md:w-auto">
|
||||
<UProgress :color="color" :min="0" :max="planData.limit" :value="planData.count">
|
||||
<UProgress v-if="planData" :color="color" :min="0" :max="planData.limit" :value="planData.count">
|
||||
</UProgress>
|
||||
</div>
|
||||
<div class="poppins"> {{ percent }}</div>
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { SettingsTemplateEntry } from './Template.vue';
|
||||
|
||||
const { projectId, isGuest } = useProject();
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const columns = [
|
||||
{ key: 'me', label: '' },
|
||||
{ key: 'email', label: 'Email' },
|
||||
{ key: 'name', label: 'Name' },
|
||||
{ key: 'role', label: 'Role' },
|
||||
{ key: 'action', label: 'Actions' },
|
||||
// { key: 'pending', label: 'Pending' },
|
||||
]
|
||||
|
||||
const { data: members, refresh: refreshMembers } = useFetch('/api/project/members/list', {
|
||||
headers: useComputedHeaders({ useSnapshotDates: false })
|
||||
});
|
||||
|
||||
const showAddMember = ref<boolean>(false);
|
||||
|
||||
const addMemberEmail = ref<string>("");
|
||||
|
||||
async function kickMember(email: string) {
|
||||
|
||||
const sure = confirm('Are you sure to kick ' + email + ' ?');
|
||||
if (!sure) return;
|
||||
|
||||
try {
|
||||
|
||||
await $fetch('/api/project/members/kick', {
|
||||
method: 'POST',
|
||||
...signHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-pid': projectId.value ?? ''
|
||||
}),
|
||||
body: JSON.stringify({ email }),
|
||||
onResponseError({ request, response, options }) {
|
||||
alert(response.statusText);
|
||||
}
|
||||
});
|
||||
|
||||
refreshMembers();
|
||||
|
||||
} catch (ex: any) { }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
async function addMember() {
|
||||
|
||||
if (addMemberEmail.value.length === 0) return;
|
||||
|
||||
try {
|
||||
|
||||
showAddMember.value = false;
|
||||
|
||||
await $fetch('/api/project/members/add', {
|
||||
method: 'POST',
|
||||
...signHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-pid': projectId.value ?? ''
|
||||
}),
|
||||
body: JSON.stringify({ email: addMemberEmail.value }),
|
||||
onResponseError({ request, response, options }) {
|
||||
alert(response.statusText);
|
||||
}
|
||||
});
|
||||
|
||||
addMemberEmail.value = '';
|
||||
|
||||
refreshMembers();
|
||||
|
||||
} catch (ex: any) { }
|
||||
|
||||
|
||||
}
|
||||
|
||||
const entries: SettingsTemplateEntry[] = [
|
||||
{ id: 'add', title: 'Add member', text: 'Add new member to project' },
|
||||
{ id: 'members', title: 'Members', text: 'Manage members of current project' },
|
||||
]
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<SettingsTemplate :entries="entries">
|
||||
<template #add>
|
||||
<div v-if="!isGuest" class="flex flex-col">
|
||||
<div class="flex gap-4 items-center">
|
||||
<LyxUiInput class="px-4 py-1 w-full" placeholder="User email" v-model="addMemberEmail"></LyxUiInput>
|
||||
<LyxUiButton @click="addMember" type="secondary"> Add </LyxUiButton>
|
||||
</div>
|
||||
<div class="poppins text-[.8rem] mt-2 text-lyx-text-darker">
|
||||
User should have been registered to Litlyx
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="isGuest" class="text-lyx-text-darker"> Guests cannot add members</div>
|
||||
</template>
|
||||
<template #members>
|
||||
|
||||
|
||||
<UTable :rows="members || []" :columns="columns">
|
||||
<template #me-data="e">
|
||||
<i v-if="e.row.me" class="far fa-user"></i>
|
||||
<i v-if="!e.row.me"></i>
|
||||
</template>
|
||||
|
||||
<template #action-data="e" v-if="!isGuest">
|
||||
<div @click="kickMember(e.row.email)" v-if="e.row.role != 'OWNER'"
|
||||
class="text-red-500 hover:bg-black/20 cursor-pointer outline outline-[1px] outline-red-500 px-3 py-1 rounded-lg text-center">
|
||||
Kick
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</UTable>
|
||||
</template>
|
||||
</SettingsTemplate>
|
||||
|
||||
</template>
|
||||
101
dashboard/components/shields/Addresses.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<script lang="ts" setup>
|
||||
import { DialogShieldsDeleteAddress, DialogShieldsAddAddress } from '#components';
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const { data: blackAddresses, refresh: refreshAddresses, pending: pendingAddresses } = useFetch('/api/shields/ip/list', {
|
||||
headers: useComputedHeaders({})
|
||||
});
|
||||
|
||||
const toast = useToast()
|
||||
const modal = useModal();
|
||||
|
||||
function showAddAddressModal() {
|
||||
modal.open(DialogShieldsAddAddress, {
|
||||
onSuccess: () => {
|
||||
refreshAddresses();
|
||||
modal.close();
|
||||
|
||||
toast.add({
|
||||
id: 'shield_address_add_success',
|
||||
title: 'Success',
|
||||
description: 'Blacklist updated with the new address',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
},
|
||||
onCancel: () => {
|
||||
modal.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function showDeleteAddressModal(address: string) {
|
||||
modal.open(DialogShieldsDeleteAddress, {
|
||||
address,
|
||||
onSuccess: () => {
|
||||
refreshAddresses();
|
||||
modal.close();
|
||||
toast.add({
|
||||
id: 'shield_address_remove_success',
|
||||
title: 'Deleted',
|
||||
description: 'Blacklist address deleted successfully',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
},
|
||||
onCancel: () => {
|
||||
modal.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div class="py-4 flex">
|
||||
<LyxUiCard class="w-full mx-2">
|
||||
<div>
|
||||
<div class="text-[1.2rem] font-semibold"> IP Block List </div>
|
||||
<div class="dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
Reject incoming traffic from specific IP addresses
|
||||
</div>
|
||||
</div>
|
||||
<LyxUiSeparator class="my-3"></LyxUiSeparator>
|
||||
|
||||
<div class="flex justify-end pb-3">
|
||||
<LyxUiButton type="primary" @click="showAddAddressModal()"> Add IP Address </LyxUiButton>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center pb-8 text-[1.2rem]" v-if="pendingAddresses">
|
||||
<i class="fas fa-loader animate-spin"></i>
|
||||
</div>
|
||||
|
||||
<div v-if="!pendingAddresses && blackAddresses && blackAddresses.length == 0"
|
||||
class="flex flex-col items-center pb-8">
|
||||
<div>
|
||||
No domain rules configured for this project.
|
||||
</div>
|
||||
<div class="font-semibold">
|
||||
Traffic from all domains is currently accepted.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!pendingAddresses && blackAddresses && blackAddresses.length > 0"
|
||||
class="grid grid-cols-[auto_auto_auto_auto] px-10">
|
||||
<div> Domain </div>
|
||||
<div class="col-span-2"> Description </div>
|
||||
<div> Actions </div>
|
||||
<LyxUiSeparator class="col-span-4 my-3"></LyxUiSeparator>
|
||||
<template v-for="entry of blackAddresses">
|
||||
<div class="mb-2"> {{ entry.address }} </div>
|
||||
<div class="col-span-2">{{ entry.description || 'No description' }}</div>
|
||||
<div> <i @click="showDeleteAddressModal(entry.address)"
|
||||
class="far fa-trash cursor-pointer hover:text-lyx-text-dark"></i> </div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</LyxUiCard>
|
||||
</div>
|
||||
</template>
|
||||
47
dashboard/components/shields/Bots.vue
Normal file
@@ -0,0 +1,47 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const { data: botOptions, refresh: refreshBotOptions, pending: pendingBotOptions } = useFetch('/api/shields/bots/options', {
|
||||
headers: useComputedHeaders({})
|
||||
});
|
||||
|
||||
async function onChange(newValue: boolean) {
|
||||
await $fetch('/api/shields/bots/update_options', {
|
||||
method: 'POST',
|
||||
headers: useComputedHeaders({ custom: { 'Content-Type': 'application/json' } }).value,
|
||||
body: JSON.stringify({ block: newValue })
|
||||
})
|
||||
await refreshBotOptions();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div class="py-4 flex">
|
||||
<LyxUiCard class="w-full mx-2">
|
||||
<div>
|
||||
<div class="text-[1.2rem] font-semibold"> Block bot traffic </div>
|
||||
<div class="dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
Automatically block unwanted bot and crawler traffic to protect your site from spam, scrapers, and
|
||||
unnecessary server load.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LyxUiSeparator class="my-3"></LyxUiSeparator>
|
||||
|
||||
<div class="flex justify-center pb-8 text-[1.2rem]" v-if="pendingBotOptions">
|
||||
<i class="fas fa-loader animate-spin"></i>
|
||||
</div>
|
||||
|
||||
<div v-if="!pendingBotOptions && botOptions">
|
||||
<div class="flex gap-2">
|
||||
<UToggle :modelValue="botOptions.block" @change="onChange"></UToggle>
|
||||
<div> Enable bot protection </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</LyxUiCard>
|
||||
</div>
|
||||
</template>
|
||||
99
dashboard/components/shields/Domains.vue
Normal file
@@ -0,0 +1,99 @@
|
||||
<script lang="ts" setup>
|
||||
import { DialogShieldsAddDomain, DialogShieldsDeleteDomain } from '#components';
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const { data: allowedDomains, refresh: refreshDomains, pending: pendingDomains } = useFetch('/api/shields/domains/list', {
|
||||
headers: useComputedHeaders({})
|
||||
});
|
||||
|
||||
const toast = useToast()
|
||||
const modal = useModal();
|
||||
|
||||
function showAddDomainModal() {
|
||||
modal.open(DialogShieldsAddDomain, {
|
||||
onSuccess: () => {
|
||||
refreshDomains();
|
||||
modal.close();
|
||||
|
||||
toast.add({
|
||||
id: 'shield_domain_add_success',
|
||||
title: 'Success',
|
||||
description: 'Whitelist updated with the new domain',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
},
|
||||
onCancel: () => {
|
||||
modal.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function showDeleteDomainModal(domain: string) {
|
||||
modal.open(DialogShieldsDeleteDomain, {
|
||||
domain,
|
||||
onSuccess: () => {
|
||||
refreshDomains();
|
||||
modal.close();
|
||||
toast.add({
|
||||
id: 'shield_domain_remove_success',
|
||||
title: 'Deleted',
|
||||
description: 'Whitelist domain deleted successfully',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
},
|
||||
onCancel: () => {
|
||||
modal.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div class="py-4 flex">
|
||||
<LyxUiCard class="w-full mx-2">
|
||||
<div>
|
||||
<div class="text-[1.2rem] font-semibold"> Domains allow list </div>
|
||||
<div class="dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
Accept incoming traffic only from familiar domains.
|
||||
</div>
|
||||
</div>
|
||||
<LyxUiSeparator class="my-3"></LyxUiSeparator>
|
||||
|
||||
<div class="flex justify-end pb-3">
|
||||
<LyxUiButton type="primary" @click="showAddDomainModal()"> Add Domain </LyxUiButton>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center pb-8 text-[1.2rem]" v-if="pendingDomains">
|
||||
<i class="fas fa-loader animate-spin"></i>
|
||||
</div>
|
||||
|
||||
<div v-if="!pendingDomains && allowedDomains && allowedDomains.length == 0"
|
||||
class="flex flex-col items-center pb-8">
|
||||
<div>
|
||||
No domain rules configured for this project.
|
||||
</div>
|
||||
<div class="font-semibold">
|
||||
Traffic from all domains is currently accepted.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!pendingDomains && allowedDomains && allowedDomains.length > 0"
|
||||
class="grid grid-cols-[auto_auto_auto_auto] px-10">
|
||||
<div class="col-span-3">Domain</div>
|
||||
<div>Actions</div>
|
||||
<LyxUiSeparator class="col-span-4 my-3"></LyxUiSeparator>
|
||||
<template v-for="domain of allowedDomains">
|
||||
<div class="col-span-3 mb-3">{{ domain }}</div>
|
||||
<div> <i @click="showDeleteDomainModal(domain)"
|
||||
class="far fa-trash cursor-pointer hover:text-lyx-text-dark"></i> </div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</LyxUiCard>
|
||||
</div>
|
||||
</template>
|
||||
@@ -71,7 +71,6 @@ export function getDefaultSnapshots(project_id: TProjectSnapshot['project_id'],
|
||||
}
|
||||
|
||||
|
||||
|
||||
const allTime: DefaultSnapshot = {
|
||||
project_id,
|
||||
_id: '___allTime' as any,
|
||||
@@ -83,8 +82,45 @@ export function getDefaultSnapshots(project_id: TProjectSnapshot['project_id'],
|
||||
}
|
||||
|
||||
|
||||
const last30Days: DefaultSnapshot = {
|
||||
project_id,
|
||||
_id: '___last30days' as any,
|
||||
name: 'Last 30 days',
|
||||
from: fns.startOfDay(fns.subDays(Date.now(), 30)),
|
||||
to: fns.endOfDay(fns.subDays(Date.now(), 0)),
|
||||
color: '#606c38',
|
||||
default: true
|
||||
}
|
||||
|
||||
const snapshotList = [lastDay, today, lastMonth, currentMonth, lastWeek, currentWeek, allTime]
|
||||
const last60Days: DefaultSnapshot = {
|
||||
project_id,
|
||||
_id: '___last60days' as any,
|
||||
name: 'Last 60 days',
|
||||
from: fns.startOfDay(fns.subDays(Date.now(), 60)),
|
||||
to: fns.endOfDay(fns.subDays(Date.now(), 0)),
|
||||
color: '#bc6c25',
|
||||
default: true
|
||||
}
|
||||
|
||||
const last90Days: DefaultSnapshot = {
|
||||
project_id,
|
||||
_id: '___last90days' as any,
|
||||
name: 'Last 90 days',
|
||||
from: fns.startOfDay(fns.subDays(Date.now(), 90)),
|
||||
to: fns.endOfDay(fns.subDays(Date.now(), 0)),
|
||||
color: '#fefae0',
|
||||
default: true
|
||||
}
|
||||
|
||||
|
||||
const snapshotList = [
|
||||
allTime,
|
||||
lastDay, today,
|
||||
lastWeek, currentWeek,
|
||||
lastMonth, currentMonth,
|
||||
last30Days,
|
||||
last60Days, last90Days,
|
||||
]
|
||||
|
||||
return snapshotList;
|
||||
|
||||
|
||||
@@ -34,10 +34,19 @@ function createAlert(title: string, text: string, icon: string, ms: number) {
|
||||
}, 250)
|
||||
}
|
||||
|
||||
function createSuccessAlert(title: string, text: string, ms?: number) {
|
||||
return createAlert(title, text, 'far fa-circle-check', ms ?? 5000);
|
||||
}
|
||||
|
||||
function createErrorAlert(title: string, text: string, ms?: number) {
|
||||
return createAlert(title, text, 'far fa-triangle-exclamation', ms ?? 5000);
|
||||
}
|
||||
|
||||
|
||||
function closeAlert(id: number) {
|
||||
alerts.value = alerts.value.filter(e => e.id != id);
|
||||
}
|
||||
|
||||
export function useAlert() {
|
||||
return { alerts, createAlert, closeAlert }
|
||||
return { alerts, createAlert, closeAlert, createSuccessAlert, createErrorAlert }
|
||||
}
|
||||
@@ -16,26 +16,22 @@ function refreshDomains() {
|
||||
domainsRequest.refresh();
|
||||
}
|
||||
|
||||
watch(domainsRequest.data, () => {
|
||||
if (!domainsRequest.data.value) return;
|
||||
setActiveDomain(domainList.value[0]._id);
|
||||
});
|
||||
|
||||
const refreshingDomains = computed(() => domainsRequest.pending.value);
|
||||
|
||||
const domainList = computed(() => {
|
||||
return [
|
||||
{
|
||||
_id: 'All domains', visits: domainsRequest.data.value?.reduce((a, e) => a + e.visits, 0)
|
||||
},
|
||||
...(domainsRequest.data.value?.sort((a, b) => b.visits - a.visits) || [])
|
||||
]
|
||||
return (domainsRequest.data.value?.sort((a, b) => b.visits - a.visits) || []);
|
||||
})
|
||||
|
||||
|
||||
const activeDomain = ref<string>();
|
||||
|
||||
const domain = computed(() => {
|
||||
if (activeDomain.value) return activeDomain.value;
|
||||
if (!domainList.value) return;
|
||||
if (domainList.value.length == 0) return;
|
||||
setActiveDomain(domainList.value[0]._id);
|
||||
return domainList.value[0]._id;
|
||||
return activeDomain.value;
|
||||
})
|
||||
|
||||
function setActiveDomain(domain: string) {
|
||||
|
||||
@@ -11,17 +11,18 @@ const isLogged = computed(() => {
|
||||
return loggedUser.value?.logged;
|
||||
})
|
||||
|
||||
function getUserRoles() {
|
||||
const isPremium = computed(() => {
|
||||
if (!loggedUser.value?.logged) return false;
|
||||
return loggedUser.value.user.roles.includes('PREMIUM');
|
||||
});
|
||||
const isAdmin = computed(() => {
|
||||
if (!loggedUser.value?.logged) return false;
|
||||
return loggedUser.value.user.roles.includes('ADMIN');
|
||||
});
|
||||
const isAdmin = computed(() => {
|
||||
if (!loggedUser.value?.logged) return false;
|
||||
return loggedUser.value.user.roles.includes('ADMIN');
|
||||
});
|
||||
|
||||
return { isPremium, isAdmin }
|
||||
const isPremium = computed(() => {
|
||||
if (!loggedUser.value?.logged) return false;
|
||||
return loggedUser.value.user.roles.includes('PREMIUM');
|
||||
});
|
||||
|
||||
function getUserRoles() {
|
||||
return { isAdmin, isPremium }
|
||||
}
|
||||
|
||||
export const isAdminHidden = ref<boolean>(false);
|
||||
@@ -29,6 +30,8 @@ export const isAdminHidden = ref<boolean>(false);
|
||||
export function useLoggedUser() {
|
||||
return {
|
||||
isLogged,
|
||||
isPremium,
|
||||
isAdmin,
|
||||
user: loggedUser,
|
||||
userRoles: getUserRoles(),
|
||||
setLoggedUser
|
||||
|
||||
14
dashboard/composables/usePermission.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
|
||||
const { data: permission } = useFetch('/api/project/members/me', {
|
||||
headers: useComputedHeaders({})
|
||||
});
|
||||
|
||||
const canSeeWeb = computed(() => permission.value?.webAnalytics || false);
|
||||
const canSeeEvents = computed(() => permission.value?.events || false);
|
||||
const canSeeAi = computed(() => permission.value?.ai || false);
|
||||
|
||||
export function usePermission() {
|
||||
return { permission, canSeeWeb, canSeeEvents, canSeeAi };
|
||||
}
|
||||
@@ -33,7 +33,10 @@ const guestProjectList = computed(() => {
|
||||
return guestProjectsRequest.data.value;
|
||||
})
|
||||
|
||||
const refreshProjectsList = () => projectsRequest.refresh();
|
||||
const refreshProjectsList = async () => {
|
||||
await projectsRequest.refresh();
|
||||
await guestProjectsRequest.refresh();
|
||||
}
|
||||
|
||||
const activeProjectId = ref<string | undefined>();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const remoteSnapshots = useFetch<TProjectSnapshot[]>('/api/project/snapshots', {
|
||||
|
||||
watch(project, async () => {
|
||||
await remoteSnapshots.refresh();
|
||||
snapshot.value = isLiveDemo.value ? snapshots.value[3] : snapshots.value[3];
|
||||
snapshot.value = isLiveDemo.value ? snapshots.value[7] : snapshots.value[7];
|
||||
});
|
||||
|
||||
const snapshots = computed<GenericSnapshot[]>(() => {
|
||||
|
||||
@@ -18,6 +18,9 @@ const sections: Section[] = [
|
||||
entries: [
|
||||
{ label: 'Web Analytics', to: '/', icon: 'fal fa-table-layout' },
|
||||
{ label: 'Custom Events', to: '/events', icon: 'fal fa-square-bolt' },
|
||||
{ label: 'Reports', to: '/reports', icon: 'fal fa-file' },
|
||||
{ label: 'Members', to: '/members', icon: 'fal fa-users' },
|
||||
{ label: 'Shields', to: '/shields', icon: 'fal fa-shield' },
|
||||
{ label: 'Ask AI', to: '/analyst', icon: 'fal fa-sparkles' },
|
||||
|
||||
// { label: 'Security', to: '/security', icon: 'fal fa-shield', disabled: selfhosted },
|
||||
@@ -25,7 +28,7 @@ const sections: Section[] = [
|
||||
// { label: 'Links (soon)', to: '#', icon: 'fal fa-globe-pointer', disabled: true },
|
||||
// { label: 'Integrations (soon)', to: '/integrations', icon: 'fal fa-cube', disabled: true },
|
||||
|
||||
{ grow: true, label: 'Settings', to: '/settings', icon: 'fal fa-gear' },
|
||||
{ label: 'Settings', to: '/settings', icon: 'fal fa-gear' },
|
||||
// {
|
||||
// grow: true,
|
||||
// label: 'Leave a Feedback', icon: 'fal fa-message',
|
||||
|
||||
@@ -45,15 +45,12 @@ export default defineNuxtConfig({
|
||||
AI_PROJECT: process.env.AI_PROJECT,
|
||||
AI_KEY: process.env.AI_KEY,
|
||||
EMAIL_SECRET: process.env.EMAIL_SECRET,
|
||||
PAYMENT_SECRET: process.env.PAYMENT_SECRET,
|
||||
AUTH_JWT_SECRET: process.env.AUTH_JWT_SECRET,
|
||||
GOOGLE_AUTH_CLIENT_ID: process.env.GOOGLE_AUTH_CLIENT_ID,
|
||||
GOOGLE_AUTH_CLIENT_SECRET: process.env.GOOGLE_AUTH_CLIENT_SECRET,
|
||||
GITHUB_AUTH_CLIENT_ID: process.env.GITHUB_AUTH_CLIENT_ID,
|
||||
GITHUB_AUTH_CLIENT_SECRET: process.env.GITHUB_AUTH_CLIENT_SECRET,
|
||||
STRIPE_SECRET: process.env.STRIPE_SECRET,
|
||||
STRIPE_WH_SECRET: process.env.STRIPE_WH_SECRET,
|
||||
STRIPE_SECRET_TEST: process.env.STRIPE_SECRET_TEST,
|
||||
STRIPE_WH_SECRET_TEST: process.env.STRIPE_WH_SECRET_TEST,
|
||||
NOAUTH_USER_EMAIL: process.env.NOAUTH_USER_EMAIL,
|
||||
NOAUTH_USER_PASS: process.env.NOAUTH_USER_PASS,
|
||||
MODE: process.env.MODE || 'NONE',
|
||||
|
||||
34
dashboard/pages/accept_invite.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const project_id = route.query.project_id;
|
||||
if (!project_id) throw Error('project_id is required');
|
||||
const res = await $fetch('/api/project/members/accept', {
|
||||
headers: useComputedHeaders({
|
||||
custom: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).value,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ project_id })
|
||||
});
|
||||
router.push('/');
|
||||
} catch (ex) {
|
||||
console.error('ERROR');
|
||||
console.error(ex);
|
||||
alert('An error occurred');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
You will be redirected soon.
|
||||
</div>
|
||||
</template>
|
||||
10
dashboard/pages/account.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-8">
|
||||
<div class="font-semibold text-[1.3rem] pl-4"> Account </div>
|
||||
<SettingsAccount></SettingsAccount>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,165 +5,8 @@ import type { CItem } from '~/components/CustomTab.vue';
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
|
||||
const filterPremium = ref<boolean>(false);
|
||||
const filterAppsumo = ref<boolean>(false);
|
||||
|
||||
|
||||
|
||||
const timeRange = ref<number>(9);
|
||||
|
||||
function setTimeRange(n: number) {
|
||||
timeRange.value = n;
|
||||
}
|
||||
|
||||
const timeRangeTimestamp = computed(() => {
|
||||
if (timeRange.value == 1) return Date.now() - 1000 * 60 * 60 * 24;
|
||||
if (timeRange.value == 2) return Date.now() - 1000 * 60 * 60 * 24 * 7;
|
||||
if (timeRange.value == 3) return Date.now() - 1000 * 60 * 60 * 24 * 30;
|
||||
return 0;
|
||||
})
|
||||
|
||||
|
||||
// const { data: projectsAggregatedResponseData } = await useFetch<AdminProjectsList[]>('/api/admin/projects', signHeaders());
|
||||
// const { data: counts } = await useFetch(() => `/api/admin/counts?from=${timeRangeTimestamp.value}`, signHeaders());
|
||||
|
||||
|
||||
|
||||
// function onHideClicked() {
|
||||
// isAdminHidden.value = true;
|
||||
// }
|
||||
|
||||
|
||||
// function isAppsumoType(type: number) {
|
||||
// return type > 6000 && type < 6004
|
||||
// }
|
||||
|
||||
// const projectsAggregated = computed(() => {
|
||||
|
||||
// let pool = projectsAggregatedResponseData.value ? [...projectsAggregatedResponseData.value] : [];
|
||||
|
||||
// let shownPool: AdminProjectsList[] = [];
|
||||
|
||||
|
||||
// for (const element of pool) {
|
||||
|
||||
// shownPool.push({ ...element, projects: [...element.projects] });
|
||||
|
||||
// if (filterAppsumo.value === true) {
|
||||
// shownPool.forEach(e => {
|
||||
// e.projects = e.projects.filter(project => {
|
||||
// return isAppsumoType(project.premium_type)
|
||||
// })
|
||||
// })
|
||||
|
||||
// shownPool = shownPool.filter(e => {
|
||||
// return e.projects.length > 0;
|
||||
// })
|
||||
|
||||
// } else if (filterPremium.value === true) {
|
||||
// shownPool.forEach(e => {
|
||||
// e.projects = e.projects.filter(project => {
|
||||
// return project.premium === true;
|
||||
// })
|
||||
// })
|
||||
|
||||
// shownPool = shownPool.filter(e => {
|
||||
// return e.projects.length > 0;
|
||||
// })
|
||||
|
||||
// } else {
|
||||
// console.log('NO DATA')
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// return shownPool.sort((a, b) => {
|
||||
// const sumVisitsA = a.projects.reduce((pa, pe) => pa + (pe.counts?.visits || 0) + (pe.counts?.events || 0), 0);
|
||||
// const sumVisitsB = b.projects.reduce((pa, pe) => pa + (pe.counts?.visits || 0) + (pe.counts?.events || 0), 0);
|
||||
// return sumVisitsB - sumVisitsA;
|
||||
// }).filter(e => {
|
||||
// return new Date(e.created_at).getTime() >= timeRangeTimestamp.value
|
||||
// });
|
||||
// })
|
||||
|
||||
// const premiumCount = computed(() => {
|
||||
// let premiums = 0;
|
||||
// projectsAggregated.value?.forEach(e => {
|
||||
// e.projects.forEach(p => {
|
||||
// if (p.premium) premiums++;
|
||||
// });
|
||||
|
||||
// })
|
||||
// return premiums;
|
||||
// })
|
||||
|
||||
|
||||
// const activeProjects = computed(() => {
|
||||
// let actives = 0;
|
||||
|
||||
// projectsAggregated.value?.forEach(e => {
|
||||
// e.projects.forEach(p => {
|
||||
// if (!p.counts) return;
|
||||
// if (!p.counts.updated_at) return;
|
||||
// const updated_at = new Date(p.counts.updated_at).getTime();
|
||||
// if (updated_at < Date.now() - 1000 * 60 * 60 * 24) return;
|
||||
// actives++;
|
||||
// });
|
||||
// })
|
||||
// return actives;
|
||||
// });
|
||||
|
||||
|
||||
|
||||
// const totalVisits = computed(() => {
|
||||
// return projectsAggregated.value?.reduce((a, e) => {
|
||||
// return a + e.projects.reduce((pa, pe) => pa + (pe.counts?.visits || 0), 0);
|
||||
// }, 0) || 0;
|
||||
// });
|
||||
|
||||
// const totalEvents = computed(() => {
|
||||
// return projectsAggregated.value?.reduce((a, e) => {
|
||||
// return a + e.projects.reduce((pa, pe) => pa + (pe.counts?.events || 0), 0);
|
||||
// }, 0) || 0;
|
||||
// });
|
||||
|
||||
|
||||
|
||||
const details = ref<any>();
|
||||
const showDetails = ref<boolean>(false);
|
||||
async function getProjectDetails(project_id: string) {
|
||||
details.value = await $fetch(`/api/admin/details?project_id=${project_id}`, signHeaders());
|
||||
showDetails.value = true;
|
||||
}
|
||||
|
||||
async function resetCount(project_id: string) {
|
||||
await $fetch(`/api/admin/reset_count?project_id=${project_id}`, signHeaders());
|
||||
}
|
||||
|
||||
|
||||
function dateDiffDays(a: string) {
|
||||
return (Date.now() - new Date(a).getTime()) / (1000 * 60 * 60 * 24)
|
||||
}
|
||||
|
||||
function getLogBg(last_logged_at?: string) {
|
||||
|
||||
const day = 1000 * 60 * 60 * 24;
|
||||
const week = 1000 * 60 * 60 * 24 * 7;
|
||||
|
||||
const lastLoggedAtDate = new Date(last_logged_at || 0);
|
||||
|
||||
if (lastLoggedAtDate.getTime() > Date.now() - day) {
|
||||
return 'bg-green-500'
|
||||
} else if (lastLoggedAtDate.getTime() > Date.now() - week) {
|
||||
return 'bg-yellow-500'
|
||||
} else {
|
||||
return 'bg-red-500'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const tabs: CItem[] = [
|
||||
{ label: 'Overview', slot: 'overview' },
|
||||
|
||||
@@ -6,6 +6,8 @@ definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const selfhosted = useSelfhosted();
|
||||
|
||||
const { permission, canSeeAi } = usePermission();
|
||||
|
||||
const debugModeAi = ref<boolean>(false);
|
||||
|
||||
const { userRoles } = useLoggedUser();
|
||||
@@ -253,7 +255,12 @@ async function clearAllChats() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full h-full overflow-y-hidden">
|
||||
|
||||
<div v-if="!canSeeAi" class="h-full w-full flex mt-[20vh] justify-center">
|
||||
<div> You need AI permission to view this page </div>
|
||||
</div>
|
||||
|
||||
<div v-if="canSeeAi" class="w-full h-full overflow-y-hidden">
|
||||
|
||||
<div class="flex flex-row h-full overflow-y-hidden">
|
||||
|
||||
|
||||
10
dashboard/pages/billing.vue
Normal file
@@ -0,0 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-8">
|
||||
<div class="font-semibold text-[1.3rem] pl-4"> Billing </div>
|
||||
<SettingsBilling></SettingsBilling>
|
||||
</div>
|
||||
</template>
|
||||
@@ -6,13 +6,6 @@ definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const { project } = useProject();
|
||||
|
||||
const isPremium = computed(() => (project.value?.premium_type || 0) > 0);
|
||||
const selfhosted = useSelfhosted();
|
||||
const canDownload = computed(() => {
|
||||
if (selfhosted) return true;
|
||||
return isPremium.value;
|
||||
});
|
||||
|
||||
const metricsInfo = ref<number>(0);
|
||||
|
||||
const columns = [
|
||||
@@ -110,17 +103,10 @@ function goToUpgrade() {
|
||||
}" v-model="selectedTimeFrom" :options="options"></USelectMenu>
|
||||
</div>
|
||||
|
||||
<div v-if="canDownload" @click="downloadCSV()"
|
||||
<div @click="downloadCSV()"
|
||||
class="bg-[#57c78fc0] hover:bg-[#57c78fab] cursor-pointer text-text poppins font-semibold px-8 py-1 rounded-lg">
|
||||
Download CSV
|
||||
</div>
|
||||
|
||||
<div v-if="!canDownload" @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>
|
||||
|
||||
|
||||
|
||||
@@ -6,13 +6,6 @@ definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const { project } = useProject();
|
||||
|
||||
const isPremium = computed(() => (project.value?.premium_type || 0) > 0);
|
||||
const selfhosted = useSelfhosted();
|
||||
const canDownload = computed(() => {
|
||||
if (selfhosted) return true;
|
||||
return isPremium.value;
|
||||
});
|
||||
|
||||
const metricsInfo = ref<number>(0);
|
||||
|
||||
const columns = [
|
||||
@@ -115,17 +108,11 @@ function goToUpgrade() {
|
||||
}" v-model="selectedTimeFrom" :options="options"></USelectMenu>
|
||||
</div>
|
||||
|
||||
<div v-if="canDownload" @click="downloadCSV()"
|
||||
<div @click="downloadCSV()"
|
||||
class="bg-[#57c78fc0] hover:bg-[#57c78fab] cursor-pointer text-text poppins font-semibold px-8 py-1 rounded-lg">
|
||||
Download CSV
|
||||
</div>
|
||||
|
||||
<div v-if="!canDownload" @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>
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import DateService, { type Slice } from '@services/DateService';
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const { permission, canSeeEvents } = usePermission();
|
||||
|
||||
const { snapshotDuration } = useSnapshot();
|
||||
|
||||
@@ -30,7 +31,12 @@ const eventsData = await useFetch(`/api/data/count`, {
|
||||
|
||||
|
||||
<template>
|
||||
<div class="w-full h-full overflow-y-auto pb-20 p-6 gap-6 flex flex-col">
|
||||
|
||||
<div v-if="!canSeeEvents" class="h-full w-full flex mt-[20vh] justify-center">
|
||||
<div> You need events permission to view this page </div>
|
||||
</div>
|
||||
|
||||
<div v-if="canSeeEvents" class="w-full h-full overflow-y-auto pb-20 p-6 gap-6 flex flex-col">
|
||||
|
||||
|
||||
<LyxUiCard class="w-full flex justify-between items-center lg:flex-row flex-col gap-6 lg:gap-0">
|
||||
@@ -47,8 +53,17 @@ const eventsData = await useFetch(`/api/data/count`, {
|
||||
</LyxUiCard>
|
||||
|
||||
|
||||
<div>
|
||||
<BarCardEvents :key="refreshKey"></BarCardEvents>
|
||||
<div class="flex gap-6 flex-col xl:flex-row xl:h-full">
|
||||
|
||||
<BarCardEvents class="xl:flex-[4]" :key="refreshKey"></BarCardEvents>
|
||||
|
||||
|
||||
<CardTitled :key="refreshKey" class="p-4 xl:flex-[2] w-full h-full" title="Top events"
|
||||
sub="Displays key events.">
|
||||
<DashboardEventsChart class="w-full"> </DashboardEventsChart>
|
||||
</CardTitled>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex gap-6 flex-col xl:flex-row xl:h-full">
|
||||
@@ -68,11 +83,6 @@ const eventsData = await useFetch(`/api/data/count`, {
|
||||
</div>
|
||||
</CardTitled>
|
||||
|
||||
<CardTitled :key="refreshKey" class="p-4 xl:flex-[2] w-full h-full" title="Top events"
|
||||
sub="Displays key events.">
|
||||
<DashboardEventsChart class="w-full"> </DashboardEventsChart>
|
||||
</CardTitled>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ const jwtLogin = computed(() => route.query.jwt_login as string);
|
||||
|
||||
const { token, setToken } = useAccessToken();
|
||||
|
||||
const { refreshingDomains } = useDomain();
|
||||
const { permission, canSeeWeb, canSeeEvents } = usePermission();
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
if (jwtLogin.value) {
|
||||
@@ -36,27 +39,39 @@ const selfhosted = useSelfhosted();
|
||||
|
||||
<template>
|
||||
|
||||
<div class="dashboard w-full h-full overflow-y-auto overflow-x-hidden pb-[7rem] md:pt-4 lg:pt-0">
|
||||
<div v-if="!canSeeWeb" class="h-full w-full flex mt-[20vh] justify-center">
|
||||
<div> You need webAnalytics permission to view this page </div>
|
||||
</div>
|
||||
|
||||
<div v-if="canSeeWeb && refreshingDomains">
|
||||
<div class="w-full flex justify-center items-center mt-[20vh]">
|
||||
<i class="fas fa-spinner text-[2rem] text-accent animate-[spin_1s_linear_infinite] duration-500"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="canSeeWeb && !refreshingDomains" class="dashboard w-full h-full overflow-y-auto overflow-x-hidden pb-[7rem] md:pt-4 lg:pt-0">
|
||||
|
||||
<div v-if="showDashboard">
|
||||
<div class="w-full px-4 py-2 gap-2 flex flex-col">
|
||||
|
||||
<div class="w-full px-4 py-2 gap-2 flex flex-col">
|
||||
<BannerLimitsInfo v-if="!selfhosted" :key="refreshKey"></BannerLimitsInfo>
|
||||
<!-- <BannerOffer v-if="!selfhosted" :key="refreshKey"></BannerOffer> -->
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<DashboardTopSection :key="refreshKey"></DashboardTopSection>
|
||||
<DashboardTopCards :key="refreshKey"></DashboardTopCards>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="mt-6 px-6 flex gap-6 flex-col 2xl:flex-row w-full">
|
||||
<DashboardActionableChart :key="refreshKey"></DashboardActionableChart>
|
||||
</div>
|
||||
<DashboardActionableChart v-if="canSeeWeb && canSeeEvents" :key="refreshKey"></DashboardActionableChart>
|
||||
<LyxUiCard v-else class="flex justify-center w-full py-4">
|
||||
You need events permission to view this widget
|
||||
</LyxUiCard>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex w-full justify-center mt-6 px-6">
|
||||
<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">
|
||||
<BarCardReferrers :key="refreshKey"></BarCardReferrers>
|
||||
@@ -66,7 +81,7 @@ const selfhosted = useSelfhosted();
|
||||
</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">
|
||||
@@ -76,9 +91,9 @@ const selfhosted = useSelfhosted();
|
||||
<BarCardDevices :key="refreshKey"></BarCardDevices>
|
||||
</div>
|
||||
</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">
|
||||
@@ -88,11 +103,10 @@ const selfhosted = useSelfhosted();
|
||||
<BarCardOperatingSystems :key="refreshKey"></BarCardOperatingSystems>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<FirstInteraction v-if="!justLogged" :refresh-interaction="firstInteraction.refresh"
|
||||
:first-interaction="(firstInteraction.data.value || false)"></FirstInteraction>
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ const router = useRouter();
|
||||
|
||||
const { token, setToken } = useAccessToken();
|
||||
|
||||
const { createErrorAlert } = useAlert();
|
||||
|
||||
async function handleOnSuccess(response: any) {
|
||||
|
||||
try {
|
||||
@@ -97,7 +99,7 @@ function goBackToEmailLogin() {
|
||||
|
||||
async function signInSelfhosted() {
|
||||
try {
|
||||
const result = await $fetch(`/api/auth/no_auth`, {
|
||||
const result: any = await $fetch(`/api/auth/no_auth`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: email.value, password: password.value })
|
||||
@@ -124,7 +126,7 @@ async function signInSelfhosted() {
|
||||
}
|
||||
|
||||
} catch (ex: any) {
|
||||
alert('Error during login.' + ex.message);
|
||||
createErrorAlert('Error', 'Error during login.' + ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +139,7 @@ async function signInWithCredentials() {
|
||||
body: JSON.stringify({ email: email.value, password: password.value })
|
||||
})
|
||||
|
||||
if (result.error) return alert(result.message);
|
||||
if (result.error) return createErrorAlert('Error', result.message);
|
||||
|
||||
setToken(result.access_token);
|
||||
|
||||
@@ -156,8 +158,8 @@ async function signInWithCredentials() {
|
||||
}
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
alert('Something went wrong.');
|
||||
} catch (ex: any) {
|
||||
createErrorAlert('Error', 'Something went wrong.' + ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +260,7 @@ async function signInWithCredentials() {
|
||||
|
||||
|
||||
|
||||
<div v-if="isNoAuth" @click="loginWithoutAuth"
|
||||
<div v-if="isNoAuth"
|
||||
class="flex text-[1.3rem] flex-col gap-4 items-center px-8 py-3 relative z-[2]">
|
||||
<div class="flex flex-col gap-4 z-[100] w-[20vw] min-w-[20rem]">
|
||||
<LyxUiInput class="px-3 py-2" placeholder="Email" v-model="email"></LyxUiInput>
|
||||
|
||||
212
dashboard/pages/members.vue
Normal file
@@ -0,0 +1,212 @@
|
||||
<script setup lang="ts">
|
||||
import { DialogPermissionManager } from '#components';
|
||||
import type { TPermission } from '~/shared/schema/TeamMemberSchema';
|
||||
|
||||
const { projectId, isGuest } = useProject();
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const columns = [
|
||||
{ key: 'me', label: '' },
|
||||
{ key: 'email', label: 'Email' },
|
||||
{ key: 'permission', label: 'Permission' },
|
||||
{ key: 'pending', label: 'Status' },
|
||||
{ key: 'action', label: 'Actions' },
|
||||
]
|
||||
|
||||
const { data: members, refresh: refreshMembers } = useFetch('/api/project/members/list', {
|
||||
headers: useComputedHeaders({ useSnapshotDates: false })
|
||||
});
|
||||
|
||||
const showAddMember = ref<boolean>(false);
|
||||
|
||||
const addMemberEmail = ref<string>("");
|
||||
|
||||
const { createErrorAlert } = useAlert();
|
||||
|
||||
async function kickMember(email: string) {
|
||||
const sure = confirm('Are you sure to kick ' + email + ' ?');
|
||||
if (!sure) return;
|
||||
try {
|
||||
await $fetch('/api/project/members/kick', {
|
||||
method: 'POST',
|
||||
...signHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-pid': projectId.value ?? ''
|
||||
}),
|
||||
body: JSON.stringify({ email }),
|
||||
onResponseError({ request, response, options }) {
|
||||
createErrorAlert('Error', response.statusText);
|
||||
}
|
||||
});
|
||||
|
||||
refreshMembers();
|
||||
} catch (ex: any) { }
|
||||
}
|
||||
|
||||
async function addMember() {
|
||||
|
||||
if (addMemberEmail.value.length === 0) return;
|
||||
|
||||
try {
|
||||
|
||||
showAddMember.value = false;
|
||||
|
||||
await $fetch('/api/project/members/add', {
|
||||
method: 'POST',
|
||||
...signHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
'x-pid': projectId.value ?? ''
|
||||
}),
|
||||
body: JSON.stringify({ email: addMemberEmail.value }),
|
||||
onResponseError({ request, response, options }) {
|
||||
createErrorAlert('Error', response.statusText);
|
||||
}
|
||||
});
|
||||
|
||||
addMemberEmail.value = '';
|
||||
|
||||
refreshMembers();
|
||||
|
||||
} catch (ex: any) { }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const modal = useModal();
|
||||
|
||||
function openPermissionManagerDialog(member_id: string) {
|
||||
modal.open(DialogPermissionManager, {
|
||||
preventClose: true,
|
||||
member_id,
|
||||
onSuccess: () => {
|
||||
modal.close();
|
||||
refreshMembers();
|
||||
},
|
||||
onCancel: () => {
|
||||
modal.close();
|
||||
refreshMembers();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function permissionToString(permission: TPermission) {
|
||||
const result: string[] = [];
|
||||
if (permission.webAnalytics) result.push('w');
|
||||
if (permission.events) result.push('e');
|
||||
if (permission.ai) result.push('a');
|
||||
if (permission.domains.includes('All domains')) {
|
||||
result.push('+');
|
||||
} else {
|
||||
result.push(permission.domains.length.toString());
|
||||
}
|
||||
return result.join('');
|
||||
}
|
||||
|
||||
async function leaveProject() {
|
||||
try {
|
||||
await $fetch('/api/project/members/leave', {
|
||||
headers: useComputedHeaders({}).value
|
||||
});
|
||||
location.reload();
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 pt-10">
|
||||
|
||||
<div v-if="!isGuest" class="flex flex-col gap-8">
|
||||
|
||||
<div class="flex flex-col">
|
||||
<div class="flex gap-4 items-center">
|
||||
<LyxUiInput class="px-4 py-1 w-full" placeholder="Add a new member" v-model="addMemberEmail">
|
||||
</LyxUiInput>
|
||||
<LyxUiButton @click="addMember" type="secondary"> Add </LyxUiButton>
|
||||
</div>
|
||||
<div class="poppins text-[.8rem] mt-2 dark:text-lyx-text-dark">
|
||||
We will send an invitation email to the user you wish to add to this project.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<UTable :rows="members || []" :columns="columns">
|
||||
|
||||
<template #me-data="e">
|
||||
<i v-if="e.row.me" class="far fa-user text-lyx-lightmode-text dark:text-lyx-text"></i>
|
||||
<i v-if="!e.row.me"></i>
|
||||
</template>
|
||||
|
||||
<template #email-data="e">
|
||||
<div class="text-lyx-lightmode-text dark:text-lyx-text">
|
||||
{{ e.row.email }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #pending-data="e">
|
||||
<div class="text-lyx-lightmode-text dark:text-lyx-text">
|
||||
{{ e.row.pending ? 'Pending' : 'Accepted' }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #permission-data="e">
|
||||
<div class="text-lyx-lightmode-text dark:text-lyx-text flex gap-2">
|
||||
<div v-if="e.row.role !== 'OWNER' && !isGuest">
|
||||
<LyxUiButton class="!px-2" type="secondary"
|
||||
@click="openPermissionManagerDialog(e.row.id.toString())">
|
||||
<UTooltip text="Manage permissions">
|
||||
<i class="far fa-gear"></i>
|
||||
</UTooltip>
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<UBadge variant="outline" size="sm" color="yellow"
|
||||
v-if="!e.row.permission.webAnalytics && !e.row.permission.events && !e.row.permission.ai && e.row.permission.domains.length == 0">
|
||||
No permission given
|
||||
</UBadge>
|
||||
<UBadge variant="outline" size="sm" v-if="e.row.permission.webAnalytics"
|
||||
label="Analytics"> </UBadge>
|
||||
<UBadge variant="outline" size="sm" v-if="e.row.permission.events" label="Events">
|
||||
</UBadge>
|
||||
<UBadge variant="outline" size="sm" v-if="e.row.permission.ai" label="AI"> </UBadge>
|
||||
<UBadge variant="outline" color="blue" size="sm"
|
||||
v-if="e.row.permission.domains.includes('All domains')" label="All domains">
|
||||
</UBadge>
|
||||
|
||||
<UBadge variant="outline" size="sm" color="blue"
|
||||
v-if="!e.row.permission.domains.includes('All domains')"
|
||||
v-for="domain of e.row.permission.domains" :label="domain"> </UBadge>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<template #action-data="e" v-if="!isGuest">
|
||||
<div @click="kickMember(e.row.email)" v-if="e.row.role != 'OWNER'"
|
||||
class="text-red-500 hover:bg-black/20 cursor-pointer outline outline-[1px] outline-red-500 px-3 py-1 rounded-lg text-center">
|
||||
Remove
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</UTable>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div v-if="isGuest" class="flex flex-col gap-8 mt-[10vh]">
|
||||
<div class="flex flex-col gap-4 items-center">
|
||||
<div class="text-[1.2rem]"> Leave this project </div>
|
||||
<LyxUiButton @click="leaveProject()" type="primary"> Leave </LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -2,29 +2,43 @@
|
||||
|
||||
definePageMeta({ layout: 'none' });
|
||||
|
||||
const colorMode = useColorMode();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<div class="w-full h-full">
|
||||
|
||||
|
||||
<div class="flex items-center h-full flex-col gap-4">
|
||||
|
||||
<div class="text-accent mt-[20vh] poppins font-semibold text-[1.5rem]">
|
||||
Payment success
|
||||
</div>
|
||||
|
||||
<div class="poppins">
|
||||
We hope Lilyx can help you make better metrics-driven decision to help your business.
|
||||
</div>
|
||||
|
||||
<NuxtLink to="/?just_logged=true" class="text-accent mt-10 bg-menu px-6 py-2 rounded-lg hover:bg-black font-semibold poppins cursor-pointer">
|
||||
Go back to dashboard
|
||||
</NuxtLink>
|
||||
<div
|
||||
class="w-full h-full flex flex-col items-center pt-[35vh] dark:bg-lyx-background bg-lyx-lightmode-background">
|
||||
|
||||
<div>
|
||||
<img v-if="colorMode.value === 'dark'" class="w-[9rem]" :src="'logo-white.png'">
|
||||
<img v-if="colorMode.value === 'light'" class="w-[9rem]" :src="'logo-black.png'">
|
||||
</div>
|
||||
<div class="poppins text-[1.2rem] text-center font-semibold mt-10">
|
||||
Payment successful
|
||||
</div>
|
||||
<div class="mt-2 dark:text-lyx-text-dark text-lyx-lightmode-text-dark">
|
||||
Thanks for choosing Litlyx. You're ready to go!
|
||||
</div>
|
||||
<LyxUiButton type="primary" class="mt-10 py-2" to="/?just_logged=true">
|
||||
Go back to dashboard
|
||||
</LyxUiButton>
|
||||
|
||||
<!-- <div class="flex items-center h-full flex-col gap-4"> -->
|
||||
|
||||
|
||||
<!-- <div class="poppins">
|
||||
We hope Litlyx can help you make better metrics-driven decision to help your business.
|
||||
</div>
|
||||
|
||||
<NuxtLink to="/?just_logged=true"
|
||||
class="text-accent mt-10 bg-menu px-6 py-2 rounded-lg hover:bg-black font-semibold poppins cursor-pointer">
|
||||
Go back to dashboard
|
||||
</NuxtLink> -->
|
||||
|
||||
<!-- </div> -->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,7 @@ onMounted(() => {
|
||||
|
||||
|
||||
async function createProject() {
|
||||
if (projectName.value.length < 2) return;
|
||||
if (projectName.value.trim().length < 2) return;
|
||||
|
||||
Lit.event('create_project');
|
||||
|
||||
@@ -34,14 +34,16 @@ async function createProject() {
|
||||
await $fetch('/api/project/create', {
|
||||
method: 'POST',
|
||||
...signHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ name: projectName.value })
|
||||
body: JSON.stringify({ name: projectName.value.trim() })
|
||||
});
|
||||
|
||||
await actions.refreshProjectsList();
|
||||
|
||||
const newActiveProjectId = projectList.value?.[projectList.value?.length - 1]._id.toString();
|
||||
|
||||
if (newActiveProjectId) {
|
||||
await actions.setActiveProject(newActiveProjectId);
|
||||
console.log('Set active project', newActiveProjectId);
|
||||
}
|
||||
|
||||
setPageLayout('dashboard');
|
||||
@@ -89,7 +91,7 @@ async function createProject() {
|
||||
|
||||
<div>
|
||||
|
||||
<LyxUiButton type="primary" @click="createProject()" :disabled="projectName.length < 2">
|
||||
<LyxUiButton type="primary" @click="createProject()" :disabled="projectName.trim().length < 2">
|
||||
Create
|
||||
</LyxUiButton>
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ async function registerAccount() {
|
||||
Sign up
|
||||
</div>
|
||||
|
||||
<div class="text-lyx-lightmode-text dark:text-lyx-text/80 text-[1.2rem] font-light text-center w-[70%] poppins mt-2">
|
||||
<div
|
||||
class="text-lyx-lightmode-text dark:text-lyx-text/80 text-[1.2rem] font-light text-center w-[70%] poppins mt-2">
|
||||
Track web analytics and custom events
|
||||
with extreme simplicity in under 30 sec.
|
||||
<br>
|
||||
@@ -88,8 +89,8 @@ async function registerAccount() {
|
||||
Password must be at least 6 chars long
|
||||
</div>
|
||||
<div class="flex justify-center mt-4 z-[100]">
|
||||
<LyxUiButton :disabled="!canRegister" @click="registerAccount()" class="text-center"
|
||||
type="primary">
|
||||
<LyxUiButton :disabled="!canRegister" @click="canRegister ? registerAccount() : ''"
|
||||
class="text-center" type="primary">
|
||||
Sign up
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const activeProject = useActiveProject();
|
||||
|
||||
|
||||
async function generatePDF() {
|
||||
|
||||
try {
|
||||
const res = await $fetch<Blob>('/api/project/generate_pdf', {
|
||||
...signHeaders(),
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
const url = URL.createObjectURL(res);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `Report.pdf`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<div class="home w-full h-full px-10 lg:px-0 overflow-y-auto pb-[12rem] md:pb-0">
|
||||
|
||||
<DialogCreateSnapshot></DialogCreateSnapshot>
|
||||
|
||||
<!-- <div class="flex flex-col items-center justify-center mt-20 gap-20">
|
||||
|
||||
<div class="flex flex-col items-center justify-center gap-10">
|
||||
<div class="poppins text-[2.4rem] font-bold text-text">
|
||||
Project Report
|
||||
</div>
|
||||
<div class="poppins text-[1.4rem] text-center lg:text-[1.8rem] text-text-sub/90">
|
||||
One-Click, Comprehensive KPI PDF for Your Investors or Team.
|
||||
</div>
|
||||
<div v-if="activeProject" class="flex md:gap-2 flex-col md:flex-row">
|
||||
<div class="poppins text-[1.4rem] font-semibold text-text-sub/90">
|
||||
Relative to:
|
||||
</div>
|
||||
<div class="poppins text-[1.4rem] font-semibold text-text">
|
||||
{{ activeProject.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
|
||||
<div @click="generatePDF()"
|
||||
class="flex flex-col rounded-xl overflow-hidden hover:shadow-[0_0_50px_#2969f1] hover:outline hover:outline-[2px] hover:outline-accent cursor-pointer">
|
||||
<div class="h-[14rem] aspect-[9/7] bg-[#2f2a64] flex relative">
|
||||
<img class="object-cover" :src="'/report/card_image.png'">
|
||||
|
||||
<div
|
||||
class="absolute px-4 py-1 rounded-lg poppins left-2 flex gap-2 bottom-2 bg-orange-500/80 items-center">
|
||||
<div class="flex items-center"> <i class="far fa-fire text-[1.1rem]"></i></div>
|
||||
<div class="poppins text-[1rem] font-semibold"> Popular </div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="bg-[#444444cc] p-4 h-[7rem] relative">
|
||||
<div class="poppins text-[1.2rem] font-bold text-text">
|
||||
Generate
|
||||
</div>
|
||||
<div class="poppins text-[1rem] text-text-sub/90">
|
||||
Create your report now
|
||||
</div>
|
||||
<div class="absolute right-4 bottom-3">
|
||||
<i class="fas fa-arrow-right text-[1.2rem]"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
132
dashboard/pages/reports.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const customization = ref<any>();
|
||||
|
||||
const { snapshot } = useSnapshot();
|
||||
const { showDrawer } = useDrawer();
|
||||
|
||||
const { isPremium } = useLoggedUser()
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await $fetch('/api/report/customization', {
|
||||
headers: useComputedHeaders().value
|
||||
})
|
||||
customization.value = res;
|
||||
})
|
||||
|
||||
async function updateCustomization() {
|
||||
await $fetch('/api/report/update_customization', {
|
||||
method: 'POST',
|
||||
headers: useComputedHeaders({
|
||||
custom: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).value,
|
||||
body: JSON.stringify(customization.value)
|
||||
})
|
||||
}
|
||||
|
||||
const generating = ref<boolean>(false);
|
||||
|
||||
async function generateReport(type: number) {
|
||||
if (generating.value === true) return;
|
||||
generating.value = true;
|
||||
try {
|
||||
const res = await $fetch<Blob>(`/api/project/generate_pdf?type=${type}`, {
|
||||
headers: useComputedHeaders({
|
||||
useSnapshotDates: false, custom: {
|
||||
'x-snapshot-name': snapshot.value.name
|
||||
}
|
||||
}).value,
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
const url = URL.createObjectURL(res);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `Report.pdf`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
}
|
||||
|
||||
generating.value = false;
|
||||
}
|
||||
|
||||
|
||||
function selectColor(color: string) {
|
||||
customization.value.bg = color;
|
||||
updateCustomization();
|
||||
}
|
||||
|
||||
function onFileSelected(e: string) {
|
||||
customization.value.logo = e;
|
||||
updateCustomization();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<div class="flex flex-col gap-4">
|
||||
<CardTitled class="w-full h-full" title="Choose a report" sub="Select a report type">
|
||||
<div class="w-full flex gap-4 h-[18rem]">
|
||||
<LyxUiCard class="flex-1 h-full">
|
||||
<div @click="generateReport(1)"
|
||||
:class="{ 'cursor-pointer hover:text-lyx-text-darker': !generating }"
|
||||
class="flex justify-center items-center text-[1.2rem] h-full">
|
||||
<div v-if="!generating"> Easy report </div>
|
||||
<div v-if="generating" class="flex justify-center pb-8 text-[1.2rem]">
|
||||
<i class="fas fa-loader animate-spin"></i>
|
||||
</div>
|
||||
</div>
|
||||
</LyxUiCard>
|
||||
<LyxUiCard class="flex-1 h-full">
|
||||
<div class="flex justify-center items-center text-[1.2rem] h-full">
|
||||
<div class="text-gray-400">(coming soon)</div>
|
||||
</div>
|
||||
</LyxUiCard>
|
||||
</div>
|
||||
</CardTitled>
|
||||
<div class="flex gap-4">
|
||||
<CardTitled class="w-full h-full relative" title="Customize theme" sub="Choose the report colors">
|
||||
<div v-if="!isPremium" @click="showDrawer('PRICING')"
|
||||
class="absolute w-full h-full top-0 left-0 bg-black/80 rounded-lg flex items-center justify-center gap-1">
|
||||
<div class="text-amber-300"> <i class="far fa-lock"></i> </div>
|
||||
<div class="text-amber-300"> Premium only </div>
|
||||
</div>
|
||||
<div v-if="customization" class="w-full flex gap-2 h-[18rem]">
|
||||
<div @click="selectColor('white')"
|
||||
class="flex items-center justify-center rounded-lg bg-white border-solid border-[1px] border-gray-200 cursor-pointer w-[4rem] h-[2rem]">
|
||||
<i v-if="customization.bg == 'white'" class="fas fa-check text-blue-600"></i>
|
||||
</div>
|
||||
<div @click="selectColor('black')"
|
||||
class="flex items-center justify-center rounded-lg bg-black border-solid border-[1px] border-gray-200 cursor-pointer w-[4rem] h-[2rem]">
|
||||
<i v-if="customization.bg == 'black'" class="fas fa-check text-blue-600"></i>
|
||||
</div>
|
||||
</div>
|
||||
</CardTitled>
|
||||
<CardTitled class="w-full h-full relative" title="Customize logo" sub="Upload your logo">
|
||||
<div v-if="!isPremium" @click="showDrawer('PRICING')"
|
||||
class="absolute w-full h-full top-0 left-0 bg-black/80 rounded-lg flex items-center justify-center gap-1">
|
||||
<div class="text-amber-300"> <i class="far fa-lock"></i> </div>
|
||||
<div class="text-amber-300"> Premium only </div>
|
||||
</div>
|
||||
<div v-if="customization" style="height: 18rem;" class="w-full flex gap-4">
|
||||
<img v-if="customization.logo" :src="customization.logo" class="w-[256px] h-[256px]">
|
||||
<div class="flex h-[10rem]">
|
||||
<SelectorImageSelector class="w-fit" @file_selected="onFileSelected">
|
||||
</SelectorImageSelector>
|
||||
</div>
|
||||
</div>
|
||||
</CardTitled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -7,16 +7,13 @@ const selfhosted = useSelfhosted();
|
||||
const items = [
|
||||
{ label: 'General', slot: 'general', tab: 'general' },
|
||||
{ label: 'Domains', slot: 'domains', tab: 'domains' },
|
||||
{ label: 'Members', slot: 'members', tab: 'members' },
|
||||
{ label: 'Billing', slot: 'billing', tab: 'billing' },
|
||||
{ label: 'Codes', slot: 'codes', tab: 'codes' },
|
||||
{ label: 'Account', slot: 'account', tab: 'account' }
|
||||
]
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="lg:px-10 lg:py-8 h-dvh overflow-y-auto overflow-x-hidden hide-scrollbars !pb-[10rem]">
|
||||
<div class="lg:px-10 h-full lg:py-8 overflow-hidden hide-scrollbars">
|
||||
|
||||
<div class="poppins font-semibold text-[1.3rem] lg:px-0 px-4 lg:py-0 py-4"> Settings </div>
|
||||
|
||||
@@ -27,16 +24,13 @@ const items = [
|
||||
<template #domains>
|
||||
<SettingsData :key="refreshKey"></SettingsData>
|
||||
</template>
|
||||
<template #members>
|
||||
<SettingsMembers :key="refreshKey"></SettingsMembers>
|
||||
</template>
|
||||
<template #billing>
|
||||
<!-- <template #billing>
|
||||
<SettingsBilling v-if="!selfhosted" :key="refreshKey"></SettingsBilling>
|
||||
<div class="flex popping text-[1.2rem] font-semibold justify-center mt-[20vh] text-lyx-lightmode-text dark:text-lyx-text"
|
||||
v-if="selfhosted">
|
||||
Billing disabled in self-host mode
|
||||
</div>
|
||||
</template>
|
||||
</template> -->
|
||||
<template #codes>
|
||||
<SettingsCodes v-if="!selfhosted" :key="refreshKey"></SettingsCodes>
|
||||
<div class="flex popping text-[1.2rem] font-semibold justify-center mt-[20vh] text-lyx-lightmode-text dark:text-lyx-text"
|
||||
|
||||
35
dashboard/pages/shields.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
definePageMeta({ layout: 'dashboard' });
|
||||
|
||||
const selfhosted = useSelfhosted();
|
||||
|
||||
const items = [
|
||||
{ label: 'Domains', slot: 'domains', tab: 'domains' },
|
||||
{ label: 'IP Addresses', slot: 'ipaddresses', tab: 'ipaddresses' },
|
||||
{ label: 'Bot traffic', slot: 'bots', tab: 'bots' },
|
||||
// { label: 'Countries', slot: 'countries', tab: 'countries' },
|
||||
// { label: 'Pages', slot: 'pages', tab: 'pages' },
|
||||
]
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="lg:px-10 h-full lg:py-8 overflow-hidden hide-scrollbars">
|
||||
|
||||
<div class="poppins font-semibold text-[1.3rem] lg:px-0 px-4 lg:py-0 py-4"> Shields </div>
|
||||
|
||||
<CustomTab :items="items" :route="true" class="mt-8">
|
||||
<template #domains>
|
||||
<ShieldsDomains></ShieldsDomains>
|
||||
</template>
|
||||
<template #ipaddresses>
|
||||
<ShieldsAddresses></ShieldsAddresses>
|
||||
</template>
|
||||
<template #bots>
|
||||
<ShieldsBots></ShieldsBots>
|
||||
</template>
|
||||
</CustomTab>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
15
dashboard/pages/test_links.vue
Normal file
@@ -0,0 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
const { data: links } = useFetch('/api/project/links/list', {
|
||||
headers: useComputedHeaders()
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-for="link of links">
|
||||
{{ link }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
8
dashboard/pnpm-lock.yaml
generated
@@ -5255,8 +5255,8 @@ packages:
|
||||
peerDependencies:
|
||||
vue: ^3.2.0
|
||||
|
||||
vue3-google-signin@2.0.1:
|
||||
resolution: {integrity: sha512-vZTlVrG56JERtqQ+6YI8e92wqfhAMDyNONCsLgKKXxzCNCWEfSkZcAvz7COm9V4bvzmGsebZ8KC3ljol2qsIcg==}
|
||||
vue3-google-signin@2.1.1:
|
||||
resolution: {integrity: sha512-RwlwyeCv8+PZjK35C/UyJN4/9MH+Fsz4bJDO7IjtmRuOaTMrvmMmI6SP5qkJgD7w9MIKOCj5rYVFMAL7+NCM0A==}
|
||||
peerDependencies:
|
||||
vue: ^3
|
||||
|
||||
@@ -9868,7 +9868,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.11.2(rollup@4.18.0)
|
||||
unimport: 3.7.2(rollup@4.18.0)
|
||||
vue3-google-signin: 2.0.1(vue@3.4.27(typescript@5.4.2))
|
||||
vue3-google-signin: 2.1.1(vue@3.4.27(typescript@5.4.2))
|
||||
transitivePeerDependencies:
|
||||
- rollup
|
||||
- supports-color
|
||||
@@ -11525,7 +11525,7 @@ snapshots:
|
||||
vue-observe-visibility: 2.0.0-alpha.1(vue@3.4.27(typescript@5.4.2))
|
||||
vue-resize: 2.0.0-alpha.1(vue@3.4.27(typescript@5.4.2))
|
||||
|
||||
vue3-google-signin@2.0.1(vue@3.4.27(typescript@5.4.2)):
|
||||
vue3-google-signin@2.1.1(vue@3.4.27(typescript@5.4.2)):
|
||||
dependencies:
|
||||
vue: 3.4.27(typescript@5.4.2)
|
||||
|
||||
|
||||
BIN
dashboard/public/flamy-black.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
dashboard/public/flamy.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
dashboard/public/lit.png
Normal file
|
After Width: | Height: | Size: 155 KiB |
BIN
dashboard/public/logo-black.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
dashboard/public/logo-white.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 20 KiB |
BIN
dashboard/public/tech-icons/shopify.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
dashboard/public/tech-icons/wpel.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
dashboard/public/yt.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
@@ -14,7 +14,7 @@ export async function getUserProjectFromId(project_id: string, user: AuthContext
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
if (!project) return;
|
||||
|
||||
const [hasAccess, role] = await hasAccessToProject(user.id, project_id, project);
|
||||
const [hasAccess, role] = await hasAccessToProject(user.id, project_id, user.user.email, project);
|
||||
if (!hasAccess) return;
|
||||
|
||||
if (role === 'GUEST' && !allowGuest) return false;
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
|
||||
import { ProjectLimitModel } from "@schema/project/ProjectsLimits";
|
||||
import { AIPlugin } from "../Plugin";
|
||||
import { MAX_LOG_LIMIT_PERCENT } from "@data/broker/Limits";
|
||||
import { ProjectModel } from "@schema/project/ProjectSchema";
|
||||
import StripeService from "~/server/services/StripeService";
|
||||
import { InvoiceData } from "~/server/api/pay/invoices";
|
||||
|
||||
export class AiBilling extends AIPlugin<[
|
||||
'getBillingInfo',
|
||||
'getLimits',
|
||||
'getInvoices'
|
||||
]> {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
|
||||
'getInvoices': {
|
||||
handler: async (data: { project_id: string }) => {
|
||||
|
||||
const project = await ProjectModel.findOne({ _id: data.project_id });
|
||||
if (!project) return { error: 'Project not found' };
|
||||
const invoices = await StripeService.getInvoices(project.customer_id);
|
||||
if (!invoices) return [];
|
||||
|
||||
return invoices?.data.map(e => {
|
||||
const result: InvoiceData = {
|
||||
link: e.invoice_pdf || '',
|
||||
id: e.number || '',
|
||||
date: e.created * 1000,
|
||||
status: e.status || 'NO_STATUS',
|
||||
cost: e.amount_due
|
||||
}
|
||||
return result;
|
||||
});
|
||||
},
|
||||
tool: {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'getInvoices',
|
||||
description: 'Gets the invoices of the user project',
|
||||
parameters: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'getBillingInfo': {
|
||||
handler: async (data: { project_id: string }) => {
|
||||
|
||||
const project = await ProjectModel.findOne({ _id: data.project_id });
|
||||
if (!project) return { error: 'Project not found' };
|
||||
|
||||
if (project.subscription_id === 'onetime') {
|
||||
|
||||
const projectLimits = await ProjectLimitModel.findOne({ project_id: data.project_id });
|
||||
if (!projectLimits) return { error: 'Limits not found' }
|
||||
|
||||
const result = {
|
||||
premium: project.premium,
|
||||
premium_type: project.premium_type,
|
||||
billing_start_at: projectLimits.billing_start_at,
|
||||
billing_expire_at: projectLimits.billing_expire_at,
|
||||
limit: projectLimits.limit,
|
||||
count: projectLimits.events + projectLimits.visits,
|
||||
subscription_status: StripeService.isDisabled() ? 'Disabled mode' : ('One time payment')
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const subscription = await StripeService.getSubscription(project.subscription_id);
|
||||
|
||||
const projectLimits = await ProjectLimitModel.findOne({ project_id: data.project_id });
|
||||
if (!projectLimits) return { error: 'Limits not found' }
|
||||
|
||||
|
||||
const result = {
|
||||
premium: project.premium,
|
||||
premium_type: project.premium_type,
|
||||
billing_start_at: projectLimits.billing_start_at,
|
||||
billing_expire_at: projectLimits.billing_expire_at,
|
||||
limit: projectLimits.limit,
|
||||
count: projectLimits.events + projectLimits.visits,
|
||||
subscription_status: StripeService.isDisabled() ? 'Disabled mode' : (subscription?.status ?? '?')
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
tool: {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'getBillingInfo',
|
||||
description: 'Gets the informations about the billing of the user project, limits, count, subscription_status, is premium, premium type, billing start at, billing expire at',
|
||||
parameters: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'getLimits': {
|
||||
handler: async (data: { project_id: string }) => {
|
||||
const projectLimits = await ProjectLimitModel.findOne({ project_id: data.project_id });
|
||||
if (!projectLimits) return { error: 'Project limits not found' };
|
||||
const TOTAL_COUNT = projectLimits.events + projectLimits.visits;
|
||||
const COUNT_LIMIT = projectLimits.limit;
|
||||
return {
|
||||
total: TOTAL_COUNT,
|
||||
limit: COUNT_LIMIT,
|
||||
limited: TOTAL_COUNT > COUNT_LIMIT * MAX_LOG_LIMIT_PERCENT,
|
||||
percent: Math.round(100 / COUNT_LIMIT * TOTAL_COUNT)
|
||||
}
|
||||
},
|
||||
tool: {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'getLimits',
|
||||
description: 'Gets the informations about the limits of the user project',
|
||||
parameters: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const AiBillingInstance = new AiBilling();
|
||||
15
dashboard/server/api/admin/delete_feedback.delete.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
import { FeedbackModel } from '@schema/FeedbackSchema';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
const { id } = await readBody(event);
|
||||
|
||||
await FeedbackModel.deleteOne({ _id: id });
|
||||
|
||||
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ProjectModel } from "@schema/project/ProjectSchema";
|
||||
import { ProjectCountModel } from "@schema/project/ProjectsCounts";
|
||||
import { ProjectLimitModel } from "@schema/project/ProjectsLimits";
|
||||
import { UserLimitModel } from "@schema/UserLimitSchema";
|
||||
import { UserModel } from "@schema/UserSchema";
|
||||
import StripeService from '~/server/services/StripeService';
|
||||
import { PremiumModel } from "~/shared/schema/PremiumSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const userData = getRequestUser(event);
|
||||
@@ -13,18 +13,24 @@ export default defineEventHandler(async event => {
|
||||
if (!project_id) return setResponseStatus(event, 400, 'ProjectId is required');
|
||||
|
||||
const project = await ProjectModel.findById(project_id);
|
||||
const limits = await ProjectLimitModel.findOne({ project_id });
|
||||
const limits = await UserLimitModel.findOne({ user_id: userData.id });
|
||||
const counts = await ProjectCountModel.findOne({ project_id });
|
||||
const user = await UserModel.findOne({ project_id });
|
||||
|
||||
const subscription =
|
||||
project?.subscription_id ?
|
||||
await StripeService.getSubscription(project.subscription_id) : 'NONE';
|
||||
const premium = await PremiumModel.findOne({ user_id: userData.id });
|
||||
|
||||
const customer =
|
||||
project?.customer_id ?
|
||||
await StripeService.getCustomer(project.customer_id) : 'NONE';
|
||||
// const subscription =
|
||||
// premium?.subscription_id ?
|
||||
// await StripeService.getSubscription(premium.subscription_id) : 'NONE';
|
||||
|
||||
// const customer =
|
||||
// premium?.customer_id ?
|
||||
// await StripeService.getCustomer(premium.customer_id) : 'NONE';
|
||||
|
||||
return {
|
||||
project, limits, counts, user,
|
||||
subscription: '',
|
||||
customer: ''
|
||||
}
|
||||
|
||||
return { project, limits, counts, user, subscription, customer }
|
||||
|
||||
});
|
||||
76
dashboard/server/api/admin/metrics.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { ProjectModel } from "@schema/project/ProjectSchema";
|
||||
import { UserModel } from "@schema/UserSchema";
|
||||
import { EventModel } from "@schema/metrics/EventSchema";
|
||||
import { VisitModel } from "@schema/metrics/VisitSchema";
|
||||
import { PremiumModel } from "~/shared/schema/PremiumSchema";
|
||||
|
||||
|
||||
function addFieldsFromArray(data: { fieldName: string, projectedName: string, arrayName: string }[]) {
|
||||
const content: Record<string, any> = {};
|
||||
data.forEach(e => {
|
||||
content[e.projectedName] = {
|
||||
"$ifNull": [{ "$getField": { "field": e.fieldName, "input": { "$arrayElemAt": [`$${e.arrayName}`, 0] } } }, 0]
|
||||
}
|
||||
});
|
||||
return content;
|
||||
}
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
const { filterFrom, filterTo } = getQuery(event);
|
||||
|
||||
|
||||
const matchQuery = {
|
||||
created_at: {
|
||||
$gte: new Date(filterFrom as string),
|
||||
$lte: new Date(filterTo as string)
|
||||
}
|
||||
}
|
||||
|
||||
const totalProjects = await ProjectModel.countDocuments({ ...matchQuery });
|
||||
const premiumProjects = await PremiumModel.countDocuments({ ...matchQuery, premium_type: { $ne: 0 } });
|
||||
|
||||
const deadProjects = await ProjectModel.aggregate([
|
||||
{ $match: matchQuery },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'project_counts',
|
||||
localField: '_id',
|
||||
foreignField: 'project_id',
|
||||
as: 'counts'
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: addFieldsFromArray([
|
||||
{ arrayName: 'counts', fieldName: 'counts', projectedName: 'counts' },
|
||||
{ arrayName: 'counts', fieldName: 'updated_at', projectedName: 'updated_at' },
|
||||
])
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
updated_at: {
|
||||
$lte: new Date(Date.now() - 1000 * 60 * 60 * 24 * 7)
|
||||
}
|
||||
}
|
||||
},
|
||||
{ $count: 'count' }
|
||||
])
|
||||
|
||||
const totalUsers = await UserModel.countDocuments({ ...matchQuery });
|
||||
|
||||
const totalVisits = 0;
|
||||
|
||||
const totalEvents = await EventModel.countDocuments({ ...matchQuery });
|
||||
|
||||
|
||||
return {
|
||||
totalProjects, premiumProjects,
|
||||
deadProjects: (deadProjects && deadProjects.length > 0 ? deadProjects[0].count : 0) as number,
|
||||
totalUsers, totalVisits, totalEvents
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
@@ -1,8 +1,11 @@
|
||||
import { ProjectModel, TProject } from "@schema/project/ProjectSchema";
|
||||
import { TProjectLimit } from "~/shared/schema/project/ProjectsLimits";
|
||||
import { TPremium } from "~/shared/schema/PremiumSchema";
|
||||
import { TUser } from "~/shared/schema/UserSchema";
|
||||
|
||||
|
||||
type ExtendedProject = {
|
||||
limits: TProjectLimit[],
|
||||
user: [TUser],
|
||||
premium: [TPremium],
|
||||
counts: [{
|
||||
events: number,
|
||||
visits: number,
|
||||
@@ -54,14 +57,14 @@ export default defineEventHandler(async event => {
|
||||
const count = await ProjectModel.countDocuments(matchQuery);
|
||||
|
||||
const projects = await ProjectModel.aggregate([
|
||||
{
|
||||
{
|
||||
$match: matchQuery
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "project_limits",
|
||||
localField: "_id",
|
||||
foreignField: "project_id",
|
||||
from: "user_limits",
|
||||
localField: "owner",
|
||||
foreignField: "user_id",
|
||||
as: "limits"
|
||||
}
|
||||
},
|
||||
@@ -73,6 +76,22 @@ export default defineEventHandler(async event => {
|
||||
as: "counts"
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "owner",
|
||||
foreignField: "_id",
|
||||
as: "user"
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "premiums",
|
||||
localField: "owner",
|
||||
foreignField: "user_id",
|
||||
as: "premium"
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: addFieldsFromArray([
|
||||
{ arrayName: 'counts', fieldName: 'visits', projectedName: 'visits' },
|
||||
|
||||
121
dashboard/server/api/admin/user_info.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import { ProjectModel, TProject } from "@schema/project/ProjectSchema";
|
||||
import { VisitModel } from "~/shared/schema/metrics/VisitSchema";
|
||||
import { TUser, UserModel } from "~/shared/schema/UserSchema";
|
||||
import { TPremium } from "~/shared/schema/PremiumSchema";
|
||||
import { Types } from "mongoose";
|
||||
import { TAdminProject } from "./projects";
|
||||
|
||||
export type TAdminUserInfo = {
|
||||
user: TUser,
|
||||
projects: (TAdminProject & { domains: string[] })[],
|
||||
premium: TPremium
|
||||
}
|
||||
|
||||
|
||||
async function getProjects(user_id: string) {
|
||||
|
||||
function addFieldsFromArray(data: { fieldName: string, projectedName: string, arrayName: string }[]) {
|
||||
const content: Record<string, any> = {};
|
||||
data.forEach(e => {
|
||||
content[e.projectedName] = {
|
||||
"$ifNull": [{ "$getField": { "field": e.fieldName, "input": { "$arrayElemAt": [`$${e.arrayName}`, 0] } } }, 0]
|
||||
}
|
||||
});
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
const projects = await ProjectModel.aggregate([
|
||||
{
|
||||
$match: { owner: new Types.ObjectId(user_id) }
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "user_limits",
|
||||
localField: "owner",
|
||||
foreignField: "user_id",
|
||||
as: "limits"
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "project_counts",
|
||||
localField: "_id",
|
||||
foreignField: "project_id",
|
||||
as: "counts"
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "premiums",
|
||||
localField: "owner",
|
||||
foreignField: "user_id",
|
||||
as: "premium"
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: addFieldsFromArray([
|
||||
{ arrayName: 'counts', fieldName: 'visits', projectedName: 'visits' },
|
||||
{ arrayName: 'counts', fieldName: 'events', projectedName: 'events' },
|
||||
{ arrayName: 'counts', fieldName: 'session', projectedName: 'session' },
|
||||
{ arrayName: 'counts', fieldName: 'updated_at', projectedName: 'last_log_at' },
|
||||
]),
|
||||
},
|
||||
{
|
||||
$addFields: addFieldsFromArray([
|
||||
{ arrayName: 'limits', fieldName: 'visits', projectedName: 'limit_visits' },
|
||||
{ arrayName: 'limits', fieldName: 'events', projectedName: 'limit_events' },
|
||||
{ arrayName: 'limits', fieldName: 'limit', projectedName: 'limit_max' },
|
||||
{ arrayName: 'limits', fieldName: 'ai_messages', projectedName: 'limit_ai_messages' },
|
||||
{ arrayName: 'limits', fieldName: 'ai_limit', projectedName: 'limit_ai_max' },
|
||||
]),
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
limit_total: {
|
||||
$add: [
|
||||
{ $ifNull: ["$limit_visits", 0] },
|
||||
{ $ifNull: ["$limit_events", 0] }
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $unset: 'counts' },
|
||||
{ $unset: 'limits' },
|
||||
]);
|
||||
|
||||
return projects as TAdminProject[];
|
||||
}
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
const { user_id } = getQuery(event);
|
||||
|
||||
const result: any = {}
|
||||
|
||||
result.user = await UserModel.findOne({ _id: user_id });
|
||||
result.projects = await getProjects(user_id as string);
|
||||
|
||||
|
||||
const promises: any[] = [];
|
||||
|
||||
for (const project of result.projects) {
|
||||
promises.push(new Promise<void>(async resolve => {
|
||||
const domains = await VisitModel.aggregate([
|
||||
{ $match: { project_id: (project as TAdminProject)._id } },
|
||||
{ $group: { _id: '$website', } }
|
||||
]);
|
||||
project.domains = domains.map(e => e._id);
|
||||
resolve();
|
||||
}));
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
return result as TAdminUserInfo;
|
||||
|
||||
});
|
||||
@@ -8,16 +8,27 @@ export default defineEventHandler(async event => {
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
const { page, limit, sortQuery, filterQuery } = getQuery(event);
|
||||
const { page, limit, sortQuery, filterQuery, filterFrom, filterTo } = getQuery(event);
|
||||
|
||||
const pageNumber = parseInt(page as string);
|
||||
const limitNumber = parseInt(limit as string);
|
||||
|
||||
const count = await UserModel.countDocuments(JSON.parse(filterQuery as string));
|
||||
const matchQuery = {
|
||||
...JSON.parse(filterQuery as string),
|
||||
created_at: {
|
||||
$gte: new Date(filterFrom as string),
|
||||
$lte: new Date(filterTo as string)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const count = await UserModel.countDocuments(matchQuery);
|
||||
|
||||
|
||||
|
||||
const users = await UserModel.aggregate([
|
||||
{
|
||||
$match: JSON.parse(filterQuery as string)
|
||||
$match: matchQuery
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { AiChatModel } from "@schema/ai/AiChatSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const data = await getRequestDataOld(event);
|
||||
const data = await getRequestData(event, [], ['AI']);
|
||||
if (!data) return;
|
||||
|
||||
const { project_id } = data;
|
||||
|
||||
@@ -4,7 +4,7 @@ import type OpenAI from "openai";
|
||||
import { getChartsInMessage } from "~/server/services/AiService";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestDataOld(event);
|
||||
const data = await getRequestData(event, [], ['AI']);
|
||||
if (!data) return;
|
||||
|
||||
const isAdmin = data.user.user.roles.includes('ADMIN');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { AiChatModel } from "@schema/ai/AiChatSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestDataOld(event);
|
||||
const data = await getRequestData(event, [], ['AI']);
|
||||
if (!data) return;
|
||||
|
||||
const { project_id } = data;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { AiChatModel } from "@schema/ai/AiChatSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const data = await getRequestDataOld(event);
|
||||
const data = await getRequestData(event, [], ['AI']);
|
||||
if (!data) return;
|
||||
|
||||
const { project_id } = data;
|
||||
|
||||