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,12 +305,13 @@
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} />
</div>
{#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}
@ -401,83 +397,85 @@
<div class="grid grid-flow-row gap-2 px-4">
{#if template[oneService].environment.length > 0}
{#each template[oneService].environment as variable}
<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'}
<input
class="w-full"
disabled
readonly
name={variable.name}
id={variable.name}
value={service.fqdn}
/>
{:else if variable.defaultValue === '$$generate_domain'}
<input
class="w-full"
disabled
readonly
name={variable.name}
id={variable.name}
value={getDomain(service.fqdn)}
/>
{:else if variable.defaultValue === '$$generate_network'}
<input
class="w-full"
disabled
readonly
name={variable.name}
id={variable.name}
value={service.destinationDocker.network}
/>
{:else if variable.defaultValue === 'true' || variable.defaultValue === 'false'}
{#if variable.value === 'true' || variable.value === 'false'}
<select
class="w-full font-normal"
readonly={isDisabled}
disabled={isDisabled}
id={variable.name}
{#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'}
<input
class="w-full"
disabled
readonly
name={variable.name}
bind:value={variable.value}
form="saveForm"
>
<option value="true">true</option>
<option value="false"> false</option>
</select>
id={variable.name}
value={service.fqdn}
/>
{:else if variable.defaultValue === '$$generate_domain'}
<input
class="w-full"
disabled
readonly
name={variable.name}
id={variable.name}
value={getDomain(service.fqdn)}
/>
{:else if variable.defaultValue === '$$generate_network'}
<input
class="w-full"
disabled
readonly
name={variable.name}
id={variable.name}
value={service.destinationDocker.network}
/>
{:else if variable.defaultValue === 'true' || variable.defaultValue === 'false'}
{#if variable.value === 'true' || variable.value === 'false'}
<select
class="w-full font-normal"
readonly={isDisabled}
disabled={isDisabled}
id={variable.name}
name={variable.name}
bind:value={variable.value}
form="saveForm"
>
<option value="true">true</option>
<option value="false"> false</option>
</select>
{:else}
<select
class="w-full font-normal"
readonly={isDisabled}
disabled={isDisabled}
id={variable.name}
name={variable.name}
bind:value={variable.defaultValue}
form="saveForm"
>
<option value="true">true</option>
<option value="false"> false</option>
</select>
{/if}
{:else if variable.defaultValue === '$$generate_password' || variable.defaultValue === '$$generate_passphrase'}
<CopyPasswordField
isPasswordField
readonly
disabled
name={variable.name}
id={variable.name}
value={variable.value}
/>
{:else}
<select
class="w-full font-normal"
<CopyPasswordField
required={variable?.extras?.required}
readonly={isDisabled}
disabled={isDisabled}
id={variable.name}
name={variable.name}
bind:value={variable.defaultValue}
form="saveForm"
>
<option value="true">true</option>
<option value="false"> false</option>
</select>
id={variable.name}
value={variable.value}
/>
{/if}
{:else if variable.defaultValue === '$$generate_password' || variable.defaultValue === '$$generate_passphrase'}
<CopyPasswordField
isPasswordField
readonly
disabled
name={variable.name}
id={variable.name}
value={variable.value}
/>
{:else}
<CopyPasswordField
required={variable?.extras?.required}
readonly={isDisabled}
disabled={isDisabled}
name={variable.name}
id={variable.name}
value={variable.value}
/>
{/if}
</div>
</div>
{/if}
{/each}
{/if}
</div>