diff --git a/app/Console/Commands/Location/DeleteLocationCommand.php b/app/Console/Commands/Location/DeleteLocationCommand.php
deleted file mode 100644
index f9e6ddb8d..000000000
--- a/app/Console/Commands/Location/DeleteLocationCommand.php
+++ /dev/null
@@ -1,55 +0,0 @@
-locations = $this->locations ?? $this->repository->all();
- $short = $this->option('short') ?? $this->anticipate(
- trans('command/messages.location.ask_short'),
- $this->locations->pluck('short')->toArray()
- );
-
- $location = $this->locations->where('short', $short)->first();
- if (is_null($location)) {
- $this->error(trans('command/messages.location.no_location_found'));
- if ($this->input->isInteractive()) {
- $this->handle();
- }
-
- return;
- }
-
- $this->deletionService->handle($location->id);
- $this->line(trans('command/messages.location.deleted'));
- }
-}
diff --git a/app/Console/Commands/Location/MakeLocationCommand.php b/app/Console/Commands/Location/MakeLocationCommand.php
deleted file mode 100644
index 6eb878b8b..000000000
--- a/app/Console/Commands/Location/MakeLocationCommand.php
+++ /dev/null
@@ -1,40 +0,0 @@
-option('short') ?? $this->ask(trans('command/messages.location.ask_short'));
- $long = $this->option('long') ?? $this->ask(trans('command/messages.location.ask_long'));
-
- $location = $this->creationService->handle(compact('short', 'long'));
- $this->line(trans('command/messages.location.created', [
- 'name' => $location->short,
- 'id' => $location->id,
- ]));
- }
-}
diff --git a/app/Console/Commands/Node/MakeNodeCommand.php b/app/Console/Commands/Node/MakeNodeCommand.php
index eaa627a52..5abf45f40 100644
--- a/app/Console/Commands/Node/MakeNodeCommand.php
+++ b/app/Console/Commands/Node/MakeNodeCommand.php
@@ -44,7 +44,6 @@ class MakeNodeCommand extends Command
{
$data['name'] = $this->option('name') ?? $this->ask('Enter a short identifier used to distinguish this node from others');
$data['description'] = $this->option('description') ?? $this->ask('Enter a description to identify the node');
- $data['location_id'] = $this->option('locationId') ?? $this->ask('Enter a valid location id');
$data['scheme'] = $this->option('scheme') ?? $this->anticipate(
'Please either enter https for SSL or http for a non-ssl connection',
['https', 'http'],
@@ -64,6 +63,6 @@ class MakeNodeCommand extends Command
$data['daemonBase'] = $this->option('daemonBase') ?? $this->ask('Enter the base folder', '/var/lib/panel/volumes');
$node = $this->creationService->handle($data);
- $this->line('Successfully created a new node on the location ' . $data['location_id'] . ' with the name ' . $data['name'] . ' and has an id of ' . $node->id . '.');
+ $this->line('Successfully created a new node with the name ' . $data['name'] . ' and has an id of ' . $node->id . '.');
}
}
diff --git a/app/Console/Commands/Node/NodeListCommand.php b/app/Console/Commands/Node/NodeListCommand.php
index 715f0c209..9cc8d7ab3 100644
--- a/app/Console/Commands/Node/NodeListCommand.php
+++ b/app/Console/Commands/Node/NodeListCommand.php
@@ -16,7 +16,6 @@ class NodeListCommand extends Command
'id' => $node->id,
'uuid' => $node->uuid,
'name' => $node->name,
- 'location' => $node->location->short,
'host' => $node->getConnectionAddress(),
];
});
@@ -24,7 +23,7 @@ class NodeListCommand extends Command
if ($this->option('format') === 'json') {
$this->output->write($nodes->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
} else {
- $this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->toArray());
+ $this->table(['ID', 'UUID', 'Name', 'Host'], $nodes->toArray());
}
$this->output->newLine();
diff --git a/app/Contracts/Repository/LocationRepositoryInterface.php b/app/Contracts/Repository/LocationRepositoryInterface.php
deleted file mode 100644
index c372988d7..000000000
--- a/app/Contracts/Repository/LocationRepositoryInterface.php
+++ /dev/null
@@ -1,33 +0,0 @@
-view->make('admin.databases.index', [
- 'locations' => $this->locationRepository->getAllWithNodes(),
+ 'nodes' => Node::all(),
'hosts' => $this->repository->getWithViewDetails(),
]);
}
@@ -53,7 +51,6 @@ class DatabaseController extends Controller
public function view(int $host): View
{
return $this->view->make('admin.databases.view', [
- 'locations' => $this->locationRepository->getAllWithNodes(),
'host' => $this->repository->find($host),
'databases' => $this->databaseRepository->getDatabasesForHost($host),
]);
diff --git a/app/Http/Controllers/Admin/LocationController.php b/app/Http/Controllers/Admin/LocationController.php
deleted file mode 100644
index c4729f77e..000000000
--- a/app/Http/Controllers/Admin/LocationController.php
+++ /dev/null
@@ -1,103 +0,0 @@
-view->make('admin.locations.index', [
- 'locations' => $this->repository->getAllWithDetails(),
- ]);
- }
-
- /**
- * Return the location view page.
- *
- * @throws \App\Exceptions\Repository\RecordNotFoundException
- */
- public function view(int $id): View
- {
- return $this->view->make('admin.locations.view', [
- 'location' => $this->repository->getWithNodes($id),
- ]);
- }
-
- /**
- * Handle request to create new location.
- *
- * @throws \Throwable
- */
- public function create(LocationFormRequest $request): RedirectResponse
- {
- $location = $this->creationService->handle($request->normalize());
- $this->alert->success('Location was created successfully.')->flash();
-
- return redirect()->route('admin.locations.view', $location->id);
- }
-
- /**
- * Handle request to update or delete location.
- *
- * @throws \Throwable
- */
- public function update(LocationFormRequest $request, Location $location): RedirectResponse
- {
- if ($request->input('action') === 'delete') {
- return $this->delete($location);
- }
-
- $this->updateService->handle($location->id, $request->normalize());
- $this->alert->success('Location was updated successfully.')->flash();
-
- return redirect()->route('admin.locations.view', $location->id);
- }
-
- /**
- * Delete a location from the system.
- *
- * @throws \Exception
- * @throws \App\Exceptions\DisplayException
- */
- public function delete(Location $location): RedirectResponse
- {
- try {
- $this->deletionService->handle($location->id);
-
- return redirect()->route('admin.locations');
- } catch (DisplayException $ex) {
- $this->alert->danger($ex->getMessage())->flash();
- }
-
- return redirect()->route('admin.locations.view', $location->id);
- }
-}
diff --git a/app/Http/Controllers/Admin/MountController.php b/app/Http/Controllers/Admin/MountController.php
index 305ef19c2..de39ac89a 100644
--- a/app/Http/Controllers/Admin/MountController.php
+++ b/app/Http/Controllers/Admin/MountController.php
@@ -8,14 +8,12 @@ use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Models\Mount;
-use App\Models\Location;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Illuminate\View\Factory as ViewFactory;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\MountFormRequest;
use App\Repositories\Eloquent\MountRepository;
-use App\Contracts\Repository\LocationRepositoryInterface;
class MountController extends Controller
{
@@ -24,7 +22,6 @@ class MountController extends Controller
*/
public function __construct(
protected AlertsMessageBag $alert,
- protected LocationRepositoryInterface $locationRepository,
protected MountRepository $repository,
protected ViewFactory $view
) {
@@ -48,12 +45,10 @@ class MountController extends Controller
public function view(string $id): View
{
$eggs = Egg::all();
- $locations = Location::query()->with('nodes')->get();
return $this->view->make('admin.mounts.view', [
'mount' => $this->repository->getWithRelations($id),
'eggs' => $eggs,
- 'locations' => $locations,
]);
}
diff --git a/app/Http/Controllers/Admin/Nodes/NodeController.php b/app/Http/Controllers/Admin/Nodes/NodeController.php
index 014527a2d..4c7d841a4 100644
--- a/app/Http/Controllers/Admin/Nodes/NodeController.php
+++ b/app/Http/Controllers/Admin/Nodes/NodeController.php
@@ -24,7 +24,7 @@ class NodeController extends Controller
public function index(Request $request): View
{
$nodes = QueryBuilder::for(
- Node::query()->with('location')->withCount('servers')
+ Node::query()->withCount('servers')
)
->allowedFilters(['uuid', 'name'])
->allowedSorts(['id'])
diff --git a/app/Http/Controllers/Admin/Nodes/NodeViewController.php b/app/Http/Controllers/Admin/Nodes/NodeViewController.php
index 632bff30c..d7d4e9e33 100644
--- a/app/Http/Controllers/Admin/Nodes/NodeViewController.php
+++ b/app/Http/Controllers/Admin/Nodes/NodeViewController.php
@@ -13,7 +13,6 @@ use App\Repositories\Eloquent\NodeRepository;
use App\Repositories\Eloquent\ServerRepository;
use App\Traits\Controllers\JavascriptInjection;
use App\Services\Helpers\SoftwareVersionService;
-use App\Repositories\Eloquent\LocationRepository;
use App\Repositories\Eloquent\AllocationRepository;
class NodeViewController extends Controller
@@ -25,7 +24,6 @@ class NodeViewController extends Controller
*/
public function __construct(
private AllocationRepository $allocationRepository,
- private LocationRepository $locationRepository,
private NodeRepository $repository,
private ServerRepository $serverRepository,
private SoftwareVersionService $versionService,
@@ -38,7 +36,7 @@ class NodeViewController extends Controller
*/
public function index(Request $request, Node $node): View
{
- $node = $this->repository->loadLocationAndServerCount($node);
+ $node = $this->repository->loadServerCount($node);
return $this->view->make('admin.nodes.view.index', [
'node' => $node,
@@ -54,7 +52,6 @@ class NodeViewController extends Controller
{
return $this->view->make('admin.nodes.view.settings', [
'node' => $node,
- 'locations' => $this->locationRepository->all(),
]);
}
diff --git a/app/Http/Controllers/Admin/NodesController.php b/app/Http/Controllers/Admin/NodesController.php
index 4a32c77bb..dd1aa666b 100644
--- a/app/Http/Controllers/Admin/NodesController.php
+++ b/app/Http/Controllers/Admin/NodesController.php
@@ -22,7 +22,6 @@ use App\Contracts\Repository\NodeRepositoryInterface;
use App\Contracts\Repository\ServerRepositoryInterface;
use App\Http\Requests\Admin\Node\AllocationFormRequest;
use App\Services\Allocations\AllocationDeletionService;
-use App\Contracts\Repository\LocationRepositoryInterface;
use App\Contracts\Repository\AllocationRepositoryInterface;
use App\Http\Requests\Admin\Node\AllocationAliasFormRequest;
@@ -39,7 +38,6 @@ class NodesController extends Controller
protected CacheRepository $cache,
protected NodeCreationService $creationService,
protected NodeDeletionService $deletionService,
- protected LocationRepositoryInterface $locationRepository,
protected NodeRepositoryInterface $repository,
protected ServerRepositoryInterface $serverRepository,
protected NodeUpdateService $updateService,
@@ -53,14 +51,7 @@ class NodesController extends Controller
*/
public function create(): View|RedirectResponse
{
- $locations = $this->locationRepository->all();
- if (count($locations) < 1) {
- $this->alert->warning(trans('admin/node.notices.location_required'))->flash();
-
- return redirect()->route('admin.locations');
- }
-
- return $this->view->make('admin.nodes.new', ['locations' => $locations]);
+ return $this->view->make('admin.nodes.new');
}
/**
diff --git a/app/Http/Controllers/Admin/Servers/CreateServerController.php b/app/Http/Controllers/Admin/Servers/CreateServerController.php
index 1bd83f378..47907fbcb 100644
--- a/app/Http/Controllers/Admin/Servers/CreateServerController.php
+++ b/app/Http/Controllers/Admin/Servers/CreateServerController.php
@@ -5,7 +5,6 @@ namespace App\Http\Controllers\Admin\Servers;
use App\Models\Egg;
use Illuminate\View\View;
use App\Models\Node;
-use App\Models\Location;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Illuminate\View\Factory as ViewFactory;
@@ -49,8 +48,8 @@ class CreateServerController extends Controller
]);
return $this->view->make('admin.servers.new', [
- 'locations' => Location::all(),
'eggs' => $eggs,
+ 'nodes' => Node::all(),
]);
}
diff --git a/app/Http/Controllers/Admin/Servers/ServerViewController.php b/app/Http/Controllers/Admin/Servers/ServerViewController.php
index 887fa1220..493873789 100644
--- a/app/Http/Controllers/Admin/Servers/ServerViewController.php
+++ b/app/Http/Controllers/Admin/Servers/ServerViewController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin\Servers;
use App\Models\Egg;
+use App\Models\Node;
use App\Repositories\Eloquent\EggRepository;
use Illuminate\View\View;
use Illuminate\Http\Request;
@@ -15,7 +16,6 @@ use App\Repositories\Eloquent\NodeRepository;
use App\Repositories\Eloquent\MountRepository;
use App\Repositories\Eloquent\ServerRepository;
use App\Traits\Controllers\JavascriptInjection;
-use App\Repositories\Eloquent\LocationRepository;
use App\Repositories\Eloquent\DatabaseHostRepository;
class ServerViewController extends Controller
@@ -27,7 +27,6 @@ class ServerViewController extends Controller
*/
public function __construct(
private DatabaseHostRepository $databaseHostRepository,
- private LocationRepository $locationRepository,
private MountRepository $mountRepository,
private EggRepository $eggRepository,
private NodeRepository $nodeRepository,
@@ -134,8 +133,8 @@ class ServerViewController extends Controller
]);
return $this->view->make('admin.servers.view.manage', [
+ 'nodes' => Node::all(),
'server' => $server,
- 'locations' => $this->locationRepository->all(),
'canTransfer' => $canTransfer,
]);
}
diff --git a/app/Http/Controllers/Api/Application/Locations/LocationController.php b/app/Http/Controllers/Api/Application/Locations/LocationController.php
deleted file mode 100644
index eb5881fcd..000000000
--- a/app/Http/Controllers/Api/Application/Locations/LocationController.php
+++ /dev/null
@@ -1,104 +0,0 @@
-allowedFilters(['short', 'long'])
- ->allowedSorts(['id'])
- ->paginate($request->query('per_page') ?? 50);
-
- return $this->fractal->collection($locations)
- ->transformWith($this->getTransformer(LocationTransformer::class))
- ->toArray();
- }
-
- /**
- * Return a single location.
- */
- public function view(GetLocationRequest $request, Location $location): array
- {
- return $this->fractal->item($location)
- ->transformWith($this->getTransformer(LocationTransformer::class))
- ->toArray();
- }
-
- /**
- * Store a new location on the Panel and return an HTTP/201 response code with the
- * new location attached.
- *
- * @throws \App\Exceptions\Model\DataValidationException
- */
- public function store(StoreLocationRequest $request): JsonResponse
- {
- $location = $this->creationService->handle($request->validated());
-
- return $this->fractal->item($location)
- ->transformWith($this->getTransformer(LocationTransformer::class))
- ->addMeta([
- 'resource' => route('api.application.locations.view', [
- 'location' => $location->id,
- ]),
- ])
- ->respond(201);
- }
-
- /**
- * Update a location on the Panel and return the updated record to the user.
- *
- * @throws \App\Exceptions\Model\DataValidationException
- * @throws \App\Exceptions\Repository\RecordNotFoundException
- */
- public function update(UpdateLocationRequest $request, Location $location): array
- {
- $location = $this->updateService->handle($location, $request->validated());
-
- return $this->fractal->item($location)
- ->transformWith($this->getTransformer(LocationTransformer::class))
- ->toArray();
- }
-
- /**
- * Delete a location from the Panel.
- *
- * @throws \App\Exceptions\Service\Location\HasActiveNodesException
- */
- public function delete(DeleteLocationRequest $request, Location $location): Response
- {
- $this->deletionService->handle($location);
-
- return response('', 204);
- }
-}
diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php
index f0ec3ad38..1cdba3ce0 100644
--- a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php
+++ b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php
@@ -27,7 +27,7 @@ class NodeDeploymentController extends ApplicationApiController
public function __invoke(GetDeployableNodesRequest $request): array
{
$data = $request->validated();
- $nodes = $this->viableNodesService->setLocations($data['location_ids'] ?? [])
+ $nodes = $this->viableNodesService
->setMemory($data['memory'])
->setDisk($data['disk'])
->handle($request->query('per_page'), $request->query('page'));
diff --git a/app/Http/Requests/Admin/LocationFormRequest.php b/app/Http/Requests/Admin/LocationFormRequest.php
deleted file mode 100644
index de465bc1c..000000000
--- a/app/Http/Requests/Admin/LocationFormRequest.php
+++ /dev/null
@@ -1,20 +0,0 @@
-method() === 'PATCH') {
- return Location::getRulesForUpdate($this->route()->parameter('location')->id);
- }
-
- return Location::getRules();
- }
-}
diff --git a/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php b/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php
deleted file mode 100644
index a3934e63e..000000000
--- a/app/Http/Requests/Api/Application/Locations/DeleteLocationRequest.php
+++ /dev/null
@@ -1,13 +0,0 @@
-only([
- 'long',
- 'short',
- ])->toArray();
- }
-
- /**
- * Rename fields to be more clear in error messages.
- */
- public function attributes(): array
- {
- return [
- 'long' => 'Location Description',
- 'short' => 'Location Identifier',
- ];
- }
-}
diff --git a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php
deleted file mode 100644
index 9304398d8..000000000
--- a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php
+++ /dev/null
@@ -1,21 +0,0 @@
-route()->parameter('location')->id;
-
- return collect(Location::getRulesForUpdate($locationId))->only([
- 'short',
- 'long',
- ])->toArray();
- }
-}
diff --git a/app/Http/Requests/Api/Application/Nodes/GetDeployableNodesRequest.php b/app/Http/Requests/Api/Application/Nodes/GetDeployableNodesRequest.php
index fbac3fb21..c5c351cf1 100644
--- a/app/Http/Requests/Api/Application/Nodes/GetDeployableNodesRequest.php
+++ b/app/Http/Requests/Api/Application/Nodes/GetDeployableNodesRequest.php
@@ -10,8 +10,6 @@ class GetDeployableNodesRequest extends GetNodesRequest
'page' => 'integer',
'memory' => 'required|integer|min:0',
'disk' => 'required|integer|min:0',
- 'location_ids' => 'array',
- 'location_ids.*' => 'integer',
];
}
}
diff --git a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php
index 13663f044..99b98c375 100644
--- a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php
+++ b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php
@@ -20,7 +20,6 @@ class StoreNodeRequest extends ApplicationApiRequest
return collect($rules ?? Node::getRules())->only([
'public',
'name',
- 'location_id',
'fqdn',
'scheme',
'behind_proxy',
@@ -48,7 +47,6 @@ class StoreNodeRequest extends ApplicationApiRequest
return [
'daemon_base' => 'Daemon Base Path',
'upload_size' => 'File Upload Size Limit',
- 'location_id' => 'Location',
'public' => 'Node Visibility',
];
}
diff --git a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php
index 9cfe2f2df..c1919255f 100644
--- a/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php
+++ b/app/Http/Requests/Api/Application/Servers/StoreServerRequest.php
@@ -123,10 +123,6 @@ class StoreServerRequest extends ApplicationApiRequest
return !$input->deploy;
});
- $validator->sometimes('deploy.locations', 'present', function ($input) {
- return $input->deploy;
- });
-
$validator->sometimes('deploy.port_range', 'present', function ($input) {
return $input->deploy;
});
@@ -143,7 +139,6 @@ class StoreServerRequest extends ApplicationApiRequest
$object = new DeploymentObject();
$object->setDedicated($this->input('deploy.dedicated_ip', false));
- $object->setLocations($this->input('deploy.locations', []));
$object->setPorts($this->input('deploy.port_range', []));
return $object;
diff --git a/app/Models/ApiKey.php b/app/Models/ApiKey.php
index 832cc8380..e6cf1f352 100644
--- a/app/Models/ApiKey.php
+++ b/app/Models/ApiKey.php
@@ -25,7 +25,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property int $r_nodes
* @property int $r_allocations
* @property int $r_users
- * @property int $r_locations
* @property int $r_eggs
* @property int $r_database_hosts
* @property int $r_server_databases
@@ -46,7 +45,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRAllocations($value)
* @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRDatabaseHosts($value)
* @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereREggs($value)
- * @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRLocations($value)
* @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRNodes($value)
* @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRServerDatabases($value)
* @method static \Illuminate\Database\Eloquent\Builder|ApiKey whereRServers($value)
@@ -105,8 +103,6 @@ class ApiKey extends Model
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int',
'r_' . AdminAcl::RESOURCE_EGGS => 'int',
- 'r_' . AdminAcl::RESOURCE_LOCATIONS => 'int',
- 'r_' . AdminAcl::RESOURCE_EGGS => 'int',
'r_' . AdminAcl::RESOURCE_NODES => 'int',
'r_' . AdminAcl::RESOURCE_SERVERS => 'int',
];
diff --git a/app/Models/Location.php b/app/Models/Location.php
deleted file mode 100644
index fed00e1a4..000000000
--- a/app/Models/Location.php
+++ /dev/null
@@ -1,66 +0,0 @@
- 'required|string|between:1,60|unique:locations,short',
- 'long' => 'string|nullable|between:1,191',
- ];
-
- /**
- * {@inheritDoc}
- */
- public function getRouteKeyName(): string
- {
- return $this->getKeyName();
- }
-
- /**
- * Gets the nodes in a specified location.
- */
- public function nodes(): HasMany
- {
- return $this->hasMany(Node::class);
- }
-
- /**
- * Gets the servers within a given location.
- */
- public function servers(): HasManyThrough
- {
- return $this->hasManyThrough(Server::class, Node::class);
- }
-}
diff --git a/app/Models/Node.php b/app/Models/Node.php
index 06aa0a766..a7785228a 100644
--- a/app/Models/Node.php
+++ b/app/Models/Node.php
@@ -17,7 +17,6 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
* @property bool $public
* @property string $name
* @property string|null $description
- * @property int $location_id
* @property string $fqdn
* @property string $scheme
* @property bool $behind_proxy
@@ -34,7 +33,6 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
* @property string $daemonBase
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
- * @property \App\Models\Location $location
* @property \App\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts
* @property \App\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
* @property \App\Models\Allocation[]|\Illuminate\Database\Eloquent\Collection $allocations
@@ -66,7 +64,6 @@ class Node extends Model
* Cast values to correct type.
*/
protected $casts = [
- 'location_id' => 'integer',
'memory' => 'integer',
'disk' => 'integer',
'daemonListen' => 'integer',
@@ -80,7 +77,7 @@ class Node extends Model
* Fields that are mass assignable.
*/
protected $fillable = [
- 'public', 'name', 'location_id',
+ 'public', 'name',
'fqdn', 'scheme', 'behind_proxy',
'memory', 'memory_overallocate', 'disk',
'disk_overallocate', 'upload_size', 'daemonBase',
@@ -91,7 +88,6 @@ class Node extends Model
public static array $validationRules = [
'name' => 'required|regex:/^([\w .-]{1,100})$/',
'description' => 'string|nullable',
- 'location_id' => 'required|exists:locations,id',
'public' => 'boolean',
'fqdn' => 'required|string',
'scheme' => 'required',
@@ -196,14 +192,6 @@ class Node extends Model
return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id');
}
- /**
- * Gets the location associated with a node.
- */
- public function location(): BelongsTo
- {
- return $this->belongsTo(Location::class);
- }
-
/**
* Gets the servers associated with a node.
*/
diff --git a/app/Models/Objects/DeploymentObject.php b/app/Models/Objects/DeploymentObject.php
index b0ea8ef9c..d5b02dd83 100644
--- a/app/Models/Objects/DeploymentObject.php
+++ b/app/Models/Objects/DeploymentObject.php
@@ -6,8 +6,6 @@ class DeploymentObject
{
private bool $dedicated = false;
- private array $locations = [];
-
private array $ports = [];
public function isDedicated(): bool
@@ -22,18 +20,6 @@ class DeploymentObject
return $this;
}
- public function getLocations(): array
- {
- return $this->locations;
- }
-
- public function setLocations(array $locations): self
- {
- $this->locations = $locations;
-
- return $this;
- }
-
public function getPorts(): array
{
return $this->ports;
diff --git a/app/Models/Server.php b/app/Models/Server.php
index 7a1f07915..f6f9fd732 100644
--- a/app/Models/Server.php
+++ b/app/Models/Server.php
@@ -289,16 +289,6 @@ class Server extends Model
return $this->hasMany(Database::class);
}
- /**
- * Returns the location that a server belongs to.
- *
- * @throws \Exception
- */
- public function location(): \Znck\Eloquent\Relations\BelongsToThrough
- {
- return $this->belongsToThrough(Location::class, Node::class);
- }
-
/**
* Returns the associated server transfer.
*/
diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php
index c7bff4ea4..2b14d07ad 100644
--- a/app/Providers/RepositoryServiceProvider.php
+++ b/app/Providers/RepositoryServiceProvider.php
@@ -12,7 +12,6 @@ use App\Repositories\Eloquent\ServerRepository;
use App\Repositories\Eloquent\SessionRepository;
use App\Repositories\Eloquent\SubuserRepository;
use App\Repositories\Eloquent\DatabaseRepository;
-use App\Repositories\Eloquent\LocationRepository;
use App\Repositories\Eloquent\ScheduleRepository;
use App\Repositories\Eloquent\SettingsRepository;
use App\Repositories\Eloquent\AllocationRepository;
@@ -28,7 +27,6 @@ use App\Repositories\Eloquent\ServerVariableRepository;
use App\Contracts\Repository\SessionRepositoryInterface;
use App\Contracts\Repository\SubuserRepositoryInterface;
use App\Contracts\Repository\DatabaseRepositoryInterface;
-use App\Contracts\Repository\LocationRepositoryInterface;
use App\Contracts\Repository\ScheduleRepositoryInterface;
use App\Contracts\Repository\SettingsRepositoryInterface;
use App\Contracts\Repository\AllocationRepositoryInterface;
@@ -50,7 +48,6 @@ class RepositoryServiceProvider extends ServiceProvider
$this->app->bind(DatabaseHostRepositoryInterface::class, DatabaseHostRepository::class);
$this->app->bind(EggRepositoryInterface::class, EggRepository::class);
$this->app->bind(EggVariableRepositoryInterface::class, EggVariableRepository::class);
- $this->app->bind(LocationRepositoryInterface::class, LocationRepository::class);
$this->app->bind(NodeRepositoryInterface::class, NodeRepository::class);
$this->app->bind(ScheduleRepositoryInterface::class, ScheduleRepository::class);
$this->app->bind(ServerRepositoryInterface::class, ServerRepository::class);
diff --git a/app/Repositories/Eloquent/LocationRepository.php b/app/Repositories/Eloquent/LocationRepository.php
deleted file mode 100644
index ed99b07b8..000000000
--- a/app/Repositories/Eloquent/LocationRepository.php
+++ /dev/null
@@ -1,64 +0,0 @@
-getBuilder()->withCount('nodes', 'servers')->get($this->getColumns());
- }
-
- /**
- * Return all the available locations with the nodes as a relationship.
- */
- public function getAllWithNodes(): Collection
- {
- return $this->getBuilder()->with('nodes')->get($this->getColumns());
- }
-
- /**
- * Return all the nodes and their respective count of servers for a location.
- *
- * @throws \App\Exceptions\Repository\RecordNotFoundException
- */
- public function getWithNodes(int $id): Location
- {
- try {
- return $this->getBuilder()->with('nodes.servers')->findOrFail($id, $this->getColumns());
- } catch (ModelNotFoundException) {
- throw new RecordNotFoundException();
- }
- }
-
- /**
- * Return a location and the count of nodes in that location.
- *
- * @throws \App\Exceptions\Repository\RecordNotFoundException
- */
- public function getWithNodeCount(int $id): Location
- {
- try {
- return $this->getBuilder()->withCount('nodes')->findOrFail($id, $this->getColumns());
- } catch (ModelNotFoundException) {
- throw new RecordNotFoundException();
- }
- }
-}
diff --git a/app/Repositories/Eloquent/NodeRepository.php b/app/Repositories/Eloquent/NodeRepository.php
index 62a97b25c..ea055db94 100644
--- a/app/Repositories/Eloquent/NodeRepository.php
+++ b/app/Repositories/Eloquent/NodeRepository.php
@@ -73,14 +73,10 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
}
/**
- * Return a single node with location and server information.
+ * Return a single node with server information.
*/
- public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node
+ public function loadServerCount(Node $node, bool $refresh = false): Node
{
- if (!$node->relationLoaded('location') || $refresh) {
- $node->load('location');
- }
-
// This is quite ugly and can probably be improved down the road.
// And by probably, I mean it should.
if (is_null($node->servers_count) || $refresh) {
diff --git a/app/Services/Acl/Api/AdminAcl.php b/app/Services/Acl/Api/AdminAcl.php
index f8b7c880e..b5f9077fc 100644
--- a/app/Services/Acl/Api/AdminAcl.php
+++ b/app/Services/Acl/Api/AdminAcl.php
@@ -28,7 +28,6 @@ class AdminAcl
public const RESOURCE_NODES = 'nodes';
public const RESOURCE_ALLOCATIONS = 'allocations';
public const RESOURCE_USERS = 'users';
- public const RESOURCE_LOCATIONS = 'locations';
public const RESOURCE_EGGS = 'eggs';
public const RESOURCE_DATABASE_HOSTS = 'database_hosts';
public const RESOURCE_SERVER_DATABASES = 'server_databases';
diff --git a/app/Services/Deployment/FindViableNodesService.php b/app/Services/Deployment/FindViableNodesService.php
index f13d85f87..a2f49f7bb 100644
--- a/app/Services/Deployment/FindViableNodesService.php
+++ b/app/Services/Deployment/FindViableNodesService.php
@@ -10,22 +10,9 @@ use App\Exceptions\Service\Deployment\NoViableNodeException;
class FindViableNodesService
{
- protected array $locations = [];
protected ?int $disk = null;
protected ?int $memory = null;
- /**
- * Set the locations that should be searched through to locate available nodes.
- */
- public function setLocations(array $locations): self
- {
- Assert::allIntegerish($locations, 'An array of location IDs should be provided when calling setLocations.');
-
- $this->locations = $locations;
-
- return $this;
- }
-
/**
* Set the amount of disk that will be used by the server being created. Nodes will be
* filtered out if they do not have enough available free disk space for this server
@@ -77,10 +64,6 @@ class FindViableNodesService
->leftJoin('servers', 'servers.node_id', '=', 'nodes.id')
->where('nodes.public', 1);
- if (!empty($this->locations)) {
- $query = $query->whereIn('nodes.location_id', $this->locations);
- }
-
$results = $query->groupBy('nodes.id')
->havingRaw('(IFNULL(SUM(servers.memory), 0) + ?) <= (nodes.memory * (1 + (nodes.memory_overallocate / 100)))', [$this->memory])
->havingRaw('(IFNULL(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1 + (nodes.disk_overallocate / 100)))', [$this->disk]);
diff --git a/app/Services/Locations/LocationCreationService.php b/app/Services/Locations/LocationCreationService.php
deleted file mode 100644
index ff7aed2bd..000000000
--- a/app/Services/Locations/LocationCreationService.php
+++ /dev/null
@@ -1,26 +0,0 @@
-repository->create($data);
- }
-}
diff --git a/app/Services/Locations/LocationDeletionService.php b/app/Services/Locations/LocationDeletionService.php
deleted file mode 100644
index ec23ac51d..000000000
--- a/app/Services/Locations/LocationDeletionService.php
+++ /dev/null
@@ -1,40 +0,0 @@
-id : $location;
-
- Assert::integerish($location, 'First argument passed to handle must be numeric or an instance of ' . Location::class . ', received %s.');
-
- $count = $this->nodeRepository->findCountWhere([['location_id', '=', $location]]);
- if ($count > 0) {
- throw new HasActiveNodesException(trans('exceptions.locations.has_nodes'));
- }
-
- return $this->repository->delete($location);
- }
-}
diff --git a/app/Services/Locations/LocationUpdateService.php b/app/Services/Locations/LocationUpdateService.php
deleted file mode 100644
index ce22ddbf3..000000000
--- a/app/Services/Locations/LocationUpdateService.php
+++ /dev/null
@@ -1,29 +0,0 @@
-id : $location;
-
- return $this->repository->update($location, $data);
- }
-}
diff --git a/app/Services/Servers/EnvironmentService.php b/app/Services/Servers/EnvironmentService.php
index 0406f6998..b960db3ed 100644
--- a/app/Services/Servers/EnvironmentService.php
+++ b/app/Services/Servers/EnvironmentService.php
@@ -66,7 +66,6 @@ class EnvironmentService
{
return [
'STARTUP' => 'startup',
- 'P_SERVER_LOCATION' => 'location.short',
'P_SERVER_UUID' => 'uuid',
];
}
diff --git a/app/Services/Servers/ServerCreationService.php b/app/Services/Servers/ServerCreationService.php
index 0d3a3d7ce..51cee3ac9 100644
--- a/app/Services/Servers/ServerCreationService.php
+++ b/app/Services/Servers/ServerCreationService.php
@@ -109,7 +109,7 @@ class ServerCreationService
private function configureDeployment(array $data, DeploymentObject $deployment): Allocation
{
/** @var \Illuminate\Support\Collection $nodes */
- $nodes = $this->findViableNodesService->setLocations($deployment->getLocations())
+ $nodes = $this->findViableNodesService
->setDisk(Arr::get($data, 'disk'))
->setMemory(Arr::get($data, 'memory'))
->handle();
diff --git a/app/Transformers/Api/Application/LocationTransformer.php b/app/Transformers/Api/Application/LocationTransformer.php
deleted file mode 100644
index 31e028c85..000000000
--- a/app/Transformers/Api/Application/LocationTransformer.php
+++ /dev/null
@@ -1,70 +0,0 @@
- $location->id,
- 'short' => $location->short,
- 'long' => $location->long,
- $location->getUpdatedAtColumn() => $this->formatTimestamp($location->updated_at),
- $location->getCreatedAtColumn() => $this->formatTimestamp($location->created_at),
- ];
- }
-
- /**
- * Return the nodes associated with this location.
- *
- * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
- */
- public function includeServers(Location $location): Collection|NullResource
- {
- if (!$this->authorize(AdminAcl::RESOURCE_SERVERS)) {
- return $this->null();
- }
-
- $location->loadMissing('servers');
-
- return $this->collection($location->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), 'server');
- }
-
- /**
- * Return the nodes associated with this location.
- *
- * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
- */
- public function includeNodes(Location $location): Collection|NullResource
- {
- if (!$this->authorize(AdminAcl::RESOURCE_NODES)) {
- return $this->null();
- }
-
- $location->loadMissing('nodes');
-
- return $this->collection($location->getRelation('nodes'), $this->makeTransformer(NodeTransformer::class), 'node');
- }
-}
diff --git a/app/Transformers/Api/Application/NodeTransformer.php b/app/Transformers/Api/Application/NodeTransformer.php
index 3bbc42b05..fbba837df 100644
--- a/app/Transformers/Api/Application/NodeTransformer.php
+++ b/app/Transformers/Api/Application/NodeTransformer.php
@@ -70,26 +70,6 @@ class NodeTransformer extends BaseTransformer
);
}
- /**
- * Return the nodes associated with this location.
- *
- * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
- */
- public function includeLocation(Node $node): Item|NullResource
- {
- if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) {
- return $this->null();
- }
-
- $node->loadMissing('location');
-
- return $this->item(
- $node->getRelation('location'),
- $this->makeTransformer(LocationTransformer::class),
- 'location'
- );
- }
-
/**
* Return the nodes associated with this location.
*
diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php
index 3be5aaf1d..6c39493a0 100644
--- a/app/Transformers/Api/Application/ServerTransformer.php
+++ b/app/Transformers/Api/Application/ServerTransformer.php
@@ -169,22 +169,6 @@ class ServerTransformer extends BaseTransformer
return $this->collection($server->getRelation('variables'), $this->makeTransformer(ServerVariableTransformer::class), 'server_variable');
}
- /**
- * Return a generic array with location information for this server.
- *
- * @throws \App\Exceptions\Transformer\InvalidTransformerLevelException
- */
- public function includeLocation(Server $server): Item|NullResource
- {
- if (!$this->authorize(AdminAcl::RESOURCE_LOCATIONS)) {
- return $this->null();
- }
-
- $server->loadMissing('location');
-
- return $this->item($server->getRelation('location'), $this->makeTransformer(LocationTransformer::class), 'location');
- }
-
/**
* Return a generic array with node information for this server.
*
diff --git a/database/Factories/LocationFactory.php b/database/Factories/LocationFactory.php
deleted file mode 100644
index e835054b6..000000000
--- a/database/Factories/LocationFactory.php
+++ /dev/null
@@ -1,28 +0,0 @@
- Str::random(8),
- 'long' => Str::random(32),
- ];
- }
-}
diff --git a/database/migrations/2024_03_14_055537_remove_locations_table.php b/database/migrations/2024_03_14_055537_remove_locations_table.php
new file mode 100644
index 000000000..a6e74e8bb
--- /dev/null
+++ b/database/migrations/2024_03_14_055537_remove_locations_table.php
@@ -0,0 +1,41 @@
+dropForeign('nodes_location_id_foreign');
+ });
+
+ Schema::drop('locations');
+
+ Schema::table('api_keys', function (Blueprint $table) {
+ $table->dropColumn('r_locations');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::create('locations', function (Blueprint $table) {
+ $table->increments('id');
+ $table->string('short');
+ $table->text('long')->nullable();
+ $table->timestamps();
+ });
+
+ Schema::table('api_keys', function (Blueprint $table) {
+ $table->unsignedTinyInteger('r_locations')->default(0);
+ });
+ }
+};
diff --git a/resources/lang/en/admin/node.php b/resources/lang/en/admin/node.php
index cffd4d737..fde28a25b 100644
--- a/resources/lang/en/admin/node.php
+++ b/resources/lang/en/admin/node.php
@@ -8,7 +8,6 @@ return [
'notices' => [
'allocations_added' => 'Allocations have successfully been added to this node.',
'node_deleted' => 'Node has been successfully removed from the panel.',
- 'location_required' => 'You must have at least one location configured before you can add a node to this panel.',
'node_created' => 'Successfully created new node. You can automatically configure the daemon on this machine by visiting the \'Configuration\' tab. Before you can add any servers you must first allocate at least one IP address and port.',
'node_updated' => 'Node information has been updated. If any daemon settings were changed you will need to reboot it for those changes to take effect.',
'unallocated_deleted' => 'Deleted all un-allocated ports for :ip
.',
diff --git a/resources/lang/en/command/messages.php b/resources/lang/en/command/messages.php
index a4a3aafdf..4e640b3fa 100644
--- a/resources/lang/en/command/messages.php
+++ b/resources/lang/en/command/messages.php
@@ -1,13 +1,6 @@
[
- 'no_location_found' => 'Could not locate a record matching the provided short code.',
- 'ask_short' => 'Location Short Code',
- 'ask_long' => 'Location Description',
- 'created' => 'Successfully created a new location (:name) with an ID of :id.',
- 'deleted' => 'Successfully deleted the requested location.',
- ],
'user' => [
'search_users' => 'Enter a Username, User ID, or Email Address',
'select_search_user' => 'ID of user to delete (Enter \'0\' to re-search)',
diff --git a/resources/views/admin/databases/index.blade.php b/resources/views/admin/databases/index.blade.php
index e4c69c513..66e125a5c 100644
--- a/resources/views/admin/databases/index.blade.php
+++ b/resources/views/admin/databases/index.blade.php
@@ -99,12 +99,8 @@
This setting does nothing other than default to this database host when adding a database to a server on the selected node.
diff --git a/resources/views/admin/locations/index.blade.php b/resources/views/admin/locations/index.blade.php deleted file mode 100644 index c54ffe0fa..000000000 --- a/resources/views/admin/locations/index.blade.php +++ /dev/null @@ -1,81 +0,0 @@ -@extends('layouts.admin') - -@section('title') - Locations -@endsection - -@section('content-header') -ID | -Short Code | -Description | -Nodes | -Servers | -
---|---|---|---|---|
{{ $location->id }} |
- {{ $location->short }} | -{{ $location->long }} | -{{ $location->nodes_count }} | -{{ $location->servers_count }} | -
ID | -Name | -FQDN | -Servers | -
---|---|---|---|
{{ $node->id }} |
- {{ $node->name }} | -{{ $node->fqdn }} |
- {{ $node->servers->count() }} | -