Skip to content

Commit 5678d64

Browse files
committed
Very basic view of databases and database servers on the system
1 parent 938df40 commit 5678d64

File tree

5 files changed

+200
-0
lines changed

5 files changed

+200
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
namespace Pterodactyl\Http\Controllers\Admin;
25+
26+
use DB;
27+
28+
use Pterodactyl\Models;
29+
30+
use Pterodactyl\Http\Controllers\Controller;
31+
use Illuminate\Http\Request;
32+
33+
class DatabaseController extends Controller
34+
{
35+
36+
/**
37+
* Controller Constructor
38+
*/
39+
public function __construct()
40+
{
41+
//
42+
}
43+
44+
public function getIndex(Request $request)
45+
{
46+
return view('admin.databases.index', [
47+
'databases' => Models\Database::select(
48+
'databases.*',
49+
'database_servers.host as a_host',
50+
'database_servers.port as a_port',
51+
'servers.id as a_serverId',
52+
'servers.name as a_serverName'
53+
)->join('database_servers', 'database_servers.id', '=', 'databases.db_server')
54+
->join('servers', 'databases.server', '=', 'servers.id')
55+
->paginate(20),
56+
'dbh' => Models\DatabaseServer::select(
57+
'database_servers.*',
58+
'nodes.name as a_linkedNode',
59+
DB::raw('(SELECT COUNT(*) FROM `databases` WHERE `databases`.`db_server` = database_servers.id) as c_databases')
60+
)->join('nodes', 'nodes.id', '=', 'database_servers.linked_node')
61+
->paginate(20)
62+
]);
63+
}
64+
65+
}

app/Http/Routes/AdminRoutes.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,28 @@ public function map(Router $router) {
308308
]);
309309
});
310310

311+
// Database Routes
312+
$router->group([
313+
'prefix' => 'admin/databases',
314+
'middleware' => [
315+
'auth',
316+
'admin',
317+
'csrf'
318+
]
319+
], function () use ($router) {
320+
$router->get('/', [
321+
'as' => 'admin.databases',
322+
'uses' => 'Admin\DatabaseController@getIndex'
323+
]);
324+
$router->get('/new', [
325+
'as' => 'admin.databases.new',
326+
'uses' => 'Admin\DatabaseController@getNew'
327+
]);
328+
$router->post('/new', [
329+
'uses' => 'Admin\DatabaseController@postNew'
330+
]);
331+
});
332+
311333
}
312334

313335
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
2+
3+
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
4+
{{-- of this software and associated documentation files (the "Software"), to deal --}}
5+
{{-- in the Software without restriction, including without limitation the rights --}}
6+
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
7+
{{-- copies of the Software, and to permit persons to whom the Software is --}}
8+
{{-- furnished to do so, subject to the following conditions: --}}
9+
10+
{{-- The above copyright notice and this permission notice shall be included in all --}}
11+
{{-- copies or substantial portions of the Software. --}}
12+
13+
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
14+
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
15+
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
16+
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
17+
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
18+
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
19+
{{-- SOFTWARE. --}}
20+
@extends('layouts.admin')
21+
22+
@section('title')
23+
Server List
24+
@endsection
25+
26+
@section('content')
27+
<div class="col-md-12">
28+
<ul class="breadcrumb">
29+
<li><a href="/admin">Admin Control</a></li>
30+
<li class="active">Databases</li>
31+
</ul>
32+
<h3>Manage Databases</h3><hr />
33+
<ul class="nav nav-tabs tabs_with_panel" id="config_tabs">
34+
<li class="active"><a href="#tab_databases" data-toggle="tab">Databases</a></li>
35+
<li><a href="#tb_dbservers" data-toggle="tab">Database Servers</a></li>
36+
</ul>
37+
<div class="tab-content">
38+
<div class="tab-pane active" id="tab_databases">
39+
<div class="panel panel-default">
40+
<div class="panel-heading"></div>
41+
<div class="panel-body">
42+
<table class="table table-bordered table-hover" style="margin-bottom:0;">
43+
<thead>
44+
<tr>
45+
<th>Server</th>
46+
<th>Database</th>
47+
<th>Username</th>
48+
<th>Connection</th>
49+
<th></th>
50+
</tr>
51+
</thead>
52+
<tbody>
53+
@foreach($databases as $db)
54+
<tr>
55+
<td>{{ $db->a_serverName }}</td>
56+
<td>{{ $db->database }}</td>
57+
<td>{{ $db->username }} ({{ $db->remote }})</td>
58+
<td><code>{{ $db->a_host }}:{{ $db->a_port }}</code></td>
59+
<td class="text-center"><a href="/admin/servers/view/{{ $db->a_serverId }}?tab=tab_database"><i class="fa fa-search"></i></a></td>
60+
</tr>
61+
@endforeach
62+
</tbody>
63+
</table>
64+
<div class="col-md-12 text-center">
65+
{{ $databases->render() }}
66+
</div>
67+
</div>
68+
</div>
69+
</div>
70+
<div class="tab-pane" id="tb_dbservers">
71+
<div class="panel panel-default">
72+
<div class="panel-heading"></div>
73+
<div class="panel-body">
74+
<table class="table table-bordered table-hover" style="margin-bottom:0;">
75+
<thead>
76+
<tr>
77+
<th>Name</th>
78+
<th>Connection</th>
79+
<th>Username</th>
80+
<th class="text-center">Databases</th>
81+
<th>Linked Node</th>
82+
<th></th>
83+
</tr>
84+
</thead>
85+
<tbody>
86+
@foreach($dbh as $db)
87+
<tr>
88+
<td><a href="#">{{ $db->name }}</a></td>
89+
<td><code>{{ $db->host }}:{{ $db->port }}</code></td>
90+
<td>{{ $db->username }}</td>
91+
<td class="text-center">{{ $db->c_databases }}</td>
92+
<td>@if(is_null($db->a_linkedNode))<em>unlinked</em>@else{{ $db->a_linkedNode }}@endif</td>
93+
<td class="text-center"><a href="#" class="text-danger"><i class="fa fa-trash-o"></i></a></td>
94+
</tr>
95+
@endforeach
96+
</tbody>
97+
</table>
98+
<div class="col-md-12 text-center">
99+
{{ $dbh->render() }}
100+
</div>
101+
</div>
102+
</div>
103+
</div>
104+
</div>
105+
</div>
106+
<script>
107+
$(document).ready(function () {
108+
$('#sidebar_links').find("a[href='/admin/databases']").addClass('active');
109+
});
110+
</script>
111+
@endsection

resources/views/admin/databases/new.blade.php

Whitespace-only changes.

resources/views/layouts/admin.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<li><a href="/admin">Admin Index</a></li>
6262
<li><a href="/admin/settings">General Settings</a></li>
6363
<li><a href="/admin/api">API Management</a></li>
64+
<li><a href="/admin/databases">Database Management</a></li>
6465
</ul>
6566
</li>
6667
<li class="dropdown">
@@ -128,6 +129,7 @@
128129
<a href="/admin" id="sidenav_admin-index" class="list-group-item">Admin Index</a>
129130
<a href="/admin/settings" class="list-group-item">General Settings</a>
130131
<a href="/admin/api" class="list-group-item">API Management</a>
132+
<a href="/admin/databases" class="list-group-item">Database Management</a>
131133
</div>
132134
<div class="list-group">
133135
<a href="#" class="list-group-item list-group-item-heading"><strong>Account Management</strong></a>

0 commit comments

Comments
 (0)