v0.11.0
This commit is contained in:
commit
1c8a903f24
306 files changed
+22212
No files matched your search
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\System;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use IriksIT\Manager\Support\System\QueueInfo;
|
||||
use IriksIT\Manager\Support\SystemInfo;
|
||||
|
||||
class SystemController
|
||||
{
|
||||
public function index(SystemInfo $info)
|
||||
{
|
||||
return response()->json($info->report())->header('Cache-Control', 'no-store');
|
||||
}
|
||||
|
||||
/** Why one job failed, in full (scrubbed). */
|
||||
public function failed(string $id, QueueInfo $queue): JsonResponse
|
||||
{
|
||||
$job = $queue->failedJob($id);
|
||||
|
||||
abort_if($job === null, 404);
|
||||
|
||||
return response()->json($job)->header('Cache-Control', 'no-store');
|
||||
}
|
||||
|
||||
/** Puts a failed job back on its queue. */
|
||||
public function retry(string $id, QueueInfo $queue): JsonResponse
|
||||
{
|
||||
abort_unless($queue->retry($id), 422, __('This job cannot be put back: it is gone or its data cannot be read any more.'));
|
||||
|
||||
return response()->json(['retried' => true]);
|
||||
}
|
||||
|
||||
/** Removes a failed job for good. */
|
||||
public function forget(string $id, QueueInfo $queue): JsonResponse
|
||||
{
|
||||
abort_unless($queue->forget($id), 404);
|
||||
|
||||
return response()->json(['forgotten' => true]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\System;
|
||||
|
||||
use IriksIT\Manager\Modules\BaseModule;
|
||||
use IriksIT\Manager\Support\Names;
|
||||
use IriksIT\Manager\Support\Permission;
|
||||
use IriksIT\Manager\Support\System\ScheduleInfo;
|
||||
use IriksIT\Manager\Support\Tier;
|
||||
|
||||
/** What runs the site: PHP, its modules, the drivers, the disk and the last lines of the log. For who looks after it; no tables. */
|
||||
class SystemModule extends BaseModule
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'system';
|
||||
}
|
||||
|
||||
public function tier(): string
|
||||
{
|
||||
return Tier::CORE;
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'System';
|
||||
}
|
||||
|
||||
public function enabledByDefault(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function permissions(): array
|
||||
{
|
||||
return [
|
||||
new Permission('system.view', 'See how the site runs: versions, PHP, the load of the server and the database, the scheduled tasks, the jobs and the last lines of the log (the log can hold personal data)', 'Site'),
|
||||
new Permission('system.manage', 'Put a failed job back on its queue, or remove it', 'Site', needs: ['system.view']),
|
||||
];
|
||||
}
|
||||
|
||||
public function navigation(): array
|
||||
{
|
||||
return [['label' => 'System', 'section' => 'Administration', 'route' => Names::route('system.index'), 'permission' => 'system.view', 'simple' => false, 'icon' => 'server']];
|
||||
}
|
||||
|
||||
public function actions(): array
|
||||
{
|
||||
return ['system.retry' => ['Put a failed job back on its queue'], 'system.forget' => ['Removed a failed job']];
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
ScheduleInfo::listen();
|
||||
}
|
||||
|
||||
public function views(): array
|
||||
{
|
||||
return ['system.index' => 'Opened the system page', 'system.failed' => 'Opened a failed job'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use IriksIT\Manager\Modules\System\SystemController;
|
||||
|
||||
Route::get('/system', [SystemController::class, 'index'])->name('system.index')->middleware('can:system.view');
|
||||
Route::get('/system/failed/{id}', [SystemController::class, 'failed'])->name('system.failed')->middleware('can:system.view')->where('id', '[A-Za-z0-9-]+');
|
||||
Route::post('/system/failed/{id}/retry', [SystemController::class, 'retry'])->name('system.retry')->middleware('can:system.manage')->where('id', '[A-Za-z0-9-]+');
|
||||
Route::delete('/system/failed/{id}', [SystemController::class, 'forget'])->name('system.forget')->middleware('can:system.manage')->where('id', '[A-Za-z0-9-]+');
|
||||
Reference in new issue
Block a user