enh: verify terminal connection
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
import XMark from '$lib/components/icons/XMark.svelte';
|
import XMark from '$lib/components/icons/XMark.svelte';
|
||||||
import AccessControlModal from '$lib/components/workspace/common/AccessControlModal.svelte';
|
import AccessControlModal from '$lib/components/workspace/common/AccessControlModal.svelte';
|
||||||
import LockClosed from '$lib/components/icons/LockClosed.svelte';
|
import LockClosed from '$lib/components/icons/LockClosed.svelte';
|
||||||
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||||
|
import { getTerminalConfig } from '$lib/apis/terminal';
|
||||||
|
|
||||||
export let show = false;
|
export let show = false;
|
||||||
export let edit = false;
|
export let edit = false;
|
||||||
@@ -56,6 +58,22 @@
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const verifyHandler = async () => {
|
||||||
|
const _url = url.replace(/\/$/, '');
|
||||||
|
if (!_url) {
|
||||||
|
toast.error($i18n.t('Please enter a valid URL'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await getTerminalConfig(_url, key);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
toast.success($i18n.t('Server connection verified'));
|
||||||
|
} else {
|
||||||
|
toast.error($i18n.t('Server connection failed'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const submitHandler = () => {
|
const submitHandler = () => {
|
||||||
if (url === '') {
|
if (url === '') {
|
||||||
toast.error($i18n.t('Please enter a valid URL'));
|
toast.error($i18n.t('Please enter a valid URL'));
|
||||||
@@ -176,6 +194,31 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Tooltip content={$i18n.t('Verify Connection')} className="self-end -mb-1">
|
||||||
|
<button
|
||||||
|
class="self-center p-1 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-850 rounded-lg transition"
|
||||||
|
on:click={() => {
|
||||||
|
verifyHandler();
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
aria-label={$i18n.t('Verify Connection')}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z"
|
||||||
|
clip-rule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
|
|||||||
Reference in New Issue
Block a user