mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Add website/reports to top nav.
This commit is contained in:
parent
c2de8e4c0a
commit
f7eeaa622b
19 changed files with 361 additions and 66 deletions
|
|
@ -26,29 +26,11 @@ export async function getWebsites(
|
|||
userId,
|
||||
teamId,
|
||||
includeTeams,
|
||||
onlyTeams,
|
||||
filter,
|
||||
filterType = WEBSITE_FILTER_TYPES.all,
|
||||
} = WebsiteSearchFilter;
|
||||
|
||||
const filterQuery = {
|
||||
AND: {
|
||||
OR: [
|
||||
{
|
||||
...((filterType === WEBSITE_FILTER_TYPES.all ||
|
||||
filterType === WEBSITE_FILTER_TYPES.name) && {
|
||||
name: { startsWith: filter, mode: 'insensitive' },
|
||||
}),
|
||||
},
|
||||
{
|
||||
...((filterType === WEBSITE_FILTER_TYPES.all ||
|
||||
filterType === WEBSITE_FILTER_TYPES.domain) && {
|
||||
domain: { startsWith: filter, mode: 'insensitive' },
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const where: Prisma.WebsiteWhereInput = {
|
||||
...(teamId && {
|
||||
teamWebsite: {
|
||||
|
|
@ -61,28 +43,53 @@ export async function getWebsites(
|
|||
{
|
||||
OR: [
|
||||
{
|
||||
...(userId && {
|
||||
userId,
|
||||
}),
|
||||
...(userId &&
|
||||
!onlyTeams && {
|
||||
userId,
|
||||
}),
|
||||
},
|
||||
{
|
||||
...(includeTeams && {
|
||||
teamWebsite: {
|
||||
some: {
|
||||
team: {
|
||||
teamUser: {
|
||||
some: {
|
||||
userId,
|
||||
...((includeTeams || onlyTeams) && {
|
||||
AND: [
|
||||
{
|
||||
teamWebsite: {
|
||||
some: {
|
||||
team: {
|
||||
teamUser: {
|
||||
some: {
|
||||
userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
userId: {
|
||||
not: userId,
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
OR: [
|
||||
{
|
||||
...((filterType === WEBSITE_FILTER_TYPES.all ||
|
||||
filterType === WEBSITE_FILTER_TYPES.name) && {
|
||||
name: { startsWith: filter, mode: 'insensitive' },
|
||||
}),
|
||||
},
|
||||
{
|
||||
...((filterType === WEBSITE_FILTER_TYPES.all ||
|
||||
filterType === WEBSITE_FILTER_TYPES.domain) && {
|
||||
domain: { startsWith: filter, mode: 'insensitive' },
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
{ ...(filter && filterQuery) },
|
||||
],
|
||||
};
|
||||
|
||||
|
|
@ -108,7 +115,27 @@ export async function getWebsitesByUserId(
|
|||
userId: string,
|
||||
filter?: WebsiteSearchFilter,
|
||||
): Promise<FilterResult<Website[]>> {
|
||||
return getWebsites({ userId, ...filter });
|
||||
return getWebsites(
|
||||
{ userId, ...filter },
|
||||
{
|
||||
include: {
|
||||
teamWebsite: {
|
||||
include: {
|
||||
team: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
user: {
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function getWebsitesByTeamId(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue