mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
update ui
This commit is contained in:
18
dashboard/server/api/admin/backend.ts
Normal file
18
dashboard/server/api/admin/backend.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
|
||||
const queueRes = await fetch("http://94.130.182.52:3031/metrics/queue");
|
||||
const queue = await queueRes.json();
|
||||
const durationsRes = await fetch("http://94.130.182.52:3031/metrics/durations");
|
||||
const durations = await durationsRes.json();
|
||||
|
||||
return { queue, durations: durations }
|
||||
|
||||
|
||||
});
|
||||
31
dashboard/server/api/admin/feedbacks.ts
Normal file
31
dashboard/server/api/admin/feedbacks.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
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 feedbacks = await FeedbackModel.aggregate([
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
localField: 'user_id',
|
||||
foreignField: '_id',
|
||||
as: 'user'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'projects',
|
||||
localField: 'project_id',
|
||||
foreignField: '_id',
|
||||
as: 'project'
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
return feedbacks;
|
||||
|
||||
});
|
||||
30
dashboard/server/api/admin/onboardings.ts
Normal file
30
dashboard/server/api/admin/onboardings.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
import { OnboardingModel } from '~/shared/schema/OnboardingSchema';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const userData = getRequestUser(event);
|
||||
if (!userData?.logged) return;
|
||||
if (!userData.user.roles.includes('ADMIN')) return;
|
||||
|
||||
const analytics = await OnboardingModel.aggregate([
|
||||
{
|
||||
$group: {
|
||||
_id: '$analytics',
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
const jobs = await OnboardingModel.aggregate([
|
||||
{
|
||||
$group: {
|
||||
_id: '$job',
|
||||
count: { $sum: 1 }
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
return { analytics, jobs };
|
||||
|
||||
});
|
||||
@@ -38,17 +38,25 @@ 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 ProjectModel.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 ProjectModel.countDocuments(matchQuery);
|
||||
|
||||
const projects = await ProjectModel.aggregate([
|
||||
{
|
||||
$match: JSON.parse(filterQuery as string)
|
||||
},
|
||||
{
|
||||
$match: matchQuery
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "project_limits",
|
||||
|
||||
Reference in New Issue
Block a user