Initial implementation of improved sever model and logic
This commit is contained in:
parent
fb589a7f4e
commit
d4bcf0be59
31 changed files with 223 additions and 158 deletions
|
@ -108,8 +108,8 @@ class NodesController extends Controller
|
|||
return view('admin.nodes.view', [
|
||||
'node' => $node,
|
||||
'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail', 'services.name as a_serviceName')
|
||||
->join('users', 'users.id', '=', 'servers.owner')
|
||||
->join('services', 'services.id', '=', 'servers.service')
|
||||
->join('users', 'users.id', '=', 'servers.owner_id')
|
||||
->join('services', 'services.id', '=', 'servers.service_id')
|
||||
->where('node', $id)->paginate(10, ['*'], 'servers'),
|
||||
'stats' => Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node', $node->id)->first(),
|
||||
'locations' => Models\Location::all(),
|
||||
|
|
|
@ -54,9 +54,9 @@ class ServersController extends Controller
|
|||
'allocations.ip',
|
||||
'allocations.port',
|
||||
'allocations.ip_alias'
|
||||
)->join('nodes', 'servers.node', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner', '=', 'users.id')
|
||||
->join('allocations', 'servers.allocation', '=', 'allocations.id');
|
||||
)->join('nodes', 'servers.node_id', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner_id', '=', 'users.id')
|
||||
->join('allocations', 'servers.allocation_id', '=', 'allocations.id');
|
||||
|
||||
if ($request->input('filter') && ! is_null($request->input('filter'))) {
|
||||
preg_match_all('/[^\s"\']+|"([^"]*)"|\'([^\']*)\'/', urldecode($request->input('filter')), $matches);
|
||||
|
@ -96,9 +96,9 @@ class ServersController extends Controller
|
|||
'allocations.ip',
|
||||
'allocations.port',
|
||||
'allocations.ip_alias'
|
||||
)->join('nodes', 'servers.node', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner', '=', 'users.id')
|
||||
->join('allocations', 'servers.allocation', '=', 'allocations.id')
|
||||
)->join('nodes', 'servers.node_id', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner_id', '=', 'users.id')
|
||||
->join('allocations', 'servers.allocation_id', '=', 'allocations.id')
|
||||
->paginate(20);
|
||||
}
|
||||
|
||||
|
@ -127,11 +127,11 @@ class ServersController extends Controller
|
|||
'allocations.ip',
|
||||
'allocations.port',
|
||||
'allocations.ip_alias'
|
||||
)->join('nodes', 'servers.node', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner', '=', 'users.id')
|
||||
->join('services', 'servers.service', '=', 'services.id')
|
||||
->join('service_options', 'servers.option', '=', 'service_options.id')
|
||||
->join('allocations', 'servers.allocation', '=', 'allocations.id')
|
||||
)->join('nodes', 'servers.node_id', '=', 'nodes.id')
|
||||
->join('users', 'servers.owner_id', '=', 'users.id')
|
||||
->join('services', 'servers.service_id', '=', 'services.id')
|
||||
->join('service_options', 'servers.option_id', '=', 'service_options.id')
|
||||
->join('allocations', 'servers.allocation_id', '=', 'allocations.id')
|
||||
->where('servers.id', $id)
|
||||
->first();
|
||||
|
||||
|
@ -145,13 +145,13 @@ class ServersController extends Controller
|
|||
'nodes.*',
|
||||
'locations.long as a_locationName'
|
||||
)->join('locations', 'nodes.location', '=', 'locations.id')
|
||||
->where('nodes.id', $server->node)
|
||||
->where('nodes.id', $server->node_id)
|
||||
->first(),
|
||||
'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(),
|
||||
'unassigned' => Models\Allocation::where('node', $server->node_id)->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('service_variables.option_id', $server->option_id)
|
||||
->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')
|
||||
|
@ -334,8 +334,8 @@ class ServersController extends Controller
|
|||
public function postUpdateServerToggleBuild(Request $request, $id)
|
||||
{
|
||||
$server = Models\Server::findOrFail($id);
|
||||
$node = Models\Node::findOrFail($server->node);
|
||||
$client = Models\Node::guzzleRequest($server->node);
|
||||
$node = Models\Node::findOrFail($server->node_id);
|
||||
$client = Models\Node::guzzleRequest($server->node_id);
|
||||
|
||||
try {
|
||||
$res = $client->request('POST', '/server/rebuild', [
|
||||
|
|
|
@ -137,7 +137,7 @@ class ServiceController extends Controller
|
|||
'option' => $opt,
|
||||
'variables' => Models\ServiceVariables::where('option_id', $option)->get(),
|
||||
'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail')
|
||||
->join('users', 'users.id', '=', 'servers.owner')
|
||||
->join('users', 'users.id', '=', 'servers.owner_id')
|
||||
->where('option', $option)
|
||||
->paginate(10),
|
||||
]);
|
||||
|
|
|
@ -87,7 +87,7 @@ class UserController extends Controller
|
|||
return view('admin.users.view', [
|
||||
'user' => User::findOrFail($id),
|
||||
'servers' => Server::select('servers.*', 'nodes.name as nodeName', 'locations.long as location')
|
||||
->join('nodes', 'servers.node', '=', 'nodes.id')
|
||||
->join('nodes', 'servers.node_id', '=', 'nodes.id')
|
||||
->join('locations', 'nodes.location', '=', 'locations.id')
|
||||
->where('owner', $id)
|
||||
->get(),
|
||||
|
|
Reference in a new issue