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

Loading…
Cancel
Save