Updated servers show controller and blade view

Updated servers show controller and blade view
This commit is contained in:
cp6 2022-02-19 23:34:37 +11:00
parent 30e4adcb10
commit e4c961ebb9
2 changed files with 141 additions and 136 deletions

View File

@ -143,15 +143,21 @@ class ServerController extends Controller
->join('providers as p', 's.provider_id', '=', 'p.id') ->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id') ->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id') ->join('os as o', 's.os_id', '=', 'o.id')
->Leftjoin('yabs as y', 's.id', '=', 'y.server_id')
->Leftjoin('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.id', '=', $server->id) ->where('s.id', '=', $server->id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'o.name as os_name', 'pr.*']); ->get(['s.*', 'p.name as provider', 'l.name as location', 'o.name as os_name', 'pr.*', 'y.*', 'ds.*']);
$network_speeds = json_decode(DB::table('network_speed')
->where('network_speed.server_id', '=', $server->id)
->get(),true);
$labels = DB::table('labels_assigned as l') $labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id') ->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $server->id) ->where('l.service_id', '=', $server->id)
->get(['labels.label']); ->get(['labels.label']);
return view('servers.show', compact(['server', 'server_extras', 'labels'])); return view('servers.show', compact(['server', 'server_extras', 'network_speeds', 'labels']));
} }
public function edit(Server $server) public function edit(Server $server)

View File

@ -4,178 +4,177 @@
{{ __('Server details') }} {{ __('Server details') }}
</x-slot> </x-slot>
<div class="container"> <div class="container">
<div class="card shadow mt-3"> <x-card class="shadow mt-3">
<div class="card-body"> <div class="row">
<div class="row"> <div class="col-12 col-md-6 mb-2">
<div class="'col-12 col-lg-6"> <h2>{{ $server->hostname }}</h2>
<div class="table-responsive"> <code>@foreach($labels as $label)
<table class="table table-borderless text-nowrap"> @if($loop->last)
<tbody> {{$label->label}}
<tr> @else
<td class="px-4 py-2 font-bold">Labels</td> {{$label->label}},
<td> @endif
@foreach($labels as $label) @endforeach</code>
@if($loop->last) </div>
{{$label->label}} <div class="col-12 col-md-6 text-md-end">
@else <h6 class="text-muted pe-lg-4">{{ $server->id }}</h6>
{{$label->label}}, @if($server->active !== 1)
@endif <h6 class="text-danger pe-lg-4">not active</h6>
@endforeach @endif
</td> </div>
</tr> </div>
<tr> <div class="row">
<td class="px-4 py-2 font-bold">Id</td> <div class="col-12 col-lg-6">
<td>{{ $server->id }}</td> <div class="table-responsive">
</tr> <table class="table table-borderless text-nowrap">
<tr>
<td class="px-4 py-2 font-bold">Name</td>
<td>{{ $server->hostname }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">OS</td>
<td>{{ $server->osIdAsString((string)$server->os_id) }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Location</td>
<td>{{ $server_extras[0]->location }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Provider</td>
<td>{{ $server_extras[0]->provider_name }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Ipv4</td>
<td><code>{{ $server->ipv4 }}</code></td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Ipv6</td>
<td><code>{{ $server->ipv6 }}</code></td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Price</td>
<td>{{ $server_extras[0]->price }} {{ $server_extras[0]->currency }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Term</td>
<td>{{ $server_extras[0]->term }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">NS1</td>
<td>{{ $server->ns1 }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">NS2</td>
<td>{{ $server->ns2 }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Server type</td>
<td>{{ $server->serviceServerType($server->server_type) }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Owned since</td>
<td>
@if(!is_null($server->owned_since))
{{ date_format(new DateTime($server->owned_since), 'jS F Y') }}
@endif
</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Next due date</td>
<td>
@if(!is_null($server_extras[0]->next_due_date))
{{ date_format(new DateTime($server_extras[0]->next_due_date), 'jS F Y') }}
@endif
</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Created on</td>
<td>{{ date_format($server->created_at, 'jS F Y') }}</td>
</tr>
<tr>
<td class="px-4 py-2 font-bold">Last updated</td>
<td>{{ date_format($server->updated_at, 'jS F Y') }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="'col-12 col-lg-6">
<!--
<table class="table table-borderless">
<tbody> <tbody>
<tr> <tr>
<td class="px-4 py-2 font-bold">CPU</td> <td class="px-2 py-2 font-bold text-muted">Type</td>
<td></td> <td>
{{ $server->serviceServerType($server->server_type) }}
</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">Disk</td> <td class="px-2 py-2 font-bold text-muted">OS</td>
<td></td> <td>{{ $server_extras[0]->os_name }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">Ram</td> <td class="px-2 py-2 font-bold text-muted">Location</td>
<td></td> <td>{{$server_extras[0]->location}}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">Bandwidth</td> <td class="px-2 py-2 font-bold text-muted">Provider</td>
<td></td> <td>{{$server_extras[0]->provider}}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">GB5 single / multi</td> <td class="px-2 py-2 font-bold text-muted">Price</td>
<td></td> <td>{{ $server_extras[0]->price }} {{ $server_extras[0]->currency }}
<small>{{\App\Process::paymentTermIntToString($server_extras[0]->term)}}</small>
</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">GB5 id</td> <td class="px-2 py-2 font-bold text-muted">Next due date</td>
<td></td> <td>{{Carbon\Carbon::parse($server_extras[0]->next_due_date)->diffForHumans()}}
({{Carbon\Carbon::parse($server_extras[0]->next_due_date)->format('d/m/Y')}})
</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2">Disk speeds:</td> <td class="px-2 py-2 font-bold text-muted">CPU</td>
<td>{{ $server_extras[0]->cpu_cores }} <small>@</small> {{ $server_extras[0]->cpu_freq }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">4k</td> <td class="px-2 py-2 font-bold text-muted">RAM</td>
<td></td> <td>{{ $server_extras[0]->ram }} {{ $server_extras[0]->ram_type }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">64k</td> <td class="px-2 py-2 font-bold text-muted">Disk</td>
<td></td> <td>{{ $server_extras[0]->disk }} {{ $server_extras[0]->disk_type }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">512k</td> <td class="px-2 py-2 font-bold text-muted">Bandwidth</td>
<td></td> <td>{{ $server_extras[0]->bandwidth }} GB</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2 font-bold">1m</td> <td class="px-2 py-2 font-bold text-muted">IPv4</td>
<td></td> <td><code>{{ $server_extras[0]->ipv4 }}</code></td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2">Network speed (location|send|receive):</td> <td class="px-2 py-2 font-bold text-muted">IPv6</td>
<td><code>{{ $server_extras[0]->ipv6 }}</code></td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2">London 984<small>MBps</small> 652<small>MBps</small></td> <td class="px-2 py-2 font-bold text-muted">Was promo</td>
<td>{{ ($server_extras[0]->was_promo === 1) ? 'Yes' : 'No' }}</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2">New York 984<small>MBps</small> 652<small>MBps</small></td> <td class="px-2 py-2 font-bold text-muted">Owned since</td>
<td>
@if(!is_null($server->owned_since))
{{ date_format(new DateTime($server->owned_since), 'jS F Y') }}
@endif
</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2">Los Angeles 984<small>MBps</small> 652<small>MBps</small></td> <td class="px-2 py-2 font-bold text-muted">Inserted</td>
<td>
@if(!is_null($server->created_at))
{{ date_format(new DateTime($server->created_at), 'jS M y g:i a') }}
@endif
</td>
</tr> </tr>
<tr> <tr>
<td class="px-4 py-2">Singapore 984<small>MBps</small> 652<small>MBps</small></td> <td class="px-2 py-2 font-bold text-muted">Updated</td>
<td>
@if(!is_null($server->updated_at))
{{ date_format(new DateTime($server->updated_at), 'jS M y g:i a') }}
@endif
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
--> </div>
<a href="{{ route('servers.index') }}"
class="btn btn-success btn-sm mx-2">
Go back
</a>
<a href="{{ route('servers.edit', $server->id) }}"
class="btn btn-primary btn-sm mx-2">
Edit
</a>
</div>
<div class="col-12 col-lg-6">
<div class="table-responsive">
<table class="table table-borderless text-nowrap">
<tbody>
<tr>
<td class="px-2 py-2 font-bold text-muted">GB5 Single/Multi</td>
<td>
{{$server_extras[0]->gb5_single}} / {{$server_extras[0]->gb5_multi}}
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">CPU</td>
<td>{{$server_extras[0]->cpu}}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">AES</td>
<td>{{ ($server_extras[0]->aes === 1) ? 'Yes' : 'No' }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">VM</td>
<td>{{ ($server_extras[0]->vm === 1) ? 'Yes' : 'No' }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Disk 4k</td>
<td>{{$server_extras[0]->d_4k}} <small>{{$server_extras[0]->d_4k_type}}</small></td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Disk 64k</td>
<td>{{$server_extras[0]->d_64k}} <small>{{$server_extras[0]->d_64k_type}}</small></td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Disk 512k</td>
<td>{{$server_extras[0]->d_512k}} <small>{{$server_extras[0]->d_512k_type}}</small></td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Disk 1m</td>
<td>{{$server_extras[0]->d_1m}} <small>{{$server_extras[0]->d_1m_type}}</small></td>
</tr>
<tr>
<td class="px-2 py-2 font-bold">Network speed (s/r)</td>
</tr>
@foreach($network_speeds as $ns)
<tr>
<td class="px-2 py-2 font-bold text-muted">{{$ns['location']}}</td>
<td>{{$ns['send']}} <small>{{$ns['send_type']}}</small> {{$ns['receive']}} <small>{{$ns['receive_type']}}</small></td>
</tr>
@endforeach
</tbody>
</table>
</div> </div>
</div> </div>
<a href="{{ route('servers.index') }}"
class="btn btn-success btn-sm mx-2">
Go back
</a>
<a href="{{ route('servers.edit', $server->id) }}"
class="btn btn-primary btn-sm mx-2">
Edit
</a>
</div> </div>
</div> </x-card>
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1) @if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)
<p class="text-muted mt-4 text-end"><small> <p class="text-muted mt-4 text-end"><small>
Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }} Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}