fix: location url for services and apps

This commit is contained in:
Andras Bacsai
2022-07-18 07:45:29 +00:00
parent 017ba61dc9
commit 60a53bb812
5 changed files with 34 additions and 28 deletions

View File

@@ -62,12 +62,13 @@
import { toast } from '@zerodevx/svelte-toast';
import { onDestroy, onMount } from 'svelte';
import { t } from '$lib/translations';
import { appSession, disabledButton, status } from '$lib/store';
import { appSession, disabledButton, status, location, setLocation } from '$lib/store';
import { errorNotification, handlerNotFoundLoad } from '$lib/common';
import Loading from '$lib/components/Loading.svelte';
let loading = false;
let statusInterval: any;
$disabledButton =
!$appSession.isAdmin ||
!application.fqdn ||
@@ -75,14 +76,7 @@
!application.repository ||
!application.destinationDocker ||
!application.buildPack;
let location = application.fqdn || null;
if (GITPOD_WORKSPACE_URL && application.exposePort) {
const { href } = new URL(GITPOD_WORKSPACE_URL);
const newURL = href
.replace('https://', `https://${application.exposePort}-`)
.replace(/\/$/, '');
location = newURL;
}
const { id } = $page.params;
async function handleDeploySubmit() {
@@ -134,9 +128,12 @@
}
onDestroy(() => {
$status.application.initialLoading = true;
$location = null;
clearInterval(statusInterval);
});
onMount(async () => {
setLocation(application);
$status.application.isRunning = false;
$status.application.isExited = false;
$status.application.loading = false;
@@ -155,9 +152,9 @@
{#if loading}
<Loading fullscreen cover />
{:else}
{#if location}
{#if $location}
<a
href={location}
href={$location}
target="_blank"
class="icons tooltip-bottom flex items-center bg-transparent text-sm"
><svg
@@ -177,7 +174,7 @@
</svg></a
>
{/if}
<div class="border border-coolgray-500 h-8" />
{#if $status.application.isExited}
<a

View File

@@ -35,7 +35,7 @@
import { get, post } from '$lib/api';
import cuid from 'cuid';
import { browser } from '$app/env';
import { appSession, disabledButton, status } from '$lib/store';
import { appSession, disabledButton, setLocation, status } from '$lib/store';
import { t } from '$lib/translations';
import { errorNotification, getDomain, notNodeDeployments, staticDeployments } from '$lib/common';
import Setting from './_Setting.svelte';
@@ -169,6 +169,7 @@
exposePort: application.exposePort
});
await post(`/applications/${id}`, { ...application });
setLocation(application)
$disabledButton = false;
forceSave = false;
return toast.push('Configurations saved.');
@@ -329,7 +330,6 @@
<div class="mt-2 grid grid-cols-2 items-center">
<label for="name" class="text-base font-bold text-stone-100">{$t('forms.name')}</label>
<input
readonly={!isDisabled}
name="name"
id="name"
bind:value={application.name}