Skip to content

Commit

Permalink
Repackaged #1087 for 4.x (Add a new "Clear Entries" button) (#1091)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDanault committed Jul 12, 2021
1 parent 234ba91 commit f5e05ef
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,11 @@ new Vue({
window.Telescope.recording = !Telescope.recording;
this.recording = !this.recording;
},

clearEntries() {
if (confirm('Are you sure you want to delete all Telescope data?')) {
axios.delete(Telescope.basePath + '/telescope-api/entries').then((response) => location.reload());
}
},
},
});
6 changes: 6 additions & 0 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
</svg>
</button>

<button class="btn btn-outline-primary mr-3" v-on:click.prevent="clearEntries" title="Clear Entries">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="icon fill-primary">
<path d="M6 2l2-2h4l2 2h4v2H2V2h4zM3 6h14l-1 14H4L3 6zm5 2v10h1V8H8zm3 0v10h1V8h-1z"/>
</svg>
</button>

<button class="btn btn-outline-primary mr-3" :class="{active: autoLoadsNewEntries}" v-on:click.prevent="autoLoadNewEntries" title="Auto Load Entries">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="icon fill-primary">
<path d="M10 3v2a5 5 0 0 0-3.54 8.54l-1.41 1.41A7 7 0 0 1 10 3zm4.95 2.05A7 7 0 0 1 10 17v-2a5 5 0 0 0 3.54-8.54l1.41-1.41zM10 20l-4-4 4-4v8zm0-12V0l4 4-4 4z"></path>
Expand Down
20 changes: 20 additions & 0 deletions src/Http/Controllers/EntriesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Laravel\Telescope\Http\Controllers;

use Illuminate\Routing\Controller;
use Laravel\Telescope\Contracts\ClearableRepository;

class EntriesController extends Controller
{
/**
* Delete all of the entries from storage.
*
* @param \Laravel\Telescope\Contracts\ClearableRepository $storage
* @return void
*/
public function destroy(ClearableRepository $storage)
{
$storage->clear();
}
}
3 changes: 3 additions & 0 deletions src/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@
// Toggle Recording...
Route::post('/telescope-api/toggle-recording', 'RecordingController@toggle');

// Clear Entries...
Route::delete('/telescope-api/entries', 'EntriesController@destroy');

Route::get('/{view?}', 'HomeController@index')->where('view', '(.*)')->name('telescope');

0 comments on commit f5e05ef

Please sign in to comment.