fix: new destinations

This commit is contained in:
Andras Bacsai 2022-07-06 16:42:31 +02:00 committed by GitHub
parent 331e13b7cb
commit 52b712d90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 13 deletions

View File

@ -43,7 +43,7 @@ export async function getDestination(request: FastifyRequest) {
const destination = await prisma.destinationDocker.findFirst({ const destination = await prisma.destinationDocker.findFirst({
where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } } where: { id, teams: { some: { id: teamId === '0' ? undefined : teamId } } }
}); });
if (!destination) { if (!destination && id !== 'new') {
throw { status: 404, message: `Destination not found.` }; throw { status: 404, message: `Destination not found.` };
} }
const settings = await listSettings(); const settings = await listSettings();
@ -62,10 +62,7 @@ export async function getDestination(request: FastifyRequest) {
// // await saveSshKey(destination); // // await saveSshKey(destination);
// payload.state = await checkContainer(engine, 'coolify-haproxy'); // payload.state = await checkContainer(engine, 'coolify-haproxy');
} else { } else {
let containerName = 'coolify-proxy'; const containerName = 'coolify-proxy';
if (!settings.isTraefikUsed) {
containerName = 'coolify-haproxy';
}
payload.state = payload.state =
destination?.engine && (await checkContainer(destination.engine, containerName)); destination?.engine && (await checkContainer(destination.engine, containerName));
} }

View File

@ -34,18 +34,12 @@
return destination; return destination;
} }
}); });
async function newDestination() {
const { id } = await post('/destinations/new', {});
return await goto(`/destinations/${id}`, { replaceState: true });
}
</script> </script>
<div class="flex space-x-1 p-6 font-bold"> <div class="flex space-x-1 p-6 font-bold">
<div class="mr-4 text-2xl tracking-tight">{$t('index.destinations')}</div> <div class="mr-4 text-2xl tracking-tight">{$t('index.destinations')}</div>
{#if $appSession.isAdmin} {#if $appSession.isAdmin}
<button <a href="/destinations/new" class="add-icon bg-sky-600 hover:bg-sky-500">
on:click={newDestination}
class="add-icon bg-sky-600 hover:bg-sky-500">
<svg <svg
class="w-6" class="w-6"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -59,7 +53,7 @@
d="M12 6v6m0 0v6m0-6h6m-6 0H6" d="M12 6v6m0 0v6m0-6h6m-6 0H6"
/></svg /></svg
> >
</button> </a>
{/if} {/if}
</div> </div>
<div class="flex-col justify-center"> <div class="flex-col justify-center">