Skip to content

Commit

Permalink
Add 'delete all files' & only show download/delete links when possible (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
cino authored and rap2hpoutre committed Mar 13, 2017
1 parent 75d0261 commit 1a4d190
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/controllers/LogViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]);
Expand Down
14 changes: 10 additions & 4 deletions src/views/log.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@
</table>
@endif
<div>
<a href="?dl={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-download-alt"></span> Download file</a>
-
<a id="delete-log" href="?del={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-trash"></span> Delete file</a>
@if($current_file)
<a href="?dl={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-download-alt"></span> Download file</a>
-
<a id="delete-log" href="?del={{ base64_encode($current_file) }}"><span class="glyphicon glyphicon-trash"></span> Delete file</a>
@if(count($files) > 1)
-
<a id="delete-all-log" href="?delall=true"><span class="glyphicon glyphicon-trash"></span> Delete all files</a>
@endif
@endif
</div>
</div>
</div>
Expand All @@ -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?');
});
});
Expand Down

0 comments on commit 1a4d190

Please sign in to comment.