diff --git a/apps/api/src/lib/services/handlers.ts b/apps/api/src/lib/services/handlers.ts index 2c1b5419e..a52c71e89 100644 --- a/apps/api/src/lib/services/handlers.ts +++ b/apps/api/src/lib/services/handlers.ts @@ -698,7 +698,7 @@ export async function startService(request: FastifyRequest) { const { workdir } = await createDirectories({ repository: type, buildId: id }); const template: any = await parseAndFindServiceTemplates(service, workdir, true) const network = destinationDockerId && destinationDocker.network; - + const config = {}; for (const service in template.services) { config[service] = { diff --git a/apps/api/src/lib/templates.ts b/apps/api/src/lib/templates.ts index d175e6a0d..e2c995cd7 100644 --- a/apps/api/src/lib/templates.ts +++ b/apps/api/src/lib/templates.ts @@ -14,8 +14,9 @@ export default [ "image": "hasura/graphql-engine:$$core_version", "volumes": [], "environment": [ - "HASURA_GRAPHQL_METADATA_DATABASE_URL=$$secret_hasura_metadata_database_url", - "HASURA_GRAPHQL_ADMIN_PASSWORD=$$secret_hasura_admin_password", + "HASURA_GRAPHQL_ENABLE_CONSOLE=$$config_hasura_graphql_enable_console", + "HASURA_GRAPHQL_METADATA_DATABASE_URL=$$secret_hasura_graphql_metadata_database_url", + "HASURA_GRAPHQL_ADMIN_PASSWORD=$$secret_hasura_graphql_admin_password", ], "ports": [ "8080" @@ -38,18 +39,28 @@ export default [ }, "variables": [ { - "id": "$$secret_hasura_metadata_database_url", + "id": "$$config_hasura_graphql_enable_console", + "name": "HASURA_GRAPHQL_ENABLE_CONSOLE", + "label": "Enable Hasura Console", + "defaultValue": "true", + "description": "", + }, + { + "id": "$$secret_hasura_graphql_metadata_database_url", "name": "HASURA_GRAPHQL_METADATA_DATABASE_URL", "label": "Hasura Metadata Database URL", "defaultValue": "postgresql://$$config_postgres_user:$$secret_postgres_password@$$id-postgresql:5432/$$config_postgres_db", "description": "" }, { - "id": "$$secret_hasura_admin_password", + "id": "$$secret_hasura_graphql_admin_password", "name": "HASURA_GRAPHQL_ADMIN_PASSWORD", "label": "Hasura Admin Password", "defaultValue": "$$generate_password", - "description": "" + "description": "", + "extras": { + "isVisibleOnUI": true, + } }, { "id": "$$config_postgres_user", diff --git a/apps/api/src/routes/api/v1/services/handlers.ts b/apps/api/src/routes/api/v1/services/handlers.ts index f406ff5ce..2e774a9b7 100644 --- a/apps/api/src/routes/api/v1/services/handlers.ts +++ b/apps/api/src/routes/api/v1/services/handlers.ts @@ -468,10 +468,12 @@ export async function saveService(request: FastifyRequest, reply: F // data[type] = { update: update } // } for (const setting of serviceSetting) { - const { id: settingId, value, changed = false } = setting - if (setting.changed) { + const { id: settingId, name, value, changed = false, isNew = false } = setting + if (changed) { await prisma.serviceSetting.update({ where: { id: settingId }, data: { value } }) - + } + if (isNew) { + await prisma.serviceSetting.create({ data: { name, value, service: { connect: { id } } } }) } } await prisma.service.update({ diff --git a/apps/ui/src/routes/applications/[id]/__layout.svelte b/apps/ui/src/routes/applications/[id]/__layout.svelte index 40ad9677c..77849f39d 100644 --- a/apps/ui/src/routes/applications/[id]/__layout.svelte +++ b/apps/ui/src/routes/applications/[id]/__layout.svelte @@ -194,6 +194,8 @@ onDestroy(() => { $status.application.initialLoading = true; $status.application.loading = false; + $status.application.statuses = []; + $status.application.overallStatus = 'stopped'; $location = null; $isDeploymentEnabled = false; clearInterval(statusInterval); diff --git a/apps/ui/src/routes/services/[id]/__layout.svelte b/apps/ui/src/routes/services/[id]/__layout.svelte index 944f3f9c2..708b2ab6f 100644 --- a/apps/ui/src/routes/services/[id]/__layout.svelte +++ b/apps/ui/src/routes/services/[id]/__layout.svelte @@ -157,6 +157,7 @@ $status.service.initialLoading = true; $status.service.loading = false; $status.service.statuses = []; + $status.service.overallStatus = 'stopped'; $location = null; $isDeploymentEnabled = false; clearInterval(statusInterval); diff --git a/apps/ui/src/routes/services/[id]/index.svelte b/apps/ui/src/routes/services/[id]/index.svelte index 747deebf2..64d7ff97a 100644 --- a/apps/ui/src/routes/services/[id]/index.svelte +++ b/apps/ui/src/routes/services/[id]/index.svelte @@ -72,6 +72,9 @@ async function handleSubmit(e: any) { const formData = new FormData(e.target); + const settings = service.serviceSetting.map((setting: { name: string }) => setting.name); + const baseCoolifySetting = ['name', 'fqdn', 'exposePort']; + for (let field of formData) { const [key, value] = field; service.serviceSetting = service.serviceSetting.map((setting: any) => { @@ -81,6 +84,14 @@ } return setting; }); + if (!settings.includes(key) && !baseCoolifySetting.includes(key)) { + service.serviceSetting.push({ + id: service.id, + name: key, + value: value, + isNew: true + }); + } } if (loading.save) return; loading.save = true; @@ -94,7 +105,11 @@ // }); await post(`/services/${id}`, { ...service }); setLocation(service); + + const reloadServices = await get(`/services/${id}`); + service = reloadServices.service forceSave = false; + $isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service); return addToast({ message: 'Configuration saved.', @@ -416,18 +431,33 @@ value={getDomain(service.fqdn)} /> {:else if variable.defaultValue === 'true' || variable.defaultValue === 'false'} - + {#if variable.value === 'true' || variable.value === 'false'} + + {:else} + + {/if} {:else if variable.defaultValue === '$$generate_password' || variable.defaultValue === '$$generate_passphrase'}