Show initial locations list
This commit is contained in:
parent
4dfba7b3b1
commit
02f6bf428e
3 changed files with 92 additions and 0 deletions
35
app/Http/Controllers/Admin/LocationsController.php
Normal file
35
app/Http/Controllers/Admin/LocationsController.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use DB;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LocationsController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function getIndex(Request $request)
|
||||
{
|
||||
return view('admin.locations.index', [
|
||||
'locations' => Models\Location::select(
|
||||
'locations.*',
|
||||
DB::raw('(SELECT COUNT(*) FROM nodes WHERE nodes.location = locations.id) as a_nodeCount'),
|
||||
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.node IN (SELECT nodes.id FROM nodes WHERE nodes.location = locations.id)) as a_serverCount')
|
||||
)->paginate(20)
|
||||
]);
|
||||
}
|
||||
|
||||
public function postView(Request $request)
|
||||
{
|
||||
$location = Models\Location::findOrFail($request->input('location_id'));
|
||||
}
|
||||
|
||||
}
|
|
@ -199,6 +199,20 @@ class AdminRoutes {
|
|||
|
||||
});
|
||||
|
||||
// Server Routes
|
||||
$router->group([
|
||||
'prefix' => 'admin/locations',
|
||||
'middleware' => [
|
||||
'auth',
|
||||
'admin'
|
||||
]
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'admin.locations',
|
||||
'uses' => 'Admin\LocationsController@getIndex'
|
||||
]);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
43
resources/views/admin/locations/index.blade.php
Normal file
43
resources/views/admin/locations/index.blade.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Location List
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="col-md-12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/admin">Admin Control</a></li>
|
||||
<li class="active">Locations</li>
|
||||
</ul>
|
||||
<h3>All Locations</h3><hr />
|
||||
<table class="table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Location</th>
|
||||
<th>Description</th>
|
||||
<th class="text-center">Nodes</th>
|
||||
<th class="text-center">Servers</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($locations as $location)
|
||||
<tr>
|
||||
<td><a href="#/edit/{{ $location->id }}" data-action="edit" data-location="{{ $location->id }}"><code>{{ $location->short }}</code></td>
|
||||
<td>{{ $location->long }}</td>
|
||||
<td class="text-center">{{ $location->a_nodeCount }}</td>
|
||||
<td class="text-center">{{ $location->a_serverCount }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center">{!! $locations->render() !!}</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#sidebar_links').find("a[href='/admin/locations']").addClass('active');
|
||||
});
|
||||
</script>
|
||||
@endsection
|
Loading…
Reference in a new issue