Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dashboard/src/app/api/config/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { NextResponse } from 'next/server';

export async function GET() {
return NextResponse.json({
defaultNamespace: process.env.NEXT_PUBLIC_DEFAULT_NAMESPACE || 'default',
// Add other client-side config here if needed
});
}
21 changes: 19 additions & 2 deletions dashboard/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { GraphTemplateBuilder } from '@/components/GraphTemplateBuilder';
import { NamespaceOverview } from '@/components/NamespaceOverview';
import { RunsTable } from '@/components/RunsTable';
Expand All @@ -21,7 +21,7 @@ import {

export default function Dashboard() {
const [activeTab, setActiveTab] = useState< 'overview' | 'graph' |'runs'>('overview');
const [namespace, setNamespace] = useState(process.env.NEXT_PUBLIC_DEFAULT_NAMESPACE || 'testnamespace');
const [namespace, setNamespace] = useState('default');
const [graphName, setGraphName] = useState('test-graph');
const [graphTemplate, setGraphTemplate] = useState<UpsertGraphTemplateRequest | null>(null);

Expand All @@ -34,6 +34,23 @@ export default function Dashboard() {
const [selectedGraphTemplate, setSelectedGraphTemplate] = useState<UpsertGraphTemplateResponse | null>(null);
const [isGraphModalOpen, setIsGraphModalOpen] = useState(false);

// Fetch configuration on component mount
useEffect(() => {
const fetchConfig = async () => {
try {
const response = await fetch('/api/config');
if (response.ok) {
const config = await response.json();
setNamespace(config.defaultNamespace);
}
Comment on lines +42 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation silently ignores failed API responses (when response.ok is false). This can make debugging difficult if the config endpoint fails for some reason. It would be better to log a warning in this case, similar to how the catch block handles network errors.

        if (response.ok) {
          const config = await response.json();
          setNamespace(config.defaultNamespace);
        } else {
          console.warn(`Failed to fetch config: ${response.status} ${response.statusText}. Using default namespace.`);
        }

} catch (error) {
console.warn('Failed to fetch config, using default namespace');
}
};

fetchConfig();
}, []);

const handleSaveGraphTemplate = async (template: UpsertGraphTemplateRequest) => {
try {
await clientApiService.upsertGraphTemplate(namespace, graphName, template);
Expand Down