feat: Admin team sees everything

This commit is contained in:
Andras Bacsai
2022-04-06 15:55:17 +02:00
parent 352bb65125
commit 8405ebd28d
13 changed files with 210 additions and 150 deletions

View File

@@ -6,7 +6,13 @@ import { getDatabaseImage } from '.';
import { prisma } from './common';
export async function listDestinations(teamId) {
return await prisma.destinationDocker.findMany({ where: { teams: { some: { id: teamId } } } });
if (teamId === '0') {
return await prisma.destinationDocker.findMany({ include: { teams: true } });
}
return await prisma.destinationDocker.findMany({
where: { teams: { some: { id: teamId } } },
include: { teams: true }
});
}
export async function configureDestinationForService({ id, destinationId }) {
@@ -124,12 +130,17 @@ export async function removeDestination({ id }) {
}
export async function getDestination({ id, teamId }) {
let destination = await prisma.destinationDocker.findFirst({
where: { id, teams: { some: { id: teamId } } }
});
if (destination.remoteEngine) {
destination.sshPrivateKey = decrypt(destination.sshPrivateKey);
let destination = {};
if (teamId === '0') {
destination = await prisma.destinationDocker.findFirst({
where: { id }
});
} else {
destination = await prisma.destinationDocker.findFirst({
where: { id, teams: { some: { id: teamId } } }
});
}
return destination;
}
export async function getDestinationByApplicationId({ id, teamId }) {