add hasura

This commit is contained in:
Andras Bacsai
2022-10-19 14:15:48 +02:00
parent e1198c42eb
commit b4c6f80e1c
6 changed files with 67 additions and 21 deletions

View File

@@ -14,8 +14,9 @@ export default [
"image": "hasura/graphql-engine:$$core_version", "image": "hasura/graphql-engine:$$core_version",
"volumes": [], "volumes": [],
"environment": [ "environment": [
"HASURA_GRAPHQL_METADATA_DATABASE_URL=$$secret_hasura_metadata_database_url", "HASURA_GRAPHQL_ENABLE_CONSOLE=$$config_hasura_graphql_enable_console",
"HASURA_GRAPHQL_ADMIN_PASSWORD=$$secret_hasura_admin_password", "HASURA_GRAPHQL_METADATA_DATABASE_URL=$$secret_hasura_graphql_metadata_database_url",
"HASURA_GRAPHQL_ADMIN_PASSWORD=$$secret_hasura_graphql_admin_password",
], ],
"ports": [ "ports": [
"8080" "8080"
@@ -38,18 +39,28 @@ export default [
}, },
"variables": [ "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", "name": "HASURA_GRAPHQL_METADATA_DATABASE_URL",
"label": "Hasura Metadata Database URL", "label": "Hasura Metadata Database URL",
"defaultValue": "postgresql://$$config_postgres_user:$$secret_postgres_password@$$id-postgresql:5432/$$config_postgres_db", "defaultValue": "postgresql://$$config_postgres_user:$$secret_postgres_password@$$id-postgresql:5432/$$config_postgres_db",
"description": "" "description": ""
}, },
{ {
"id": "$$secret_hasura_admin_password", "id": "$$secret_hasura_graphql_admin_password",
"name": "HASURA_GRAPHQL_ADMIN_PASSWORD", "name": "HASURA_GRAPHQL_ADMIN_PASSWORD",
"label": "Hasura Admin Password", "label": "Hasura Admin Password",
"defaultValue": "$$generate_password", "defaultValue": "$$generate_password",
"description": "" "description": "",
"extras": {
"isVisibleOnUI": true,
}
}, },
{ {
"id": "$$config_postgres_user", "id": "$$config_postgres_user",

View File

@@ -468,10 +468,12 @@ export async function saveService(request: FastifyRequest<SaveService>, reply: F
// data[type] = { update: update } // data[type] = { update: update }
// } // }
for (const setting of serviceSetting) { for (const setting of serviceSetting) {
const { id: settingId, value, changed = false } = setting const { id: settingId, name, value, changed = false, isNew = false } = setting
if (setting.changed) { if (changed) {
await prisma.serviceSetting.update({ where: { id: settingId }, data: { value } }) 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({ await prisma.service.update({

View File

@@ -194,6 +194,8 @@
onDestroy(() => { onDestroy(() => {
$status.application.initialLoading = true; $status.application.initialLoading = true;
$status.application.loading = false; $status.application.loading = false;
$status.application.statuses = [];
$status.application.overallStatus = 'stopped';
$location = null; $location = null;
$isDeploymentEnabled = false; $isDeploymentEnabled = false;
clearInterval(statusInterval); clearInterval(statusInterval);

View File

@@ -157,6 +157,7 @@
$status.service.initialLoading = true; $status.service.initialLoading = true;
$status.service.loading = false; $status.service.loading = false;
$status.service.statuses = []; $status.service.statuses = [];
$status.service.overallStatus = 'stopped';
$location = null; $location = null;
$isDeploymentEnabled = false; $isDeploymentEnabled = false;
clearInterval(statusInterval); clearInterval(statusInterval);

View File

@@ -72,6 +72,9 @@
async function handleSubmit(e: any) { async function handleSubmit(e: any) {
const formData = new FormData(e.target); 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) { for (let field of formData) {
const [key, value] = field; const [key, value] = field;
service.serviceSetting = service.serviceSetting.map((setting: any) => { service.serviceSetting = service.serviceSetting.map((setting: any) => {
@@ -81,6 +84,14 @@
} }
return setting; 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; if (loading.save) return;
loading.save = true; loading.save = true;
@@ -94,7 +105,11 @@
// }); // });
await post(`/services/${id}`, { ...service }); await post(`/services/${id}`, { ...service });
setLocation(service); setLocation(service);
const reloadServices = await get(`/services/${id}`);
service = reloadServices.service
forceSave = false; forceSave = false;
$isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service); $isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service);
return addToast({ return addToast({
message: 'Configuration saved.', message: 'Configuration saved.',
@@ -416,6 +431,7 @@
value={getDomain(service.fqdn)} value={getDomain(service.fqdn)}
/> />
{:else if variable.defaultValue === 'true' || variable.defaultValue === 'false'} {:else if variable.defaultValue === 'true' || variable.defaultValue === 'false'}
{#if variable.value === 'true' || variable.value === 'false'}
<select <select
class="w-full font-normal" class="w-full font-normal"
readonly={isDisabled} readonly={isDisabled}
@@ -428,6 +444,20 @@
<option value="true">true</option> <option value="true">true</option>
<option value="false"> false</option> <option value="false"> false</option>
</select> </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'} {:else if variable.defaultValue === '$$generate_password' || variable.defaultValue === '$$generate_passphrase'}
<CopyPasswordField <CopyPasswordField
isPasswordField isPasswordField