parent
e9762b4277
commit
99497adcb2
|
@ -73,6 +73,14 @@ class AjaxController extends Controller
|
||||||
return response()->json([], 404);
|
return response()->json([], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $server->installed) {
|
||||||
|
return response()->json(['status' => 20]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($server->suspended) {
|
||||||
|
return response()->json(['status' => 30]);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = $server->guzzleClient()->request('GET', '/server');
|
$res = $server->guzzleClient()->request('GET', '/server');
|
||||||
if ($res->getStatusCode() === 200) {
|
if ($res->getStatusCode() === 200) {
|
||||||
|
|
|
@ -30,6 +30,13 @@ class ServerRoutes
|
||||||
{
|
{
|
||||||
public function map(Router $router)
|
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([
|
$router->group([
|
||||||
'prefix' => 'server/{server}',
|
'prefix' => 'server/{server}',
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
|
@ -164,12 +171,6 @@ class ServerRoutes
|
||||||
|
|
||||||
// Assorted AJAX Routes
|
// Assorted AJAX Routes
|
||||||
$router->group(['prefix' => 'ajax'], function ($server) use ($router) {
|
$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
|
// Sets the Default Connection for the Server
|
||||||
$router->post('set-primary', [
|
$router->post('set-primary', [
|
||||||
'uses' => 'Server\AjaxController@postSetPrimary',
|
'uses' => 'Server\AjaxController@postSetPrimary',
|
||||||
|
|
|
@ -28,6 +28,7 @@ var Status = {
|
||||||
$('.dynamic-update').each(function (index, data) {
|
$('.dynamic-update').each(function (index, data) {
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
var serverShortUUID = $(this).data('server');
|
var serverShortUUID = $(this).data('server');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: Router.route('server.ajax.status', { server: serverShortUUID }),
|
url: Router.route('server.ajax.status', { server: serverShortUUID }),
|
||||||
|
@ -53,8 +54,14 @@ var Status = {
|
||||||
case 3:
|
case 3:
|
||||||
element.find('[data-action="status"]').html('<span class="label label-info">Stopping</span>');
|
element.find('[data-action="status"]').html('<span class="label label-info">Stopping</span>');
|
||||||
break;
|
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 cpuMax = element.find('[data-action="cpu"]').data('cpumax');
|
||||||
var currentCpu = data.proc.cpu.total;
|
var currentCpu = data.proc.cpu.total;
|
||||||
if (cpuMax !== 0) {
|
if (cpuMax !== 0) {
|
||||||
|
|
Loading…
Reference in New Issue