fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import cuid from "cuid";
|
import cuid from "cuid";
|
||||||
import { decrypt, encrypt, generatePassword, getDomain, prisma } from "./lib/common";
|
import { decrypt, encrypt, fixType, generatePassword, getDomain, prisma } from "./lib/common";
|
||||||
import { getTemplates } from "./lib/services";
|
import { getTemplates } from "./lib/services";
|
||||||
import { includeServices } from "./lib/services/common";
|
import { includeServices } from "./lib/services/common";
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ export async function migrateServicesToNewTemplate() {
|
|||||||
if (!service.type) {
|
if (!service.type) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let template = templates.find(t => t.name.toLowerCase() === service.type.toLowerCase());
|
let template = templates.find(t => fixType(t.name) === fixType(service.type));
|
||||||
if (template) {
|
if (template) {
|
||||||
template = JSON.parse(JSON.stringify(template).replaceAll('$$id', service.id))
|
template = JSON.parse(JSON.stringify(template).replaceAll('$$id', service.id))
|
||||||
if (service.type === 'plausibleanalytics' && service.plausibleAnalytics) await plausibleAnalytics(service, template)
|
if (service.type === 'plausibleanalytics' && service.plausibleAnalytics) await plausibleAnalytics(service, template)
|
||||||
|
@@ -1457,8 +1457,8 @@ export async function getServiceFromDB({
|
|||||||
if (!body) {
|
if (!body) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
let { type } = body;
|
body.type = fixType(body.type);
|
||||||
type = fixType(type);
|
|
||||||
if (body?.serviceSecret.length > 0) {
|
if (body?.serviceSecret.length > 0) {
|
||||||
body.serviceSecret = body.serviceSecret.map((s) => {
|
body.serviceSecret = body.serviceSecret.map((s) => {
|
||||||
s.value = decrypt(s.value);
|
s.value = decrypt(s.value);
|
||||||
@@ -1466,7 +1466,6 @@ export async function getServiceFromDB({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// body[type] = { ...body[type], ...getUpdateableFields(type, body[type]) };
|
|
||||||
return { ...body, settings };
|
return { ...body, settings };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1532,10 +1531,7 @@ export function getUpdateableFields(type: string, data: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function fixType(type) {
|
export function fixType(type) {
|
||||||
// Hack to fix the type case sensitivity...
|
return type?.replaceAll(' ', '').toLowerCase() || null;
|
||||||
if (type === 'plausibleanalytics') type = 'plausibleAnalytics';
|
|
||||||
if (type === 'meilisearch') type = 'meiliSearch';
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServiceMainPort = (service: string) => {
|
export const getServiceMainPort = (service: string) => {
|
||||||
|
@@ -115,7 +115,7 @@ export async function getServiceStatus(request: FastifyRequest<OnlyId>) {
|
|||||||
}
|
}
|
||||||
export async function parseAndFindServiceTemplates(service: any, workdir?: string, isDeploy: boolean = false) {
|
export async function parseAndFindServiceTemplates(service: any, workdir?: string, isDeploy: boolean = false) {
|
||||||
const templates = await getTemplates()
|
const templates = await getTemplates()
|
||||||
const foundTemplate = templates.find(t => t.name.toLowerCase() === service.type.toLowerCase())
|
const foundTemplate = templates.find(t => fixType(t.name) === service.type)
|
||||||
let parsedTemplate = {}
|
let parsedTemplate = {}
|
||||||
if (foundTemplate) {
|
if (foundTemplate) {
|
||||||
if (!isDeploy) {
|
if (!isDeploy) {
|
||||||
@@ -249,7 +249,7 @@ export async function saveServiceType(request: FastifyRequest<SaveServiceType>,
|
|||||||
const { id } = request.params;
|
const { id } = request.params;
|
||||||
const { type } = request.body;
|
const { type } = request.body;
|
||||||
const templates = await getTemplates()
|
const templates = await getTemplates()
|
||||||
let foundTemplate = templates.find(t => t.name === type)
|
let foundTemplate = templates.find(t => fixType(t.name) === fixType(type))
|
||||||
if (foundTemplate) {
|
if (foundTemplate) {
|
||||||
foundTemplate = JSON.parse(JSON.stringify(foundTemplate).replaceAll('$$id', id))
|
foundTemplate = JSON.parse(JSON.stringify(foundTemplate).replaceAll('$$id', id))
|
||||||
if (foundTemplate.variables.length > 0) {
|
if (foundTemplate.variables.length > 0) {
|
||||||
@@ -495,7 +495,7 @@ export async function saveService(request: FastifyRequest<SaveService>, reply: F
|
|||||||
}
|
}
|
||||||
const templates = await getTemplates()
|
const templates = await getTemplates()
|
||||||
const service = await prisma.service.findUnique({ where: { id } })
|
const service = await prisma.service.findUnique({ where: { id } })
|
||||||
const foundTemplate = templates.find(t => t.name.toLowerCase() === service.type.toLowerCase())
|
const foundTemplate = templates.find(t => fixType(t.name) === service.type)
|
||||||
for (const setting of serviceSetting) {
|
for (const setting of serviceSetting) {
|
||||||
let { id: settingId, name, value, changed = false, isNew = false, variableName } = setting
|
let { id: settingId, name, value, changed = false, isNew = false, variableName } = setting
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@@ -679,15 +679,18 @@ export async function activatePlausibleUsers(request: FastifyRequest<OnlyId>, re
|
|||||||
const {
|
const {
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
destinationDocker,
|
destinationDocker,
|
||||||
plausibleAnalytics: { postgresqlUser, postgresqlPassword, postgresqlDatabase }
|
serviceSecret
|
||||||
} = await getServiceFromDB({ id, teamId });
|
} = await getServiceFromDB({ id, teamId });
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
|
const databaseUrl = serviceSecret.find((secret) => secret.name === 'DATABASE_URL');
|
||||||
|
if (databaseUrl) {
|
||||||
await executeDockerCmd({
|
await executeDockerCmd({
|
||||||
dockerId: destinationDocker.id,
|
dockerId: destinationDocker.id,
|
||||||
command: `docker exec ${id}-postgresql psql -H postgresql://${postgresqlUser}:${postgresqlPassword}@localhost:5432/${postgresqlDatabase} -c "UPDATE users SET email_verified = true;"`
|
command: `docker exec ${id}-postgresql psql -H ${databaseUrl.value} -c "UPDATE users SET email_verified = true;"`
|
||||||
})
|
})
|
||||||
return await reply.code(201).send()
|
return await reply.code(201).send()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
throw { status: 500, message: 'Could not activate users.' }
|
throw { status: 500, message: 'Could not activate users.' }
|
||||||
} catch ({ status, message }) {
|
} catch ({ status, message }) {
|
||||||
return errorHandler({ status, message })
|
return errorHandler({ status, message })
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { FastifyRequest } from "fastify";
|
import { FastifyRequest } from "fastify";
|
||||||
import { errorHandler, getDomain, isDev, prisma, executeDockerCmd } from "../../../lib/common";
|
import { errorHandler, getDomain, isDev, prisma, executeDockerCmd, fixType } from "../../../lib/common";
|
||||||
import { supportedServiceTypesAndVersions } from "../../../lib/services/supportedVersions";
|
import { supportedServiceTypesAndVersions } from "../../../lib/services/supportedVersions";
|
||||||
import { includeServices } from "../../../lib/services/common";
|
import { includeServices } from "../../../lib/services/common";
|
||||||
import { TraefikOtherConfiguration } from "./types";
|
import { TraefikOtherConfiguration } from "./types";
|
||||||
@@ -378,8 +378,7 @@ export async function traefikConfiguration(request, reply) {
|
|||||||
} = service;
|
} = service;
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const templates = await getTemplates();
|
const templates = await getTemplates();
|
||||||
let found = templates.find((a) => a.name === type);
|
let found = templates.find((a) => fixType(a.name) === fixType(type));
|
||||||
type = type.toLowerCase();
|
|
||||||
if (found) {
|
if (found) {
|
||||||
found = JSON.parse(JSON.stringify(found).replaceAll('$$id', id));
|
found = JSON.parse(JSON.stringify(found).replaceAll('$$id', id));
|
||||||
for (const oneService of Object.keys(found.services)) {
|
for (const oneService of Object.keys(found.services)) {
|
||||||
|
@@ -157,7 +157,7 @@
|
|||||||
try {
|
try {
|
||||||
await post(`/services/${id}/${service.type}/cleanup`, { id: service.id });
|
await post(`/services/${id}/${service.type}/cleanup`, { id: service.id });
|
||||||
return addToast({
|
return addToast({
|
||||||
message: 'Cleared DB Logs',
|
message: 'Cleared unnecessary database logs.',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -166,28 +166,25 @@
|
|||||||
loading.cleanup = false;
|
loading.cleanup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function doNothing() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {
|
if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {
|
||||||
service.fqdn = `http://${cuid()}.demo.coolify.io`;
|
service.fqdn = `http://${cuid()}.demo.coolify.io`;
|
||||||
if (service.type === 'wordpress') {
|
// if (service.type === 'wordpress') {
|
||||||
service.wordpress.mysqlDatabase = 'db';
|
// service.wordpress.mysqlDatabase = 'db';
|
||||||
}
|
// }
|
||||||
// if (service.type === 'plausibleanalytics') {
|
// if (service.type === 'plausibleanalytics') {
|
||||||
// service.plausibleAnalytics.email = 'noreply@demo.com';
|
// service.plausibleAnalytics.email = 'noreply@demo.com';
|
||||||
// service.plausibleAnalytics.username = 'admin';
|
// service.plausibleAnalytics.username = 'admin';
|
||||||
// }
|
// }
|
||||||
if (service.type === 'minio') {
|
// if (service.type === 'minio') {
|
||||||
service.minio.apiFqdn = `http://${cuid()}.demo.coolify.io`;
|
// service.minio.apiFqdn = `http://${cuid()}.demo.coolify.io`;
|
||||||
}
|
// }
|
||||||
if (service.type === 'ghost') {
|
// if (service.type === 'ghost') {
|
||||||
service.ghost.mariadbDatabase = 'db';
|
// service.ghost.mariadbDatabase = 'db';
|
||||||
}
|
// }
|
||||||
if (service.type === 'fider') {
|
// if (service.type === 'fider') {
|
||||||
service.fider.emailNoreply = 'noreply@demo.com';
|
// service.fider.emailNoreply = 'noreply@demo.com';
|
||||||
}
|
// }
|
||||||
// await handleSubmit();
|
// await handleSubmit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -214,8 +211,7 @@
|
|||||||
: $t('forms.save')}</button
|
: $t('forms.save')}</button
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
<!-- {#if service.type === 'plausibleanalytics' && $status.service.isRunning}
|
{#if service.type === 'plausibleanalytics' && $status.service.overallStatus === 'healthy'}
|
||||||
<div class="btn-group">
|
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm"
|
class="btn btn-sm"
|
||||||
on:click|preventDefault={setEmailsToVerified}
|
on:click|preventDefault={setEmailsToVerified}
|
||||||
@@ -231,8 +227,7 @@
|
|||||||
disabled={loading.cleanup}
|
disabled={loading.cleanup}
|
||||||
class:loading={loading.cleanup}>Cleanup Unnecessary Database Logs</button
|
class:loading={loading.cleanup}>Cleanup Unnecessary Database Logs</button
|
||||||
>
|
>
|
||||||
</div>
|
{/if}
|
||||||
{/if} -->
|
|
||||||
{#if service.type === 'appwrite' && $status.service.isRunning}
|
{#if service.type === 'appwrite' && $status.service.isRunning}
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm"
|
class="btn btn-sm"
|
||||||
@@ -384,8 +379,6 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div />
|
|
||||||
<div>
|
<div>
|
||||||
{#each Object.keys(template) as oneService}
|
{#each Object.keys(template) as oneService}
|
||||||
<div
|
<div
|
||||||
|
Reference in New Issue
Block a user