Skip to content

Commit de943ea

Browse files
authored
Merge pull request pterodactyl#2636 from AreYouRlyScared/copynetwork
Network info added to details + ClickToCopy
2 parents 74b1776 + e340cf1 commit de943ea

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
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.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>

resources/scripts/routers/ServerRouter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
103103
<Can action={'backup.*'}>
104104
<NavLink to={`${match.url}/backups`}>Backups</NavLink>
105105
</Can>
106-
<Can action={'allocations.*'}>
106+
<Can action={'allocation.*'}>
107107
<NavLink to={`${match.url}/network`}>Network</NavLink>
108108
</Can>
109109
<Can action={'startup.*'}>

0 commit comments

Comments
 (0)