diff --git a/app/Http/Controllers/Admin/AjaxController.php b/app/Http/Controllers/Admin/AjaxController.php new file mode 100644 index 000000000..a63609e59 --- /dev/null +++ b/app/Http/Controllers/Admin/AjaxController.php @@ -0,0 +1,63 @@ +middleware('auth'); + $this->middleware('admin'); + + } + + public function postNewServerGetNodes(Request $request) + { + + if(!$request->input('location')) { + return response()->json([ + 'error' => 'Missing location in request.' + ], 500); + } + + return response(Node::select('id', 'name', 'public')->where('location', $request->input('location'))->get()->toJson()); + + } + + public function postNewServerGetIps(Request $request) + { + + if(!$request->input('node')) { + return response()->json([ + 'error' => 'Missing node in request.' + ], 500); + } + + $ips = Allocation::where('node', $request->input('node'))->whereNull('assigned_to')->get(); + $listing = []; + + foreach($ips as &$ip) { + if (array_key_exists($ip->ip, $listing)) { + $listing[$ip->ip] = array_merge($listing[$ip->ip], [$ip->port]); + } else { + $listing[$ip->ip] = [$ip->port]; + } + } + return response()->json($listing); + + } + +} diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 2fad3b61e..d5834c270 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -5,6 +5,7 @@ namespace Pterodactyl\Http\Controllers\Admin; use Debugbar; use Pterodactyl\Models\Server; use Pterodactyl\Models\Node; +use Pterodactyl\Models\Location; use Pterodactyl\Http\Controllers\Controller; use Illuminate\Http\Request; @@ -36,7 +37,9 @@ class ServersController extends Controller public function getNew(Request $request) { - // + return view('admin.servers.new', [ + 'locations' => Location::all() + ]); } public function getView(Request $request, $id) diff --git a/app/Http/Routes/AdminRoutes.php b/app/Http/Routes/AdminRoutes.php index 91c506a2e..ed89779fa 100644 --- a/app/Http/Routes/AdminRoutes.php +++ b/app/Http/Routes/AdminRoutes.php @@ -24,6 +24,12 @@ class AdminRoutes { $router->get('/view/{id}', [ 'as' => 'admin.servers.view', 'uses' => 'Admin\ServersController@getView' ]); }); + // AJAX Routes + $router->group(['prefix' => 'ajax'], function ($server) use ($router) { + $router->post('/new/server/get-nodes', [ 'uses' => 'Admin\AjaxController@postNewServerGetNodes' ]); + $router->post('/new/server/get-ips', [ 'uses' => 'Admin\AjaxController@postNewServerGetIps' ]); + }); + }); } diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php new file mode 100644 index 000000000..651044de9 --- /dev/null +++ b/app/Models/Allocation.php @@ -0,0 +1,17 @@ +mediumInteger('assigned_to')->unsigned()->nullable()->after('port'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('allocations', function (Blueprint $table) { + $table->dropColumn('assigned_to'); + }); + } +} diff --git a/public/css/pterodactyl.css b/public/css/pterodactyl.css index 2d03277e9..a43260d74 100755 --- a/public/css/pterodactyl.css +++ b/public/css/pterodactyl.css @@ -63,8 +63,8 @@ body{font-size:13px} .centered{text-align:center} .console{font:85% 'Droid Sans Mono',monospace;color:#333;height:300px!important;text-wrap:normal;overflow-y:scroll;overflow-x:hidden;border:0;resize:none} .console[readonly=readonly]{background:#fefefe;cursor:default} -.files_loading_box{position:absolute;background:rgba(255,255,255,.8);width:100%;z-index:9999;display:none} -.files_loading_box i{font-size:30px;color:rgba(0,0,0,.6);position:absolute} +.ajax_loading_box{position:absolute;background:rgba(255,255,255,.8);width:100%;z-index:9999;display:none} +.ajax_loading_box i{font-size:30px;color:rgba(0,0,0,.6);position:absolute} .btn-xxs{padding:2px 6px;font-size:10px;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:2px} .form-control{height:36px} .input-group-addon{font-size:12px;} diff --git a/resources/views/admin/servers/new.blade.php b/resources/views/admin/servers/new.blade.php new file mode 100644 index 000000000..cdfb68e85 --- /dev/null +++ b/resources/views/admin/servers/new.blade.php @@ -0,0 +1,200 @@ +@extends('layouts.admin') + +@section('title') + Server List +@endsection + +@section('content') +