From ef4410bac67c8df78c4bb34b3cbc8afe62e77c23 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 24 Oct 2021 20:12:17 +0300 Subject: [PATCH 1/3] expose uptime to client resources API endpoint (#3705) resolves #3704 --- app/Transformers/Api/Client/StatsTransformer.php | 1 + resources/scripts/api/server/getServerResourceUsage.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/Transformers/Api/Client/StatsTransformer.php b/app/Transformers/Api/Client/StatsTransformer.php index bbe5afe8..66827bf3 100644 --- a/app/Transformers/Api/Client/StatsTransformer.php +++ b/app/Transformers/Api/Client/StatsTransformer.php @@ -28,6 +28,7 @@ class StatsTransformer extends BaseClientTransformer 'disk_bytes' => Arr::get($data, 'utilization.disk_bytes', 0), 'network_rx_bytes' => Arr::get($data, 'utilization.network.rx_bytes', 0), 'network_tx_bytes' => Arr::get($data, 'utilization.network.tx_bytes', 0), + 'uptime' => Arr::get($data, 'utilization.uptime', 0), ], ]; } diff --git a/resources/scripts/api/server/getServerResourceUsage.ts b/resources/scripts/api/server/getServerResourceUsage.ts index 6b71dcf5..2a4c01cf 100644 --- a/resources/scripts/api/server/getServerResourceUsage.ts +++ b/resources/scripts/api/server/getServerResourceUsage.ts @@ -10,6 +10,7 @@ export interface ServerStats { diskUsageInBytes: number; networkRxInBytes: number; networkTxInBytes: number; + uptime: number; } export default (server: string): Promise => { @@ -23,6 +24,7 @@ export default (server: string): Promise => { diskUsageInBytes: attributes.resources.disk_bytes, networkRxInBytes: attributes.resources.network_rx_bytes, networkTxInBytes: attributes.resources.network_tx_bytes, + uptime: attributes.resources.uptime, })) .catch(reject); }); From c4ab318d5a63b2163ae7190665b0a2f105140af8 Mon Sep 17 00:00:00 2001 From: Samuel Ryberg Date: Sun, 24 Oct 2021 19:21:58 +0200 Subject: [PATCH 2/3] Update docker-compose.example.yml (#3707) --- docker-compose.example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 42b02dba..8ebc8d11 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -57,7 +57,7 @@ services: - cache volumes: - "/srv/pterodactyl/var/:/app/var/" - - "/srv/pterodactyl/nginx/:/etc/nginx/conf.d/" + - "/srv/pterodactyl/nginx/:/etc/nginx/http.d/" - "/srv/pterodactyl/certs/:/etc/letsencrypt/" - "/srv/pterodactyl/logs/:/app/storage/logs" environment: From 4dca4f0aa9ef55cf7046b2ab71c94ab7e7d0d579 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 25 Oct 2021 00:41:01 +0300 Subject: [PATCH 3/3] change display format of the container uptime (#3706) * change display format of the container uptime Display `day, hour, min` if days is more than 0, otherwise default to existing `hour, min, sec`. Removes pads to make it more clean in this new format. * clean the return --- .../components/server/ServerDetailsBlock.tsx | 2 +- .../scripts/components/server/UptimeDuration.tsx | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/resources/scripts/components/server/ServerDetailsBlock.tsx b/resources/scripts/components/server/ServerDetailsBlock.tsx index a87dc3b0..e0706832 100644 --- a/resources/scripts/components/server/ServerDetailsBlock.tsx +++ b/resources/scripts/components/server/ServerDetailsBlock.tsx @@ -92,7 +92,7 @@ const ServerDetailsBlock = () => { />  {!status ? 'Connecting...' : (isInstalling ? 'Installing' : (isTransferring) ? 'Transferring' : status)} {stats.uptime > 0 && - + () } diff --git a/resources/scripts/components/server/UptimeDuration.tsx b/resources/scripts/components/server/UptimeDuration.tsx index 1406450f..98c613a7 100644 --- a/resources/scripts/components/server/UptimeDuration.tsx +++ b/resources/scripts/components/server/UptimeDuration.tsx @@ -1,14 +1,15 @@ import React from 'react'; export default ({ uptime }: { uptime: number }) => { - const hours = Math.floor(Math.floor(uptime) / 60 / 60); + const days = Math.floor(uptime / (24 * 60 * 60)); + const hours = Math.floor(Math.floor(uptime) / 60 / 60 % 24); const remainder = Math.floor(uptime - (hours * 60 * 60)); - const minutes = Math.floor(remainder / 60); + const minutes = Math.floor(remainder / 60 % 60); const seconds = remainder % 60; - return ( - <> - {hours.toString().padStart(2, '0')}:{minutes.toString().padStart(2, '0')}:{seconds.toString().padStart(2, '0')} - - ); + if (days > 0) { + return <>{days}d {hours}h {minutes}m; + } + + return <>{hours}h {minutes}m {seconds}s; };