1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-25 10:32:31 +01:00

Very basic view of databases and database servers on the system

This commit is contained in:
Dane Everitt 2016-02-13 00:18:32 -05:00
parent 938df4023d
commit 5678d643cd
5 changed files with 200 additions and 0 deletions

View File

@ -0,0 +1,65 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Http\Controllers\Admin;
use DB;
use Pterodactyl\Models;
use Pterodactyl\Http\Controllers\Controller;
use Illuminate\Http\Request;
class DatabaseController extends Controller
{
/**
* Controller Constructor
*/
public function __construct()
{
//
}
public function getIndex(Request $request)
{
return view('admin.databases.index', [
'databases' => Models\Database::select(
'databases.*',
'database_servers.host as a_host',
'database_servers.port as a_port',
'servers.id as a_serverId',
'servers.name as a_serverName'
)->join('database_servers', 'database_servers.id', '=', 'databases.db_server')
->join('servers', 'databases.server', '=', 'servers.id')
->paginate(20),
'dbh' => Models\DatabaseServer::select(
'database_servers.*',
'nodes.name as a_linkedNode',
DB::raw('(SELECT COUNT(*) FROM `databases` WHERE `databases`.`db_server` = database_servers.id) as c_databases')
)->join('nodes', 'nodes.id', '=', 'database_servers.linked_node')
->paginate(20)
]);
}
}

View File

@ -308,6 +308,28 @@ class AdminRoutes {
]);
});
// Database Routes
$router->group([
'prefix' => 'admin/databases',
'middleware' => [
'auth',
'admin',
'csrf'
]
], function () use ($router) {
$router->get('/', [
'as' => 'admin.databases',
'uses' => 'Admin\DatabaseController@getIndex'
]);
$router->get('/new', [
'as' => 'admin.databases.new',
'uses' => 'Admin\DatabaseController@getNew'
]);
$router->post('/new', [
'uses' => 'Admin\DatabaseController@postNew'
]);
});
}
}

View File

@ -0,0 +1,111 @@
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
{{-- of this software and associated documentation files (the "Software"), to deal --}}
{{-- in the Software without restriction, including without limitation the rights --}}
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
{{-- copies of the Software, and to permit persons to whom the Software is --}}
{{-- furnished to do so, subject to the following conditions: --}}
{{-- The above copyright notice and this permission notice shall be included in all --}}
{{-- copies or substantial portions of the Software. --}}
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
{{-- SOFTWARE. --}}
@extends('layouts.admin')
@section('title')
Server List
@endsection
@section('content')
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="/admin">Admin Control</a></li>
<li class="active">Databases</li>
</ul>
<h3>Manage Databases</h3><hr />
<ul class="nav nav-tabs tabs_with_panel" id="config_tabs">
<li class="active"><a href="#tab_databases" data-toggle="tab">Databases</a></li>
<li><a href="#tb_dbservers" data-toggle="tab">Database Servers</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_databases">
<div class="panel panel-default">
<div class="panel-heading"></div>
<div class="panel-body">
<table class="table table-bordered table-hover" style="margin-bottom:0;">
<thead>
<tr>
<th>Server</th>
<th>Database</th>
<th>Username</th>
<th>Connection</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($databases as $db)
<tr>
<td>{{ $db->a_serverName }}</td>
<td>{{ $db->database }}</td>
<td>{{ $db->username }} ({{ $db->remote }})</td>
<td><code>{{ $db->a_host }}:{{ $db->a_port }}</code></td>
<td class="text-center"><a href="/admin/servers/view/{{ $db->a_serverId }}?tab=tab_database"><i class="fa fa-search"></i></a></td>
</tr>
@endforeach
</tbody>
</table>
<div class="col-md-12 text-center">
{{ $databases->render() }}
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tb_dbservers">
<div class="panel panel-default">
<div class="panel-heading"></div>
<div class="panel-body">
<table class="table table-bordered table-hover" style="margin-bottom:0;">
<thead>
<tr>
<th>Name</th>
<th>Connection</th>
<th>Username</th>
<th class="text-center">Databases</th>
<th>Linked Node</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($dbh as $db)
<tr>
<td><a href="#">{{ $db->name }}</a></td>
<td><code>{{ $db->host }}:{{ $db->port }}</code></td>
<td>{{ $db->username }}</td>
<td class="text-center">{{ $db->c_databases }}</td>
<td>@if(is_null($db->a_linkedNode))<em>unlinked</em>@else{{ $db->a_linkedNode }}@endif</td>
<td class="text-center"><a href="#" class="text-danger"><i class="fa fa-trash-o"></i></a></td>
</tr>
@endforeach
</tbody>
</table>
<div class="col-md-12 text-center">
{{ $dbh->render() }}
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#sidebar_links').find("a[href='/admin/databases']").addClass('active');
});
</script>
@endsection

View File

@ -61,6 +61,7 @@
<li><a href="/admin">Admin Index</a></li>
<li><a href="/admin/settings">General Settings</a></li>
<li><a href="/admin/api">API Management</a></li>
<li><a href="/admin/databases">Database Management</a></li>
</ul>
</li>
<li class="dropdown">
@ -128,6 +129,7 @@
<a href="/admin" id="sidenav_admin-index" class="list-group-item">Admin Index</a>
<a href="/admin/settings" class="list-group-item">General Settings</a>
<a href="/admin/api" class="list-group-item">API Management</a>
<a href="/admin/databases" class="list-group-item">Database Management</a>
</div>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-heading"><strong>Account Management</strong></a>