From e1860d6c978ed49796d04bc51f229db5cc8c2f65 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Mon, 17 Dec 2012 19:15:26 +0100 Subject: [PATCH] Display traffic graphs properly for both split and combined traffic accounting --- frontend/locales/english.lng | 2 + frontend/modules/client/vps/lookup.php | 32 +++++++-- .../templates/default/client/vps/lookup.tpl | 67 ++++++++++++++----- 3 files changed, 77 insertions(+), 24 deletions(-) diff --git a/frontend/locales/english.lng b/frontend/locales/english.lng index b397968..a35ba55 100644 --- a/frontend/locales/english.lng +++ b/frontend/locales/english.lng @@ -86,6 +86,8 @@ notfound; The specified VPS was not found. overview-quota-title-disk; Disk space overview-quota-title-ram; RAM overview-quota-title-traffic; Traffic +overview-quota-title-traffic-incoming; Incoming traffic +overview-quota-title-traffic-outgoing; Outgoing traffic overview-title-configuration; VPS configuration overview-title-status; Status overview-title-location; Server location diff --git a/frontend/modules/client/vps/lookup.php b/frontend/modules/client/vps/lookup.php index 8edd62e..e9fe608 100644 --- a/frontend/modules/client/vps/lookup.php +++ b/frontend/modules/client/vps/lookup.php @@ -29,15 +29,15 @@ if(!empty($router->uVariables['action'])) } } -/* TODO: Display incoming and outcoming traffic separately in the graphs when applicable. */ - if($sVps->sTotalTrafficLimit != 0) { $sTrafficLimit = $sVps->sTotalTrafficLimit; + $sTrafficSplit = false; } else { $sTrafficLimit = $sVps->sIncomingTrafficLimit + $sVps->sOutgoingTrafficLimit; + $sTrafficSplit = true; } $sVariables = array( @@ -52,12 +52,32 @@ $sVariables = array( 'outgoing-traffic-limit'=> format_size($sVps->sOutgoingTrafficLimit, 1024, true, 0) . "B", 'bandwidth-limit' => "100mbit", 'status' => $sVps->sStatusText, - 'traffic-used' => number_format(($sVps->sIncomingTrafficUsed + $sVps->sOutgoingTrafficUsed) / 1024 / 1024 / 1024, 2), - 'traffic-total' => number_format($sTrafficLimit / 1024 / 1024 / 1024, 0), - 'traffic-percentage' => number_format(($sVps->sIncomingTrafficUsed + $sVps->sOutgoingTrafficUsed) / $sTrafficLimit, 2), - 'traffic-unit' => "GB" + 'traffic-split' => $sTrafficSplit ); +if($sTrafficSplit == true) +{ + $sVariables = array_merge($sVariables, array( + 'inbound-used' => number_format(($sVps->sIncomingTrafficUsed) / 1024 / 1024 / 1024, 2), + 'inbound-total' => number_format($sIncomingTrafficLimit / 1024 / 1024 / 1024, 0), + 'inbound-percentage' => number_format(($sVps->sIncomingTrafficUsed) / $sTrafficLimit, 2), + 'inbound-unit' => "GB", + 'outbound-used' => number_format(($sVps->sOutgoingTrafficUsed) / 1024 / 1024 / 1024, 2), + 'outbound-total' => number_format($sOutgoingTrafficLimit / 1024 / 1024 / 1024, 0), + 'outbound-percentage' => number_format(($sVps->sOutgoingTrafficUsed) / $sTrafficLimit, 2), + 'outbound-unit' => "GB" + )); +} +else +{ + $sVariables = array_merge($sVariables, array( + 'traffic-used' => number_format(($sVps->sIncomingTrafficUsed + $sVps->sOutgoingTrafficUsed) / 1024 / 1024 / 1024, 2), + 'traffic-total' => number_format($sTrafficLimit / 1024 / 1024 / 1024, 0), + 'traffic-percentage' => number_format(($sVps->sIncomingTrafficUsed + $sVps->sOutgoingTrafficUsed) / $sTrafficLimit, 2), + 'traffic-unit' => "GB" + )); +} + try { $sVariables = array_merge($sVariables, array( diff --git a/frontend/templates/default/client/vps/lookup.tpl b/frontend/templates/default/client/vps/lookup.tpl index dad1683..605fb32 100644 --- a/frontend/templates/default/client/vps/lookup.tpl +++ b/frontend/templates/default/client/vps/lookup.tpl @@ -1,27 +1,58 @@

{%!title-overview}

-
-

{%!overview-quota-title-disk}

-
-
-
{%?disk-used}/{%?disk-total}{%?disk-unit}
+ {%if traffic-split == false} +
+

{%!overview-quota-title-disk}

+
+
+
{%?disk-used}/{%?disk-total}{%?disk-unit}
+
-
-
-

{%!overview-quota-title-ram}

-
-
-
{%?ram-used}/{%?ram-total}{%?ram-unit}
+
+

{%!overview-quota-title-ram}

+
+
+
{%?ram-used}/{%?ram-total}{%?ram-unit}
+
-
-
-

{%!overview-quota-title-traffic}

-
-
-
{%?traffic-used}/{%?traffic-total}{%?traffic-unit}
+
+

{%!overview-quota-title-traffic}

+
+
+
{%?traffic-used}/{%?traffic-total}{%?traffic-unit}
+
-
+ {%else} +
+

{%!overview-quota-title-disk}

+
+
+
{%?disk-used}/{%?disk-total}{%?disk-unit}
+
+
+
+

{%!overview-quota-title-ram}

+
+
+
{%?ram-used}/{%?ram-total}{%?ram-unit}
+
+
+
+

{%!overview-quota-title-traffic-incoming}

+
+
+
{%?inbound-used}/{%?inbound-total}{%?inbound-unit}
+
+
+
+

{%!overview-quota-title-traffic-outgoing}

+
+
+
{%?outbound-used}/{%?outbound-total}{%?outbound-unit}
+
+
+ {%/if}