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

Show proper server status when viewing listing.

closes #308
This commit is contained in:
Dane Everitt 2017-02-17 20:34:57 -05:00
parent e9762b4277
commit 99497adcb2
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 23 additions and 7 deletions

View File

@ -73,6 +73,14 @@ class AjaxController extends Controller
return response()->json([], 404);
}
if (! $server->installed) {
return response()->json(['status' => 20]);
}
if ($server->suspended) {
return response()->json(['status' => 30]);
}
try {
$res = $server->guzzleClient()->request('GET', '/server');
if ($res->getStatusCode() === 200) {

View File

@ -30,6 +30,13 @@ class ServerRoutes
{
public function map(Router $router)
{
// Returns Server Status
$router->get('/server/{server}/ajax/status', [
'middleware' => ['auth', 'csrf'],
'as' => 'server.ajax.status',
'uses' => 'Server\AjaxController@getStatus',
]);
$router->group([
'prefix' => 'server/{server}',
'middleware' => [
@ -164,12 +171,6 @@ class ServerRoutes
// Assorted AJAX Routes
$router->group(['prefix' => 'ajax'], function ($server) use ($router) {
// Returns Server Status
$router->get('status', [
'as' => 'server.ajax.status',
'uses' => 'Server\AjaxController@getStatus',
]);
// Sets the Default Connection for the Server
$router->post('set-primary', [
'uses' => 'Server\AjaxController@postSetPrimary',

View File

@ -28,6 +28,7 @@ var Status = {
$('.dynamic-update').each(function (index, data) {
var element = $(this);
var serverShortUUID = $(this).data('server');
$.ajax({
type: 'GET',
url: Router.route('server.ajax.status', { server: serverShortUUID }),
@ -53,8 +54,14 @@ var Status = {
case 3:
element.find('[data-action="status"]').html('<span class="label label-info">Stopping</span>');
break;
case 20:
element.find('[data-action="status"]').html('<span class="label label-warning">Installing</span>');
break;
case 30:
element.find('[data-action="status"]').html('<span class="label label-warning">Suspended</span>');
break;
}
if (data.status !== 0) {
if (data.status > 0 && data.status < 4) {
var cpuMax = element.find('[data-action="cpu"]').data('cpumax');
var currentCpu = data.proc.cpu.total;
if (cpuMax !== 0) {