From e80b125543c427154d4d6abca2ae1465feef30b5 Mon Sep 17 00:00:00 2001
From: Charles Morgan
Date: Sun, 1 Nov 2020 02:50:35 -0500
Subject: [PATCH 1/6] Add network info
Adds network info to the server details section, Also copied to clipboard when clicked.
Closes https://github.com/pterodactyl/panel/issues/2585
---
.../scripts/components/server/ServerDetailsBlock.tsx | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index 17a16370c..cc33c493c 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -1,10 +1,11 @@
import React, { useEffect, useState } from 'react';
import tw from 'twin.macro';
-import { faCircle, faHdd, faMemory, faMicrochip, faServer } from '@fortawesome/free-solid-svg-icons';
+import { faCircle, faEthernet, faHdd, faMemory, faMicrochip, faServer } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { bytesToHuman, megabytesToHuman } from '@/helpers';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { ServerContext } from '@/state/server';
+import CopyOnClick from '@/components/elements/CopyOnClick';
interface Stats {
memory: number;
@@ -49,6 +50,9 @@ const ServerDetailsBlock = () => {
const name = ServerContext.useStoreState(state => state.server.data!.name);
const limits = ServerContext.useStoreState(state => state.server.data!.limits);
+ const primaryAllocation = ServerContext.useStoreState(state => state.server.data!.allocations.filter(alloc => alloc.isDefault).map(
+ allocation => allocation.alias + ':' + allocation.port || allocation.ip + ':' + allocation.port
+ )).toString();
const disklimit = limits.disk ? megabytesToHuman(limits.disk) : 'Unlimited';
const memorylimit = limits.memory ? megabytesToHuman(limits.memory) : 'Unlimited';
@@ -66,6 +70,12 @@ const ServerDetailsBlock = () => {
/>
{!status ? 'Connecting...' : status}
+
+
+
+ {primaryAllocation}
+
+
{stats.cpu.toFixed(2)}%
From fc0f8ee48eeb1b2dbf354e857dab1360a0400e28 Mon Sep 17 00:00:00 2001
From: Charles Morgan
Date: Sun, 1 Nov 2020 02:55:29 -0500
Subject: [PATCH 2/6] Update ServerDetailsBlock.tsx
---
resources/scripts/components/server/ServerDetailsBlock.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index cc33c493c..321c01943 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -51,7 +51,7 @@ const ServerDetailsBlock = () => {
const name = ServerContext.useStoreState(state => state.server.data!.name);
const limits = ServerContext.useStoreState(state => state.server.data!.limits);
const primaryAllocation = ServerContext.useStoreState(state => state.server.data!.allocations.filter(alloc => alloc.isDefault).map(
- allocation => allocation.alias + ':' + allocation.port || allocation.ip + ':' + allocation.port
+ allocation => (allocation.alias || allocation.ip) + ':' + allocation.port
)).toString();
const disklimit = limits.disk ? megabytesToHuman(limits.disk) : 'Unlimited';
From c75a621c521c1438dec9850b852a65be93a4cd30 Mon Sep 17 00:00:00 2001
From: Charles Morgan
Date: Mon, 2 Nov 2020 00:49:07 -0500
Subject: [PATCH 3/6] Only show allocation if user has permission
prevents just a blank scetion in the details box if a sub user dosn't have the permission of `allocation.read`
Also fixes the server router where it was set to `allocations` and not `allocation` making it not showup period even if the sub user had the correct permissions.
---
.../components/server/ServerDetailsBlock.tsx | 15 +++++++++------
resources/scripts/routers/ServerRouter.tsx | 2 +-
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index 321c01943..fdd4599c4 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -6,6 +6,7 @@ import { bytesToHuman, megabytesToHuman } from '@/helpers';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { ServerContext } from '@/state/server';
import CopyOnClick from '@/components/elements/CopyOnClick';
+import Can from '@/elements/Can';
interface Stats {
memory: number;
@@ -70,12 +71,14 @@ const ServerDetailsBlock = () => {
/>
{!status ? 'Connecting...' : status}
-
-
-
- {primaryAllocation}
-
-
+
+
+
+
+ {primaryAllocation}
+
+
+
{stats.cpu.toFixed(2)}%
diff --git a/resources/scripts/routers/ServerRouter.tsx b/resources/scripts/routers/ServerRouter.tsx
index ec6bc20b4..f5f8855a8 100644
--- a/resources/scripts/routers/ServerRouter.tsx
+++ b/resources/scripts/routers/ServerRouter.tsx
@@ -100,7 +100,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
Backups
-
+
Network
From 40eee1220c92d4517d342921ce61fd91b91a0e95 Mon Sep 17 00:00:00 2001
From: Charles Morgan
Date: Mon, 2 Nov 2020 02:31:57 -0500
Subject: [PATCH 4/6] Update ServerDetailsBlock.tsx
---
resources/scripts/components/server/ServerDetailsBlock.tsx | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index fdd4599c4..5647253d3 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -6,8 +6,7 @@ import { bytesToHuman, megabytesToHuman } from '@/helpers';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { ServerContext } from '@/state/server';
import CopyOnClick from '@/components/elements/CopyOnClick';
-import Can from '@/elements/Can';
-
+import Can from '@/components/elements/Can';
interface Stats {
memory: number;
cpu: number;
From 274ed6c23290595605f3750501b9196dd821ecac Mon Sep 17 00:00:00 2001
From: Charles Morgan
Date: Mon, 2 Nov 2020 02:32:38 -0500
Subject: [PATCH 5/6] Update ServerDetailsBlock.tsx
---
resources/scripts/components/server/ServerDetailsBlock.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index 5647253d3..bf036d8f9 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -7,6 +7,7 @@ import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { ServerContext } from '@/state/server';
import CopyOnClick from '@/components/elements/CopyOnClick';
import Can from '@/components/elements/Can';
+
interface Stats {
memory: number;
cpu: number;
From e340cf16bff1f29e7fae4273d1c587327ec44237 Mon Sep 17 00:00:00 2001
From: Charles Morgan
Date: Sat, 7 Nov 2020 17:25:05 -0500
Subject: [PATCH 6/6] remove permission based view
recent changes that were made always show the primary allocation to the end users even if they don't have the read permission.
---
.../components/server/ServerDetailsBlock.tsx | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx
index bf036d8f9..321c01943 100644
--- a/resources/scripts/components/server/ServerDetailsBlock.tsx
+++ b/resources/scripts/components/server/ServerDetailsBlock.tsx
@@ -6,7 +6,6 @@ import { bytesToHuman, megabytesToHuman } from '@/helpers';
import TitledGreyBox from '@/components/elements/TitledGreyBox';
import { ServerContext } from '@/state/server';
import CopyOnClick from '@/components/elements/CopyOnClick';
-import Can from '@/components/elements/Can';
interface Stats {
memory: number;
@@ -71,14 +70,12 @@ const ServerDetailsBlock = () => {
/>
{!status ? 'Connecting...' : status}
-
-
-
-
- {primaryAllocation}
-
-
-
+
+
+
+ {primaryAllocation}
+
+
{stats.cpu.toFixed(2)}%