feat: add server count in desktop layout
This commit is contained in:
parent
92f8700254
commit
720a1d744e
@ -81,7 +81,7 @@ export const DesktopLayout: React.FC<LayoutProps> = React.memo((props) => {
|
||||
},
|
||||
{
|
||||
title: t('Servers'),
|
||||
label: '',
|
||||
label: String(serviceCount?.server ?? ''),
|
||||
icon: LuServer,
|
||||
to: '/server',
|
||||
},
|
||||
|
@ -1,4 +1,3 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { ServerStatusInfo } from '../../types';
|
||||
import { createSubscribeInitializer, subscribeEventBus } from '../ws/shared';
|
||||
import _ from 'lodash';
|
||||
@ -75,3 +74,11 @@ export function clearOfflineServerStatus(workspaceId: string) {
|
||||
|
||||
return serverMap[workspaceId];
|
||||
}
|
||||
|
||||
export function getServerCount(workspaceId: string): number {
|
||||
if (!serverMap[workspaceId]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Object.keys(serverMap[workspaceId]).length;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import { workspaceDashboardLayoutSchema } from '../../model/_schema';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { OPENAPI_TAG } from '../../utils/const';
|
||||
import { OpenApiMeta } from 'trpc-openapi';
|
||||
import { getServerCount } from '../../model/serverStatus';
|
||||
|
||||
export const workspaceRouter = router({
|
||||
getUserWorkspaceRole: publicProcedure
|
||||
@ -46,6 +47,7 @@ export const workspaceRouter = router({
|
||||
z.object({
|
||||
website: z.number(),
|
||||
monitor: z.number(),
|
||||
server: z.number(),
|
||||
telemetry: z.number(),
|
||||
page: z.number(),
|
||||
})
|
||||
@ -76,9 +78,12 @@ export const workspaceRouter = router({
|
||||
}),
|
||||
]);
|
||||
|
||||
const server = getServerCount(workspaceId);
|
||||
|
||||
return {
|
||||
website,
|
||||
monitor,
|
||||
server,
|
||||
telemetry,
|
||||
page,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user