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

Made a base

This commit is contained in:
stanjg 2018-05-04 18:45:37 +02:00
parent 7cf79a12cb
commit 93a7d11c28
No known key found for this signature in database
GPG Key ID: 27D9DF9D28935303
6 changed files with 273 additions and 0 deletions

View File

@ -0,0 +1,59 @@
<?php
namespace Pterodactyl\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Models\Allocation;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Node;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\User;
use JavaScript;
use Illuminate\Support\Facades\DB;
class StatisticsController extends Controller
{
public function index(Request $request)
{
$servers = Server::all();
$serversCount = count($servers);
$nodesCount = Node::count();
$usersCount = User::count();
$eggsCount = Egg::count();
$databasesCount = Database::count();
$totalServerRam = DB::table('servers')->sum('memory');
$totalNodeRam = DB::table('nodes')->sum('memory');
$totalServerDisk = DB::table('servers')->sum('disk');
$totalNodeDisk = DB::table('nodes')->sum('disk');
$totalAllocations = Allocation::count();
$suspendedServersCount = Server::where('suspended', true)->count();
Javascript::put([
'servers' => Server::all(),
'serverCount' => $serversCount,
'suspendedServers' => $suspendedServersCount,
'totalServerRam' => $totalServerRam,
'totalNodeRam' => $totalNodeRam,
'totalServerDisk' => $totalServerDisk,
'totalNodeDisk' => $totalNodeDisk,
]);
return view('admin.statistics', [
'serversCount' => $serversCount,
'nodesCount' => $nodesCount,
'usersCount' => $usersCount,
'eggsCount' => $eggsCount,
'totalServerRam' => $totalServerRam,
'databasesCount' => $databasesCount,
'totalNodeRam' => $totalNodeRam,
'totalNodeDisk' => $totalNodeDisk,
'totalServerDisk' => $totalServerDisk,
'totalAllocations' => $totalAllocations,
]);
}
}

View File

@ -473,3 +473,7 @@ label.control-label > span.field-optional:before {
height: 42px;
width: auto;
}
.number-info-box-content {
padding: 15px 10px 0;
}

View File

@ -0,0 +1,101 @@
var freeDisk = Pterodactyl.totalNodeDisk - Pterodactyl.totalServerDisk;
let diskChart = new Chart($('#disk_chart'), {
type: 'pie',
data: {
labels: ['Free Disk', 'Used Disk'],
datasets: [
{
label: 'Disk in MBs',
backgroundColor: ['#51B060', '#ff0000'],
data: [freeDisk, Pterodactyl.totalServerDisk]
}
]
}
});
var freeRam = Pterodactyl.totalNodeRam - Pterodactyl.totalServerRam;
let ramChart = new Chart($('#ram_chart'), {
type: 'pie',
data: {
labels: ['Free RAM', 'Used RAM'],
datasets: [
{
label: 'RAM in MBs',
backgroundColor: ['#51B060', '#ff0000'],
data: [freeRam, Pterodactyl.totalServerRam]
}
]
}
});
var activeServers = Pterodactyl.serverCount - Pterodactyl.suspendedServers;
let serversChart = new Chart($('#servers_chart'), {
type: 'pie',
data: {
labels: ['Active', 'Suspended'],
datasets: [
{
label: 'Servers',
backgroundColor: ['#51B060', '#E08E0B'],
data: [activeServers, Pterodactyl.suspendedServers]
}
]
}
});
let statusChart = new Chart($('#status_chart'), {
type: 'pie',
data: {
labels: ['Online', 'Offline', 'Installing', 'Error'],
datasets: [
{
label: '',
backgroundColor: ['#51B060', '#b7b7b7', '#E08E0B', '#ff0000'],
data: [0,0,0,0]
}
]
}
});
var servers = Pterodactyl.servers;
servers.forEach(function (server) {
$.ajax({
type: 'GET',
url: Router.route('index.status', { server: server.uuidShort}),
timeout: 5000,
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content'),
}
}).done(function (data) {
if (typeof data.status === 'undefined') {
// Error
statusChart.data.datasets[0].data[3]++;
return;
}
switch (data.status) {
case 0:
case 3:
case 30:
// Offline
statusChart.data.datasets[0].data[1]++;
break;
case 1:
case 2:
// Online
console.log('online');
statusChart.data.datasets[0].data[0]++;
break;
case 20:
// Installing
statusChart.data.datasets[0].data[2]++;
break;
}
statusChart.update();
}).fail(function (jqXHR) {
// Error
statusChart.data.datasets[0].data[3]++;
statusChart.update();
});
});

View File

@ -0,0 +1,103 @@
@extends('layouts.admin')
@include('partials/admin.settings.nav', ['activeTab' => 'basic'])
@section('title')
Statistics Overview
@endsection
@section('content-header')
<h1>Statistics Overview<small>Monitor your panel usage.</small></h1>
<ol class="breadcrumb">
<li><a href="{{ route('admin.index') }}">Admin</a></li>
<li class="active">Statistics</li>
</ol>
@endsection
@section('content')
<div class="row">
<div class="col-xs-12 col-md-8">
<div class="box box-primary">
<div class="box-header with-border">
Servers
</div>
<div class="box-body">
<div class="col-xs-12 col-md-6">
<canvas id="servers_chart" width="100%" height="50"></canvas>
</div>
<div class="col-xs-12 col-md-6">
<canvas id="status_chart" width="100%" height="50"></canvas>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-md-4">
<div class="info-box bg-blue">
<span class="info-box-icon"><i class="fa fa-server"></i></span>
<div class="info-box-content number-info-box-content">
<span class="info-box-text">Servers</span>
<span class="info-box-number">{{ $serversCount }}</span>
</div>
</div>
<div class="info-box bg-blue">
<span class="info-box-icon"><i class="ion ion-ios-barcode-outline"></i></span>
<div class="info-box-content number-info-box-content">
<span class="info-box-text">Total used RAM</span>
<span class="info-box-number">{{ $totalServerRam }}MB</span>
</div>
</div>
<div class="info-box bg-blue">
<span class="info-box-icon"><i class="ion ion-stats-bars"></i></span>
<div class="info-box-content number-info-box-content">
<span class="info-box-text">Total used disk space</span>
<span class="info-box-number">{{ $totalServerDisk }}MB</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-8">
<div class="box box-primary">
<div class="box-header with-border">
Nodes
</div>
<dib class="box-body">
<div class="col-xs-12 col-md-6">
<canvas id="ram_chart" width="100%" height="50"></canvas>
</div>
<div class="col-xs-12 col-md-6">
<canvas id="disk_chart" width="100%" height="50"></canvas>
</div>
</dib>
</div>
</div>
<div class="col-xs-12 col-md-4">
<div class="info-box bg-blue">
<span class="info-box-icon"><i class="ion ion-ios-barcode-outline"></i></span>
<div class="info-box-content number-info-box-content">
<span class="info-box-text">Total RAM</span>
<span class="info-box-number">{{ $totalNodeRam }}MB</span>
</div>
</div>
<div class="info-box bg-blue">
<span class="info-box-icon"><i class="ion ion-stats-bars"></i></span>
<div class="info-box-content number-info-box-content">
<span class="info-box-text">Total Disk Space</span>
<span class="info-box-number">{{ $totalNodeDisk }}MB</span>
</div>
</div>
<div class="info-box bg-blue">
<span class="info-box-icon"><i class="fa fa-location-arrow"></i></span>
<div class="info-box-content number-info-box-content">
<span class="info-box-text">Total Allocations</span>
<span class="info-box-number">{{ $totalAllocations }}</span>
</div>
</div>
</div>
</div>
@endsection
@section('footer-scripts')
@parent
{!! Theme::js('vendor/chartjs/chart.min.js') !!}
{!! Theme::js('js/admin/statistics.js') !!}
@endsection

View File

@ -80,6 +80,11 @@
<i class="fa fa-home"></i> <span>Overview</span>
</a>
</li>
<li class="{{ Route::currentRouteName() !== 'admin.statistics' ?: 'active' }}">
<a href="{{ route('admin.statistics') }}">
<i class="fa fa-tachometer"></i> <span>Statistics</span>
</a>
</li>
<li class="{{ ! starts_with(Route::currentRouteName(), 'admin.settings') ?: 'active' }}">
<a href="{{ route('admin.settings')}}">
<i class="fa fa-wrench"></i> <span>Settings</span>

View File

@ -1,6 +1,7 @@
<?php
Route::get('/', 'BaseController@index')->name('admin.index');
Route::get('/statistics', 'StatisticsController@index')->name('admin.statistics');
/*
|--------------------------------------------------------------------------