fix: Instant save on demo instance

This commit is contained in:
Andras Bacsai 2022-05-19 14:38:38 +02:00
parent e2bf02841f
commit 26eacfc2c0
2 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,6 @@
<script lang="ts"> <script lang="ts">
import { browser } from '$app/env';
export let service; export let service;
export let isRunning; export let isRunning;
export let readOnly; export let readOnly;
@ -12,6 +14,8 @@
import { errorNotification } from '$lib/form'; import { errorNotification } from '$lib/form';
import { t } from '$lib/translations'; import { t } from '$lib/translations';
import { toast } from '@zerodevx/svelte-toast'; import { toast } from '@zerodevx/svelte-toast';
import cuid from 'cuid';
import { onMount } from 'svelte';
import Fider from './_Fider.svelte'; import Fider from './_Fider.svelte';
import Ghost from './_Ghost.svelte'; import Ghost from './_Ghost.svelte';
import Hasura from './_Hasura.svelte'; import Hasura from './_Hasura.svelte';
@ -29,6 +33,7 @@
let dualCerts = service.dualCerts; let dualCerts = service.dualCerts;
async function handleSubmit() { async function handleSubmit() {
if (loading) return;
loading = true; loading = true;
try { try {
await post(`/services/${id}/check.json`, { await post(`/services/${id}/check.json`, {
@ -66,6 +71,12 @@
return errorNotification(error); return errorNotification(error);
} }
} }
onMount(async () => {
if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {
service.fqdn = `http://${cuid()}.demo.coolify.io`;
await handleSubmit();
}
});
</script> </script>
<div class="mx-auto max-w-4xl px-6 pb-12"> <div class="mx-auto max-w-4xl px-6 pb-12">

View File

@ -30,8 +30,6 @@
</script> </script>
<script lang="ts"> <script lang="ts">
import cuid from 'cuid';
import { browser } from '$app/env';
import ServiceLinks from '$lib/components/ServiceLinks.svelte'; import ServiceLinks from '$lib/components/ServiceLinks.svelte';
import Services from './_Services/_Services.svelte'; import Services from './_Services/_Services.svelte';
@ -39,10 +37,6 @@
export let isRunning; export let isRunning;
export let readOnly; export let readOnly;
export let settings; export let settings;
if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {
service.fqdn = `http://${cuid()}.demo.coolify.io`;
}
</script> </script>
<div class="flex h-20 items-center space-x-2 p-5 px-6 font-bold"> <div class="flex h-20 items-center space-x-2 p-5 px-6 font-bold">