Skip to content

Commit e80b125

Browse files
Add network info
Adds network info to the server details section, Also copied to clipboard when clicked. Closes pterodactyl#2585
1 parent 9ff691b commit e80b125

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

resources/scripts/components/server/ServerDetailsBlock.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React, { useEffect, useState } from 'react';
22
import tw from 'twin.macro';
3-
import { faCircle, faHdd, faMemory, faMicrochip, faServer } from '@fortawesome/free-solid-svg-icons';
3+
import { faCircle, faEthernet, faHdd, faMemory, faMicrochip, faServer } from '@fortawesome/free-solid-svg-icons';
44
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
55
import { bytesToHuman, megabytesToHuman } from '@/helpers';
66
import TitledGreyBox from '@/components/elements/TitledGreyBox';
77
import { ServerContext } from '@/state/server';
8+
import CopyOnClick from '@/components/elements/CopyOnClick';
89

910
interface Stats {
1011
memory: number;
@@ -49,6 +50,9 @@ const ServerDetailsBlock = () => {
4950

5051
const name = ServerContext.useStoreState(state => state.server.data!.name);
5152
const limits = ServerContext.useStoreState(state => state.server.data!.limits);
53+
const primaryAllocation = ServerContext.useStoreState(state => state.server.data!.allocations.filter(alloc => alloc.isDefault).map(
54+
allocation => allocation.alias + ':' + allocation.port || allocation.ip + ':' + allocation.port
55+
)).toString();
5256

5357
const disklimit = limits.disk ? megabytesToHuman(limits.disk) : 'Unlimited';
5458
const memorylimit = limits.memory ? megabytesToHuman(limits.memory) : 'Unlimited';
@@ -66,6 +70,12 @@ const ServerDetailsBlock = () => {
6670
/>
6771
 {!status ? 'Connecting...' : status}
6872
</p>
73+
<CopyOnClick text={primaryAllocation}>
74+
<p css={tw`text-xs mt-2`}>
75+
<FontAwesomeIcon icon={faEthernet} fixedWidth css={tw`mr-1`}/>
76+
<code css={tw`ml-1`}>{primaryAllocation}</code>
77+
</p>
78+
</CopyOnClick>
6979
<p css={tw`text-xs mt-2`}>
7080
<FontAwesomeIcon icon={faMicrochip} fixedWidth css={tw`mr-1`}/> {stats.cpu.toFixed(2)}%
7181
</p>

0 commit comments

Comments
 (0)