ability to download log from admin

This commit is contained in:
Čarodej
2022-03-08 10:51:32 +01:00
parent 4e2155b75a
commit dd1f3b299d
52 changed files with 182 additions and 46 deletions
@@ -0,0 +1,34 @@
<?php
namespace Domain\Settings\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\File;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class DownloadLogController extends Controller
{
public function __invoke($log): Response|BinaryFileResponse|Application|ResponseFactory
{
if (is_demo()) {
return response('Done.', 204);
}
// Get log path
$logPath = storage_path("logs/$log");
// Download log
return response()->download(
storage_path("logs/$log"), $log, [
'Accept-Ranges' => 'bytes',
'Content-Type' => 'text/plain',
'Content-Length' => File::size($logPath),
'Content-Range' => 'bytes 0-600/' . File::size($logPath),
'Content-Disposition' => "attachment; filename=$log",
]
);
}
}
@@ -16,6 +16,9 @@ class GetServerStatusController
// Get server data
$status = ($this->getServerSetupStatus)();
// Get latest logs
$status['logs'] = getListOfLatestLogs();
// Add latest database backups
$status['backups'] = collect(Storage::allFiles('app-backup'))
->map(fn ($path) => str_replace('app-backup/', '', $path))