This commit is contained in:
Andras Bacsai 2022-10-24 13:10:05 +02:00
parent 17badf95dc
commit c578fa63e5
3 changed files with 94 additions and 89 deletions

View File

@ -60,6 +60,7 @@ export async function getTemplates() {
"variables": [
{
"id": "$$config_weblate_site_domain",
"main":"$$id",
"name": "WEBLATE_SITE_DOMAIN",
"label": "Weblate Domain",
"defaultValue": "$$generate_domain",
@ -67,6 +68,7 @@ export async function getTemplates() {
},
{
"id": "$$secret_weblate_admin_password",
"main":"$$id",
"name": "WEBLATE_ADMIN_PASSWORD",
"label": "Weblate Admin Password",
"defaultValue": "$$generate_password",
@ -84,6 +86,7 @@ export async function getTemplates() {
},
{
"id": "$$config_postgres_user",
"main":"$$id-postgresql",
"name": "POSTGRES_USER",
"label": "PostgreSQL User",
"defaultValue": "$$generate_username",
@ -91,6 +94,7 @@ export async function getTemplates() {
},
{
"id": "$$secret_postgres_password",
"main":"$$id-postgresql",
"name": "POSTGRES_PASSWORD",
"label": "PostgreSQL Password",
"defaultValue": "$$generate_password(32)",
@ -112,6 +116,7 @@ export async function getTemplates() {
},
{
"id": "$$config_postgres_db",
"main":"$$id-postgresql",
"name": "POSTGRES_DB",
"label": "PostgreSQL Database",
"defaultValue": "weblate",
@ -700,7 +705,7 @@ export async function getTemplates() {
{
"id": "$$config__app_influxdb_host",
"name": "_APP_INFLUXDB_HOST",
"label": "",
"label": "InfluxDB | _APP_INFLUXDB_HOST",
"defaultValue": "$$id-influxdb",
"description": ""
},
@ -818,7 +823,7 @@ export async function getTemplates() {
},
{
"id": "$$config__app_redis_host",
"name": "_APP_REDIS_HOST",
"name": "Redis | _APP_REDIS_HOST",
"label": "",
"defaultValue": "$$id-redis",
"description": ""
@ -846,7 +851,7 @@ export async function getTemplates() {
},
{
"id": "$$config__app_db_host",
"name": "_APP_DB_HOST",
"name": "MariaDB | _APP_DB_HOST",
"label": "",
"defaultValue": "$$id-mariadb",
"description": ""

View File

@ -125,6 +125,7 @@ export async function parseAndFindServiceTemplates(service: any, workdir?: strin
name: value.name,
image: value.image,
environment: [],
fqdns: [],
proxy: {}
}
if (value.environment?.length > 0) {
@ -134,14 +135,14 @@ export async function parseAndFindServiceTemplates(service: any, workdir?: strin
const label = variable?.label
const description = variable?.description
const defaultValue = variable?.defaultValue
const main = variable?.main || '$$id'
const extras = variable?.extras
if (envValue.startsWith('$$config') || extras?.isVisibleOnUI) {
if (envValue.startsWith('$$config_coolify')) {
continue
console.log({ envValue, envKey })
}
parsedTemplate[realKey].environment.push(
{ name: envKey, value: envValue, label, description, defaultValue, extras }
{ name: envKey, value: envValue, main, label, description, defaultValue, extras }
)
}
}
@ -154,7 +155,7 @@ export async function parseAndFindServiceTemplates(service: any, workdir?: strin
if (variable) {
const { name, label, description, defaultValue, extras } = variable
const found = await prisma.serviceSetting.findFirst({ where: { variableName: proxyValue.domain } })
parsedTemplate[realKey].environment.push(
parsedTemplate[realKey].fqdns.push(
{ name, value: found.value || '', label, description, defaultValue, extras }
)
}
@ -163,6 +164,7 @@ export async function parseAndFindServiceTemplates(service: any, workdir?: strin
}
}
}
} else {
parsedTemplate = foundTemplate
}

View File

@ -9,7 +9,6 @@
<script lang="ts">
export let service: any;
export let readOnly: any;
export let template: any;
import cuid from 'cuid';
import { onMount } from 'svelte';
@ -19,7 +18,6 @@
import { get, post } from '$lib/api';
import { errorNotification, getDomain } from '$lib/common';
import { t } from '$lib/translations';
import Select from 'svelte-select';
import {
appSession,
status,
@ -54,9 +52,7 @@
let nonWWWDomain = service.fqdn && getDomain(service.fqdn).replace(/^www\./, '');
let isNonWWWDomainOK = false;
let isWWWDomainOK = false;
let secondaryFQDNs = service.serviceSetting.filter((setting) =>
setting.name.startsWith('COOLIFY_FQDN')
);
async function isDNSValid(domain: any, isWWW: any) {
try {
await get(`/services/${id}/check?domain=${domain}`);
@ -76,7 +72,6 @@
async function handleSubmit(e: any) {
if (loading.save) return;
loading.save = true;
try {
// await post(`/services/${id}/check`, {
// fqdn: service.fqdn,
@ -310,13 +305,14 @@
required
/>
</div>
{#each secondaryFQDNs as fqdn}
{JSON.stringify(fqdn)}
<div class="grid grid-cols-2 items-center">
<label class="h-10" for={fqdn.name}>{fqdn.label || fqdn.name}</label>
<input class="w-full" name={fqdn.name} id={fqdn.name} value={fqdn.value} />
{#each Object.keys(template) as oneService}
{#each template[oneService].fqdns as fqdn}
<div class="grid grid-cols-2 items-center py-1">
<label for={fqdn.name}>{fqdn.label || fqdn.name}</label>
<input class="w-full" name={fqdn.name} id={fqdn.name} bind:value={fqdn.value} />
</div>
{/each}
{/each}
</div>
{#if forceSave}
<div class="flex-col space-y-2 pt-4 text-center">
@ -401,6 +397,7 @@
<div class="grid grid-flow-row gap-2 px-4">
{#if template[oneService].environment.length > 0}
{#each template[oneService].environment as variable}
{#if variable.main === oneService}
<div class="grid grid-cols-2 items-center gap-2">
<label class="h-10" for={variable.name}>{variable.label || variable.name}</label>
{#if variable.defaultValue === '$$generate_fqdn'}
@ -478,6 +475,7 @@
/>
{/if}
</div>
{/if}
{/each}
{/if}
</div>