Display traffic graphs properly for both split and combined traffic accounting

feature/node-rewrite
Sven Slootweg 12 years ago
parent 4e6549cbc9
commit e1860d6c97

@ -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

@ -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(

@ -1,27 +1,58 @@
<h1>{%!title-overview}</h1>
<div class="quota">
<div class="quota-item">
<h3>{%!overview-quota-title-disk}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?disk-percentage}%;"></div>
<div class="quota-bar-label">{%?disk-used}/{%?disk-total}{%?disk-unit}</div>
{%if traffic-split == false}
<div class="quota-item">
<h3>{%!overview-quota-title-disk}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?disk-percentage}%;"></div>
<div class="quota-bar-label">{%?disk-used}/{%?disk-total}{%?disk-unit}</div>
</div>
</div>
</div>
<div class="quota-item">
<h3>{%!overview-quota-title-ram}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?ram-percentage}%;"></div>
<div class="quota-bar-label">{%?ram-used}/{%?ram-total}{%?ram-unit}</div>
<div class="quota-item">
<h3>{%!overview-quota-title-ram}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?ram-percentage}%;"></div>
<div class="quota-bar-label">{%?ram-used}/{%?ram-total}{%?ram-unit}</div>
</div>
</div>
</div>
<div class="quota-item last">
<h3>{%!overview-quota-title-traffic}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?traffic-percentage}%;"></div>
<div class="quota-bar-label">{%?traffic-used}/{%?traffic-total}{%?traffic-unit}</div>
<div class="quota-item last">
<h3>{%!overview-quota-title-traffic}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?traffic-percentage}%;"></div>
<div class="quota-bar-label">{%?traffic-used}/{%?traffic-total}{%?traffic-unit}</div>
</div>
</div>
</div>
{%else}
<div class="quota-item wide">
<h3>{%!overview-quota-title-disk}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?disk-percentage}%;"></div>
<div class="quota-bar-label">{%?disk-used}/{%?disk-total}{%?disk-unit}</div>
</div>
</div>
<div class="quota-item wide last">
<h3>{%!overview-quota-title-ram}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?ram-percentage}%;"></div>
<div class="quota-bar-label">{%?ram-used}/{%?ram-total}{%?ram-unit}</div>
</div>
</div>
<div class="quota-item wide">
<h3>{%!overview-quota-title-traffic-incoming}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?inbound-percentage}%;"></div>
<div class="quota-bar-label">{%?inbound-used}/{%?inbound-total}{%?inbound-unit}</div>
</div>
</div>
<div class="quota-item wide last">
<h3>{%!overview-quota-title-traffic-outgoing}</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: {%?outbound-percentage}%;"></div>
<div class="quota-bar-label">{%?outbound-used}/{%?outbound-total}{%?outbound-unit}</div>
</div>
</div>
{%/if}
<div class="clear"></div>
</div>

Loading…
Cancel
Save