mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
feat: hide network utils config when tools settings url is set (#411)
This commit is contained in:
1 parent
5efbb87ea5
commit
b6f8cb0546
4 files changed
+39
-11
No files matched your search
@@ -1,9 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-config';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const serverHost = useITStorage('dns-prop:url', 'http://localhost:8000');
|
||||
const serverAuth = useITStorage('dns-prop:auth', '');
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'dns-prop',
|
||||
urlStorageKey: 'dns-prop:url',
|
||||
authStorageKey: 'dns-prop:auth',
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
@@ -172,7 +176,7 @@ async function runPropagation() {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<details mb-2>
|
||||
<details v-if="!hasFixedConfig" mb-2>
|
||||
<summary>Network Utilities Service Configuration (self hosted)</summary>
|
||||
<n-card>
|
||||
<NFormItem label="Network Utilities Service Url:" label-placement="top">
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { useITStorage } from '@/composable/queryParams';
|
||||
import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-config';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const serverHost = useITStorage('https-tester:url', 'http://localhost:8000');
|
||||
const serverAuth = useITStorage('https-tester:auth', '');
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'dns-tester',
|
||||
urlStorageKey: 'dns-tester:url',
|
||||
authStorageKey: 'dns-tester:auth',
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
@@ -203,7 +206,7 @@ const labelProps = {
|
||||
|
||||
<template>
|
||||
<div style="min-height: 80vh;">
|
||||
<details mb-2>
|
||||
<details v-if="!hasFixedConfig" mb-2>
|
||||
<summary>Network Utilities Service Configuration (self hosted)</summary>
|
||||
<n-card>
|
||||
<NFormItem label="Network Utilities Service Url:" label-placement="top">
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { useITStorage } from '@/composable/queryParams';
|
||||
import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-config';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const serverHost = useITStorage('https-tester:url', 'http://localhost:8000');
|
||||
const serverAuth = useITStorage('https-tester:auth', '');
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'https-tester',
|
||||
urlStorageKey: 'https-tester:url',
|
||||
authStorageKey: 'https-tester:auth',
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
@@ -128,7 +131,7 @@ const labelProps = {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<details mb-2>
|
||||
<details v-if="!hasFixedConfig" mb-2>
|
||||
<summary>Network Utilities Service Configuration (self hosted)</summary>
|
||||
<n-card>
|
||||
<NFormItem label="Network Utilities Service Url:" label-placement="top">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { getITToolsSetting, useITStorage } from '@/composable/queryParams';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export function useNetworkUtilsConfig({ toolKey, urlStorageKey, authStorageKey }: { toolKey: string; urlStorageKey: string; authStorageKey: string }) {
|
||||
const fixedUrl = String(getITToolsSetting(`${toolKey}:url`, '') || '').trim();
|
||||
const fixedAuth = String(getITToolsSetting(`${toolKey}:auth`, '') || '').trim();
|
||||
const hasFixedConfig = Boolean(fixedUrl);
|
||||
|
||||
return {
|
||||
serverHost: hasFixedConfig
|
||||
? ref(fixedUrl)
|
||||
: useITStorage(urlStorageKey, 'http://localhost:8000'),
|
||||
serverAuth: hasFixedConfig
|
||||
? ref(fixedAuth)
|
||||
: useITStorage(authStorageKey, ''),
|
||||
hasFixedConfig,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user