diff --git a/react/src/components/MainLayout/WebUISider.tsx b/react/src/components/MainLayout/WebUISider.tsx index 7eb69a347d..617b4b17c3 100644 --- a/react/src/components/MainLayout/WebUISider.tsx +++ b/react/src/components/MainLayout/WebUISider.tsx @@ -260,18 +260,19 @@ const WebUISider: React.FC = (props) => { ]); const adminMenu: MenuProps['items'] = filterOutEmpty([ + // TODO: Enable the menu item when the page is ready. // WARN: Currently only superadmins can access AdminDashboardPage. // To place the Admin Dashboard menu item at the top of adminMenu, // add it to adminMenu instead of superAdminMenu: - currentUserRole === 'superadmin' && { - label: ( - - {t('webui.menu.AdminDashboard')} - - ), - icon: , - key: 'admin-dashboard', - }, + // currentUserRole === 'superadmin' && { + // label: ( + // + // {t('webui.menu.AdminDashboard')} + // + // ), + // icon: , + // key: 'admin-dashboard', + // }, { label: {t('webui.menu.Users')}, icon: , diff --git a/react/src/pages/DashboardPage.tsx b/react/src/pages/DashboardPage.tsx index e51a5665ff..e5fbbe7be9 100644 --- a/react/src/pages/DashboardPage.tsx +++ b/react/src/pages/DashboardPage.tsx @@ -7,7 +7,11 @@ import SessionCountDashboardItem from '../components/SessionCountDashboardItem'; import TotalResourceWithinResourceGroup, { useIsAvailableTotalResourceWithinResourceGroup, } from '../components/TotalResourceWithinResourceGroup'; -import { INITIAL_FETCH_KEY, useFetchKey } from '../hooks'; +import { + INITIAL_FETCH_KEY, + useFetchKey, + useSuspendedBackendaiClient, +} from '../hooks'; import { useBAISettingUserState } from '../hooks/useBAISetting'; import { useCurrentProjectValue, @@ -20,6 +24,8 @@ import _ from 'lodash'; import { Suspense, useTransition } from 'react'; import { useTranslation } from 'react-i18next'; import { graphql, useLazyLoadQuery } from 'react-relay'; +import ActiveAgents from 'src/components/ActiveAgents'; +import AgentStats from 'src/components/AgentStats'; import { useCurrentUserRole } from 'src/hooks/backendai'; const DashboardPage: React.FC = () => { @@ -29,6 +35,7 @@ const DashboardPage: React.FC = () => { const currentProject = useCurrentProjectValue(); const currentResourceGroup = useCurrentResourceGroupValue(); const userRole = useCurrentUserRole(); + const baiClient = useSuspendedBackendaiClient(); const [fetchKey, updateFetchKey] = useFetchKey(); const [isPendingIntervalRefetch, startIntervalRefetchTransition] = @@ -40,6 +47,8 @@ const DashboardPage: React.FC = () => { const isAvailableTotalResourcePanel = useIsAvailableTotalResourceWithinResourceGroup(); + const isAgentStatsSupported = baiClient.supports('agent-stats'); + const queryRef = useLazyLoadQuery( graphql` query DashboardPageQuery( @@ -59,6 +68,7 @@ const DashboardPage: React.FC = () => { isSuperAdmin: $isSuperAdmin agentNodeFilter: $agentNodeFilter ) + ...AgentStatsFragment @include(if: $isSuperAdmin) @alias } `, { @@ -98,9 +108,13 @@ const DashboardPage: React.FC = () => { } > ), @@ -157,6 +171,57 @@ const DashboardPage: React.FC = () => { ), }, }, + _.isEqual(userRole, 'superadmin') && + isAgentStatsSupported && + queryRef.AgentStatsFragment && { + id: 'agentStats', + rowSpan: 2, + columnSpan: 2, + definition: { + minRowSpan: 2, + minColumnSpan: 2, + }, + data: { + content: ( + + } + > + + + ), + }, + }, + _.isEqual(userRole, 'superadmin') && { + id: 'activeAgents', + rowSpan: 4, + columnSpan: 4, + definition: { + minRowSpan: 3, + minColumnSpan: 4, + }, + data: { + content: ( + + } + > + updateFetchKey()} + /> + + ), + }, + }, { id: 'recentlyCreatedSession', rowSpan: 3,