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'),
|
title: t('Servers'),
|
||||||
label: '',
|
label: String(serviceCount?.server ?? ''),
|
||||||
icon: LuServer,
|
icon: LuServer,
|
||||||
to: '/server',
|
to: '/server',
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import dayjs from 'dayjs';
|
|
||||||
import { ServerStatusInfo } from '../../types';
|
import { ServerStatusInfo } from '../../types';
|
||||||
import { createSubscribeInitializer, subscribeEventBus } from '../ws/shared';
|
import { createSubscribeInitializer, subscribeEventBus } from '../ws/shared';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@ -75,3 +74,11 @@ export function clearOfflineServerStatus(workspaceId: string) {
|
|||||||
|
|
||||||
return serverMap[workspaceId];
|
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 { Prisma } from '@prisma/client';
|
||||||
import { OPENAPI_TAG } from '../../utils/const';
|
import { OPENAPI_TAG } from '../../utils/const';
|
||||||
import { OpenApiMeta } from 'trpc-openapi';
|
import { OpenApiMeta } from 'trpc-openapi';
|
||||||
|
import { getServerCount } from '../../model/serverStatus';
|
||||||
|
|
||||||
export const workspaceRouter = router({
|
export const workspaceRouter = router({
|
||||||
getUserWorkspaceRole: publicProcedure
|
getUserWorkspaceRole: publicProcedure
|
||||||
@ -46,6 +47,7 @@ export const workspaceRouter = router({
|
|||||||
z.object({
|
z.object({
|
||||||
website: z.number(),
|
website: z.number(),
|
||||||
monitor: z.number(),
|
monitor: z.number(),
|
||||||
|
server: z.number(),
|
||||||
telemetry: z.number(),
|
telemetry: z.number(),
|
||||||
page: z.number(),
|
page: z.number(),
|
||||||
})
|
})
|
||||||
@ -76,9 +78,12 @@ export const workspaceRouter = router({
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const server = getServerCount(workspaceId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
website,
|
website,
|
||||||
monitor,
|
monitor,
|
||||||
|
server,
|
||||||
telemetry,
|
telemetry,
|
||||||
page,
|
page,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user