v 0.8.3 made by Vysoky Vagon

Development
This commit is contained in:
Dennis 2022-10-13 11:07:08 +02:00 committed by GitHub
commit e37eb6c157
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 473 additions and 161 deletions

View file

@ -14,11 +14,6 @@ use Illuminate\Support\Facades\Http;
class Pterodactyl
{
/**
* @description per_page option to pull more than the default 50 from pterodactyl
*/
public const PER_PAGE = 200;
//TODO: Extend error handling (maybe logger for more errors when debugging)
/**
@ -73,7 +68,7 @@ class Pterodactyl
public static function getEggs(Nest $nest)
{
try {
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . self::PER_PAGE);
$response = self::client()->get("/application/nests/{$nest->id}/eggs?include=nest,variables&per_page=" . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
} catch (Exception $e) {
throw self::getException($e->getMessage());
}
@ -88,7 +83,7 @@ class Pterodactyl
public static function getNodes()
{
try {
$response = self::client()->get('/application/nodes?per_page=' . self::PER_PAGE);
$response = self::client()->get('/application/nodes?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
} catch (Exception $e) {
throw self::getException($e->getMessage());
}
@ -115,7 +110,7 @@ class Pterodactyl
public static function getServers() {
try {
$response = self::client()->get('/application/servers');
$response = self::client()->get('/application/servers?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
} catch (Exception $e) {
throw self::getException($e->getMessage());
}
@ -130,7 +125,7 @@ class Pterodactyl
public static function getNests()
{
try {
$response = self::client()->get('/application/nests?per_page=' . self::PER_PAGE);
$response = self::client()->get('/application/nests?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
} catch (Exception $e) {
throw self::getException($e->getMessage());
}
@ -145,7 +140,7 @@ class Pterodactyl
public static function getLocations()
{
try {
$response = self::client()->get('/application/locations?per_page=' . self::PER_PAGE);
$response = self::client()->get('/application/locations?per_page=' . config("SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT"));
} catch (Exception $e) {
throw self::getException($e->getMessage());
}
@ -292,7 +287,7 @@ class Pterodactyl
* @param int $pterodactylId
* @return mixed
*/
public static function getServerAttributes(int $pterodactylId)
public static function getServerAttributes(int $pterodactylId, bool $deleteOn404 = false)
{
try {
$response = self::client()->get("/application/servers/{$pterodactylId}?include=egg,node,nest,location");
@ -304,7 +299,13 @@ class Pterodactyl
if ($response->failed()) throw self::getException("Failed to get server attributes from pterodactyl - ", $response->status());
if ($response->failed()){
if($deleteOn404){ //Delete the server if it does not exist (server deleted on pterodactyl)
Server::where('pterodactyl_id', $pterodactylId)->first()->delete();
return;
}
else throw self::getException("Failed to get server attributes from pterodactyl - ", $response->status());
}
return $response->json()['attributes'];
}
@ -368,8 +369,8 @@ class Pterodactyl
throw self::getException($e->getMessage());
}
$node = $response['attributes'];
$freeMemory = $node['memory'] - $node['allocated_resources']['memory'];
$freeDisk = $node['disk'] - $node['allocated_resources']['disk'];
$freeMemory = ($node['memory']*($node['memory_overallocate']+100)/100) - $node['allocated_resources']['memory'];
$freeDisk = ($node['disk']*($node['disk_overallocate']+100)/100) - $node['allocated_resources']['disk'];
if ($freeMemory < $requireMemory) {
return false;
}

View file

@ -42,6 +42,7 @@ public function checkPteroClientkey(){
"server-limit-purchase" => "required|min:0|integer",
"pterodactyl-api-key" => "required|string",
"pterodactyl-url" => "required|string",
"per-page-limit" => "required|min:0|integer",
"pterodactyl-admin-api-key" => "required|string",
"enable-upgrades" => "string",
@ -79,6 +80,7 @@ public function checkPteroClientkey(){
"SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE" => "server-limit-purchase",
"SETTINGS::MISC:PHPMYADMIN:URL" => "phpmyadmin-url",
"SETTINGS::SYSTEM:PTERODACTYL:URL" => "pterodactyl-url",
'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT' => "per-page-limit",
"SETTINGS::SYSTEM:PTERODACTYL:TOKEN" => "pterodactyl-api-key",
"SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO" => "enable-login-logo",
"SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN" => "pterodactyl-admin-api-key",

View file

@ -11,6 +11,10 @@ use App\Models\Payment;
use App\Models\Server;
use App\Models\User;
use Illuminate\Support\Facades\Cache;
use App\Classes\Pterodactyl;
use App\Models\Product;
use App\Models\Ticket;
use Carbon\Carbon;
class OverViewController extends Controller
{
@ -18,38 +22,139 @@ class OverViewController extends Controller
public function index()
{
$userCount = Cache::remember('user:count', self::TTL, function () {
return User::query()->count();
});
$counters = Cache::remember('counters', self::TTL, function () {
$output = collect();
//Set basic variables in the collection
$output->put('users', User::query()->count());
$output->put('credits', number_format(User::query()->where("role","!=","admin")->sum('credits'), 2, '.', ''));
$output->put('payments', Payment::query()->count());
$output->put('eggs', Egg::query()->count());
$output->put('nests', Nest::query()->count());
$output->put('locations', Location::query()->count());
$creditCount = Cache::remember('credit:count', self::TTL, function () {
return User::query()->where("role","!=","admin")->sum('credits');
});
//Prepare for counting
$output->put('servers', collect());
$output['servers']->active = 0;
$output['servers']->total = 0;
$output->put('earnings', collect());
$output['earnings']->active = 0;
$output['earnings']->total = 0;
$output->put('totalUsagePercent', 0);
$paymentCount = Cache::remember('payment:count', self::TTL, function () {
return Payment::query()->count();
});
$serverCount = Cache::remember('server:count', self::TTL, function () {
return Server::query()->count();
//Prepare subCollection 'payments'
$output->put('payments', collect());
//Get and save payments from last 2 months for later filtering and looping
$payments = Payment::query()->where('created_at', '>=', Carbon::today()->startOfMonth()->subMonth())->where('status', 'paid')->get();
//Prepare collections and set a few variables
$output['payments']->put('thisMonth', collect());
$output['payments']->put('lastMonth', collect());
$output['payments']['thisMonth']->timeStart = Carbon::today()->startOfMonth()->toDateString();
$output['payments']['thisMonth']->timeEnd = Carbon::today()->toDateString();
$output['payments']['lastMonth']->timeStart = Carbon::today()->startOfMonth()->subMonth()->toDateString();
$output['payments']['lastMonth']->timeEnd = Carbon::today()->endOfMonth()->subMonth()->toDateString();
//Fill out variables for each currency separately
foreach($payments->where('created_at', '>=', Carbon::today()->startOfMonth()) as $payment){
$paymentCurrency = $payment->currency_code;
if(!isset($output['payments']['thisMonth'][$paymentCurrency])){
$output['payments']['thisMonth']->put($paymentCurrency, collect());
$output['payments']['thisMonth'][$paymentCurrency]->total = 0;
$output['payments']['thisMonth'][$paymentCurrency]->count = 0;
}
$output['payments']['thisMonth'][$paymentCurrency]->total += $payment->total_price;
$output['payments']['thisMonth'][$paymentCurrency]->count ++;
}
foreach($payments->where('created_at', '<', Carbon::today()->startOfMonth()) as $payment){
$paymentCurrency = $payment->currency_code;
if(!isset($output['payments']['lastMonth'][$paymentCurrency])){
$output['payments']['lastMonth']->put($paymentCurrency, collect());
$output['payments']['lastMonth'][$paymentCurrency]->total = 0;
$output['payments']['lastMonth'][$paymentCurrency]->count = 0;
}
$output['payments']['lastMonth'][$paymentCurrency]->total += $payment->total_price;
$output['payments']['lastMonth'][$paymentCurrency]->count ++;
}
$output['payments']->total = Payment::query()->count();
return $output;
});
$lastEgg = Egg::query()->latest('updated_at')->first();
$syncLastUpdate = $lastEgg ? $lastEgg->updated_at->isoFormat('LLL') : __('unknown');
$nodes = Cache::remember('nodes', self::TTL, function() use($counters){
$output = collect();
foreach($nodes = Node::query()->get() as $node){ //gets all node information and prepares the structure
$nodeId = $node['id'];
$output->put($nodeId, collect());
$output[$nodeId]->name = $node['name'];
$node = Pterodactyl::getNode($nodeId);
$output[$nodeId]->usagePercent = round(max($node['allocated_resources']['memory']/($node['memory']*($node['memory_overallocate']+100)/100), $node['allocated_resources']['disk']/($node['disk']*($node['disk_overallocate']+100)/100))*100, 2);
$counters['totalUsagePercent'] += $output[$nodeId]->usagePercent;
$output[$nodeId]->totalServers = 0;
$output[$nodeId]->activeServers = 0;
$output[$nodeId]->totalEarnings = 0;
$output[$nodeId]->activeEarnings = 0;
}
$counters['totalUsagePercent'] = ($nodes->count())?round($counters['totalUsagePercent']/$nodes->count(), 2):0;
foreach(Pterodactyl::getServers() as $server){ //gets all servers from Pterodactyl and calculates total of credit usage for each node separately + total
$nodeId = $server['attributes']['node'];
if($CPServer = Server::query()->where('pterodactyl_id', $server['attributes']['id'])->first()){
$prize = Product::query()->where('id', $CPServer->product_id)->first()->price;
if (!$CPServer->suspended){
$counters['earnings']->active += $prize;
$counters['servers']->active ++;
$output[$nodeId]->activeEarnings += $prize;
$output[$nodeId]->activeServers ++;
}
$counters['earnings']->total += $prize;
$counters['servers']->total ++;
$output[$nodeId]->totalEarnings += $prize;
$output[$nodeId]->totalServers ++;
}
}
return $output;
});
$tickets = Cache::remember('tickets', self::TTL, function(){
$output = collect();
foreach(Ticket::query()->latest()->take(3)->get() as $ticket){
$output->put($ticket->ticket_id, collect());
$output[$ticket->ticket_id]->title = $ticket->title;
$user = User::query()->where('id', $ticket->user_id)->first();
$output[$ticket->ticket_id]->user_id = $user->id;
$output[$ticket->ticket_id]->user = $user->name;
$output[$ticket->ticket_id]->status = $ticket->status;
$output[$ticket->ticket_id]->last_updated = $ticket->updated_at->diffForHumans();
switch ($ticket->status) {
case 'Open':
$output[$ticket->ticket_id]->statusBadgeColor = 'badge-success';
break;
case 'Closed':
$output[$ticket->ticket_id]->statusBadgeColor = 'badge-danger';
break;
case 'Answered':
$output[$ticket->ticket_id]->statusBadgeColor = 'badge-info';
break;
default:
$output[$ticket->ticket_id]->statusBadgeColor = 'badge-warning';
break;
}
}
return $output;
});
//dd($counters);
return view('admin.overview.index', [
'serverCount' => $serverCount,
'userCount' => $userCount,
'paymentCount' => $paymentCount,
'creditCount' => number_format($creditCount, 2, '.', ''),
'locationCount' => Location::query()->count(),
'nodeCount' => Node::query()->count(),
'nestCount' => Nest::query()->count(),
'eggCount' => Egg::query()->count(),
'syncLastUpdate' => $syncLastUpdate
'counters' => $counters,
'nodes' => $nodes,
'syncLastUpdate' => $syncLastUpdate,
'perPageLimit' => ($counters['servers']->total != Server::query()->count())?true:false,
'tickets' => $tickets
]);
}
}
/**
* @description Sync locations,nodes,nests,eggs with the linked pterodactyl panel

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Classes\Pterodactyl;
use App\Models\Egg;
use App\Models\Location;
use App\Models\Node;
@ -55,6 +56,10 @@ class ProductController extends Controller
public function getLocationsBasedOnEgg(Request $request, Egg $egg)
{
$nodes = $this->getNodesBasedOnEgg($request, $egg);
foreach($nodes as $key => $node){
$pteroNode = Pterodactyl::getNode($node->id);
if($pteroNode['allocated_resources']['memory']>=($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)||$pteroNode['allocated_resources']['disk']>=($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)) $nodes->forget($key);
}
$locations = collect();
//locations
@ -87,7 +92,7 @@ class ProductController extends Controller
{
if (is_null($egg->id) || is_null($node->id)) return response()->json('node and egg id is required', '400');
return Product::query()
$products = Product::query()
->where('disabled', '=', false)
->whereHas('nodes', function (Builder $builder) use ($node) {
$builder->where('id', '=', $node->id);
@ -96,5 +101,12 @@ class ProductController extends Controller
$builder->where('id', '=', $egg->id);
})
->get();
$pteroNode = Pterodactyl::getNode($node->id);
foreach($products as $key => $product){
if($product->memory>($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)-$pteroNode['allocated_resources']['memory']||$product->disk>($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)-$pteroNode['allocated_resources']['disk']) $product->doesNotFit = true;
}
return $products;
}
}

View file

@ -30,8 +30,8 @@ class ServerController extends Controller
foreach ($servers as $server) {
//Get server infos from ptero
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id);
$serverAttributes = Pterodactyl::getServerAttributes($server->pterodactyl_id, true);
if(!$serverAttributes) continue;
$serverRelationships = $serverAttributes['relationships'];
$serverLocationAttributes = $serverRelationships['location']['attributes'];
@ -45,6 +45,13 @@ class ServerController extends Controller
$server->node = $serverRelationships['node']['attributes']['name'];
//Check if a server got renamed on Pterodactyl
$savedServer = Server::query()->where('id', $server->id)->first();
if($savedServer->name != $serverAttributes['name']){
$savedServer->name = $serverAttributes['name'];
$server->name = $serverAttributes['name'];
$savedServer->save();
}
//get productname by product_id for server
$product = Product::find($server->product_id);
@ -234,6 +241,9 @@ class ServerController extends Controller
$serverRelationships = $serverAttributes['relationships'];
$serverLocationAttributes = $serverRelationships['location']['attributes'];
//Get current product
$currentProduct = Product::where('id', $server->product_id)->first();
//Set server infos
$server->location = $serverLocationAttributes['long'] ?
$serverLocationAttributes['long'] :
@ -242,11 +252,19 @@ class ServerController extends Controller
$server->node = $serverRelationships['node']['attributes']['name'];
$server->name = $serverAttributes['name'];
$server->egg = $serverRelationships['egg']['attributes']['name'];
$products = Product::orderBy("created_at")->get();
$pteroNode = Pterodactyl::getNode($serverRelationships['node']['attributes']['id']);
$products = Product::orderBy("created_at")
->whereHas('nodes', function (Builder $builder) use ($serverRelationships) { //Only show products for that node
$builder->where('id', '=', $serverRelationships['node']['attributes']['id']);
})
->get();
// Set the each product eggs array to just contain the eggs name
foreach ($products as $product) {
$product->eggs = $product->eggs->pluck('name')->toArray();
if($product->memory-$currentProduct->memory>($pteroNode['memory']*($pteroNode['memory_overallocate']+100)/100)-$pteroNode['allocated_resources']['memory']||$product->disk-$currentProduct->disk>($pteroNode['disk']*($pteroNode['disk_overallocate']+100)/100)-$pteroNode['allocated_resources']['disk']) $product->doesNotFit = true;
}
return view('servers.settings')->with([

View file

@ -4,7 +4,7 @@ use App\Models\Settings;
return [
'version' => '0.8.2',
'version' => '0.8.3',
/*
|--------------------------------------------------------------------------

View file

@ -378,6 +378,13 @@ class SettingsSeeder extends Seeder
'type' => 'string',
'description' => 'The URL to your Pterodactyl Panel. Must not end with a / '
]);
Settings::firstOrCreate([
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT',
], [
'value' => 200,
'type' => 'integer',
'description' => 'The Pterodactyl API perPage limit. It is necessary to set it higher than your server count.'
]);
Settings::firstOrCreate([
'key' => 'SETTINGS::MISC:PHPMYADMIN:URL',
], [

View file

@ -50,7 +50,7 @@
<div class="info-box-content">
<span class="info-box-text">{{__('Servers')}}</span>
<span class="info-box-number">{{$serverCount}}</span>
<span class="info-box-number">{{$counters['servers']->total}}</span>
</div>
<!-- /.info-box-content -->
</div>
@ -63,7 +63,7 @@
<div class="info-box-content">
<span class="info-box-text">{{__('Users')}}</span>
<span class="info-box-number">{{$userCount}}</span>
<span class="info-box-number">{{$counters['users']}}</span>
</div>
<!-- /.info-box-content -->
</div>
@ -77,7 +77,7 @@
<div class="info-box-content">
<span class="info-box-text">{{__('Total')}} {{CREDITS_DISPLAY_NAME}}</span>
<span class="info-box-number">{{$creditCount}}</span>
<span class="info-box-number">{{$counters['credits']}}</span>
</div>
<!-- /.info-box-content -->
</div>
@ -90,7 +90,7 @@
<div class="info-box-content">
<span class="info-box-text">{{__('Payments')}}</span>
<span class="info-box-number">{{$paymentCount}}</span>
<span class="info-box-number">{{$counters['payments']->total}}</span>
</div>
<!-- /.info-box-content -->
</div>
@ -121,19 +121,19 @@
<tbody>
<tr>
<td>{{__('Locations')}}</td>
<td>{{$locationCount}}</td>
<td>{{$counters['locations']}}</td>
</tr>
<tr>
<td>{{__('Nodes')}}</td>
<td>{{$nodeCount}}</td>
<td>{{$nodes->count()}}</td>
</tr>
<tr>
<td>{{__('Nests')}}</td>
<td>{{$nestCount}}</td>
<td>{{$counters['nests']}}</td>
</tr>
<tr>
<td>{{__('Eggs')}}</td>
<td>{{$eggCount}}</td>
<td>{{$counters['eggs']}}</td>
</tr>
</tbody>
</table>
@ -142,20 +142,173 @@
<span><i class="fas fa-sync mr-2"></i>{{__('Last updated :date', ['date' => $syncLastUpdate])}}</span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="card-title ">
<span><i class="fas fa-ticket-alt mr-2"></i>{{__('Latest tickets')}}</span>
</div>
</div>
</div>
<div class="card-body py-1">
@if(!$tickets->count())<span style="font-size: 16px; font-weight:700">{{__('There are no tickets')}}.</span>
@else
<table class="table">
<thead>
<tr>
<th>{{__('Title')}}</th>
<th>{{__('User')}}</th>
<th>{{__('Status')}}</th>
<th>{{__('Last updated')}}</th>
</tr>
</thead>
<tbody>
@foreach($tickets as $ticket_id => $ticket)
<tr>
<td><a class="text-info" href="{{route('moderator.ticket.show', ['ticket_id' => $ticket_id])}}">#{{$ticket_id}} - {{$ticket->title}}</td>
<td><a href="{{route('admin.users.show', $ticket->user_id)}}">{{$ticket->user}}</a></td>
<td><span class="badge {{$ticket->statusBadgeColor}}">{{$ticket->status}}</span></td>
<td>{{$ticket->last_updated}}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div>
</div>
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="card-title ">
<span><i class="fas fa-server mr-2"></i>{{__('Controlpanel.gg')}}</span>
</div>
</div>
<div class="card-body py-1">
</div>
<div class="card-footer">
<span><i class="fas fa-info mr-2"></i>{{__("Version")}} {{config("app.version")}} - {{config("BRANCHNAME")}}</span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="card-title ">
<span><i class="fas fa-server mr-2"></i>{{__('Individual nodes')}}</span>
</div>
</div>
</div>
<div class="card-body py-1">
@if ($perPageLimit)
<div class="alert alert-danger m-2">
<h5><i class="icon fas fa-exclamation-circle"></i>{{ __('Error!') }}</h5>
<p class="">
{{ __('You reached the Pterodactyl perPage limit. Please make sure to set it higher than your server count.') }}<br>
{{ __('You can do that in settings.') }}<br>
{{ __('Note') }}: {{ __('If this error persists even after changing the limit, it might mean a server was deleted on Pterodactyl, but not on ControlPanel.') }}
</p>
</div>
@endif
<table class="table">
<thead>
<tr>
<th>{{__('ID')}}</th>
<th>{{__('Node')}}</th>
<th>{{__('Server count')}}</th>
<th>{{__('Resource usage')}}</th>
<th>{{CREDITS_DISPLAY_NAME . ' ' . __('Usage')}}</th>
</tr>
</thead>
<tbody>
@foreach($nodes as $nodeID => $node)
<tr>
<td>{{$nodeID}}</td>
<td>{{$node->name}}</td>
<td>{{$node->activeServers}}/{{$node->totalServers}}</td>
<td>{{$node->usagePercent}}%</td>
<td>{{$node->activeEarnings}}/{{$node->totalEarnings}}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="2"><span style="float: right; font-weight: 700">{{__('Total')}} ({{__('active')}}/{{__('total')}}):</span></td>
<td>{{$counters['servers']->active}}/{{$counters['servers']->total}}</td>
<td>{{$counters['totalUsagePercent']}}%</td>
<td>{{$counters['earnings']->active}}/{{$counters['earnings']->total}}</td>
</tr>
</tfoot>
</table>
</div>
<div class="card-footer">
<span><i class="fas fa-info mr-2"></i>{{__("Version")}} {{config("app.version")}} - {{config("BRANCHNAME")}}</span>
</div>
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="card-title ">
<span><i class="fas fa-file-invoice-dollar mr-2"></i>{{__('Latest payments')}}</span>
</div>
</div>
</div>
<div class="card-body py-1">
<div class="row">
<div class="col-md-6" style="border-right:1px solid #6c757d">
<span style="margin:auto; display:table; font-size: 18px; font-weight:700">{{__('Last month')}}:
<i data-toggle="popover" data-trigger="hover" data-html="true"
data-content="{{ __('Payments in this time window') }}:<br>{{$counters['payments']['lastMonth']->timeStart}} - {{$counters['payments']['lastMonth']->timeEnd}}"
class="fas fa-info-circle"></i>
</span>
<table class="table">
<thead>
<tr>
<th><b>{{__('Currency')}}</b></th>
<th>{{__('Number of payments')}}</th>
<th>{{__('Total income')}}</th>
</tr>
</thead>
<tbody>
@foreach($counters['payments']['lastMonth'] as $currency => $income)
<tr>
<td>{{$currency}}</td>
<td>{{$income->count}}</td>
<td>{{$income->total}}</td>
</tr>
@endforeach
</tbody>
</table>
<hr style="width: 100%; height:1px; border-width:0; background-color:#6c757d; margin-top: -16px">
</div><div class="col-md-6">
<span style="margin:auto; display:table; font-size: 18px; font-weight:700">{{__('This month')}}:
<i data-toggle="popover" data-trigger="hover" data-html="true"
data-content="{{ __('Payments in this time window') }}:<br>{{$counters['payments']['thisMonth']->timeStart}} - {{$counters['payments']['thisMonth']->timeEnd}}"
class="fas fa-info-circle"></i>
</span>
<table class="table">
<thead>
<tr>
<th><b>{{__('Currency')}}</b></th>
<th>{{__('Number of payments')}}</th>
<th>{{__('Total income')}}</th>
</tr>
</thead>
<tbody>
@foreach($counters['payments']['thisMonth'] as $currency => $income)
<tr>
<td>{{$currency}}</td>
<td>{{$income->count}}</td>
<td>{{$income->total}}</td>
</tr>
@endforeach
</tbody>
</table>
<hr style="width: 100%; height:1px; border-width:0; background-color:#6c757d; margin-top: -16px">
</div>
</div>
</div>
</div>
</div>

View file

@ -70,6 +70,17 @@
value="{{ config('SETTINGS::SYSTEM:PTERODACTYL:URL') }}"
class="form-control @error('pterodactyl-url') is-invalid @enderror" required>
</div>
<div class="custom-control mb-3 p-0">
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
<label for="per-page-limit">{{ __('Pterodactyl API perPage limit') }}</label>
<i data-toggle="popover" data-trigger="hover" data-html="true"
data-content="{{ __('The Pterodactyl API perPage limit. It is necessary to set it higher than your server count.') }}"
class="fas fa-info-circle"></i>
</div>
<input x-model="per-page-limit" id="per-page-limit" name="per-page-limit" type="number"
value="{{ config('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') }}"
class="form-control @error('per-page-limit') is-invalid @enderror" required>
</div>
<div class="custom-control p-0 mb-3">
<div class="col m-0 p-0 d-flex justify-content-between align-items-center">
<label for="pterodactyl-api-key">{{ __('Pterodactyl API Key') }}</label>

View file

@ -51,11 +51,13 @@
@endif
</p>
<p><b>Created on:</b> {{ $ticket->created_at->diffForHumans() }}</p>
@if($ticket->status!='Closed')
<form class="d-inline" method="post" action="{{route('moderator.ticket.close', ['ticket_id' => $ticket->ticket_id ])}}">
{{csrf_field()}}
{{method_field("POST") }}
<button data-content="{{__("Close")}}" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm text-white btn-warning mr-1"><i class="fas fa-times"></i>{{__("Close")}}</button>
</form>
@endif
</div>
</div>
</div>

View file

@ -218,10 +218,10 @@
</div>
</div>
<button type="submit" x-model="selectedProduct" name="product"
:disabled="product.minimum_credits > user.credits"
:disabled="product.minimum_credits > user.credits||product.doesNotFit == true"
:class="product.minimum_credits > user.credits ? 'disabled' : ''"
class="btn btn-primary btn-block mt-2" @click="setProduct(product.id)"
x-text=" product.minimum_credits > user.credits ? '{{ __('Not enough') }} {{ CREDITS_DISPLAY_NAME }}!' : '{{ __('Create server') }}'">
x-text=" product.doesNotFit == true? '{{ __('Server can´t fit on this node') }}' : (product.minimum_credits > user.credits ? '{{ __('Not enough') }} {{ CREDITS_DISPLAY_NAME }}!' : '{{ __('Create server') }}')">
</button>
</div>
</div>

View file

@ -40,127 +40,128 @@
<div class="row d-flex flex-row justify-content-center justify-content-md-start">
@foreach ($servers as $server)
<div class="col-xl-3 col-lg-5 col-md-6 col-sm-6 col-xs-12 card pr-0 pl-0 ml-sm-2 mr-sm-3"
style="max-width: 350px">
<div class="card-header">
<div class="d-flex justify-content-between align-items-center">
<h5 class="card-title mt-1">{{ $server->name }}
</h5>
<div class="card-tools mt-1">
<div class="dropdown no-arrow">
<a href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-sm fa-fw text-white-50"></i>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
aria-labelledby="dropdownMenuLink">
@if (!empty(config('SETTINGS::MISC:PHPMYADMIN:URL')))
<a href="{{ config('SETTINGS::MISC:PHPMYADMIN:URL') }}"
class="dropdown-item text-info" target="__blank"><i title="manage"
class="fas fa-database mr-2"></i><span>{{ __('Database') }}</span></a>
@endif
<div class="dropdown-divider"></div>
<span class="dropdown-item"><i title="Created at"
class="fas fa-sync-alt mr-2"></i><span>{{ $server->created_at->isoFormat('LL') }}</span></span>
@if($server->location&&$server->node&&$server->nest&&$server->egg)
<div class="col-xl-3 col-lg-5 col-md-6 col-sm-6 col-xs-12 card pr-0 pl-0 ml-sm-2 mr-sm-3"
style="max-width: 350px">
<div class="card-header">
<div class="d-flex justify-content-between align-items-center">
<h5 class="card-title mt-1">{{ $server->name }}
</h5>
<div class="card-tools mt-1">
<div class="dropdown no-arrow">
<a href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-sm fa-fw text-white-50"></i>
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
aria-labelledby="dropdownMenuLink">
@if (!empty(config('SETTINGS::MISC:PHPMYADMIN:URL')))
<a href="{{ config('SETTINGS::MISC:PHPMYADMIN:URL') }}"
class="dropdown-item text-info" target="__blank"><i title="manage"
class="fas fa-database mr-2"></i><span>{{ __('Database') }}</span></a>
@endif
<div class="dropdown-divider"></div>
<span class="dropdown-item"><i title="Created at"
class="fas fa-sync-alt mr-2"></i><span>{{ $server->created_at->isoFormat('LL') }}</span></span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="container mt-1">
<div class="row mb-3">
<div class="col my-auto">{{ __('Status') }}:</div>
<div class="col-7 my-auto">
<i
class="fas {{ $server->isSuspended() ? 'text-danger' : 'text-success' }} fa-circle mr-2"></i>
{{ $server->isSuspended() ? 'Suspended' : 'Active' }}
</div>
</div>
<div class="row mb-2">
<div class="col-5">
{{ __('Location') }}:
</div>
<div class="col-7 d-flex justify-content-between align-items-center">
<span class="">{{ $server->location }}</span>
<i data-toggle="popover" data-trigger="hover"
data-content="{{ __('Node') }}: {{ $server->node }}"
class="fas fa-info-circle"></i>
<div class="card-body">
<div class="container mt-1">
<div class="row mb-3">
<div class="col my-auto">{{ __('Status') }}:</div>
<div class="col-7 my-auto">
<i
class="fas {{ $server->isSuspended() ? 'text-danger' : 'text-success' }} fa-circle mr-2"></i>
{{ $server->isSuspended() ? 'Suspended' : 'Active' }}
</div>
</div>
<div class="row mb-2">
<div class="col-5">
{{ __('Location') }}:
</div>
<div class="col-7 d-flex justify-content-between align-items-center">
<span class="">{{ $server->location }}</span>
<i data-toggle="popover" data-trigger="hover"
data-content="{{ __('Node') }}: {{ $server->node }}"
class="fas fa-info-circle"></i>
</div>
</div>
<div class="row mb-2">
<div class="col-5 ">
{{ __('Software') }}:
</div>
<div class="col-7 text-wrap">
<span>{{ $server->nest }}</span>
</div>
<div class="row mb-2">
<div class="col-5 ">
{{ __('Software') }}:
</div>
<div class="col-7 text-wrap">
<span>{{ $server->nest }}</span>
</div>
</div>
<div class="row mb-2">
<div class="col-5 ">
{{ __('Specification') }}:
</div>
<div class="col-7 text-wrap">
<span>{{ $server->egg }}</span>
</div>
</div>
<div class="row mb-4">
<div class="col-5 ">
{{ __('Resource plan') }}:
</div>
<div class="col-7 text-wrap d-flex justify-content-between align-items-center">
<span>{{ $server->product->name }}
</span>
<i data-toggle="popover" data-trigger="hover" data-html="true"
data-content="{{ __('CPU') }}: {{ $server->product->cpu / 100 }} {{ __('vCores') }} <br/>{{ __('RAM') }}: {{ $server->product->memory }} MB <br/>{{ __('Disk') }}: {{ $server->product->disk }} MB <br/>{{ __('Backups') }}: {{ $server->product->backups }} <br/> {{ __('MySQL Databases') }}: {{ $server->product->databases }} <br/> {{ __('Allocations') }}: {{ $server->product->allocations }} <br/>"
class="fas fa-info-circle"></i>
<div class="row mb-2">
<div class="col-5 ">
{{ __('Specification') }}:
</div>
<div class="col-7 text-wrap">
<span>{{ $server->egg }}</span>
</div>
</div>
<div class="row mb-4">
<div class="col-5 ">
{{ __('Resource plan') }}:
</div>
<div class="col-7 text-wrap d-flex justify-content-between align-items-center">
<span>{{ $server->product->name }}
</span>
<i data-toggle="popover" data-trigger="hover" data-html="true"
data-content="{{ __('CPU') }}: {{ $server->product->cpu / 100 }} {{ __('vCores') }} <br/>{{ __('RAM') }}: {{ $server->product->memory }} MB <br/>{{ __('Disk') }}: {{ $server->product->disk }} MB <br/>{{ __('Backups') }}: {{ $server->product->backups }} <br/> {{ __('MySQL Databases') }}: {{ $server->product->databases }} <br/> {{ __('Allocations') }}: {{ $server->product->allocations }} <br/>"
class="fas fa-info-circle"></i>
</div>
</div>
<div class="row mb-2">
<div class="col-4">
{{ __('Price') }}:
<span class="text-muted">
({{ CREDITS_DISPLAY_NAME }})
</span>
</div>
<div class="col-8">
<div class="row">
<div class="col-6 text-center">
<div class="text-muted">{{ __('per Hour') }}</div>
<span>
{{ number_format($server->product->getHourlyPrice(), 2, '.', '') }}
</span>
</div>
<div class="col-6 text-center">
<div class="text-muted">{{ __('per Month') }}
<div class="row mb-2">
<div class="col-4">
{{ __('Price') }}:
<span class="text-muted">
({{ CREDITS_DISPLAY_NAME }})
</span>
</div>
<div class="col-8">
<div class="row">
<div class="col-6 text-center">
<div class="text-muted">{{ __('per Hour') }}</div>
<span>
{{ number_format($server->product->getHourlyPrice(), 2, '.', '') }}
</span>
</div>
<div class="col-6 text-center">
<div class="text-muted">{{ __('per Month') }}
</div>
<span>
{{ $server->product->getHourlyPrice() * 24 * 30 }}
</span>
</div>
<span>
{{ $server->product->getHourlyPrice() * 24 * 30 }}
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer d-flex align-items-center justify-content-between">
<a href="{{ config('SETTINGS::SYSTEM:PTERODACTYL:URL') }}/server/{{ $server->identifier }}"
target="__blank"
class="btn btn-info mx-3 w-100 align-items-center justify-content-center d-flex">
<i class="fas fa-tools mr-2"></i>
<span>{{ __('Manage') }}</span>
</a>
<a href="{{ route('servers.show', ['server' => $server->id])}}" class="btn btn-warning mx-3 w-100 align-items-center justify-content-center d-flex">
<i class="fas fa-cog mr-2"></i>
<span>{{ __('Settings') }}</span>
</a>
<div class="card-footer d-flex align-items-center justify-content-between">
<a href="{{ config('SETTINGS::SYSTEM:PTERODACTYL:URL') }}/server/{{ $server->identifier }}"
target="__blank"
class="btn btn-info mx-3 w-100 align-items-center justify-content-center d-flex">
<i class="fas fa-tools mr-2"></i>
<span>{{ __('Manage') }}</span>
</a>
<a href="{{ route('servers.show', ['server' => $server->id])}}" class="btn btn-warning mx-3 w-100 align-items-center justify-content-center d-flex">
<i class="fas fa-cog mr-2"></i>
<span>{{ __('Settings') }}</span>
</a>
</div>
</div>
</div>
@endif
@endforeach
</div>
<!-- END CUSTOM CONTENT -->

View file

@ -255,13 +255,13 @@
<option value="">{{__("Select the product")}}</option>
@foreach($products as $product)
@if(in_array($server->egg, $product->eggs) && $product->id != $server->product->id && $product->disabled == false)
<option value="{{ $product->id }}">{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} @if($product->minimum_credits!=-1) /
{{__("Required")}}: {{$product->minimum_credits}} {{ CREDITS_DISPLAY_NAME }}@endif ]</option>
<option value="{{ $product->id }}" @if($product->doesNotFit)disabled @endif>{{ $product->name }} [ {{ CREDITS_DISPLAY_NAME }} {{ $product->price }} @if($product->doesNotFit)] {{__('Server can´t fit on this node')}} @else @if($product->minimum_credits!=-1) /
{{__("Required")}}: {{$product->minimum_credits}} {{ CREDITS_DISPLAY_NAME }}@endif ] @endif</option>
@endif
@endforeach
</select>
<br> {{__("Once the Upgrade button is pressed, we will automatically deduct the amount for the first hour according to the new product from your credits")}}. <br>
<br> {{_("Server will be automatically restarted once upgraded")}}
<br> {{__("Server will be automatically restarted once upgraded")}}
</div>
<div class="modal-footer card-body">
<button type="submit" class="btn btn-primary upgrade-once" style="width: 100%"><strong>{{__("Change Product")}}</strong></button>