mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
DataTable refactor.
This commit is contained in:
parent
92ccc64e47
commit
6846355c63
17 changed files with 94 additions and 114 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import * as yup from 'yup';
|
||||
import { useAuth, useCors, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, SearchFilter, TeamSearchFilterType } from 'lib/types';
|
||||
import { getFilterValidation } from 'lib/yup';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { getTeamsByUserId } from 'queries';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export interface UserTeamsRequestQuery extends SearchFilter<TeamSearchFilterType> {
|
||||
id: string;
|
||||
}
|
||||
|
|
@ -18,7 +19,7 @@ export interface UserTeamsRequestBody {
|
|||
const schema = {
|
||||
GET: yup.object().shape({
|
||||
id: yup.string().uuid().required(),
|
||||
...getFilterValidation('/All|Name|Owner/i'),
|
||||
...pageInfo,
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -40,12 +41,12 @@ export default async (
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { page, filter, pageSize } = req.query;
|
||||
const { page, query, pageSize } = req.query;
|
||||
|
||||
const teams = await getTeamsByUserId(userId, {
|
||||
query,
|
||||
page,
|
||||
filter,
|
||||
pageSize: +pageSize || undefined,
|
||||
pageSize,
|
||||
});
|
||||
|
||||
return ok(res, teams);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useAuth, useCors, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, SearchFilter, WebsiteSearchFilterType } from 'lib/types';
|
||||
import { getFilterValidation } from 'lib/yup';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { getWebsitesByUserId } from 'queries';
|
||||
|
|
@ -17,7 +17,7 @@ const schema = {
|
|||
id: yup.string().uuid().required(),
|
||||
includeTeams: yup.boolean(),
|
||||
onlyTeams: yup.boolean(),
|
||||
...getFilterValidation(/All|Name|Domain/i),
|
||||
...pageInfo,
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ export default async (
|
|||
await useValidate(req, res);
|
||||
|
||||
const { user } = req.auth;
|
||||
const { id: userId, page, filter, pageSize, includeTeams, onlyTeams } = req.query;
|
||||
const { id: userId, page, pageSize, query, includeTeams, onlyTeams } = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (!user.isAdmin && user.id !== userId) {
|
||||
|
|
@ -40,8 +40,8 @@ export default async (
|
|||
}
|
||||
|
||||
const websites = await getWebsitesByUserId(userId, {
|
||||
query,
|
||||
page,
|
||||
filter,
|
||||
pageSize: +pageSize || undefined,
|
||||
includeTeams,
|
||||
onlyTeams,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { ROLES } from 'lib/constants';
|
|||
import { uuid } from 'lib/crypto';
|
||||
import { useAuth, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, Role, SearchFilter, User, UserSearchFilterType } from 'lib/types';
|
||||
import { getFilterValidation } from 'lib/yup';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { badRequest, hashPassword, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createUser, getUserByUsername, getUsers } from 'queries';
|
||||
|
|
@ -19,7 +19,7 @@ export interface UsersRequestBody {
|
|||
import * as yup from 'yup';
|
||||
const schema = {
|
||||
GET: yup.object().shape({
|
||||
...getFilterValidation(/All|Username/i),
|
||||
...pageInfo,
|
||||
}),
|
||||
POST: yup.object().shape({
|
||||
username: yup.string().max(255).required(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue