[pbs-devel] [PATCH proxmox-backup 2/3] report: add webui button for system report
Hannes Laimer
h.laimer at proxmox.com
Tue Nov 3 13:29:07 CET 2020
Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
www/Subscription.js | 75 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/www/Subscription.js b/www/Subscription.js
index d2ad5af0..498600bf 100644
--- a/www/Subscription.js
+++ b/www/Subscription.js
@@ -28,6 +28,73 @@ Ext.define('PBS.Subscription', {
enableTextSelection: true,
},
+ showReport: function() {
+ var me = this;
+
+ var getReportFileName = function() {
+ var now = Ext.Date.format(new Date(), 'D-d-F-Y-G-i');
+ return `${me.nodename}-pbs-report-${now}.txt`;
+ };
+
+ var view = Ext.createWidget('component', {
+ itemId: 'system-report-view',
+ scrollable: true,
+ style: {
+ 'background-color': 'white',
+ 'white-space': 'pre',
+ 'font-family': 'monospace',
+ padding: '5px',
+ },
+ });
+
+ var reportWindow = Ext.create('Ext.window.Window', {
+ title: gettext('System Report'),
+ width: 1024,
+ height: 600,
+ layout: 'fit',
+ modal: true,
+ buttons: [
+ '->',
+ {
+ text: gettext('Download'),
+ handler: function() {
+ var fileContent = Ext.String.htmlDecode(reportWindow.getComponent('system-report-view').html);
+ var fileName = getReportFileName();
+
+ // Internet Explorer
+ if (window.navigator.msSaveOrOpenBlob) {
+ navigator.msSaveOrOpenBlob(new Blob([fileContent]), fileName);
+ } else {
+ var element = document.createElement('a');
+ element.setAttribute('href', 'data:text/plain;charset=utf-8,' +
+ encodeURIComponent(fileContent));
+ element.setAttribute('download', fileName);
+ element.style.display = 'none';
+ document.body.appendChild(element);
+ element.click();
+ document.body.removeChild(element);
+ }
+ },
+ },
+ ],
+ items: view,
+ });
+
+ Proxmox.Utils.API2Request({
+ url: '/api2/extjs/nodes/' + me.nodename + '/report',
+ method: 'GET',
+ waitMsgTarget: me,
+ failure: function(response) {
+ Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+ },
+ success: function(response) {
+ var report = Ext.htmlEncode(response.result.data);
+ reportWindow.show();
+ view.update(report);
+ },
+ });
+ },
+
initComponent: function() {
let me = this;
@@ -105,7 +172,13 @@ Ext.define('PBS.Subscription', {
selModel: false,
callback: reload,
},
- //'-',
+ '-',
+ {
+ text: gettext('System Report'),
+ handler: function() {
+ Proxmox.Utils.checked_command(function() { me.showReport(); });
+ },
+ },
],
rows: rows,
});
--
2.20.1
More information about the pbs-devel
mailing list