feat: add Integration Credentials CRUD and Deploy UI
Integration Credentials: - Add IntegrationCredential model with encrypted payload - Add full CRUD: ManageIntegrationCredentialsAction, 4 Tasks, Controller, Requests - Add migration for integration_credentials table - Add Vue pages: Index, Create, Edit - AI tasks now read API keys from DB instead of .env - Add sidebar menu item Deploy UI: - Add DeployTask with full deploy lifecycle management - Extend DeployController with index, log, history endpoints - Add Deploy/Index.vue with live polling and deploy log viewer - Add sidebar menu item and QuickAction for Sveden UI: - Add 'key' icon to SidebarNavItem - Change deploy button color to amber in Main.vue
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Containers\Dashboard\Actions\Posts\DeploySiteAction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class DeployController extends Controller
|
||||
{
|
||||
@@ -13,9 +14,17 @@ class DeployController extends Controller
|
||||
private readonly DeploySiteAction $deploySiteAction,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Запускает деплой (создаёт файл-триггер)
|
||||
*/
|
||||
public function index(): \Inertia\Response
|
||||
{
|
||||
$history = $this->deploySiteAction->getHistory();
|
||||
$status = $this->deploySiteAction->getStatus();
|
||||
|
||||
return Inertia::render('Dashboard/Deploy/Index', [
|
||||
'history' => $history['history'],
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
|
||||
public function deploy(Request $request): JsonResponse
|
||||
{
|
||||
if (app()->environment() !== 'production') {
|
||||
@@ -37,9 +46,6 @@ class DeployController extends Controller
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверяет статус деплоя
|
||||
*/
|
||||
public function status(Request $request): JsonResponse
|
||||
{
|
||||
if (app()->environment() !== 'production') {
|
||||
@@ -58,9 +64,29 @@ class DeployController extends Controller
|
||||
return response()->json($status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Очищает статус деплоя
|
||||
*/
|
||||
public function log(Request $request): JsonResponse
|
||||
{
|
||||
if (!$request->user()->hasRole('super_admin')) {
|
||||
return response()->json(['success' => false], 403);
|
||||
}
|
||||
|
||||
$lines = (int) $request->query('lines', 50);
|
||||
$result = $this->deploySiteAction->getLog($lines);
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
public function history(Request $request): JsonResponse
|
||||
{
|
||||
if (!$request->user()->hasRole('super_admin')) {
|
||||
return response()->json(['success' => false], 403);
|
||||
}
|
||||
|
||||
$result = $this->deploySiteAction->getHistory();
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
public function clear(Request $request): JsonResponse
|
||||
{
|
||||
if (!$request->user()->hasRole('super_admin')) {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\UI\WEB\Controllers;
|
||||
|
||||
use App\Containers\Dashboard\Actions\IntegrationCredentials\ManageIntegrationCredentialsAction;
|
||||
use App\Containers\Dashboard\Models\IntegrationCredential;
|
||||
use App\Containers\Dashboard\UI\WEB\Requests\StoreIntegrationCredentialRequest;
|
||||
use App\Containers\Dashboard\UI\WEB\Requests\UpdateIntegrationCredentialRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class IntegrationCredentialsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ManageIntegrationCredentialsAction $action,
|
||||
) {}
|
||||
|
||||
public function index(): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('Dashboard/IntegrationCredentials/Index', [
|
||||
'credentials' => $this->action->list(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('Dashboard/IntegrationCredentials/Create');
|
||||
}
|
||||
|
||||
public function store(StoreIntegrationCredentialRequest $request): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->action->create($request->validated());
|
||||
|
||||
return redirect()->route('dashboard.integration-credentials.index')
|
||||
->with('success', 'Провайдер успешно добавлен!');
|
||||
} catch (\Exception $e) {
|
||||
return back()
|
||||
->withInput()
|
||||
->with('error', 'Ошибка при добавлении: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(IntegrationCredential $credential): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('Dashboard/IntegrationCredentials/Edit', [
|
||||
'credential' => $credential,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(UpdateIntegrationCredentialRequest $request, IntegrationCredential $credential): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->action->update($credential, $request->validated());
|
||||
|
||||
return redirect()->route('dashboard.integration-credentials.index')
|
||||
->with('success', 'Провайдер успешно обновлён!');
|
||||
} catch (\Exception $e) {
|
||||
return back()
|
||||
->withInput()
|
||||
->with('error', 'Ошибка при обновлении: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function destroy(IntegrationCredential $credential): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->action->delete($credential);
|
||||
|
||||
return redirect()->route('dashboard.integration-credentials.index')
|
||||
->with('success', 'Провайдер успешно удалён!');
|
||||
} catch (\Exception $e) {
|
||||
return back()
|
||||
->with('error', 'Ошибка при удалении: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\UI\WEB\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreIntegrationCredentialRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'provider' => ['required', 'string', 'max:255', 'unique:integration_credentials,provider'],
|
||||
'payload' => ['required', 'array'],
|
||||
'payload.*' => ['required', 'string'],
|
||||
'is_active' => ['boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Dashboard\UI\WEB\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateIntegrationCredentialRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'provider' => ['required', 'string', 'max:255', 'unique:integration_credentials,provider,' . $this->route('credential')->id],
|
||||
'payload' => ['required', 'array'],
|
||||
'payload.*' => ['required', 'string'],
|
||||
'is_active' => ['boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user