parent
3078b61ac6
commit
969b16a563
|
@ -202,7 +202,7 @@ interface RepositoryInterface
|
||||||
public function insertIgnore(array $values): bool;
|
public function insertIgnore(array $values): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of entries in the database
|
* Get the amount of entries in the database.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -147,7 +147,7 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
|
||||||
public function isUniqueUuidCombo(string $uuid, string $short): bool;
|
public function isUniqueUuidCombo(string $uuid, string $short): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of servers that are suspended
|
* Get the amount of servers that are suspended.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,16 +2,14 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Http\Controllers\Admin;
|
namespace Pterodactyl\Http\Controllers\Admin;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
|
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||||
use Pterodactyl\Traits\Controllers\PlainJavascriptInjection;
|
use Pterodactyl\Traits\Controllers\PlainJavascriptInjection;
|
||||||
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
||||||
|
|
||||||
class StatisticsController extends Controller
|
class StatisticsController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -29,15 +27,14 @@ class StatisticsController extends Controller
|
||||||
|
|
||||||
private $userRepository;
|
private $userRepository;
|
||||||
|
|
||||||
function __construct(
|
public function __construct(
|
||||||
AllocationRepositoryInterface $allocationRepository,
|
AllocationRepositoryInterface $allocationRepository,
|
||||||
DatabaseRepositoryInterface $databaseRepository,
|
DatabaseRepositoryInterface $databaseRepository,
|
||||||
EggRepositoryInterface $eggRepository,
|
EggRepositoryInterface $eggRepository,
|
||||||
NodeRepositoryInterface $nodeRepository,
|
NodeRepositoryInterface $nodeRepository,
|
||||||
ServerRepositoryInterface $serverRepository,
|
ServerRepositoryInterface $serverRepository,
|
||||||
UserRepositoryInterface $userRepository
|
UserRepositoryInterface $userRepository
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->allocationRepository = $allocationRepository;
|
$this->allocationRepository = $allocationRepository;
|
||||||
$this->databaseRepository = $databaseRepository;
|
$this->databaseRepository = $databaseRepository;
|
||||||
$this->eggRepository = $eggRepository;
|
$this->eggRepository = $eggRepository;
|
||||||
|
@ -83,7 +80,7 @@ class StatisticsController extends Controller
|
||||||
'nodes' => $nodes,
|
'nodes' => $nodes,
|
||||||
'tokens' => $tokens,
|
'tokens' => $tokens,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return view('admin.statistics', [
|
return view('admin.statistics', [
|
||||||
'servers' => $servers,
|
'servers' => $servers,
|
||||||
'nodes' => $nodes,
|
'nodes' => $nodes,
|
||||||
|
@ -97,5 +94,4 @@ class StatisticsController extends Controller
|
||||||
'totalAllocations' => $totalAllocations,
|
'totalAllocations' => $totalAllocations,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Http;
|
namespace Pterodactyl\Http;
|
||||||
|
|
||||||
use Pterodactyl\Http\Middleware\MaintenanceMiddleware;
|
|
||||||
use Pterodactyl\Models\ApiKey;
|
use Pterodactyl\Models\ApiKey;
|
||||||
use Illuminate\Auth\Middleware\Authorize;
|
use Illuminate\Auth\Middleware\Authorize;
|
||||||
use Illuminate\Auth\Middleware\Authenticate;
|
use Illuminate\Auth\Middleware\Authenticate;
|
||||||
|
@ -21,6 +20,7 @@ use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||||
use Pterodactyl\Http\Middleware\AccessingValidServer;
|
use Pterodactyl\Http\Middleware\AccessingValidServer;
|
||||||
use Pterodactyl\Http\Middleware\Api\SetSessionDriver;
|
use Pterodactyl\Http\Middleware\Api\SetSessionDriver;
|
||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
use Pterodactyl\Http\Middleware\MaintenanceMiddleware;
|
||||||
use Pterodactyl\Http\Middleware\RedirectIfAuthenticated;
|
use Pterodactyl\Http\Middleware\RedirectIfAuthenticated;
|
||||||
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
||||||
use Pterodactyl\Http\Middleware\Api\AuthenticateIPAccess;
|
use Pterodactyl\Http\Middleware\Api\AuthenticateIPAccess;
|
||||||
|
|
|
@ -298,7 +298,7 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of entries in the database
|
* Get the amount of entries in the database.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -330,7 +330,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of servers that are suspended
|
* Get the amount of servers that are suspended.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: Stan
|
* User: Stan
|
||||||
* Date: 26-5-2018
|
* Date: 26-5-2018
|
||||||
* Time: 20:56
|
* Time: 20:56.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Pterodactyl\Traits\Controllers;
|
namespace Pterodactyl\Traits\Controllers;
|
||||||
|
@ -12,13 +12,11 @@ use JavaScript;
|
||||||
|
|
||||||
trait PlainJavascriptInjection
|
trait PlainJavascriptInjection
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects statistics into javascript
|
* Injects statistics into javascript.
|
||||||
*/
|
*/
|
||||||
public function injectJavascript($data)
|
public function injectJavascript($data)
|
||||||
{
|
{
|
||||||
Javascript::put($data);
|
Javascript::put($data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class AddMaintenanceToNodes extends Migration
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('nodes', function (Blueprint $table) {
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
$table->boolean('maintenance_mode')->after('behind_proxy')->default(false);
|
$table->boolean('maintenance_mode')->after('behind_proxy')->default(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class AddMaintenanceToNodes extends Migration
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('nodes', function (Blueprint $table) {
|
Schema::table('nodes', function (Blueprint $table) {
|
||||||
$table->dropColumn('maintenance_mode');
|
$table->dropColumn('maintenance_mode');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,24 +3,22 @@
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: Stan
|
* User: Stan
|
||||||
* Date: 26-5-2018
|
* Date: 26-5-2018
|
||||||
* Time: 21:06
|
* Time: 21:06.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Tests\Unit\Http\Controllers\Admin;
|
namespace Tests\Unit\Http\Controllers\Admin;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Routing\Controller;
|
|
||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|
||||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|
||||||
use Pterodactyl\Http\Controllers\Admin\StatisticsController;
|
|
||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Tests\Assertions\ControllerAssertionsTrait;
|
use Tests\Assertions\ControllerAssertionsTrait;
|
||||||
use Tests\Unit\Http\Controllers\ControllerTestCase;
|
use Tests\Unit\Http\Controllers\ControllerTestCase;
|
||||||
|
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||||
|
use Pterodactyl\Http\Controllers\Admin\StatisticsController;
|
||||||
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||||
|
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
||||||
|
|
||||||
class StatisticsControllerTest extends ControllerTestCase
|
class StatisticsControllerTest extends ControllerTestCase
|
||||||
{
|
{
|
||||||
|
@ -88,7 +86,7 @@ class StatisticsControllerTest extends ControllerTestCase
|
||||||
'disk' => [
|
'disk' => [
|
||||||
'value' => 1024,
|
'value' => 1024,
|
||||||
'max' => 512,
|
'max' => 512,
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$controller->shouldReceive('injectJavascript')->once();
|
$controller->shouldReceive('injectJavascript')->once();
|
||||||
|
@ -106,8 +104,7 @@ class StatisticsControllerTest extends ControllerTestCase
|
||||||
$this->eggRepository,
|
$this->eggRepository,
|
||||||
$this->nodeRepository,
|
$this->nodeRepository,
|
||||||
$this->serverRepository,
|
$this->serverRepository,
|
||||||
$this->userRepository]
|
$this->userRepository, ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue