fix: service deploymentEnabled
This commit is contained in:
		@@ -56,6 +56,15 @@ export function checkIfDeploymentEnabledApplications(isAdmin: boolean, applicati
 | 
				
			|||||||
        application.buildPack
 | 
					        application.buildPack
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					export function checkIfDeploymentEnabledServices(isAdmin: boolean, service: any) {
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
 | 
					        isAdmin &&
 | 
				
			||||||
 | 
					        service.fqdn &&
 | 
				
			||||||
 | 
					        service.destinationDocker &&
 | 
				
			||||||
 | 
					        service.version &&
 | 
				
			||||||
 | 
					        service.type
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
export const status: Writable<any> = writable({
 | 
					export const status: Writable<any> = writable({
 | 
				
			||||||
    application: {
 | 
					    application: {
 | 
				
			||||||
        isRunning: false,
 | 
					        isRunning: false,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -164,6 +164,7 @@
 | 
				
			|||||||
		$status.application.isExited = false;
 | 
							$status.application.isExited = false;
 | 
				
			||||||
		$status.application.loading = false;
 | 
							$status.application.loading = false;
 | 
				
			||||||
		$location = null;
 | 
							$location = null;
 | 
				
			||||||
 | 
							$isDeploymentEnabled = false;
 | 
				
			||||||
		clearInterval(statusInterval);
 | 
							clearInterval(statusInterval);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	onMount(async () => {
 | 
						onMount(async () => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,19 +60,21 @@
 | 
				
			|||||||
	import { goto } from '$app/navigation';
 | 
						import { goto } from '$app/navigation';
 | 
				
			||||||
	import { t } from '$lib/translations';
 | 
						import { t } from '$lib/translations';
 | 
				
			||||||
	import { errorNotification, handlerNotFoundLoad } from '$lib/common';
 | 
						import { errorNotification, handlerNotFoundLoad } from '$lib/common';
 | 
				
			||||||
	import { appSession, disabledButton, status, location, setLocation } from '$lib/store';
 | 
						import {
 | 
				
			||||||
 | 
							appSession,
 | 
				
			||||||
 | 
							isDeploymentEnabled,
 | 
				
			||||||
 | 
							status,
 | 
				
			||||||
 | 
							location,
 | 
				
			||||||
 | 
							setLocation,
 | 
				
			||||||
 | 
							checkIfDeploymentEnabledServices
 | 
				
			||||||
 | 
						} from '$lib/store';
 | 
				
			||||||
	import { onDestroy, onMount } from 'svelte';
 | 
						import { onDestroy, onMount } from 'svelte';
 | 
				
			||||||
	import Tooltip from '$lib/components/Tooltip.svelte';
 | 
						import Tooltip from '$lib/components/Tooltip.svelte';
 | 
				
			||||||
	const { id } = $page.params;
 | 
						const { id } = $page.params;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	export let service: any;
 | 
						export let service: any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	$disabledButton =
 | 
						$isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service);
 | 
				
			||||||
		!$appSession.isAdmin ||
 | 
					 | 
				
			||||||
		!service.fqdn ||
 | 
					 | 
				
			||||||
		!service.destinationDocker ||
 | 
					 | 
				
			||||||
		!service.version ||
 | 
					 | 
				
			||||||
		!service.type;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	let statusInterval: any;
 | 
						let statusInterval: any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -133,6 +135,7 @@
 | 
				
			|||||||
		$status.service.isExited = false;
 | 
							$status.service.isExited = false;
 | 
				
			||||||
		$status.service.loading = false;
 | 
							$status.service.loading = false;
 | 
				
			||||||
		$location = null;
 | 
							$location = null;
 | 
				
			||||||
 | 
							$isDeploymentEnabled = false;
 | 
				
			||||||
		clearInterval(statusInterval);
 | 
							clearInterval(statusInterval);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	onMount(async () => {
 | 
						onMount(async () => {
 | 
				
			||||||
@@ -151,7 +154,6 @@
 | 
				
			|||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<nav class="nav-side">
 | 
					<nav class="nav-side">
 | 
				
			||||||
	{#if service.type && service.destinationDockerId && service.version && service.fqdn}
 | 
					 | 
				
			||||||
	{#if $location}
 | 
						{#if $location}
 | 
				
			||||||
		<a
 | 
							<a
 | 
				
			||||||
			id="open"
 | 
								id="open"
 | 
				
			||||||
@@ -180,7 +182,7 @@
 | 
				
			|||||||
	{#if $status.service.isExited}
 | 
						{#if $status.service.isExited}
 | 
				
			||||||
		<a
 | 
							<a
 | 
				
			||||||
			id="error"
 | 
								id="error"
 | 
				
			||||||
				href={!$disabledButton ? `/services/${id}/logs` : null}
 | 
								href={$isDeploymentEnabled ? `/services/${id}/logs` : null}
 | 
				
			||||||
			class="icons bg-transparent text-sm flex items-center text-red-500 tooltip-error"
 | 
								class="icons bg-transparent text-sm flex items-center text-red-500 tooltip-error"
 | 
				
			||||||
			sveltekit:prefetch
 | 
								sveltekit:prefetch
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
@@ -232,7 +234,7 @@
 | 
				
			|||||||
			id="stop"
 | 
								id="stop"
 | 
				
			||||||
			on:click={stopService}
 | 
								on:click={stopService}
 | 
				
			||||||
			type="submit"
 | 
								type="submit"
 | 
				
			||||||
				disabled={$disabledButton}
 | 
								disabled={!$isDeploymentEnabled}
 | 
				
			||||||
			class="icons bg-transparent text-sm flex items-center space-x-2 text-red-500"
 | 
								class="icons bg-transparent text-sm flex items-center space-x-2 text-red-500"
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
			<svg
 | 
								<svg
 | 
				
			||||||
@@ -256,7 +258,7 @@
 | 
				
			|||||||
			id="start"
 | 
								id="start"
 | 
				
			||||||
			on:click={startService}
 | 
								on:click={startService}
 | 
				
			||||||
			type="submit"
 | 
								type="submit"
 | 
				
			||||||
				disabled={$disabledButton}
 | 
								disabled={!$isDeploymentEnabled}
 | 
				
			||||||
			class="icons bg-transparent text-sm flex items-center space-x-2 text-green-500"
 | 
								class="icons bg-transparent text-sm flex items-center space-x-2 text-green-500"
 | 
				
			||||||
			><svg
 | 
								><svg
 | 
				
			||||||
				xmlns="http://www.w3.org/2000/svg"
 | 
									xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
@@ -275,17 +277,19 @@
 | 
				
			|||||||
		<Tooltip triggeredBy="#start">Start</Tooltip>
 | 
							<Tooltip triggeredBy="#start">Start</Tooltip>
 | 
				
			||||||
	{/if}
 | 
						{/if}
 | 
				
			||||||
	<div class="border border-stone-700 h-8" />
 | 
						<div class="border border-stone-700 h-8" />
 | 
				
			||||||
	{/if}
 | 
					 | 
				
			||||||
	{#if service.type && service.destinationDockerId && service.version}
 | 
						{#if service.type && service.destinationDockerId && service.version}
 | 
				
			||||||
		<a
 | 
							<a
 | 
				
			||||||
			id="configuration"
 | 
					 | 
				
			||||||
			href="/services/{id}"
 | 
								href="/services/{id}"
 | 
				
			||||||
			sveltekit:prefetch
 | 
								sveltekit:prefetch
 | 
				
			||||||
			class="hover:text-yellow-500 rounded"
 | 
								class="hover:text-yellow-500 rounded"
 | 
				
			||||||
			class:text-yellow-500={$page.url.pathname === `/services/${id}`}
 | 
								class:text-yellow-500={$page.url.pathname === `/services/${id}`}
 | 
				
			||||||
			class:bg-coolgray-500={$page.url.pathname === `/services/${id}`}
 | 
								class:bg-coolgray-500={$page.url.pathname === `/services/${id}`}
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
			<button class="icons bg-transparent text-sm disabled:text-red-500">
 | 
								<button
 | 
				
			||||||
 | 
									id="configuration"
 | 
				
			||||||
 | 
									disabled={!$isDeploymentEnabled}
 | 
				
			||||||
 | 
									class="icons bg-transparent text-sm"
 | 
				
			||||||
 | 
								>
 | 
				
			||||||
				<svg
 | 
									<svg
 | 
				
			||||||
					xmlns="http://www.w3.org/2000/svg"
 | 
										xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
					class="h-6 w-6"
 | 
										class="h-6 w-6"
 | 
				
			||||||
@@ -311,14 +315,17 @@
 | 
				
			|||||||
		>
 | 
							>
 | 
				
			||||||
		<Tooltip triggeredBy="#configuration">Configuration</Tooltip>
 | 
							<Tooltip triggeredBy="#configuration">Configuration</Tooltip>
 | 
				
			||||||
		<a
 | 
							<a
 | 
				
			||||||
			id="secrets"
 | 
					 | 
				
			||||||
			href="/services/{id}/secrets"
 | 
								href="/services/{id}/secrets"
 | 
				
			||||||
			sveltekit:prefetch
 | 
								sveltekit:prefetch
 | 
				
			||||||
			class="hover:text-pink-500 rounded"
 | 
								class="hover:text-pink-500 rounded"
 | 
				
			||||||
			class:text-pink-500={$page.url.pathname === `/services/${id}/secrets`}
 | 
								class:text-pink-500={$page.url.pathname === `/services/${id}/secrets`}
 | 
				
			||||||
			class:bg-coolgray-500={$page.url.pathname === `/services/${id}/secrets`}
 | 
								class:bg-coolgray-500={$page.url.pathname === `/services/${id}/secrets`}
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
			<button class="icons bg-transparent text-sm disabled:text-red-500">
 | 
								<button
 | 
				
			||||||
 | 
									id="secrets"
 | 
				
			||||||
 | 
									disabled={!$isDeploymentEnabled}
 | 
				
			||||||
 | 
									class="icons bg-transparent text-sm "
 | 
				
			||||||
 | 
								>
 | 
				
			||||||
				<svg
 | 
									<svg
 | 
				
			||||||
					xmlns="http://www.w3.org/2000/svg"
 | 
										xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
					class="w-6 h-6"
 | 
										class="w-6 h-6"
 | 
				
			||||||
@@ -340,14 +347,17 @@
 | 
				
			|||||||
		>
 | 
							>
 | 
				
			||||||
		<Tooltip triggeredBy="#secrets">Secrets</Tooltip>
 | 
							<Tooltip triggeredBy="#secrets">Secrets</Tooltip>
 | 
				
			||||||
		<a
 | 
							<a
 | 
				
			||||||
			id="persistentstorage"
 | 
					 | 
				
			||||||
			href="/services/{id}/storages"
 | 
								href="/services/{id}/storages"
 | 
				
			||||||
			sveltekit:prefetch
 | 
								sveltekit:prefetch
 | 
				
			||||||
			class="hover:text-pink-500 rounded"
 | 
								class="hover:text-pink-500 rounded"
 | 
				
			||||||
			class:text-pink-500={$page.url.pathname === `/services/${id}/storages`}
 | 
								class:text-pink-500={$page.url.pathname === `/services/${id}/storages`}
 | 
				
			||||||
			class:bg-coolgray-500={$page.url.pathname === `/services/${id}/storages`}
 | 
								class:bg-coolgray-500={$page.url.pathname === `/services/${id}/storages`}
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
			<button class="icons bg-transparent text-sm disabled:text-red-500">
 | 
								<button
 | 
				
			||||||
 | 
									id="persistentstorage"
 | 
				
			||||||
 | 
									disabled={!$isDeploymentEnabled}
 | 
				
			||||||
 | 
									class="icons bg-transparent text-sm"
 | 
				
			||||||
 | 
								>
 | 
				
			||||||
				<svg
 | 
									<svg
 | 
				
			||||||
					xmlns="http://www.w3.org/2000/svg"
 | 
										xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
					class="w-6 h-6"
 | 
										class="w-6 h-6"
 | 
				
			||||||
@@ -368,14 +378,13 @@
 | 
				
			|||||||
		<Tooltip triggeredBy="#persistentstorage">Persistent Storage</Tooltip>
 | 
							<Tooltip triggeredBy="#persistentstorage">Persistent Storage</Tooltip>
 | 
				
			||||||
		<div class="border border-stone-700 h-8" />
 | 
							<div class="border border-stone-700 h-8" />
 | 
				
			||||||
		<a
 | 
							<a
 | 
				
			||||||
			id="logs"
 | 
								href={$isDeploymentEnabled && $status.service.isRunning ? `/services/${id}/logs` : null}
 | 
				
			||||||
			href={!$disabledButton && $status.service.isRunning ? `/services/${id}/logs` : null}
 | 
					 | 
				
			||||||
			sveltekit:prefetch
 | 
								sveltekit:prefetch
 | 
				
			||||||
			class="hover:text-pink-500 rounded"
 | 
								class="hover:text-pink-500 rounded"
 | 
				
			||||||
			class:text-pink-500={$page.url.pathname === `/services/${id}/logs`}
 | 
								class:text-pink-500={$page.url.pathname === `/services/${id}/logs`}
 | 
				
			||||||
			class:bg-coolgray-500={$page.url.pathname === `/services/${id}/logs`}
 | 
								class:bg-coolgray-500={$page.url.pathname === `/services/${id}/logs`}
 | 
				
			||||||
		>
 | 
							>
 | 
				
			||||||
			<button disabled={!$status.service.isRunning} class="icons bg-transparent text-sm">
 | 
								<button id="logs" disabled={!$status.service.isRunning} class="icons bg-transparent text-sm">
 | 
				
			||||||
				<svg
 | 
									<svg
 | 
				
			||||||
					xmlns="http://www.w3.org/2000/svg"
 | 
										xmlns="http://www.w3.org/2000/svg"
 | 
				
			||||||
					class="h-6 w-6"
 | 
										class="h-6 w-6"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user