Ejemplo n.º 1
0
 public function getView(Request $request, $id)
 {
     $server = Models\Server::select('servers.*', 'nodes.name as a_nodeName', 'users.email as a_ownerEmail', 'locations.long as a_locationName', 'services.name as a_serviceName', DB::raw('IFNULL(service_options.executable, services.executable) as a_serviceExecutable'), 'service_options.docker_image', 'service_options.name as a_servceOptionName', 'allocations.ip', 'allocations.port', 'allocations.ip_alias')->join('nodes', 'servers.node', '=', 'nodes.id')->join('users', 'servers.owner', '=', 'users.id')->join('locations', 'nodes.location', '=', 'locations.id')->join('services', 'servers.service', '=', 'services.id')->join('service_options', 'servers.option', '=', 'service_options.id')->join('allocations', 'servers.allocation', '=', 'allocations.id')->where('servers.id', $id)->first();
     if (!$server) {
         return abort(404);
     }
     return view('admin.servers.view', ['server' => $server, 'assigned' => Models\Allocation::where('assigned_to', $id)->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(), 'unassigned' => Models\Allocation::where('node', $server->node)->whereNull('assigned_to')->orderBy('ip', 'asc')->orderBy('port', 'asc')->get(), 'startup' => 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(), 'databases' => Models\Database::select('databases.*', 'database_servers.host as a_host', 'database_servers.port as a_port')->where('server_id', $server->id)->join('database_servers', 'database_servers.id', '=', 'databases.db_server')->get(), 'db_servers' => Models\DatabaseServer::all()]);
 }
Ejemplo n.º 2
0
 public function getIndex(Request $request)
 {
     return view('admin.databases.index', ['databases' => Models\Database::select('databases.*', 'database_servers.host as a_host', 'database_servers.port as a_port', 'servers.id as a_serverId', 'servers.name as a_serverName')->join('database_servers', 'database_servers.id', '=', 'databases.db_server')->join('servers', 'databases.server_id', '=', 'servers.id')->paginate(20), 'dbh' => Models\DatabaseServer::select('database_servers.*', 'nodes.name as a_linkedNode', DB::raw('(SELECT COUNT(*) FROM `databases` WHERE `databases`.`db_server` = database_servers.id) as c_databases'))->join('nodes', 'nodes.id', '=', 'database_servers.linked_node')->paginate(20)]);
 }
Ejemplo n.º 3
0
 /**
  * Renders server settings page.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Contracts\View\View
  */
 public function getSettings(Request $request, $uuid)
 {
     $server = Models\Server::getByUUID($uuid);
     $allocation = Models\Allocation::findOrFail($server->allocation);
     $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('service_variables.option_id', $server->option)->where('server_variables.server_id', $server->id)->get();
     $service = Models\Service::select(DB::raw('IFNULL(service_options.executable, services.executable) as executable'))->leftJoin('service_options', 'service_options.parent_service', '=', 'services.id')->where('service_options.id', $server->option)->where('services.id', $server->service)->first();
     $serverVariables = ['{{SERVER_MEMORY}}' => $server->memory, '{{SERVER_IP}}' => $allocation->ip, '{{SERVER_PORT}}' => $allocation->port];
     $processed = str_replace(array_keys($serverVariables), array_values($serverVariables), $server->startup);
     foreach ($variables as &$variable) {
         $replace = $variable->user_viewable === 1 ? $variable->a_serverValue : '**';
         $processed = str_replace('{{' . $variable->env_variable . '}}', $replace, $processed);
     }
     return view('server.settings', ['server' => $server, 'databases' => Models\Database::select('databases.*', 'database_servers.host as a_host', 'database_servers.port as a_port')->where('server_id', $server->id)->join('database_servers', 'database_servers.id', '=', 'databases.db_server')->get(), 'node' => Models\Node::find($server->node), 'variables' => $variables->where('user_viewable', 1), 'service' => $service, 'processedStartup' => $processed]);
 }