Skip to content

Commit c7f8997

Browse files
committed
fix: remove stale baseEndpoint references and fix downloadBulkData
- App.tsx: remove baseEndpoint from store selector and connect() call - ServerConnectionDialog.tsx: remove base endpoint input field entirely (generated client normalizes URLs automatically) - store.ts: remove unused dynamic import, use store serverUrl instead of fragile type cast for download URL construction
1 parent 586f5a0 commit c7f8997

3 files changed

Lines changed: 11 additions & 33 deletions

File tree

src/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import { useAppStore } from '@/lib/store';
1616
type ViewMode = 'entity' | 'faults-dashboard';
1717

1818
function App() {
19-
const { isConnected, serverUrl, baseEndpoint, connect, clearSelection, selectedPath } = useAppStore(
19+
const { isConnected, serverUrl, connect, clearSelection, selectedPath } = useAppStore(
2020
useShallow((state) => ({
2121
isConnected: state.isConnected,
2222
serverUrl: state.serverUrl,
23-
baseEndpoint: state.baseEndpoint,
2423
connect: state.connect,
2524
clearSelection: state.clearSelection,
2625
selectedPath: state.selectedPath,
@@ -67,7 +66,7 @@ function App() {
6766
useEffect(() => {
6867
if (serverUrl && !isConnected && !autoConnectAttempted.current) {
6968
autoConnectAttempted.current = true;
70-
connect(serverUrl, baseEndpoint).then((success) => {
69+
connect(serverUrl).then((success) => {
7170
if (!success) {
7271
toast.error('Auto-connect failed. Please check your server settings.');
7372
setShowConnectionDialog(true);

src/components/ServerConnectionDialog.tsx

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@ interface ServerConnectionDialogProps {
1818
}
1919

2020
export function ServerConnectionDialog({ open, onOpenChange }: ServerConnectionDialogProps) {
21-
const { serverUrl, baseEndpoint, isConnecting, connectionError, connect } = useAppStore();
21+
const { serverUrl, isConnecting, connectionError, connect } = useAppStore();
2222
const [url, setUrl] = useState(serverUrl || 'localhost:8080');
23-
const [endpoint, setEndpoint] = useState(baseEndpoint || 'api/v1');
2423

25-
// Update local state when serverUrl/baseEndpoint changes (e.g., from localStorage)
26-
// Only update if the dialog is just opened or if the store values change externally
24+
// Update local state when serverUrl changes (e.g., from localStorage)
2725
useEffect(() => {
2826
if (open) {
2927
setUrl(serverUrl || '');
30-
setEndpoint(baseEndpoint || '');
3128
}
32-
}, [open, serverUrl, baseEndpoint]);
29+
}, [open, serverUrl]);
3330

3431
const handleConnect = async () => {
3532
if (!url.trim()) return;
3633

37-
const success = await connect(url.trim(), endpoint.trim());
34+
const success = await connect(url.trim());
3835
if (success) {
3936
onOpenChange(false);
4037
}
@@ -56,7 +53,7 @@ export function ServerConnectionDialog({ open, onOpenChange }: ServerConnectionD
5653
</div>
5754
<div>
5855
<DialogTitle>Connect to SOVD Server</DialogTitle>
59-
<DialogDescription>Enter the URL and base endpoint of your SOVD server</DialogDescription>
56+
<DialogDescription>Enter the URL of your SOVD server</DialogDescription>
6057
</div>
6158
</div>
6259
</DialogHeader>
@@ -68,32 +65,15 @@ export function ServerConnectionDialog({ open, onOpenChange }: ServerConnectionD
6865
</label>
6966
<Input
7067
id="server-url"
71-
placeholder="192.168.1.100:8080 or http://localhost:3000"
68+
placeholder="192.168.1.100:8080 or http://localhost:8080"
7269
value={url}
7370
onChange={(e) => setUrl(e.target.value)}
7471
onKeyDown={handleKeyDown}
7572
disabled={isConnecting}
7673
aria-invalid={!!connectionError}
7774
/>
7875
<p className="text-xs text-muted-foreground">
79-
You can enter just IP:port or a full URL with protocol
80-
</p>
81-
</div>
82-
83-
<div className="space-y-2">
84-
<label htmlFor="base-endpoint" className="text-sm font-medium">
85-
Base Endpoint
86-
</label>
87-
<Input
88-
id="base-endpoint"
89-
placeholder="e.g. api/v1 (optional)"
90-
value={endpoint}
91-
onChange={(e) => setEndpoint(e.target.value)}
92-
onKeyDown={handleKeyDown}
93-
disabled={isConnecting}
94-
/>
95-
<p className="text-xs text-muted-foreground">
96-
The path prefix for SOVD entities (leave empty for root)
76+
Enter IP:port or a full URL. The API path (/api/v1) is added automatically.
9777
</p>
9878
</div>
9979

src/lib/store.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,10 +1663,9 @@ export const useAppStore = create<AppState>()(
16631663
const items = (data as unknown as { items?: Array<{ id: string; name?: string }> })?.items || [];
16641664
const fileDesc = items.find((item) => item.id === fileId);
16651665
const filename = fileDesc?.name || fileId;
1666-
// Use the generated client for actual download
1667-
await import('./api-dispatch');
16681666
// Construct the download URL manually since openapi-fetch doesn't support blob responses well
1669-
const baseUrl = (client as unknown as { baseUrl?: string }).baseUrl || '';
1667+
const { serverUrl: storedUrl } = get();
1668+
const baseUrl = storedUrl ? storedUrl.replace(/\/$/, '') : '';
16701669
const downloadUrl = `${baseUrl}/${entityType}/${entityId}/bulk-data/${category}/${fileId}`;
16711670
const response = await fetch(downloadUrl);
16721671
if (!response.ok) return null;

0 commit comments

Comments
 (0)