Add per-service-option startup & executable
Also fixes display issue on front-end where users could see and edit hidden settings Fixes a bug in relation to #57
This commit is contained in:
parent
5678d643cd
commit
a903ae313a
5 changed files with 150 additions and 84 deletions
|
@ -25,6 +25,7 @@ namespace Pterodactyl\Http\Controllers\Admin;
|
|||
|
||||
use Alert;
|
||||
use Debugbar;
|
||||
use DB;
|
||||
use Log;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
|
@ -196,11 +197,7 @@ class ServersController extends Controller
|
|||
}
|
||||
|
||||
$service = Models\Service::select('executable', 'startup')->where('id', $request->input('service'))->first();
|
||||
return response()->json([
|
||||
'exec' => $service->executable,
|
||||
'startup' => $service->startup,
|
||||
'options' => Models\ServiceOptions::select('id', 'name', 'docker_image')->where('parent_service', $request->input('service'))->orderBy('name', 'asc')->get()
|
||||
]);
|
||||
return response()->json(Models\ServiceOptions::select('id', 'name', 'docker_image')->where('parent_service', $request->input('service'))->orderBy('name', 'asc')->get());
|
||||
|
||||
}
|
||||
|
||||
|
@ -219,7 +216,18 @@ class ServersController extends Controller
|
|||
], 500);
|
||||
}
|
||||
|
||||
return response()->json(Models\ServiceVariables::where('option_id', $request->input('option'))->get());
|
||||
$option = Models\ServiceOptions::select(
|
||||
DB::raw('COALESCE(service_options.executable, services.executable) as executable'),
|
||||
DB::raw('COALESCE(service_options.startup, services.startup) as startup')
|
||||
)->leftJoin('services', 'services.id', '=', 'service_options.parent_service')
|
||||
->where('service_options.id', $request->input('option'))
|
||||
->first();
|
||||
|
||||
return response()->json([
|
||||
'variables' => Models\ServiceVariables::where('option_id', $request->input('option'))->get(),
|
||||
'exec' => $option->executable,
|
||||
'startup' => $option->startup
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Server;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use Debugbar;
|
||||
use Uuid;
|
||||
use Alert;
|
||||
|
@ -194,12 +195,24 @@ class ServerController extends Controller
|
|||
public function getSettings(Request $request, $uuid)
|
||||
{
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$variables = Models\ServiceVariables::select('service_variables.*', 'server_variables.variable_value as a_serverValue')
|
||||
->join('server_variables', 'server_variables.variable_id', '=', 'service_variables.id')
|
||||
->where('service_variables.option_id', $server->option)
|
||||
->where('server_variables.server_id', $server->id)
|
||||
// $variables = Models\ServiceVariables::select('service_variables.*', 'server_variables.variable_value as a_serverValue')
|
||||
// ->join('server_variables', 'server_variables.variable_id', '=', 'service_variables.id')
|
||||
// ->where('service_variables.option_id', $server->option)
|
||||
// ->where('server_variables.server_id', $server->id)
|
||||
// ->get();
|
||||
$variables = Models\ServiceVariables::select(
|
||||
'service_variables.*',
|
||||
DB::raw('COALESCE(server_variables.variable_value, service_variables.default_value) as a_serverValue')
|
||||
)->leftJoin('server_variables', 'server_variables.variable_id', '=', 'service_variables.id')
|
||||
->where('option_id', $server->option)
|
||||
->get();
|
||||
$service = Models\Service::findOrFail($server->service);
|
||||
|
||||
$service = Models\Service::select(
|
||||
DB::raw('COALESCE(service_options.executable, services.executable) as executable'),
|
||||
DB::raw('COALESCE(service_options.startup, services.startup) as startup')
|
||||
)->leftJoin('service_options', 'service_options.parent_service', '=', 'services.id')
|
||||
->where('services.id', $server->service)
|
||||
->first();
|
||||
|
||||
$serverVariables = [
|
||||
'{{SERVER_MEMORY}}' => $server->memory,
|
||||
|
@ -216,7 +229,7 @@ class ServerController extends Controller
|
|||
return view('server.settings', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::find($server->node),
|
||||
'variables' => $variables,
|
||||
'variables' => $variables->where('user_viewable', 1),
|
||||
'service' => $service,
|
||||
'processedStartup' => $processed,
|
||||
]);
|
||||
|
@ -258,12 +271,11 @@ class ServerController extends Controller
|
|||
} catch(\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An unhandled exception occured while attemping to update startup variables for this server. Please try again.')->flash();
|
||||
} finally {
|
||||
return redirect()->route('server.settings', [
|
||||
'uuid' => $uuid,
|
||||
'tab' => 'tab_startup'
|
||||
])->withInput();
|
||||
}
|
||||
return redirect()->route('server.settings', [
|
||||
'uuid' => $uuid,
|
||||
'tab' => 'tab_startup'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue