Skip to content

Commit e33b179

Browse files
authored
Show CPU limit next to CPU usage (pterodactyl#3307)
1 parent 647d2cb commit e33b179

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

resources/scripts/components/dashboard/ServerRow.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default ({ server, className }: { server: Server; className?: string }) =
7676

7777
const diskLimit = server.limits.disk !== 0 ? megabytesToHuman(server.limits.disk) : 'Unlimited';
7878
const memoryLimit = server.limits.memory !== 0 ? megabytesToHuman(server.limits.memory) : 'Unlimited';
79+
const cpuLimit = server.limits.cpu !== 0 ? server.limits.cpu + ' %' : 'Unlimited';
7980

8081
return (
8182
<StatusIndicatorBox as={Link} to={`/server/${server.id}`} className={className} $status={stats?.status}>
@@ -130,12 +131,15 @@ export default ({ server, className }: { server: Server; className?: string }) =
130131
<Spinner size={'small'}/>
131132
:
132133
<React.Fragment>
133-
<div css={tw`flex-1 flex md:ml-4 sm:flex hidden justify-center`}>
134+
<div css={tw`flex-1 ml-4 sm:block hidden`}>
135+
<div css={tw`flex justify-center`}>
134136
<Icon icon={faMicrochip} $alarm={alarms.cpu}/>
135137
<IconDescription $alarm={alarms.cpu}>
136-
{stats.cpuUsagePercent} %
138+
{stats.cpuUsagePercent.toFixed(2)} %
137139
</IconDescription>
138140
</div>
141+
<p css={tw`text-xs text-neutral-600 text-center mt-1`}>of {cpuLimit}</p>
142+
</div>
139143
<div css={tw`flex-1 ml-4 sm:block hidden`}>
140144
<div css={tw`flex justify-center`}>
141145
<Icon icon={faMemory} $alarm={alarms.memory}/>
@@ -160,4 +164,4 @@ export default ({ server, className }: { server: Server; className?: string }) =
160164
<div className={'status-bar'}/>
161165
</StatusIndicatorBox>
162166
);
163-
};
167+
};

resources/scripts/components/server/ServerDetailsBlock.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const ServerDetailsBlock = () => {
7474

7575
const diskLimit = limits.disk ? megabytesToHuman(limits.disk) : 'Unlimited';
7676
const memoryLimit = limits.memory ? megabytesToHuman(limits.memory) : 'Unlimited';
77+
const cpuLimit = limits.cpu ? limits.cpu + '%' : 'Unlimited';
7778

7879
return (
7980
<TitledGreyBox css={tw`break-words`} title={name} icon={faServer}>
@@ -96,6 +97,7 @@ const ServerDetailsBlock = () => {
9697
</CopyOnClick>
9798
<p css={tw`text-xs mt-2`}>
9899
<FontAwesomeIcon icon={faMicrochip} fixedWidth css={tw`mr-1`}/> {stats.cpu.toFixed(2)}%
100+
<span css={tw`text-neutral-500`}> / {cpuLimit}</span>
99101
</p>
100102
<p css={tw`text-xs mt-2`}>
101103
<FontAwesomeIcon icon={faMemory} fixedWidth css={tw`mr-1`}/> {bytesToHuman(stats.memory)}

0 commit comments

Comments
 (0)