Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new "Clear Entries" button at the top of Telescope #1087

Merged
merged 2 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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() {
axios.post(Telescope.basePath + '/telescope-api/clear-entries');

this.$emit('clear-entries');
},
},
});
11 changes: 11 additions & 0 deletions resources/js/components/IndexScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@

this.tag = this.$route.query.tag || '';

this.$root.$on('clear-entries', () => {
this.entries = [];
this.hasMoreEntries = false;
this.hasNewEntries = false;
this.lastEntryIndex = '';

this.checkForNewEntries();

this.ready = true;
})

this.loadEntries((entries) => {
this.entries = entries;

Expand Down
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
19 changes: 19 additions & 0 deletions src/Http/Controllers/EntriesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Laravel\Telescope\Http\Controllers;

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

class EntriesController extends Controller
{
/**
* Clear entries.
*
* @return void
*/
public function clear(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::post('/telescope-api/clear-entries', 'EntriesController@clear');

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