Skip to content

Commit

Permalink
Add Namespaces to the director UI
Browse files Browse the repository at this point in the history
- Add iconography to the server list to indicate type
  • Loading branch information
CannonLock committed Nov 18, 2024
1 parent 78ae774 commit 0ac23a2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 24 deletions.
4 changes: 2 additions & 2 deletions web_ui/frontend/app/director/components/NamespaceDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const NamespaceDropdown = ({
<Grid item xs={12} md={12}>
<InformationSpan name={'Path'} value={namespace.path} />
<InformationSpanHeader title={'Token Generation'} />
{namespace.tokenGeneration.map((tg) =>
{namespace.tokenGeneration?.map((tg) =>
<Fragment key={tg.issuer}>
<InformationSpan indent={1} name={'Issuer'} value={tg.issuer} />
<InformationSpan indent={2} name={'Strategy'} value={tg.strategy} />
Expand All @@ -31,7 +31,7 @@ export const NamespaceDropdown = ({
</Fragment>
)}
<InformationSpanHeader title={'Token Issuer'} />
{namespace.tokenIssuer.map((ti) =>
{namespace.tokenIssuer?.map((ti) =>
<Fragment key={ti.issuer}>
<InformationSpan indent={1} name={'Issuer'} value={ti.issuer} />
<InformationSpanHeader indent={2} title={"Base Paths"} />
Expand Down
70 changes: 53 additions & 17 deletions web_ui/frontend/components/Namespace/NamespaceIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,102 @@
import { Avatar, Box, Tooltip } from '@mui/material';
import { FolderOpen, Storage, TripOrigin } from '@mui/icons-material';
import React from 'react';
import React, { useMemo } from 'react';

const NamespaceIcon = ({
serverType: prefixType,
serverType,
size,
color = 'white',
bgcolor = 'primary.main',
}: {
serverType: 'origin' | 'cache' | 'namespace';
size?: 'large' | 'medium' | 'small';
color?: string;
bgcolor?: string;
}) => {
if (prefixType == 'namespace') {

const avatarPixelSize = useMemo(() => {
switch (size) {
case 'large':
return 50;
case 'medium':
return 30;
case 'small':
return 20;
default:
return 30;
}
}, [size])

const iconPixelSize = useMemo(() => {
switch (size) {
case 'large':
return 30;
case 'medium':
return 24;
case 'small':
return 15;
default:
return 24;
}
}, [])

if (serverType == 'namespace') {
return (
<Box>
<Tooltip title={'Namespace'} placement={'left'}>
<Avatar
sizes={'small'}
sx={{
height: '30px',
width: '30px',
height: avatarPixelSize,
width: avatarPixelSize,
my: 'auto',
mr: 1,
bgcolor: 'primary.main',
bgcolor
}}
>
<FolderOpen />
<FolderOpen sx={{fontSize: iconPixelSize}} htmlColor={color} />
</Avatar>
</Tooltip>
</Box>
);
}

if (prefixType == 'origin') {
if (serverType == 'origin') {
return (
<Box>
<Tooltip title={'Origin'} placement={'left'}>
<Avatar
sizes={'small'}
sx={{
height: '30px',
width: '30px',
height: avatarPixelSize,
width: avatarPixelSize,
my: 'auto',
mr: 1,
bgcolor: 'primary.main',
bgcolor
}}
>
<TripOrigin />
<TripOrigin sx={{fontSize: iconPixelSize}} htmlColor={color} />
</Avatar>
</Tooltip>
</Box>
);
}

if (prefixType == 'cache') {
if (serverType == 'cache') {
return (
<Box>
<Tooltip title={'Cache'} placement={'left'}>
<Avatar
sizes={'small'}
sx={{
height: '30px',
width: '30px',
height: avatarPixelSize,
width: avatarPixelSize,
my: 'auto',
mr: 1,
bgcolor: 'primary.main',
bgcolor
}}
>
<Storage />
<Storage sx={{fontSize: iconPixelSize}} htmlColor={color} />
</Avatar>
</Tooltip>
</Box>
Expand Down
11 changes: 8 additions & 3 deletions web_ui/frontend/components/NamespaceCapabilitiesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
*/

import { Namespace, ServerDetailed, ServerGeneral } from '@/types';
import { Box, Grid, Typography } from '@mui/material';
import { Box, Grid, Typography, useTheme } from '@mui/material';
import { CapabilitiesRow } from '@/app/director/components/DirectorDropdown';
import { grey } from '@mui/material/colors';
import { NamespaceIcon } from '@/components/Namespace';

interface NamespaceCapabilitiesTableProps {
namespace: Namespace
Expand All @@ -27,6 +28,9 @@ export const NamespaceCapabilitiesTable = ({
namespace,
servers
}: NamespaceCapabilitiesTableProps) => {

const theme = useTheme();

return (
<Grid container spacing={1}>
<Grid item xs={12}>
Expand All @@ -41,7 +45,7 @@ export const NamespaceCapabilitiesTable = ({
<Grid item xs={3}>
<Box display={'flex'} height={'100%'}>
<Typography variant={'body2'} my={'auto'}>
{namespace.path} Capabilities
Namespace Capabilities
</Typography>
</Box>
</Grid>
Expand All @@ -60,7 +64,8 @@ export const NamespaceCapabilitiesTable = ({
<Grid container spacing={1}>
<Grid item xs={3}>
<Box display={'flex'} height={'100%'}>
<Typography variant={'body2'} my={'auto'}>
<Typography variant={'body2'} my={'auto'} display={"flex"}>
<NamespaceIcon serverType={server.type.toLowerCase() as 'origin' | 'cache'} size={"small"} bgcolor={"white"} color={theme.palette.primary.main} />
{server.name}
</Typography>
</Box>
Expand Down
4 changes: 2 additions & 2 deletions web_ui/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface TokenIssuer {
export interface Namespace {
path: string;
capabilities: Capabilities;
tokenGeneration: TokenGeneration[];
tokenIssuer: TokenIssuer[];
tokenGeneration: TokenGeneration[] | null;
tokenIssuer: TokenIssuer[] | null;
fromTopology: boolean;
caches: string[];
origins: string[];
Expand Down

0 comments on commit 0ac23a2

Please sign in to comment.