enhancement: disabled config when server is running (#5058)
This commit is contained in:
parent
fab8f0a9c9
commit
a7d2e72313
@ -14,6 +14,7 @@ import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
|||||||
import { useAppState } from '@/hooks/useAppState'
|
import { useAppState } from '@/hooks/useAppState'
|
||||||
import { windowKey } from '@/constants/windows'
|
import { windowKey } from '@/constants/windows'
|
||||||
import { IconLogs } from '@tabler/icons-react'
|
import { IconLogs } from '@tabler/icons-react'
|
||||||
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export const Route = createFileRoute(route.settings.local_api_server as any)({
|
export const Route = createFileRoute(route.settings.local_api_server as any)({
|
||||||
@ -101,6 +102,8 @@ function LocalAPIServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isServerRunning = serverStatus === 'running'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-full">
|
<div className="flex flex-col h-full">
|
||||||
<HeaderPage>
|
<HeaderPage>
|
||||||
@ -122,12 +125,10 @@ function LocalAPIServer() {
|
|||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
onClick={toggleAPIServer}
|
onClick={toggleAPIServer}
|
||||||
variant={
|
variant={isServerRunning ? 'destructive' : 'default'}
|
||||||
serverStatus === 'running' ? 'destructive' : 'default'
|
|
||||||
}
|
|
||||||
size="sm"
|
size="sm"
|
||||||
>
|
>
|
||||||
{`${serverStatus === 'running' ? 'Stop' : 'Start'}`} Server
|
{`${isServerRunning ? 'Stop' : 'Start'}`} Server
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@ -155,16 +156,25 @@ function LocalAPIServer() {
|
|||||||
<CardItem
|
<CardItem
|
||||||
title="Server Host"
|
title="Server Host"
|
||||||
description="Choose between 127.0.0.1 or 0.0.0.0"
|
description="Choose between 127.0.0.1 or 0.0.0.0"
|
||||||
|
className={cn(
|
||||||
|
isServerRunning && 'opacity-50 pointer-events-none'
|
||||||
|
)}
|
||||||
actions={<ServerHostSwitcher />}
|
actions={<ServerHostSwitcher />}
|
||||||
/>
|
/>
|
||||||
<CardItem
|
<CardItem
|
||||||
title="Server Port"
|
title="Server Port"
|
||||||
description="Set the port number for the API server"
|
description="Set the port number for the API server"
|
||||||
|
className={cn(
|
||||||
|
isServerRunning && 'opacity-50 pointer-events-none'
|
||||||
|
)}
|
||||||
actions={<PortInput />}
|
actions={<PortInput />}
|
||||||
/>
|
/>
|
||||||
<CardItem
|
<CardItem
|
||||||
title="API Prefix"
|
title="API Prefix"
|
||||||
description="Set the API endpoint prefix"
|
description="Set the API endpoint prefix"
|
||||||
|
className={cn(
|
||||||
|
isServerRunning && 'opacity-50 pointer-events-none'
|
||||||
|
)}
|
||||||
actions={<ApiPrefixInput />}
|
actions={<ApiPrefixInput />}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
@ -174,6 +184,9 @@ function LocalAPIServer() {
|
|||||||
<CardItem
|
<CardItem
|
||||||
title="Cross-Origin Resource Sharing (CORS)"
|
title="Cross-Origin Resource Sharing (CORS)"
|
||||||
description="Allow requests from different origins to access the API"
|
description="Allow requests from different origins to access the API"
|
||||||
|
className={cn(
|
||||||
|
isServerRunning && 'opacity-50 pointer-events-none'
|
||||||
|
)}
|
||||||
actions={
|
actions={
|
||||||
<Switch
|
<Switch
|
||||||
checked={corsEnabled}
|
checked={corsEnabled}
|
||||||
@ -184,6 +197,9 @@ function LocalAPIServer() {
|
|||||||
<CardItem
|
<CardItem
|
||||||
title="Verbose Server Logs"
|
title="Verbose Server Logs"
|
||||||
description="Enable detailed logging for debugging purposes"
|
description="Enable detailed logging for debugging purposes"
|
||||||
|
className={cn(
|
||||||
|
isServerRunning && 'opacity-50 pointer-events-none'
|
||||||
|
)}
|
||||||
actions={
|
actions={
|
||||||
<Switch
|
<Switch
|
||||||
checked={verboseLogs}
|
checked={verboseLogs}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user