wowowowowo
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Services\CreateService;
|
||||
use App\Enums\DeployPolicy;
|
||||
use App\Enums\ServiceCategory;
|
||||
use App\Enums\ServiceType;
|
||||
use App\Http\Requests\StoreServiceRequest;
|
||||
use App\Http\Requests\UpdateServiceRequest;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -49,7 +51,7 @@ class ServiceController extends Controller
|
||||
{
|
||||
$server = Server::findOrFail($request->route('server'));
|
||||
$service = $server->services()
|
||||
->with(['replicas', 'slices', 'operations.steps', 'environment.application'])
|
||||
->with(['replicas', 'slices', 'endpoints', 'operations.steps', 'operations.children.target', 'environment.application'])
|
||||
->findOrFail($request->route('service'));
|
||||
|
||||
return inertia('services/Show', [
|
||||
@@ -58,6 +60,23 @@ class ServiceController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function showForEnvironment(Request $request): Response
|
||||
{
|
||||
$organisation = Organisation::findOrFail($request->route('organisation'));
|
||||
$application = $organisation->applications()->findOrFail($request->route('application'));
|
||||
$environment = $application->environments()->findOrFail($request->route('environment'));
|
||||
$service = $environment->services()
|
||||
->with(['server', 'replicas', 'slices', 'endpoints', 'operations.steps', 'operations.children.target', 'environment.application'])
|
||||
->findOrFail($request->route('service'));
|
||||
|
||||
return inertia('services/Show', [
|
||||
'server' => $service->server,
|
||||
'service' => $service,
|
||||
'environment' => $environment,
|
||||
'application' => $application,
|
||||
]);
|
||||
}
|
||||
|
||||
public function edit(Request $request): Response
|
||||
{
|
||||
$server = Server::findOrFail($request->route('server'));
|
||||
@@ -66,6 +85,7 @@ class ServiceController extends Controller
|
||||
return inertia('services/Edit', [
|
||||
'server' => $server,
|
||||
'service' => $service,
|
||||
'deployPolicies' => array_values(DeployPolicy::toArray()),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -74,7 +94,31 @@ class ServiceController extends Controller
|
||||
$server = Server::findOrFail($request->route('server'));
|
||||
$service = $server->services()->findOrFail($request->route('service'));
|
||||
|
||||
$service->update($request->validated());
|
||||
$validated = $request->validated();
|
||||
|
||||
$service->update([
|
||||
'name' => $validated['name'],
|
||||
'desired_replicas' => $validated['desired_replicas'],
|
||||
'default_cpu_limit' => $validated['default_cpu_limit'] ?? null,
|
||||
'default_memory_limit_mb' => $validated['default_memory_limit_mb'] ?? null,
|
||||
'deploy_policy' => $request->enum('deploy_policy', DeployPolicy::class) ?? $service->deploy_policy,
|
||||
'version_track' => $validated['version_track'] ?? $service->version_track,
|
||||
'available_image_digest' => $validated['available_image_digest'] ?? null,
|
||||
'process_roles' => collect(explode(',', $validated['process_roles'] ?? ''))
|
||||
->map(fn (string $role): string => trim($role))
|
||||
->filter()
|
||||
->values()
|
||||
->all(),
|
||||
'config' => [
|
||||
...($service->config ?? []),
|
||||
'migration_mode' => $validated['migration_mode'] ?? null,
|
||||
'migration_timing' => $validated['migration_timing'] ?? null,
|
||||
'migration_command' => $validated['migration_command'] ?? null,
|
||||
'health_path' => $validated['health_path'] ?? null,
|
||||
'backup_enabled' => $request->boolean('backup_enabled'),
|
||||
'backup_command' => $validated['backup_command'] ?? null,
|
||||
],
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->route('services.show', [
|
||||
@@ -84,4 +128,19 @@ class ServiceController extends Controller
|
||||
])
|
||||
->with('success', 'Service updated.');
|
||||
}
|
||||
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
$server = Server::findOrFail($request->route('server'));
|
||||
$service = $server->services()->findOrFail($request->route('service'));
|
||||
|
||||
$service->delete();
|
||||
|
||||
return redirect()
|
||||
->route('servers.show', [
|
||||
'organisation' => $server->organisation_id,
|
||||
'server' => $server->id,
|
||||
])
|
||||
->with('success', 'Service deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user