feat: hide network utils config when tools settings url is set (#411)

This commit is contained in:
fred-head authored and GitHub committed 2026-07-04 14:39:19 +02:00
1 parent 5efbb87ea5
commit b6f8cb0546
4 files changed
+39 -11

No files matched your search

@@ -1,9 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams'; import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-config';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
const serverHost = useITStorage('dns-prop:url', 'http://localhost:8000'); const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
const serverAuth = useITStorage('dns-prop:auth', ''); toolKey: 'dns-prop',
urlStorageKey: 'dns-prop:url',
authStorageKey: 'dns-prop:auth',
});
const loading = ref(false); const loading = ref(false);
@@ -172,7 +176,7 @@ async function runPropagation() {
<template> <template>
<div> <div>
<details mb-2> <details v-if="!hasFixedConfig" mb-2>
<summary>Network Utilities Service Configuration (self hosted)</summary> <summary>Network Utilities Service Configuration (self hosted)</summary>
<n-card> <n-card>
<NFormItem label="Network Utilities Service Url:" label-placement="top"> <NFormItem label="Network Utilities Service Url:" label-placement="top">
+7 -4
View File
@@ -1,9 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { useITStorage } from '@/composable/queryParams'; import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-config';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
const serverHost = useITStorage('https-tester:url', 'http://localhost:8000'); const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
const serverAuth = useITStorage('https-tester:auth', ''); toolKey: 'dns-tester',
urlStorageKey: 'dns-tester:url',
authStorageKey: 'dns-tester:auth',
});
const loading = ref(false); const loading = ref(false);
const error = ref<string | null>(null); const error = ref<string | null>(null);
@@ -203,7 +206,7 @@ const labelProps = {
<template> <template>
<div style="min-height: 80vh;"> <div style="min-height: 80vh;">
<details mb-2> <details v-if="!hasFixedConfig" mb-2>
<summary>Network Utilities Service Configuration (self hosted)</summary> <summary>Network Utilities Service Configuration (self hosted)</summary>
<n-card> <n-card>
<NFormItem label="Network Utilities Service Url:" label-placement="top"> <NFormItem label="Network Utilities Service Url:" label-placement="top">
+7 -4
View File
@@ -1,9 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { useITStorage } from '@/composable/queryParams'; import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-config';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
const serverHost = useITStorage('https-tester:url', 'http://localhost:8000'); const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
const serverAuth = useITStorage('https-tester:auth', ''); toolKey: 'https-tester',
urlStorageKey: 'https-tester:url',
authStorageKey: 'https-tester:auth',
});
const loading = ref(false); const loading = ref(false);
const error = ref<string | null>(null); const error = ref<string | null>(null);
@@ -128,7 +131,7 @@ const labelProps = {
<template> <template>
<div> <div>
<details mb-2> <details v-if="!hasFixedConfig" mb-2>
<summary>Network Utilities Service Configuration (self hosted)</summary> <summary>Network Utilities Service Configuration (self hosted)</summary>
<n-card> <n-card>
<NFormItem label="Network Utilities Service Url:" label-placement="top"> <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,
};
}