1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 09:02:28 +01:00

Model and template cleanup

This commit is contained in:
Dane Everitt 2017-03-03 23:37:41 -05:00
parent d38f89a468
commit e6d3663b3b
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
5 changed files with 35 additions and 44 deletions

View File

@ -26,10 +26,8 @@ namespace Pterodactyl\Http\Controllers\Admin;
use DB; use DB;
use Log; use Log;
use Hash;
use Alert; use Alert;
use Carbon; use Carbon;
use Validator;
use Javascript; use Javascript;
use Pterodactyl\Models; use Pterodactyl\Models;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -41,21 +39,12 @@ use Pterodactyl\Exceptions\DisplayValidationException;
class NodesController extends Controller class NodesController extends Controller
{ {
/** /**
* Controller Constructor. * Displays the index page listing all nodes on the panel.
*
* @param Request $request
* @return \Illuminate\View\View
*/ */
public function __construct() public function index(Request $request)
{
//
}
public function getScript(Request $request, $id)
{
return response()->view('admin.nodes.remote.deploy', [
'node' => Models\Node::findOrFail($id),
])->header('Content-Type', 'text/plain');
}
public function getIndex(Request $request)
{ {
$nodes = Models\Node::with('location')->withCount('servers'); $nodes = Models\Node::with('location')->withCount('servers');
@ -66,36 +55,42 @@ class NodesController extends Controller
return view('admin.nodes.index', ['nodes' => $nodes->paginate(25)]); return view('admin.nodes.index', ['nodes' => $nodes->paginate(25)]);
} }
public function getNew(Request $request) /**
* Displays create new node page.
*
* @param Request $request
* @return \Illuminate\View\View|\Illuminate\Response\RedirectResponse
*/
public function new(Request $request)
{ {
if (! Models\Location::all()->count()) { $locations = Models\Location::all();
if (! $locations->count()) {
Alert::warning('You must add a location before you can add a new node.')->flash(); Alert::warning('You must add a location before you can add a new node.')->flash();
return redirect()->route('admin.locations'); return redirect()->route('admin.locations');
} }
return view('admin.nodes.new', [ return view('admin.nodes.new', ['locations' => $locations]);
'locations' => Models\Location::all(),
]);
} }
public function postNew(Request $request) /**
* Post controller to create a new node on the system.
*
* @param Request $request
* @return \Illuminate\Response\RedirectResponse
*/
public function create(Request $request)
{ {
try { try {
$repo = new NodeRepository; $repo = new NodeRepository;
$node = $repo->create($request->only([ $node = $repo->create($request->intersect([
'name', 'location_id', 'public', 'name', 'location_id', 'public', 'fqdn', 'scheme', 'memory',
'fqdn', 'scheme', 'memory', 'memory_overallocate', 'disk', 'disk_overallocate',
'memory_overallocate', 'disk', 'daemonBase', 'daemonSFTP', 'daemonListen',
'disk_overallocate', 'daemonBase',
'daemonSFTP', 'daemonListen',
])); ]));
Alert::success('Successfully created new node that can be configured automatically on your remote machine by visiting the configuration tab. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash(); Alert::success('Successfully created new node that can be configured automatically on your remote machine by visiting the configuration tab. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash();
return redirect()->route('admin.nodes.view', [ return redirect()->route('admin.nodes.view', $node->id);
'id' => $node->id,
'tab' => 'tab_allocation',
]);
} catch (DisplayValidationException $e) { } catch (DisplayValidationException $e) {
return redirect()->route('admin.nodes.new')->withErrors(json_decode($e->getMessage()))->withInput(); return redirect()->route('admin.nodes.new')->withErrors(json_decode($e->getMessage()))->withInput();
} catch (DisplayException $e) { } catch (DisplayException $e) {

View File

@ -219,17 +219,17 @@ class AdminRoutes
// View All Nodes // View All Nodes
$router->get('/', [ $router->get('/', [
'as' => 'admin.nodes', 'as' => 'admin.nodes',
'uses' => 'Admin\NodesController@getIndex', 'uses' => 'Admin\NodesController@index',
]); ]);
// Add New Node // Add New Node
$router->get('/new', [ $router->get('/new', [
'as' => 'admin.nodes.new', 'as' => 'admin.nodes.new',
'uses' => 'Admin\NodesController@getNew', 'uses' => 'Admin\NodesController@new',
]); ]);
$router->post('/new', [ $router->post('/new', [
'uses' => 'Admin\NodesController@postNew', 'uses' => 'Admin\NodesController@create',
]); ]);
$router->get('/view/{id}', [ $router->get('/view/{id}', [

View File

@ -130,10 +130,6 @@ class Node extends Model
'port' => $this->daemonSFTP, 'port' => $this->daemonSFTP,
'container' => 'ptdl-sftp', 'container' => 'ptdl-sftp',
], ],
'query' => [
'kill_on_fail' => true,
'fail_limit' => 5,
],
'logger' => [ 'logger' => [
'path' => 'logs/', 'path' => 'logs/',
'src' => false, 'src' => false,

File diff suppressed because one or more lines are too long

View File

@ -85,23 +85,23 @@
<i class="fa fa-home"></i> <span>Overview</span> <i class="fa fa-home"></i> <span>Overview</span>
</a> </a>
</li> </li>
<li class="{{ Route::currentRouteName() !== 'admin.settings' ?: 'active' }}"> <li class="{{ ! starts_with(Route::currentRouteName(), 'admin.settings') ?: 'active' }}">
<a href="{{ route('admin.settings')}}"> <a href="{{ route('admin.settings')}}">
<i class="fa fa-wrench"></i> <span>Settings</span> <i class="fa fa-wrench"></i> <span>Settings</span>
</a> </a>
</li> </li>
<li class="header">MANAGEMENT</li> <li class="header">MANAGEMENT</li>
<li class="{{ Route::currentRouteName() !== 'admin.servers' ?: 'active' }}"> <li class="{{ ! starts_with(Route::currentRouteName(), 'admin.servers') ?: 'active' }}">
<a href="{{ route('admin.servers') }}"> <a href="{{ route('admin.servers') }}">
<i class="fa fa-server"></i> <span>Servers</span> <i class="fa fa-server"></i> <span>Servers</span>
</a> </a>
</li> </li>
<li class="{{ Route::currentRouteName() !== 'admin.nodes' ?: 'active' }}"> <li class="{{ ! starts_with(Route::currentRouteName(), 'admin.nodes') ?: 'active' }}">
<a href="{{ route('admin.nodes') }}"> <a href="{{ route('admin.nodes') }}">
<i class="fa fa-sitemap"></i> <span>Nodes</span> <i class="fa fa-sitemap"></i> <span>Nodes</span>
</a> </a>
</li> </li>
<li class="{{ Route::currentRouteName() !== 'admin.users' ?: 'active' }}"> <li class="{{ ! starts_with(Route::currentRouteName(), 'admin.users') ?: 'active' }}">
<a href="{{ route('admin.users') }}"> <a href="{{ route('admin.users') }}">
<i class="fa fa-users"></i> <span>Users</span> <i class="fa fa-users"></i> <span>Users</span>
</a> </a>