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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ class SettingsInitializer(UserInitializerBase):
"is_multiple": False,
"tags": '["auto_generated", "ui"]'
},
{
"id": "branding_logo_settings",
"name": "Branding Logo Settings",
"description": "Light/dark logo URLs and alt text",
"category": "ui",
"type": "object",
"default_value": '{"light": "/braindrive/braindrive-light.svg", "dark": "/braindrive/braindrive-dark.svg", "alt": "BrainDrive"}',
"allowed_scopes": '["system", "user"]',
"validation": None,
"is_multiple": False,
"tags": '["auto_generated", "ui"]'
},
{
"id": "copyright_settings",
"name": "Copyright",
"description": "Footer copyright line content",
"category": "ui",
"type": "object",
"default_value": '{"text": "© 2025 BrainDrive"}',
"allowed_scopes": '["system", "user"]',
"validation": None,
"is_multiple": False,
"tags": '["auto_generated", "ui"]'
},
{
"id": "ollama_servers_settings",
"name": "Ollama Servers Settings",
Expand Down Expand Up @@ -96,6 +120,20 @@ class SettingsInitializer(UserInitializerBase):
"scope": "user",
"page_id": None
},
{
"definition_id": "branding_logo_settings",
"name": "Branding Logo Settings",
"value": '{"light": "/braindrive/braindrive-light.svg", "dark": "/braindrive/braindrive-dark.svg", "alt": "BrainDrive"}',
"scope": "user",
"page_id": None
},
{
"definition_id": "copyright_settings",
"name": "Copyright",
"value": '{"text": "© 2025 BrainDrive"}',
"scope": "user",
"page_id": None
},
{
"definition_id": "ollama_servers_settings",
"name": "Ollama Servers Settings",
Expand Down
56 changes: 55 additions & 1 deletion frontend/src/components/dashboard/DashboardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,57 @@ import { Outlet } from 'react-router-dom';
import Header from './Header';
import Sidebar from './Sidebar';
import { ThemeSelector } from '../ThemeSelector';
import { useSettings } from '../../contexts/ServiceContext';

const DRAWER_WIDTH = 240;

const DashboardLayout = () => {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
const [sidebarOpen, setSidebarOpen] = useState(!isMobile);
const settingsService = useSettings();
const defaultCopyright = { text: '© 2025 BrainDrive' };
const [copyright, setCopyright] = useState(defaultCopyright);

// Update sidebar state when screen size changes
useEffect(() => {
setSidebarOpen(!isMobile);
}, [isMobile]);

// Load copyright setting
useEffect(() => {
let active = true;
(async () => {
try {
const value = await settingsService.getSetting<any>('copyright_settings');
if (!active) return;
if (value) {
if (typeof value === 'string') {
try {
const parsed = JSON.parse(value);
if (parsed && parsed.text) {
// Only update if we have text; else keep default
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
setCopyright({ text: parsed.text });
}
} catch {
// Ignore parse errors, keep default
}
} else if (typeof value === 'object' && value.text) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
setCopyright({ text: value.text });
}
}
} catch {
// Keep default on error
}
})();
return () => {
active = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const handleToggleSidebar = () => {
setSidebarOpen(!sidebarOpen);
};
Expand All @@ -39,6 +77,8 @@ const DashboardLayout = () => {
flexGrow: 1,
p: { xs: 1, sm: 2 },
width: '100%',
display: 'flex',
flexDirection: 'column',
marginLeft: {
xs: 0,
sm: sidebarOpen ? 0 : `-${DRAWER_WIDTH}px`
Expand All @@ -49,15 +89,29 @@ const DashboardLayout = () => {
}),
}}
>
<Toolbar /> {/* This creates space for the header */}
<Toolbar /> {/* Spacer for header */}
<Box
sx={{
maxWidth: '100%',
overflow: 'hidden',
flexGrow: 1,
}}
>
<Outlet />
</Box>
<Box
component="footer"
sx={{
borderTop: `1px solid ${theme.palette.divider}`,
color: 'text.secondary',
typography: 'caption',
textAlign: 'center',
pt: 1,
mt: 1,
}}
>
{copyright.text}
</Box>
</Box>
</Box>
);
Expand Down
56 changes: 51 additions & 5 deletions frontend/src/components/dashboard/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MenuIcon from '@mui/icons-material/Menu';
import MenuOpenIcon from '@mui/icons-material/MenuOpen';
import { useAuth } from '../../contexts/AuthContext';
import { useLocation } from 'react-router-dom';
import { useSettings } from '../../contexts/ServiceContext';

// Declare a global interface for the Window object
declare global {
Expand All @@ -35,6 +36,15 @@ const Header = ({ onToggleSidebar, rightContent, sidebarOpen }: HeaderProps) =>
const theme = useTheme();
const { user, logout } = useAuth();
const location = useLocation();
const settingsService = useSettings();

type BrandingLogo = { light: string; dark: string; alt?: string };
const defaultBranding: BrandingLogo = {
light: '/braindrive/braindrive-light.svg',
dark: '/braindrive/braindrive-dark.svg',
alt: 'BrainDrive',
};
const [branding, setBranding] = useState<BrandingLogo>(defaultBranding);

// State to track the global variables
const [pageTitle, setPageTitle] = useState<string>('');
Expand Down Expand Up @@ -94,6 +104,45 @@ const Header = ({ onToggleSidebar, rightContent, sidebarOpen }: HeaderProps) =>
return () => clearInterval(intervalId);
}, [pageTitle, isStudioPage, location.pathname]);

// Load branding logo settings
useEffect(() => {
let active = true;
(async () => {
try {
const value = await settingsService.getSetting<any>('branding_logo_settings');
if (!active) return;
if (value) {
if (typeof value === 'string') {
try {
const parsed = JSON.parse(value);
setBranding({
light: parsed?.light || defaultBranding.light,
dark: parsed?.dark || defaultBranding.dark,
alt: parsed?.alt || defaultBranding.alt,
});
} catch {
setBranding(defaultBranding);
}
} else if (typeof value === 'object') {
setBranding({
light: value?.light || defaultBranding.light,
dark: value?.dark || defaultBranding.dark,
alt: value?.alt || defaultBranding.alt,
});
}
} else {
setBranding(defaultBranding);
}
} catch {
setBranding(defaultBranding);
}
})();
return () => {
active = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const handleMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
Expand Down Expand Up @@ -131,11 +180,8 @@ const Header = ({ onToggleSidebar, rightContent, sidebarOpen }: HeaderProps) =>
}}
>
<img
src={theme.palette.mode === 'dark'
? '/braindrive/braindrive-dark.svg'
: '/braindrive/braindrive-light.svg'
}
alt="BrainDrive.ai Plugin Studio"
src={theme.palette.mode === 'dark' ? branding.dark : branding.light}
alt={branding.alt || 'BrainDrive'}
style={{
height: '32px',
width: 'auto',
Expand Down