From 1a4d1905fd3835d946ca51e6e4d62c77fa19dc9c Mon Sep 17 00:00:00 2001 From: Ricardo Cino Date: Mon, 13 Mar 2017 08:50:58 +0100 Subject: [PATCH] Add 'delete all files' & only show download/delete links when possible (#84) * Add 'delete all files' option & only show download/delete links when possible * Confirm dialog for delete-all-log * Return to /logs instead of /logs?delall=true --- src/controllers/LogViewerController.php | 9 ++++++--- src/views/log.blade.php | 14 ++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/controllers/LogViewerController.php b/src/controllers/LogViewerController.php index c6cc417..db5e892 100644 --- a/src/controllers/LogViewerController.php +++ b/src/controllers/LogViewerController.php @@ -28,12 +28,15 @@ public function index() } elseif ($this->request->has('del')) { app('files')->delete(LaravelLogViewer::pathToLogFile(base64_decode($this->request->input('del')))); return $this->redirect($this->request->url()); + } elseif ($this->request->has('delall')){ + foreach(LaravelLogViewer::getFiles(true) as $file){ + app('files')->delete(LaravelLogViewer::pathToLogFile($file)); + } + return $this->redirect($this->request->url()); } - $logs = LaravelLogViewer::all(); - return app('view')->make('laravel-log-viewer::log', [ - 'logs' => $logs, + 'logs' => LaravelLogViewer::all(), 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName() ]); diff --git a/src/views/log.blade.php b/src/views/log.blade.php index a3cd73d..da72231 100644 --- a/src/views/log.blade.php +++ b/src/views/log.blade.php @@ -91,9 +91,15 @@ @endif
- Download file - - - Delete file + @if($current_file) + Download file + - + Delete file + @if(count($files) > 1) + - + Delete all files + @endif + @endif
@@ -119,7 +125,7 @@ $('.table-container').on('click', '.expand', function(){ $('#' + $(this).data('display')).toggle(); }); - $('#delete-log').click(function(){ + $('#delete-log, #delete-all-log').click(function(){ return confirm('Are you sure?'); }); });