Skip to content

Commit

Permalink
Updated Ram and Disk MB, GB and TB conversion to binary
Browse files Browse the repository at this point in the history
Updated Ram and Disk MB, GB and TB conversion to binary
  • Loading branch information
cp6 committed Mar 13, 2022
1 parent 8195fba commit f3c3d3a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public function store(Request $request)
'location_id' => $request->location_id,
'ram' => $request->ram,
'ram_type' => $request->ram_type,
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram / 1000),
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram * 1024),
'disk' => $request->disk,
'disk_type' => $request->disk_type,
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1000),
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1024),
'owned_since' => $request->owned_since,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
Expand Down Expand Up @@ -268,10 +268,10 @@ public function update(Request $request, Server $server)
'location_id' => $request->location_id,
'ram' => $request->ram,
'ram_type' => $request->ram_type,
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram / 1000),
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram * 1024),
'disk' => $request->disk,
'disk_type' => $request->disk_type,
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1000),
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1024),
'owned_since' => $request->owned_since,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/YabsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ public function store(Request $request)
->update([
'ram' => $yabs['ram'],
'ram_type' => $yabs['ram_type'],
'ram_as_mb' => ($yabs['ram_type'] === 'GB') ? ($yabs['ram'] * 1000) : $yabs['ram'],
'ram_as_mb' => ($yabs['ram_type'] === 'GB') ? ($yabs['ram'] * 1024) : $yabs['ram'],
'disk' => $yabs['disk'],
'disk_type' => $yabs['disk_type'],
'disk_as_gb' => ($yabs['disk_type'] === 'TB') ? ($yabs['disk'] * 1000) : $yabs['disk'],
'disk_as_gb' => ($yabs['disk_type'] === 'TB') ? ($yabs['disk'] * 1024) : $yabs['disk'],
'cpu' => $yabs['cpu_cores'],
'has_yabs' => 1
]);
Expand Down
6 changes: 3 additions & 3 deletions app/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ private function TBtoGB(string $tb): float
private function GBpstoMBps(string $gbps, bool $format = false): float
{//Gigabits to Megabits
if ($format) {
return (float)number_format(((float)$gbps * 1000), 3);
return (float)number_format(((float)$gbps * 1024), 3);
}
return (float)$gbps * 1000;
return (float)$gbps * 1024;
}

private function diskSpeedAsMbps(string $type, string $value): float
Expand All @@ -105,7 +105,7 @@ private function diskSpeedAsMbps(string $type, string $value): float
return $this->GBpstoMBps($value);
}
if ($type === "KB/s") {
return (float)($value / 1000);
return (float)($value / 1024);
}
return $value;
}
Expand Down
6 changes: 3 additions & 3 deletions resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<div class="card">
<div class="card-body text-center shadow">
<div class="row">
<h4>{{$information['servers_summary']['ram_mb_sum'] / 1000}} <small
<h4>{{$information['servers_summary']['ram_mb_sum'] / 1024}} <small
class="text-muted">GB</small></h4>
<p>Ram</p>
</div>
Expand All @@ -159,7 +159,7 @@ class="text-muted">GB</small></h4>
<div class="row">
<h4>
@if($information['servers_summary']['disk_gb_sum'] >= 1000)
{{$information['servers_summary']['disk_gb_sum'] / 1000}} <small
{{$information['servers_summary']['disk_gb_sum'] / 1024}} <small
class="text-muted">TB</small>
@else
{{$information['servers_summary']['disk_gb_sum']}} <small
Expand All @@ -175,7 +175,7 @@ class="text-muted">GB</small>
<div class="card">
<div class="card-body text-center shadow">
<div class="row">
<h4>{{$information['servers_summary']['bandwidth_sum'] / 1000}} <small
<h4>{{$information['servers_summary']['bandwidth_sum'] / 1024}} <small
class="text-muted">TB</small></h4>
<p>Bandwidth</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/servers/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ class="text-body mx-1">
<td class="text-center">{{$server->cpu}}</td>
<td class="text-center">
@if($server->ram_as_mb > 1024)
{{ number_format(($server->ram_as_mb / 1000),0) }}<small>GB</small>
{{ number_format(($server->ram_as_mb / 1024),0) }}<small>GB</small>
@else
{{$server->ram_as_mb}}<small>MB</small>
@endif
</td>
<td class="text-center">
@if($server->disk > 1000)
{{ number_format(($server->disk / 1000),1) }}<small>TB</small>
{{ number_format(($server->disk / 1024),1) }}<small>TB</small>
@else
{{$server->disk}}<small>GB</small>
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/servers/public-index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</td>
<td class="text-nowrap">
@if($s->disk > 1000)
{{ number_format(($s->disk / 1000),1) }}<small>TB</small>
{{ number_format(($s->disk / 1024),1) }}<small>TB</small>
@else
{{$s->disk}}<small>GB</small>
@endif
Expand Down

0 comments on commit f3c3d3a

Please sign in to comment.