Implement base service file modification through panel
This commit is contained in:
parent
b8a6a15b08
commit
cfd5e0e854
19 changed files with 855 additions and 1 deletions
|
@ -27,6 +27,7 @@ use Alert;
|
|||
use DB;
|
||||
use Log;
|
||||
use Validator;
|
||||
use Storage;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\ServiceRepository;
|
||||
|
@ -274,4 +275,36 @@ class ServiceController extends Controller
|
|||
return redirect()->route('admin.services.option', [$service, $option]);
|
||||
}
|
||||
|
||||
public function getConfiguration(Request $request, $serviceId)
|
||||
{
|
||||
$service = Models\Service::findOrFail($serviceId);
|
||||
return view('admin.services.config', [
|
||||
'service' => $service,
|
||||
'contents' => [
|
||||
'json' => Storage::get('services/' . $service->file . '/main.json'),
|
||||
'index' => Storage::get('services/' . $service->file . '/index.js')
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function postConfiguration(Request $request, $serviceId)
|
||||
{
|
||||
try {
|
||||
$repo = new ServiceRepository\Service;
|
||||
$repo->updateFile($serviceId, $request->except([
|
||||
'_token'
|
||||
]));
|
||||
return response('', 204);
|
||||
} catch (DisplayException $ex) {
|
||||
return response()->json([
|
||||
'error' => $ex->getMessage()
|
||||
], 503);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
return response()->json([
|
||||
'error' => 'An error occured while attempting to save the file.'
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -379,6 +379,15 @@ class AdminRoutes {
|
|||
'uses' => 'Admin\ServiceController@deleteService'
|
||||
]);
|
||||
|
||||
$router->get('/service/{id}/configuration', [
|
||||
'as' => 'admin.services.service.config',
|
||||
'uses' => 'Admin\ServiceController@getConfiguration'
|
||||
]);
|
||||
|
||||
$router->post('/service/{id}/configuration', [
|
||||
'uses' => 'Admin\ServiceController@postConfiguration'
|
||||
]);
|
||||
|
||||
$router->get('/service/{service}/option/new', [
|
||||
'as' => 'admin.services.option.new',
|
||||
'uses' => 'Admin\ServiceController@newOption'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue