Skip to content

Commit

Permalink
Merge pull request #714 from barryvdh/dump-headers
Browse files Browse the repository at this point in the history
[Dumps] Only load sfDump header once
  • Loading branch information
taylorotwell authored Aug 26, 2019
2 parents 382dc02 + e2587c5 commit 76a5df6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions resources/js/screens/dumps/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
data() {
return {
dump: null,
entries: [],
ready: false,
newEntriesTimeout: null,
Expand Down Expand Up @@ -39,6 +40,7 @@
loadEntries(){
axios.post(Telescope.basePath + '/telescope-api/dumps').then(response => {
this.ready = true;
this.dump = response.data.dump;
this.entries = response.data.entries;
this.recordingStatus = response.data.status;
Expand Down Expand Up @@ -102,8 +104,13 @@
<span>We didn't find anything - just empty space.</span>
</div>

<div style="display: none;" v-if="dump">
<div v-html="dump"></div>
</div>

<div v-if="ready && entries.length > 0" class="code-bg px-3 pt-3">
<transition-group tag="div" name="list">

<div v-for="entry in entries" :key="entry.id" class="mb-4">
<div class="entryPointDescription d-flex justify-content-between align-items-center">
<router-link :to="{name:'request-preview', params:{id: entry.content.entry_point_uuid}}" class="control-action" v-if="entry.content.entry_point_type == 'request'">
Expand Down
12 changes: 11 additions & 1 deletion src/Http/Controllers/DumpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Illuminate\Cache\ArrayStore;
use Laravel\Telescope\EntryType;
use Laravel\Telescope\Watchers\DumpWatcher;
use Laravel\Telescope\Storage\EntryQueryOptions;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Laravel\Telescope\Contracts\EntriesRepository;
use Illuminate\Contracts\Cache\Repository as CacheRepository;

Expand Down Expand Up @@ -40,7 +43,14 @@ public function index(Request $request, EntriesRepository $storage)
{
$this->cache->put('telescope:dump-watcher', true, now()->addSeconds(4));

return parent::index($request, $storage);
return response()->json([
'dump' => (new HtmlDumper())->dump((new VarCloner)->cloneVar(true), true),
'entries' => $storage->get(
$this->entryType(),
EntryQueryOptions::fromRequest($request)
),
'status' => $this->status(),
]);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/Watchers/DumpWatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ public function register($app)
return;
}

VarDumper::setHandler(function ($var) {
$this->recordDump((new HtmlDumper)->dump(
$htmlDumper = new HtmlDumper();
$htmlDumper->setDumpHeader('');

VarDumper::setHandler(function ($var) use ($htmlDumper) {
$this->recordDump($htmlDumper->dump(
(new VarCloner)->cloneVar($var), true
));
});
Expand Down

0 comments on commit 76a5df6

Please sign in to comment.