From 4acc59204c62085ce749228fa66d1d570196a4d5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Sep 2022 15:59:37 +0200 Subject: [PATCH] ui: dashboard updates and a lot more --- apps/api/src/routes/api/v1/base/index.ts | 1 + .../src/routes/api/v1/databases/handlers.ts | 19 +- apps/api/src/routes/api/v1/databases/index.ts | 5 +- apps/api/src/routes/api/v1/databases/types.ts | 49 +- apps/api/src/routes/api/v1/handlers.ts | 21 +- apps/api/src/types.ts | 47 - apps/ui/src/lib/store.ts | 3 +- apps/ui/src/routes/_NewResource.svelte | 150 ++ apps/ui/src/routes/__layout.svelte | 21 +- .../routes/applications/[id]/__layout.svelte | 2 +- apps/ui/src/routes/applications/_index.svelte | 142 ++ apps/ui/src/routes/applications/index.svelte | 140 +- .../src/routes/databases/[id]/__layout.svelte | 187 +-- apps/ui/src/routes/databases/_index.svelte | 124 ++ apps/ui/src/routes/databases/index.svelte | 120 +- .../routes/destinations/[id]/__layout.svelte | 2 +- apps/ui/src/routes/destinations/_index.svelte | 187 +++ apps/ui/src/routes/destinations/index.svelte | 187 +-- apps/ui/src/routes/index.svelte | 1224 +++++++++++++++-- apps/ui/src/routes/login.svelte | 13 +- apps/ui/src/routes/register.svelte | 7 +- .../src/routes/services/[id]/__layout.svelte | 2 +- apps/ui/src/routes/services/_index.svelte | 131 ++ apps/ui/src/routes/services/index.svelte | 127 +- .../src/routes/sources/[id]/__layout.svelte | 2 +- apps/ui/src/routes/sources/_index.svelte | 159 +++ apps/ui/src/routes/sources/index.svelte | 157 +-- apps/ui/src/tailwind.css | 2 +- 28 files changed, 2197 insertions(+), 1034 deletions(-) create mode 100644 apps/ui/src/routes/_NewResource.svelte create mode 100644 apps/ui/src/routes/applications/_index.svelte create mode 100644 apps/ui/src/routes/databases/_index.svelte create mode 100644 apps/ui/src/routes/destinations/_index.svelte create mode 100644 apps/ui/src/routes/services/_index.svelte create mode 100644 apps/ui/src/routes/sources/_index.svelte diff --git a/apps/api/src/routes/api/v1/base/index.ts b/apps/api/src/routes/api/v1/base/index.ts index 76735a032..f1b64baf3 100644 --- a/apps/api/src/routes/api/v1/base/index.ts +++ b/apps/api/src/routes/api/v1/base/index.ts @@ -11,6 +11,7 @@ const root: FastifyPluginAsync = async (fastify): Promise => { version, whiteLabeled: process.env.COOLIFY_WHITE_LABELED === 'true', whiteLabeledIcon: process.env.COOLIFY_WHITE_LABELED_ICON, + isRegistrationEnabled: settings.isRegistrationEnabled, } } catch ({ status, message }) { return errorHandler({ status, message }) diff --git a/apps/api/src/routes/api/v1/databases/handlers.ts b/apps/api/src/routes/api/v1/databases/handlers.ts index c76502be7..5e78dbfe9 100644 --- a/apps/api/src/routes/api/v1/databases/handlers.ts +++ b/apps/api/src/routes/api/v1/databases/handlers.ts @@ -61,16 +61,18 @@ export async function getDatabaseStatus(request: FastifyRequest) { where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } }, include: { destinationDocker: true, settings: true } }); - const { destinationDockerId, destinationDocker } = database; - if (destinationDockerId) { - try { - const { stdout } = await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker inspect --format '{{json .State}}' ${id}` }) + if (database) { + const { destinationDockerId, destinationDocker } = database; + if (destinationDockerId) { + try { + const { stdout } = await executeDockerCmd({ dockerId: destinationDocker.id, command: `docker inspect --format '{{json .State}}' ${id}` }) - if (JSON.parse(stdout).Running) { - isRunning = true; + if (JSON.parse(stdout).Running) { + isRunning = true; + } + } catch (error) { + // } - } catch (error) { - // } } return { @@ -363,6 +365,7 @@ export async function deleteDatabase(request: FastifyRequest) { } } await prisma.databaseSettings.deleteMany({ where: { databaseId: id } }); + await prisma.databaseSecret.deleteMany({ where: { databaseId: id } }); await prisma.database.delete({ where: { id } }); return {} } catch ({ status, message }) { diff --git a/apps/api/src/routes/api/v1/databases/index.ts b/apps/api/src/routes/api/v1/databases/index.ts index 5dcc20c68..8f269c8b5 100644 --- a/apps/api/src/routes/api/v1/databases/index.ts +++ b/apps/api/src/routes/api/v1/databases/index.ts @@ -1,8 +1,9 @@ import { FastifyPluginAsync } from 'fastify'; import { deleteDatabase, deleteDatabaseSecret, getDatabase, getDatabaseLogs, getDatabaseSecrets, getDatabaseStatus, getDatabaseTypes, getDatabaseUsage, getVersions, listDatabases, newDatabase, saveDatabase, saveDatabaseDestination, saveDatabaseSecret, saveDatabaseSettings, saveDatabaseType, saveVersion, startDatabase, stopDatabase } from './handlers'; -import type { DeleteDatabase, DeleteDatabaseSecret, GetDatabaseLogs, OnlyId, SaveDatabase, SaveDatabaseDestination, SaveDatabaseSecret, SaveDatabaseSettings, SaveVersion } from '../../../../types'; -import type { SaveDatabaseType } from './types'; +import type { OnlyId } from '../../../../types'; + +import type { DeleteDatabase, SaveDatabaseType, DeleteDatabaseSecret, GetDatabaseLogs, SaveDatabase, SaveDatabaseDestination, SaveDatabaseSecret, SaveDatabaseSettings, SaveVersion } from './types'; const root: FastifyPluginAsync = async (fastify): Promise => { fastify.addHook('onRequest', async (request) => { diff --git a/apps/api/src/routes/api/v1/databases/types.ts b/apps/api/src/routes/api/v1/databases/types.ts index a56a45c23..ba9b0b8e9 100644 --- a/apps/api/src/routes/api/v1/databases/types.ts +++ b/apps/api/src/routes/api/v1/databases/types.ts @@ -5,4 +5,51 @@ export interface SaveDatabaseType extends OnlyId { } export interface DeleteDatabase extends OnlyId { Body: { force: string } -} \ No newline at end of file +} +export interface SaveVersion extends OnlyId { + Body: { + version: string + } +} +export interface SaveDatabaseDestination extends OnlyId { + Body: { + destinationId: string + } +} +export interface GetDatabaseLogs extends OnlyId { + Querystring: { + since: number + } +} +export interface SaveDatabase extends OnlyId { + Body: { + name: string, + defaultDatabase: string, + dbUser: string, + dbUserPassword: string, + rootUser: string, + rootUserPassword: string, + version: string, + isRunning: boolean + } +} +export interface SaveDatabaseSettings extends OnlyId { + Body: { + isPublic: boolean, + appendOnly: boolean + } +} + +export interface SaveDatabaseSecret extends OnlyId { + Body: { + name: string, + value: string, + isNew: string, + } +} +export interface DeleteDatabaseSecret extends OnlyId { + Body: { + name: string, + } +} + diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index 702ad31a8..09dfbea48 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -52,9 +52,7 @@ export async function update(request: FastifyRequest) { const { latestVersion } = request.body; try { if (!isDev) { - const { isAutoUpdateEnabled } = (await prisma.setting.findFirst()) || { - isAutoUpdateEnabled: false - }; + const { isAutoUpdateEnabled } = await prisma.setting.findFirst(); await asyncExecShell(`docker pull coollabsio/coolify:${latestVersion}`); await asyncExecShell(`env | grep COOLIFY > .env`); await asyncExecShell( @@ -113,20 +111,31 @@ export async function showDashboard(request: FastifyRequest) { const teamId = request.user.teamId; const applications = await prisma.application.findMany({ where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }, - include: { settings: true } + include: { settings: true, destinationDocker: true, teams: true } }); const databases = await prisma.database.findMany({ where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }, - include: { settings: true } + include: { settings: true, destinationDocker: true, teams: true } }); const services = await prisma.service.findMany({ - where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } } + where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }, + include: { destinationDocker: true, teams: true } + }); + const gitSources = await prisma.gitSource.findMany({ + where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }, + include: { teams: true } + }); + const destinations = await prisma.destinationDocker.findMany({ + where: { teams: { some: { id: teamId === '0' ? undefined : teamId } } }, + include: { teams: true } }); const settings = await listSettings(); return { applications, databases, services, + gitSources, + destinations, settings, }; } catch ({ status, message }) { diff --git a/apps/api/src/types.ts b/apps/api/src/types.ts index 3767ab4dd..acb44c8e0 100644 --- a/apps/api/src/types.ts +++ b/apps/api/src/types.ts @@ -1,51 +1,4 @@ export interface OnlyId { Params: { id: string }, } -export interface SaveVersion extends OnlyId { - Body: { - version: string - } -} -export interface SaveDatabaseDestination extends OnlyId { - Body: { - destinationId: string - } -} -export interface GetDatabaseLogs extends OnlyId { - Querystring: { - since: number - } -} -export interface SaveDatabase extends OnlyId { - Body: { - name: string, - defaultDatabase: string, - dbUser: string, - dbUserPassword: string, - rootUser: string, - rootUserPassword: string, - version: string, - isRunning: boolean - } -} -export interface SaveDatabaseSettings extends OnlyId { - Body: { - isPublic: boolean, - appendOnly: boolean - } -} - -export interface SaveDatabaseSecret extends OnlyId { - Body: { - name: string, - value: string, - isNew: string, - } -} -export interface DeleteDatabaseSecret extends OnlyId { - Body: { - name: string, - } -} - diff --git a/apps/ui/src/lib/store.ts b/apps/ui/src/lib/store.ts index 4114026d5..5355d22c8 100644 --- a/apps/ui/src/lib/store.ts +++ b/apps/ui/src/lib/store.ts @@ -3,7 +3,7 @@ import cuid from 'cuid'; import { writable, readable, type Writable } from 'svelte/store'; interface AppSession { - registrationEnabled: boolean; + isRegistrationEnabled: boolean; ipv4: string | null, ipv6: string | null, version: string | null, @@ -28,6 +28,7 @@ interface AddToast { } export const loginEmail: Writable = writable() export const appSession: Writable = writable({ + isRegistrationEnabled: false, ipv4: null, ipv6: null, version: null, diff --git a/apps/ui/src/routes/_NewResource.svelte b/apps/ui/src/routes/_NewResource.svelte new file mode 100644 index 000000000..ccc15e8d9 --- /dev/null +++ b/apps/ui/src/routes/_NewResource.svelte @@ -0,0 +1,150 @@ + + + diff --git a/apps/ui/src/routes/__layout.svelte b/apps/ui/src/routes/__layout.svelte index 901aedea5..38fb61673 100644 --- a/apps/ui/src/routes/__layout.svelte +++ b/apps/ui/src/routes/__layout.svelte @@ -66,7 +66,7 @@ + + + +
+
{$t('index.applications')}
+ {#if $appSession.isAdmin} + + {/if} +
+ diff --git a/apps/ui/src/routes/applications/index.svelte b/apps/ui/src/routes/applications/index.svelte index 60644e16d..8136f76e8 100644 --- a/apps/ui/src/routes/applications/index.svelte +++ b/apps/ui/src/routes/applications/index.svelte @@ -1,142 +1,4 @@ - - - -
-
{$t('index.applications')}
- {#if $appSession.isAdmin} - - {/if} -
- diff --git a/apps/ui/src/routes/databases/[id]/__layout.svelte b/apps/ui/src/routes/databases/[id]/__layout.svelte index 9b690a7ba..94e1e6114 100644 --- a/apps/ui/src/routes/databases/[id]/__layout.svelte +++ b/apps/ui/src/routes/databases/[id]/__layout.svelte @@ -75,7 +75,7 @@ $status.database.initialLoading = true; try { await del(`/databases/${database.id}`, { id: database.id, force }); - return await goto('/databases'); + return await goto('/', { replaceState: true }); } catch (error) { return errorNotification(error); } finally { @@ -246,99 +246,100 @@ {'Start'} {/if} +
+ + + {'Configuration'} + + + Secrets +
+ + + {'Logs'} {/if} -
- - - {'Configuration'} - - - Secrets -
- - - {'Logs'} + {#if forceDelete} + {/if} +
+ +
+ {#if !databases || ownDatabases.length === 0} +
+
{$t('database.no_databases_found')}
+
+ {/if} + {#if ownDatabases.length > 0 || otherDatabases.length > 0} + + {/if} +
diff --git a/apps/ui/src/routes/databases/index.svelte b/apps/ui/src/routes/databases/index.svelte index cdb45d0c4..8136f76e8 100644 --- a/apps/ui/src/routes/databases/index.svelte +++ b/apps/ui/src/routes/databases/index.svelte @@ -1,122 +1,4 @@ - - - -
-
{$t('index.databases')}
- -
- -
- {#if !databases || ownDatabases.length === 0} -
-
{$t('database.no_databases_found')}
-
- {/if} - {#if ownDatabases.length > 0 || otherDatabases.length > 0} - - {/if} -
diff --git a/apps/ui/src/routes/destinations/[id]/__layout.svelte b/apps/ui/src/routes/destinations/[id]/__layout.svelte index 4be92c02f..1b82265e2 100644 --- a/apps/ui/src/routes/destinations/[id]/__layout.svelte +++ b/apps/ui/src/routes/destinations/[id]/__layout.svelte @@ -69,7 +69,7 @@ if (sure) { try { await del(`/destinations/${destination.id}`, { id: destination.id }); - return await goto('/destinations'); + return await goto('/', { replaceState: true }); } catch (error) { return errorNotification(error); } diff --git a/apps/ui/src/routes/destinations/_index.svelte b/apps/ui/src/routes/destinations/_index.svelte new file mode 100644 index 000000000..27656cdb7 --- /dev/null +++ b/apps/ui/src/routes/destinations/_index.svelte @@ -0,0 +1,187 @@ + + + + +
+
{$t('index.destinations')}
+ {#if $appSession.isAdmin} + + + + {/if} +
+ diff --git a/apps/ui/src/routes/destinations/index.svelte b/apps/ui/src/routes/destinations/index.svelte index 27656cdb7..8136f76e8 100644 --- a/apps/ui/src/routes/destinations/index.svelte +++ b/apps/ui/src/routes/destinations/index.svelte @@ -1,187 +1,4 @@ - - - -
-
{$t('index.destinations')}
- {#if $appSession.isAdmin} - - - - {/if} -
- diff --git a/apps/ui/src/routes/index.svelte b/apps/ui/src/routes/index.svelte index f01ffd33e..d9c646a83 100644 --- a/apps/ui/src/routes/index.svelte +++ b/apps/ui/src/routes/index.svelte @@ -24,31 +24,62 @@ export let databases: any; export let services: any; export let settings: any; + export let gitSources: any; + export let destinations: any; + let filtered = { + applications: applications.filter( + (application: any) => application.teams[0].id === $appSession.teamId + ), + otherApplications: applications.filter( + (application: any) => application.teams[0].id !== $appSession.teamId + ), + databases: databases.filter((database: any) => database.teams[0].id === $appSession.teamId), + otherDatabases: databases.filter( + (database: any) => database.teams[0].id !== $appSession.teamId + ), + services: services.filter((service: any) => service.teams[0].id === $appSession.teamId), + otherServices: services.filter((service: any) => service.teams[0].id !== $appSession.teamId), + settings, + gitSources: gitSources.filter((gitSource: any) => gitSource.teams[0].id === $appSession.teamId), + otherGitSources: gitSources.filter( + (gitSource: any) => gitSource.teams[0].id !== $appSession.teamId + ), + destinations: destinations.filter( + (destination: any) => destination.teams[0].id === $appSession.teamId + ), + otherDestinations: destinations.filter( + (destination: any) => destination.teams[0].id !== $appSession.teamId + ) + }; import { get, post } from '$lib/api'; import Usage from '$lib/components/Usage.svelte'; import { t } from '$lib/translations'; - import { errorNotification, asyncSleep } from '$lib/common'; - import { addToast, appSession } from '$lib/store'; + import { asyncSleep } from '$lib/common'; + import { appSession } from '$lib/store'; import ApplicationsIcons from '$lib/components/svg/applications/ApplicationIcons.svelte'; import DatabaseIcons from '$lib/components/svg/databases/DatabaseIcons.svelte'; import ServiceIcons from '$lib/components/svg/services/ServiceIcons.svelte'; import { dev } from '$app/env'; + import NewResource from './_NewResource.svelte'; let numberOfGetStatus = 0; + let search = ''; + let status: any = {}; function getRndInteger(min: number, max: number) { return Math.floor(Math.random() * (max - min + 1)) + min; } async function getStatus(resources: any) { + const { id, buildPack, dualCerts } = resources; + if (status[id]) return status[id]; while (numberOfGetStatus > 1) { await asyncSleep(getRndInteger(100, 200)); } try { numberOfGetStatus++; - const { id, buildPack, dualCerts } = resources; let isRunning = false; if (buildPack) { const response = await get(`/applications/${id}/status`); @@ -61,57 +92,511 @@ isRunning = response.isRunning; } if (isRunning) { + status[id] = 'Running'; return 'Running'; } else { + status[id] = 'Stopped'; return 'Stopped'; } } catch (error) { + status[id] = 'Error'; return 'Error'; } finally { numberOfGetStatus--; } } + + function doSearch(bang?: string) { + if (bang || bang === '') search = bang; + if (search) { + if (search.startsWith('!')) { + if (search === '!running') { + filtered.applications = applications.filter((application: any) => { + if ( + status[application.id] === 'Running' && + application.teams[0].id === $appSession.teamId + ) + return application; + }); + filtered.otherApplications = applications.filter((application: any) => { + if ( + status[application.id] === 'Running' && + application.teams[0].id !== $appSession.teamId + ) + return application; + }); + filtered.databases = databases.filter((database: any) => { + if (status[database.id] === 'Running' && database.teams[0].id === $appSession.teamId) + return database; + }); + filtered.otherDatabases = databases.filter((database: any) => { + if (status[database.id] === 'Running' && database.teams[0].id !== $appSession.teamId) + return database; + }); + filtered.services = services.filter((service: any) => { + if (status[service.id] === 'Running' && service.teams[0].id === $appSession.teamId) + return service; + }); + filtered.otherServices = services.filter((service: any) => { + if (status[service.id] === 'Running' && service.teams[0].id !== $appSession.teamId) + return service; + }); + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!stopped') { + filtered.applications = applications.filter((application: any) => { + if ( + status[application.id] === 'Stopped' && + application.teams[0].id === $appSession.teamId + ) + return application; + }); + filtered.otherApplications = applications.filter((application: any) => { + if ( + status[application.id] === 'Stopped' && + application.teams[0].id !== $appSession.teamId + ) + return application; + }); + filtered.databases = databases.filter((database: any) => { + if (status[database.id] === 'Stopped' && database.teams[0].id === $appSession.teamId) + return database; + }); + filtered.otherDatabases = databases.filter((database: any) => { + if (status[database.id] === 'Stopped' && database.teams[0].id !== $appSession.teamId) + return database; + }); + filtered.services = services.filter((service: any) => { + if (status[service.id] === 'Stopped' && service.teams[0].id === $appSession.teamId) + return service; + }); + filtered.otherServices = services.filter((service: any) => { + if (status[service.id] === 'Stopped' && service.teams[0].id !== $appSession.teamId) + return service; + }); + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!error') { + filtered.applications = applications.filter((application: any) => { + if ( + status[application.id] === 'Error' && + application.teams[0].id === $appSession.teamId + ) + return application; + }); + filtered.otherApplications = applications.filter((application: any) => { + if ( + status[application.id] === 'Error' && + application.teams[0].id !== $appSession.teamId + ) + return application; + }); + filtered.databases = databases.filter((database: any) => { + if (status[database.id] === 'Error' && database.teams[0].id === $appSession.teamId) + return database; + }); + filtered.otherDatabases = databases.filter((database: any) => { + if (status[database.id] === 'Error' && database.teams[0].id !== $appSession.teamId) + return database; + }); + filtered.services = services.filter((service: any) => { + if (status[service.id] === 'Error' && service.teams[0].id === $appSession.teamId) + return service; + }); + filtered.otherServices = services.filter((service: any) => { + if (status[service.id] === 'Error' && service.teams[0].id !== $appSession.teamId) + return service; + }); + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!app') { + filtered.applications = applications.filter( + (application: any) => application.teams[0].id === $appSession.teamId + ); + filtered.databases = []; + filtered.otherDatabases = []; + filtered.services = []; + filtered.otherServices = []; + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!db') { + filtered.applications = []; + filtered.otherApplications = []; + filtered.databases = databases.filter( + (database: any) => database.teams[0].id === $appSession.teamId + ); + filtered.services = []; + filtered.otherServices = []; + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!service') { + filtered.applications = []; + filtered.otherApplications = []; + filtered.databases = []; + filtered.otherDatabases = []; + filtered.services = services.filter( + (service: any) => service.teams[0].id === $appSession.teamId + ); + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!git') { + filtered.applications = []; + filtered.otherApplications = []; + filtered.databases = []; + filtered.otherDatabases = []; + filtered.services = []; + filtered.otherServices = []; + filtered.gitSources = gitSources.filter( + (source: any) => source.teams[0].id === $appSession.teamId + ); + filtered.destinations = []; + filtered.otherDestinations = []; + } else if (search === '!destination') { + filtered.applications = []; + filtered.otherApplications = []; + filtered.databases = []; + filtered.otherDatabases = []; + filtered.services = []; + filtered.otherServices = []; + filtered.gitSources = []; + filtered.otherGitSources = []; + filtered.destinations = destinations.filter( + (destination: any) => destination.teams[0].id === $appSession.teamId + ); + } else if (search === '!bot') { + filtered.applications = applications.filter((application: any) => { + return application.settings.isBot; + }); + filtered.otherApplications = applications.filter((application: any) => { + return application.settings.isBot && application.teams[0].id !== $appSession.teamId; + }); + filtered.databases = []; + filtered.otherDatabases = []; + filtered.services = []; + filtered.otherServices = []; + filtered.gitSources = []; + filtered.otherGitSources = []; + } else if (search === '!notmine') { + filtered.applications = []; + filtered.databases = []; + filtered.services = []; + filtered.gitSources = []; + filtered.destinations = []; + } + } else { + filtered.applications = applications.filter((application: any) => { + return ( + (application.name && application.name.toLowerCase().includes(search.toLowerCase())) || + (application.fqdn && application.fqdn.toLowerCase().includes(search.toLowerCase())) || + (application.repository && + application.repository.toLowerCase().includes(search.toLowerCase())) || + (application.buildpack && + application.buildpack.toLowerCase().includes(search.toLowerCase())) || + (application.branch && + application.branch.toLowerCase().includes(search.toLowerCase())) || + (application.destinationDockerId && + application.destinationDocker.name.toLowerCase().includes(search.toLowerCase())) || + ('bot'.includes(search) && application.settings.isBot) + ); + }); + filtered.databases = databases.filter((database: any) => { + return ( + (database.name && database.name.toLowerCase().includes(search.toLowerCase())) || + (database.type && database.type.toLowerCase().includes(search.toLowerCase())) || + (database.version && database.version.toLowerCase().includes(search.toLowerCase())) || + (database.destinationDockerId && + database.destinationDocker.name.toLowerCase().includes(search.toLowerCase())) + ); + }); + filtered.services = services.filter((service: any) => { + return ( + (service.name && service.name.toLowerCase().includes(search.toLowerCase())) || + (service.type && service.type.toLowerCase().includes(search.toLowerCase())) || + (service.version && service.version.toLowerCase().includes(search.toLowerCase())) || + (service.destinationDockerId && + service.destinationDocker.name.toLowerCase().includes(search.toLowerCase())) + ); + }); + filtered.gitSources = gitSources.filter((source: any) => { + return ( + (source.name && source.name.toLowerCase().includes(search.toLowerCase())) || + (source.type && source.type.toLowerCase().includes(search.toLowerCase())) || + (source.htmlUrl && source.htmlUrl.toLowerCase().includes(search.toLowerCase())) || + (source.apiUrl && source.apiUrl.toLowerCase().includes(search.toLowerCase())) + ); + }); + filtered.destinations = destinations.filter((destination: any) => { + return ( + (destination.name && destination.name.toLowerCase().includes(search.toLowerCase())) || + (destination.type && destination.type.toLowerCase().includes(search.toLowerCase())) + ); + }); + } + } else { + filtered.applications = applications; + filtered.databases = databases; + filtered.services = services; + filtered.gitSources = gitSources; + filtered.destinations = destinations; + } + }
{$t('index.dashboard')}
+ {#if $appSession.isAdmin && (applications.length !== 0 || destinations.length !== 0 || databases.length !== 0 || services.length !== 0 || gitSources.length !== 0 || destinations.length !== 0)} + + {/if}
- {#if $appSession.teamId === '0'} + + {#if applications.length !== 0 || destinations.length !== 0 || databases.length !== 0 || services.length !== 0 || gitSources.length !== 0 || destinations.length !== 0} +
+
+
+ +
+ + doSearch()} + /> +
+ +
{/if} -

Applications

-
-
- {#if applications.length > 0} - {#each applications as application} + {#if (filtered.applications.length > 0 && applications.length > 0) || filtered.otherApplications.length > 0} +
+

Applications

+
+ {/if} + {#if filtered.applications.length > 0 && applications.length > 0} +
+ + + {/if} + {#if filtered.otherApplications.length > 0} + {#if filtered.applications.length > 0} +
+ {/if} +
+

Other Teams

+
+ {/if} +
+ {#if filtered.otherApplications.length > 0} + {#each filtered.otherApplications as application}
{#await getStatus(application)} - + {:then status} {#if status === 'Running'} - + {:else} - + {/if} {/await}
-

+

{application.name} {#if application.settings.isBot} - BOT + BOT {/if}

-
+
{#if application?.fqdn}

{application?.fqdn.replace('https://', '').replace('http://', '')}

{:else if !application.settings.isBot && !application?.fqdn}

Not configured

{/if} + {#if application.destinationDocker?.name} +
{application.destinationDocker.name}
+ {/if}
+
{#if application.fqdn} @@ -132,6 +617,7 @@ {/if} + {#if application.settings.isBot && application.exposePort} {/each} - {:else} -

Nothing is configured yet.

{/if}
-

Services

-
- - -

Databases

-
-
- {#if databases.length > 0} - {#each databases as database} - -
- {#await getStatus(database)} - - {:then status} - {#if status === 'Running'} - - {:else} - - {/if} - {/await} -
- -
-
-

{database.name}

-
- {#if database?.version} -

{database?.version}

+ {#if (filtered.services.length > 0 && services.length > 0) || filtered.services.length > 0} +
+

Services

+
+ {/if} + {#if filtered.services.length > 0 && services.length > 0} +
+ + {/if} + {#if (filtered.databases.length > 0 && databases.length > 0) || filtered.databases.length > 0} +
+

Databases

+
+ {/if} + {#if filtered.databases.length > 0 && databases.length > 0} +
+ + {#if filtered.otherDatabases.length > 0} + {#if databases.length > 0} +
+ {/if} +
+

Other Teams

+
+ {/if} + {#if filtered.otherDatabases.length > 0} + + {/if} + {/if} + {#if (filtered.gitSources.length > 0 && gitSources.length > 0) || filtered.gitSources.length > 0} +
+

Git Sources

+
+ {/if} + {#if filtered.gitSources.length > 0 && gitSources.length > 0} +
+
+ {#if filtered.gitSources.length > 0} + {#each filtered.gitSources as source} + + + {#if filtered.otherGitSources.length > 0} + {#if gitSources.length > 0} +
+ {/if} +
+

Other Teams

+
+ {/if} + {#if filtered.otherGitSources.length > 0} +
+ {#each filtered.otherGitSources as source} + + + {/if} + {/if} + {#if (filtered.destinations.length > 0 && destinations.length > 0) || filtered.destinations.length > 0} +
+

Destinations

+
+ {/if} + {#if filtered.destinations.length > 0 && destinations.length > 0} +
+ + {#if filtered.otherDestinations.length > 0} + {#if destinations.length > 0} +
+ {/if} +
+

Other Teams

+
+ {/if} + {#if filtered.otherDestinations.length > 0} + + {/if} + {/if} + + {#if filtered.applications.length === 0 && filtered.destinations.length === 0 && filtered.databases.length === 0 && filtered.services.length === 0 && filtered.gitSources.length === 0 && filtered.destinations.length === 0 && search} +
+

+ Nothing found with {search}. +

+
+ {/if} + {#if applications.length === 0 && destinations.length === 0 && databases.length === 0 && services.length === 0 && gitSources.length === 0 && destinations.length === 0} +
+
+
+

+ Hey +

+

It looks like you did not configure anything yet.

+ +
+
+
+ {/if}
+
diff --git a/apps/ui/src/routes/login.svelte b/apps/ui/src/routes/login.svelte index 9b68b6d11..0fe0e6193 100644 --- a/apps/ui/src/routes/login.svelte +++ b/apps/ui/src/routes/login.svelte @@ -110,10 +110,15 @@ class:bg-coollabs={!loading} >{loading ? $t('login.authenticating') : $t('login.login')} - - + {#if $appSession.isRegistrationEnabled} + + {:else} +
+ Registration is disabled. Please ask an admin to activate it. +
+ {/if}
{#if browser && window.location.host === 'demo.coolify.io'} diff --git a/apps/ui/src/routes/register.svelte b/apps/ui/src/routes/register.svelte index 2c920311a..a6ad5c8bf 100644 --- a/apps/ui/src/routes/register.svelte +++ b/apps/ui/src/routes/register.svelte @@ -1,6 +1,6 @@ + + + +
+
{$t('index.services')}
+ {#if $appSession.isAdmin} + + {/if} +
+ + diff --git a/apps/ui/src/routes/services/index.svelte b/apps/ui/src/routes/services/index.svelte index fe3bed644..8136f76e8 100644 --- a/apps/ui/src/routes/services/index.svelte +++ b/apps/ui/src/routes/services/index.svelte @@ -1,129 +1,4 @@ - - - -
-
{$t('index.services')}
- -
- - diff --git a/apps/ui/src/routes/sources/[id]/__layout.svelte b/apps/ui/src/routes/sources/[id]/__layout.svelte index cafe8ae92..0cd0c27b4 100644 --- a/apps/ui/src/routes/sources/[id]/__layout.svelte +++ b/apps/ui/src/routes/sources/[id]/__layout.svelte @@ -45,7 +45,7 @@ if (sure) { try { await del(`/sources/${id}`, {}); - await goto('/sources', { replaceState: true }); + await goto('/', { replaceState: true }); } catch (error) { errorNotification(error); } diff --git a/apps/ui/src/routes/sources/_index.svelte b/apps/ui/src/routes/sources/_index.svelte new file mode 100644 index 000000000..a5a5f98ff --- /dev/null +++ b/apps/ui/src/routes/sources/_index.svelte @@ -0,0 +1,159 @@ + + + + +
+
{$t('index.git_sources')}
+ {#if $appSession.isAdmin} + + + + {/if} +
+ diff --git a/apps/ui/src/routes/sources/index.svelte b/apps/ui/src/routes/sources/index.svelte index a5a5f98ff..8136f76e8 100644 --- a/apps/ui/src/routes/sources/index.svelte +++ b/apps/ui/src/routes/sources/index.svelte @@ -1,159 +1,4 @@ - - - -
-
{$t('index.git_sources')}
- {#if $appSession.isAdmin} - - - - {/if} -
- diff --git a/apps/ui/src/tailwind.css b/apps/ui/src/tailwind.css index f4233cf8d..71323105a 100644 --- a/apps/ui/src/tailwind.css +++ b/apps/ui/src/tailwind.css @@ -24,7 +24,7 @@ body { @apply min-h-screen overflow-x-hidden bg-coolblack text-sm text-white scrollbar-w-1 scrollbar-thumb-coollabs scrollbar-track-coolgray-200; } -input { +input, .input { @apply h-12 w-96 rounded border border-transparent bg-transparent bg-coolgray-200 p-2 text-xs tracking-tight text-white placeholder-stone-600 outline-none transition duration-150 hover:bg-coolgray-500 focus:bg-coolgray-500 disabled:border disabled:border-dashed disabled:border-coolgray-300 disabled:bg-transparent md:text-sm; } textarea {