Skip to content

Commit 10a97a9

Browse files
committed
Updating in real time the amount of xhr requests done in the history panel
1 parent 92a6e6b commit 10a97a9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Panel/HistoryPanel.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ public function data()
3737
'requests' => $recent->toArray(),
3838
];
3939
}
40+
41+
/**
42+
* Gets the initial text for the history summary
43+
*
44+
* @return string
45+
*/
46+
public function summary()
47+
{
48+
return '0 xhr';
49+
}
4050
}

webroot/js/toolbar-app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,15 @@ Toolbar.prototype = {
224224

225225
onMessage: function(event) {
226226
if (event.data.startsWith('ajax-completed$$')) {
227-
this.ajaxRequests.push(JSON.parse(event.data.split('$$')[1]));
227+
this.onRequest(JSON.parse(event.data.split('$$')[1]))
228228
}
229229
},
230230

231+
onRequest: function(request) {
232+
this.ajaxRequests.push(request);
233+
$(".panel-summary:contains(xhr)").text("" + this.ajaxRequests.length + ' xhr');
234+
},
235+
231236
initialize: function() {
232237
this.windowOrigin();
233238
this.mouseListener();

0 commit comments

Comments
 (0)