Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: Admin team sees everything

Andras Bacsai8405ebd28d27
diff --git a/src/lib/database/applications.ts b/src/lib/database/applications.ts
index 1d81401449..1c6e172c2a 100644
--- a/src/lib/database/applications.ts
+++ b/src/lib/database/applications.ts
@@ -5,7 +5,13 @@ import { getDomain, removeDestinationDocker } from '$lib/common';
import { prisma } from './common';
export async function listApplications(teamId) {
- return await prisma.application.findMany({ where: { teams: { some: { id: teamId } } } });
+ if (teamId === '0') {
+ return await prisma.application.findMany({ include: { teams: true } });
+ }
+ return await prisma.application.findMany({
+ where: { teams: { some: { id: teamId } } },
+ include: { teams: true }
+ });
}
export async function newApplication({ name, teamId }) {
@@ -130,16 +136,30 @@ export async function getApplicationById({ id }) {
return { ...body };
}
export async function getApplication({ id, teamId }) {
- let body = await prisma.application.findFirst({
- where: { id, teams: { some: { id: teamId } } },
- include: {
- destinationDocker: true,
- settings: true,
- gitSource: { include: { githubApp: true, gitlabApp: true } },
- secrets: true,
- persistentStorage: true
- }
- });
+ let body = {};
+ if (teamId === '0') {
+ body = await prisma.application.findFirst({
+ where: { id },
+ include: {
+ destinationDocker: true,
+ settings: true,
+ gitSource: { include: { githubApp: true, gitlabApp: true } },
+ secrets: true,
+ persistentStorage: true
+ }
+ });
+ } else {
+ body = await prisma.application.findFirst({
+ where: { id, teams: { some: { id: teamId } } },
+ include: {
+ destinationDocker: true,
+ settings: true,
+ gitSource: { include: { githubApp: true, gitlabApp: true } },
+ secrets: true,
+ persistentStorage: true
+ }
+ });
+ }
if (body?.gitSource?.githubApp?.clientSecret) {
body.gitSource.githubApp.clientSecret = decrypt(body.gitSource.githubApp.clientSecret);
diff --git a/src/lib/database/databases.ts b/src/lib/database/databases.ts
index be5ddacd3b..7fc2379442 100644
--- a/src/lib/database/databases.ts
+++ b/src/lib/database/databases.ts
@@ -7,7 +7,14 @@ import getPort, { portNumbers } from 'get-port';
import { asyncExecShell, getEngine, removeContainer } from '$lib/common';
export async function listDatabases(teamId) {
- return await prisma.database.findMany({ where: { teams: { some: { id: teamId } } } });
+ if (teamId === '0') {
+ return await prisma.database.findMany({ include: { teams: true } });
+ } else {
+ return await prisma.database.findMany({
+ where: { teams: { some: { id: teamId } } },
+ include: { teams: true }
+ });
+ }
}
export async function newDatabase({ name, teamId }) {
const dbUser = cuid();
@@ -31,10 +38,18 @@ export async function newDatabase({ name, teamId }) {
}
export async function getDatabase({ id, teamId }) {
- const body = await prisma.database.findFirst({
- where: { id, teams: { some: { id: teamId } } },
- include: { destinationDocker: true, settings: true }
- });
+ let body = {};
+ if (teamId === '0') {
+ body = await prisma.database.findFirst({
+ where: { id },
+ include: { destinationDocker: true, settings: true }
+ });
+ } else {
+ body = await prisma.database.findFirst({
+ where: { id, teams: { some: { id: teamId } } },
+ include: { destinationDocker: true, settings: true }
+ });
+ }
if (body.dbUserPassword) body.dbUserPassword = decrypt(body.dbUserPassword);
if (body.rootUserPassword) body.rootUserPassword = decrypt(body.rootUserPassword);
diff --git a/src/lib/database/destinations.ts b/src/lib/database/destinations.ts
index 3f3aadec53..5bd63c81b6 100644
--- a/src/lib/database/destinations.ts
+++ b/src/lib/database/destinations.ts
@@ -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 }) {
diff --git a/src/lib/database/gitSources.ts b/src/lib/database/gitSources.ts
index 927907964e..7e4e90633f 100644
--- a/src/lib/database/gitSources.ts
+++ b/src/lib/database/gitSources.ts
@@ -2,9 +2,14 @@ import { decrypt, encrypt } from '$lib/crypto';
import { prisma } from './common';
export async function listSources(teamId) {
+ if (teamId === '0') {
+ return await prisma.gitSource.findMany({
+ include: { githubApp: true, gitlabApp: true, teams: true }
+ });
+ }
return await prisma.gitSource.findMany({
where: { teams: { some: { id: teamId } } },
- include: { githubApp: true, gitlabApp: true }
+ include: { githubApp: true, gitlabApp: true, teams: true }
});
}
@@ -31,10 +36,18 @@ export async function removeSource({ id }) {
}
export async function getSource({ id, teamId }) {
- let body = await prisma.gitSource.findFirst({
- where: { id, teams: { some: { id: teamId } } },
- include: { githubApp: true, gitlabApp: true }
- });
+ let body = {};
+ if (teamId === '0') {
+ body = await prisma.gitSource.findFirst({
+ where: { id },
+ include: { githubApp: true, gitlabApp: true }
+ });
+ } else {
+ body = await prisma.gitSource.findFirst({
+ where: { id, teams: { some: { id: teamId } } },
+ include: { githubApp: true, gitlabApp: true }
+ });
+ }
if (body?.githubApp?.clientSecret)
body.githubApp.clientSecret = decrypt(body.githubApp.clientSecret);
if (body?.githubApp?.webhookSecret)
diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts
index bc25b93277..d578a500c0 100644
--- a/src/lib/database/services.ts
+++ b/src/lib/database/services.ts
@@ -5,7 +5,14 @@ import { generatePassword } from '.';
import { prisma } from './common';
export async function listServices(teamId) {
- return await prisma.service.findMany({ where: { teams: { some: { id: teamId } } } });
+ if (teamId === '0') {
+ return await prisma.service.findMany({ include: { teams: true } });
+ } else {
+ return await prisma.service.findMany({
+ where: { teams: { some: { id: teamId } } },
+ include: { teams: true }
+ });
+ }
}
export async function newService({ name, teamId }) {
@@ -13,19 +20,28 @@ export async function newService({ name, teamId }) {
}
export async function getService({ id, teamId }) {
- const body = await prisma.service.findFirst({
- where: { id, teams: { some: { id: teamId } } },
- include: {
- destinationDocker: true,
- plausibleAnalytics: true,
- minio: true,
- vscodeserver: true,
- wordpress: true,
- ghost: true,
- serviceSecret: true,
- meiliSearch: true
- }
- });
+ let body = {};
+ const include = {
+ destinationDocker: true,
+ plausibleAnalytics: true,
+ minio: true,
+ vscodeserver: true,
+ wordpress: true,
+ ghost: true,
+ serviceSecret: true,
+ meiliSearch: true
+ };
+ if (teamId === '0') {
+ body = await prisma.service.findFirst({
+ where: { id },
+ include
+ });
+ } else {
+ body = await prisma.service.findFirst({
+ where: { id, teams: { some: { id: teamId } } },
+ include
+ });
+ }
if (body.plausibleAnalytics?.postgresqlPassword)
body.plausibleAnalytics.postgresqlPassword = decrypt(
diff --git a/src/routes/applications/_Application.svelte b/src/routes/applications/_Application.svelte
index 16d19a42f5..fb6a157c78 100644
--- a/src/routes/applications/_Application.svelte
+++ b/src/routes/applications/_Application.svelte
@@ -54,6 +54,7 @@
{/if}
<div class="truncate text-center text-xl font-bold">{application.name}</div>
+ <div class="truncate text-center">Team {application.teams[0].name}</div>
{#if application.fqdn}
<div class="truncate text-center">{application.fqdn}</div>
{/if}
diff --git a/src/routes/databases/index.svelte b/src/routes/databases/index.svelte
index f6834cd0b7..6caa4d90eb 100644
--- a/src/routes/databases/index.svelte
+++ b/src/routes/databases/index.svelte
@@ -59,6 +59,7 @@
<div class="font-bold text-xl text-center truncate">
{database.name}
</div>
+ <div class="text-center truncate">Team {database.teams[0].name}</div>
{#if !database.type}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
Configuration missing
diff --git a/src/routes/destinations/[id]/_LocalDocker.svelte b/src/routes/destinations/[id]/_LocalDocker.svelte
index 329d23c2fd..1ed6d3b995 100644
--- a/src/routes/destinations/[id]/_LocalDocker.svelte
+++ b/src/routes/destinations/[id]/_LocalDocker.svelte
@@ -184,41 +184,19 @@
value={destination.network}
/>
</div>
- <div class="grid grid-cols-2 items-center">
- <Setting
- disabled={cannotDisable}
- bind:setting={destination.isCoolifyProxyUsed}
- on:click={changeProxySetting}
- title="Use Coolify Proxy?"
- description={`This will install a proxy on the destination to allow you to access your applications and services without any manual configuration. Databases will have their own proxy. <br><br>${
- cannotDisable
- ? '<span class="font-bold text-white">You cannot disable this proxy as FQDN is configured for Coolify.</span>'
- : ''
- }`}
- />
- </div>
-</form>
-<!-- <div class="flex justify-center">
- {#if payload.isCoolifyProxyUsed}
- {#if state}
- <button on:click={stopProxy}>Stop proxy</button>
- {:else}
- <button on:click={startProxy}>Start proxy</button>
- {/if}
- {/if}
-</div> -->
-
-<!-- {#if scannedApps.length > 0}
- <div class="flex justify-center px-6 pb-10">
- <div class="flex space-x-2 h-8 items-center">
- <div class="font-bold text-xl text-white">Found applications</div>
+ {#if $session.teamId === '0'}
+ <div class="grid grid-cols-2 items-center">
+ <Setting
+ disabled={cannotDisable}
+ bind:setting={destination.isCoolifyProxyUsed}
+ on:click={changeProxySetting}
+ title="Use Coolify Proxy?"
+ description={`This will install a proxy on the destination to allow you to access your applications and services without any manual configuration. Databases will have their own proxy. <br><br>${
+ cannotDisable
+ ? '<span class="font-bold text-white">You cannot disable this proxy as FQDN is configured for Coolify.</span>'
+ : ''
+ }`}
+ />
</div>
- </div>
- <div class="max-w-4xl mx-auto px-6">
- <div class="flex space-x-2 justify-center">
- {#each scannedApps as app}
- <FoundApp {app} />
- {/each}
- </div>
- </div>
-{/if} -->
+ {/if}
+</form>
diff --git a/src/routes/destinations/[id]/index.json.ts b/src/routes/destinations/[id]/index.json.ts
index e88c298258..d64df8c08e 100644
--- a/src/routes/destinations/[id]/index.json.ts
+++ b/src/routes/destinations/[id]/index.json.ts
@@ -8,7 +8,7 @@ import type { RequestHandler } from '@sveltejs/kit';
export const get: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
-
+ console.log(teamId);
const { id } = event.params;
try {
const destination = await db.getDestination({ id, teamId });
diff --git a/src/routes/destinations/index.svelte b/src/routes/destinations/index.svelte
index 01f860b212..a7b6b9a7e5 100644
--- a/src/routes/destinations/index.svelte
+++ b/src/routes/destinations/index.svelte
@@ -57,6 +57,7 @@
<a href="/destinations/{destination.id}" class="no-underline p-2 w-96">
<div class="box-selection hover:bg-sky-600">
<div class="font-bold text-xl text-center truncate">{destination.name}</div>
+ <div class="text-center truncate">Team {destination.teams[0].name}</div>
<div class="text-center truncate">{destination.network}</div>
</div>
</a>
diff --git a/src/routes/services/index.svelte b/src/routes/services/index.svelte
index 4cba9a702c..f2a6e5fb08 100644
--- a/src/routes/services/index.svelte
+++ b/src/routes/services/index.svelte
@@ -74,6 +74,7 @@
<div class="font-bold text-xl text-center truncate">
{service.name}
</div>
+ <div class="text-center truncate">Team {service.teams[0].name}</div>
{#if !service.type || !service.fqdn}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
Configuration missing
diff --git a/src/routes/sources/[id]/_Gitlab.svelte b/src/routes/sources/[id]/_Gitlab.svelte
index 56bb0288df..7823aebe96 100644
--- a/src/routes/sources/[id]/_Gitlab.svelte
+++ b/src/routes/sources/[id]/_Gitlab.svelte
@@ -91,93 +91,95 @@
</script>
{#if !source.gitlabApp?.appId}
- <form class="grid grid-flow-row gap-2 py-4" on:submit|preventDefault={newApp}>
- <div class="grid grid-cols-2 items-center">
- <label for="type">GitLab Application Type</label>
- <select name="type" id="type" class="w-96" bind:value={payload.applicationType}>
- <option value="user">User owned application</option>
- <option value="group">Group owned application</option>
- {#if source.htmlUrl !== 'https://gitlab.com'}
- <option value="instance">Instance-wide application (self-hosted)</option>
- {/if}
- </select>
- </div>
- {#if payload.applicationType === 'group'}
+ <div>
+ <form class="grid grid-flow-row gap-2 py-4" on:submit|preventDefault={newApp}>
<div class="grid grid-cols-2 items-center">
- <label for="groupName">Group Name</label>
- <input name="groupName" id="groupName" required bind:value={payload.groupName} />
+ <label for="type">GitLab Application Type</label>
+ <select name="type" id="type" class="w-96" bind:value={payload.applicationType}>
+ <option value="user">User owned application</option>
+ <option value="group">Group owned application</option>
+ {#if source.htmlUrl !== 'https://gitlab.com'}
+ <option value="instance">Instance-wide application (self-hosted)</option>
+ {/if}
+ </select>
</div>
- {/if}
+ {#if payload.applicationType === 'group'}
+ <div class="grid grid-cols-2 items-center">
+ <label for="groupName">Group Name</label>
+ <input name="groupName" id="groupName" required bind:value={payload.groupName} />
+ </div>
+ {/if}
- <div class="w-full pt-10 text-center">
- <button class="w-96 bg-orange-600 hover:bg-orange-500" type="submit"
- >Register new OAuth application on GitLab</button
- >
- </div>
+ <div class="w-full pt-10 text-center">
+ <button class="w-96 bg-orange-600 hover:bg-orange-500" type="submit"
+ >Register new OAuth application on GitLab</button
+ >
+ </div>
- <Explainer
- customClass="w-full"
- text="<span class='font-bold text-base text-white'>Scopes required:</span>
+ <Explainer
+ customClass="w-full"
+ text="<span class='font-bold text-base text-white'>Scopes required:</span>
<br>- <span class='text-orange-500 font-bold'>api</span> (Access the authenticated user's API)
<br>- <span class='text-orange-500 font-bold'>read_repository</span> (Allows read-only access to the repository)
<br>- <span class='text-orange-500 font-bold'>email</span> (Allows read-only access to the user's primary email address using OpenID Connect)
<br>
<br>For extra security, you can set Expire access tokens!
<br><br>Webhook URL: <span class='text-orange-500 font-bold'>{browser
- ? window.location.origin
- : ''}/webhooks/gitlab</span>
+ ? window.location.origin
+ : ''}/webhooks/gitlab</span>
<br>But if you will set a custom domain name for Coolify, use that instead."
- />
- </form>
- <form on:submit|preventDefault={handleSubmit} class="grid grid-flow-row gap-2 py-4 pt-10">
- <div class="flex h-8 items-center space-x-2">
- <div class="text-xl font-bold text-white">Configuration</div>
- <button
- type="submit"
- class:bg-orange-600={!loading}
- class:hover:bg-orange-500={!loading}
- disabled={loading}>{loading ? 'Saving...' : 'Save'}</button
- >
- </div>
+ />
+ </form>
+ <form on:submit|preventDefault={handleSubmit} class="grid grid-flow-row gap-2 py-4 pt-10">
+ <div class="flex h-8 items-center space-x-2">
+ <div class="text-xl font-bold text-white">Configuration</div>
+ <button
+ type="submit"
+ class:bg-orange-600={!loading}
+ class:hover:bg-orange-500={!loading}
+ disabled={loading}>{loading ? 'Saving...' : 'Save'}</button
+ >
+ </div>
- <div class="grid grid-cols-2 items-start">
- <div class="flex-col">
- <label for="oauthId" class="pt-2">OAuth ID</label>
- <Explainer
- text="The OAuth ID is the unique identifier of the GitLab application. <br>You can find it <span class='font-bold text-orange-600' >in the URL</span> of your GitLab OAuth Application."
+ <div class="grid grid-cols-2 items-start">
+ <div class="flex-col">
+ <label for="oauthId" class="pt-2">OAuth ID</label>
+ <Explainer
+ text="The OAuth ID is the unique identifier of the GitLab application. <br>You can find it <span class='font-bold text-orange-600' >in the URL</span> of your GitLab OAuth Application."
+ />
+ </div>
+ <input
+ on:change={checkOauthId}
+ bind:this={oauthIdEl}
+ name="oauthId"
+ id="oauthId"
+ type="number"
+ required
+ bind:value={payload.oauthId}
/>
</div>
- <input
- on:change={checkOauthId}
- bind:this={oauthIdEl}
- name="oauthId"
- id="oauthId"
- type="number"
- required
- bind:value={payload.oauthId}
- />
- </div>
- {#if payload.applicationType === 'group'}
+ {#if payload.applicationType === 'group'}
+ <div class="grid grid-cols-2 items-center">
+ <label for="groupName">Group Name</label>
+ <input name="groupName" id="groupName" required bind:value={payload.groupName} />
+ </div>
+ {/if}
<div class="grid grid-cols-2 items-center">
- <label for="groupName">Group Name</label>
- <input name="groupName" id="groupName" required bind:value={payload.groupName} />
+ <label for="appId">Application ID</label>
+ <input name="appId" id="appId" required bind:value={payload.appId} />
</div>
- {/if}
- <div class="grid grid-cols-2 items-center">
- <label for="appId">Application ID</label>
- <input name="appId" id="appId" required bind:value={payload.appId} />
- </div>
- <div class="grid grid-cols-2 items-center">
- <label for="appSecret">Secret</label>
- <input
- name="appSecret"
- id="appSecret"
- type="password"
- required
- bind:value={payload.appSecret}
- />
- </div>
- </form>
+ <div class="grid grid-cols-2 items-center">
+ <label for="appSecret">Secret</label>
+ <input
+ name="appSecret"
+ id="appSecret"
+ type="password"
+ required
+ bind:value={payload.appSecret}
+ />
+ </div>
+ </form>
+ </div>
{:else}
<div class="mx-auto max-w-4xl px-6">
<form on:submit|preventDefault={handleSubmitSave} class="py-4">
diff --git a/src/routes/sources/index.svelte b/src/routes/sources/index.svelte
index bd90395145..d805792726 100644
--- a/src/routes/sources/index.svelte
+++ b/src/routes/sources/index.svelte
@@ -60,6 +60,7 @@
class:border-l-4={source.gitlabApp && !source.gitlabAppId}
>
<div class="font-bold text-xl text-center truncate">{source.name}</div>
+ <div class="text-center truncate">Team {source.teams[0].name}</div>
{#if (source.type === 'gitlab' && !source.gitlabAppId) || (source.type === 'github' && !source.githubAppId && !source.githubApp?.installationId)}
<div class="font-bold text-center truncate text-red-500 group-hover:text-white">
Configuration missing