Esempio n. 1
0
 public function view(Request $request, $id)
 {
     $service = Models\Service::find($id);
     if (!$service) {
         throw new NotFoundHttpException('No service by that ID was found.');
     }
     $options = Models\ServiceOptions::select('id', 'name', 'description', 'tag', 'docker_image')->where('parent_service', $service->id)->get();
     foreach ($options as &$opt) {
         $opt->variables = Models\ServiceVariables::where('option_id', $opt->id)->get();
     }
     return ['service' => $service, 'options' => $options];
 }
Esempio n. 2
0
 public function delete($id)
 {
     $service = Models\Service::findOrFail($id);
     $servers = Models\Server::where('service', $service->id)->get();
     $options = Models\ServiceOptions::select('id')->where('parent_service', $service->id);
     if (count($servers) !== 0) {
         throw new DisplayException('You cannot delete a service that has servers associated with it.');
     }
     DB::beginTransaction();
     try {
         Models\ServiceVariables::whereIn('option_id', $options->get()->toArray())->delete();
         $options->delete();
         $service->delete();
         DB::commit();
     } catch (\Exception $ex) {
         DB::rollBack();
         throw $ex;
     }
 }
Esempio n. 3
0
 /**
  * Returns a JSON tree of all avaliable variables for a given service option.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Contracts\View\View
  */
 public function postNewServerServiceVariables(Request $request)
 {
     if (!$request->input('option')) {
         return response()->json(['error' => 'Missing option in request.'], 500);
     }
     $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]);
 }
Esempio n. 4
0
 public function deleteOption(Request $request, $service, $option)
 {
     try {
         $service = Models\ServiceOptions::select('parent_service')->where('id', $option)->first();
         $repo = new ServiceRepository\Option();
         $repo->delete($option);
         Alert::success('Successfully deleted that option.')->flash();
         return redirect()->route('admin.services.service', $service->parent_service);
     } catch (DisplayException $ex) {
         Alert::danger($ex->getMessage())->flash();
     } catch (\Exception $ex) {
         Log::error($ex);
         Alert::danger('An error was encountered while attempting to delete this option.')->flash();
     }
     return redirect()->route('admin.services.option', [$service, $option]);
 }