add a 'refresh' button to the performance tab of the admin panel

pull/1/head
ansuz 4 years ago
parent 19d82f1b3e
commit 112afc0de2

@ -66,6 +66,7 @@ define([
'cp-admin-support-init'
],
'performance': [
'cp-admin-refresh-performance',
'cp-admin-performance-profiling',
]
};
@ -931,9 +932,22 @@ define([
return;
};
var onRefreshPerformance = Util.mkEvent();
create['refresh-performance'] = function () {
var key = 'refresh-performance';
var btn = h('button.btn.btn-primary', Messages.oo_refresh);
var div = h('div.cp-admin-' + key + '.cp-sidebarlayout-element', btn);
$(btn).click(function () {
onRefreshPerformance.fire();
});
return $(div);
};
create['performance-profiling'] = function () {
var $div = makeBlock('performance-profiling');
var onRefresh = function () {
var body = h('tbody');
var table = h('table#cp-performance-table', [
@ -944,16 +958,12 @@ define([
]),
body,
]);
$div.append(table);
var appendRow = function (key, time, percent) {
console.log("[%s] %ss running time (%s%)", key, time, percent);
body.appendChild(h('tr', [ key, time, percent ].map(function (x) {
return h('td', x);
})));
};
var process = function (_o) {
var o = _o[0];
var sorted = Object.keys(o).sort(function (a, b) {
@ -973,8 +983,16 @@ define([
}, function (e, data) {
if (e) { return void console.error(e); }
//console.info(data);
$div.find("table").remove();
process(data);
$div.append(table);
});
};
onRefresh();
onRefreshPerformance.reg(onRefresh);
return $div;
};

Loading…
Cancel
Save