Add ability to change service implementation for a server.

This commit is contained in:
Dane Everitt 2017-04-21 17:52:44 -04:00
parent e0958414d7
commit a5a1ea3165
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 383 additions and 85 deletions

View file

@ -198,7 +198,24 @@ class ServersController extends Controller
return $item;
});
return view('admin.servers.view.startup', ['server' => $server]);
$services = Models\Service::with('options.packs', 'options.variables')->get();
Javascript::put([
'services' => $services->map(function ($item) {
return array_merge($item->toArray(), [
'options' => $item->options->keyBy('id')->toArray(),
]);
})->keyBy('id'),
'server_variables' => $server->variables->mapWithKeys(function ($item) {
return ['env_' . $item->variable_id => [
'value' => $item->variable_value,
]];
})->toArray(),
]);
return view('admin.servers.view.startup', [
'server' => $server,
'services' => $services,
]);
}
/**
@ -479,9 +496,13 @@ class ServersController extends Controller
$repo = new ServerRepository;
try {
$repo->updateStartup($id, $request->except('_token'), true);
if ($repo->updateStartup($id, $request->except('_token'), true)) {
Alert::success('Service configuration successfully modfied for this server, reinstalling now.')->flash();
Alert::success('Startup variables were successfully modified and assigned for this server.')->flash();
return redirect()->route('admin.servers.view', $id);
} else {
Alert::success('Startup variables were successfully modified and assigned for this server.')->flash();
}
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.servers.view.startup', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {