[pve-devel] [PATCH manager 2/2] web-syslog: add date span selection
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Mar 1 16:32:36 CET 2016
This allows the user to only show logs from a specific date span.
For that two date picker and a 'Update' button were added to the
header bar.
For the until date we assume always 23:59:59 o'clock, as witouth
a specific time journalctl assumes 00:00 which would result in an
empty log if we only wanted to look at todays log.
As the LogView is shared with others (e.g. ceph log) use an boolean
variable to set if we want to show those date pickers)
Fixes timeout when the user has a long uptime and or persistent logs
---
www/manager/node/Config.js | 4 ++-
www/manager/panel/LogView.js | 80 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 79 insertions(+), 5 deletions(-)
diff --git a/www/manager/node/Config.js b/www/manager/node/Config.js
index bc0494e..a634ef1 100644
--- a/www/manager/node/Config.js
+++ b/www/manager/node/Config.js
@@ -160,7 +160,9 @@ Ext.define('PVE.node.Config', {
title: 'Syslog',
itemId: 'syslog',
xtype: 'pveLogView',
- url: "/api2/extjs/nodes/" + nodename + "/syslog"
+ url: "/api2/extjs/nodes/" + nodename + "/syslog",
+ log_select_timespan: 1
+
}
]);
}
diff --git a/www/manager/panel/LogView.js b/www/manager/panel/LogView.js
index 49be118..55f6708 100644
--- a/www/manager/panel/LogView.js
+++ b/www/manager/panel/LogView.js
@@ -63,12 +63,21 @@ Ext.define('PVE.panel.LogView', {
doAttemptLoad: function(start) {
var me = this;
+ var req_params = {
+ start: start,
+ limit: me.pageSize
+ };
+
+ if (me.log_select_timespan) {
+ // always show log until the end of the selected day
+ req_params.until = Ext.Date.format(me.until_date, 'Y-m-d') + ' 23:59:59';
+ req_params.since = Ext.Date.format(me.since_date, 'Y-m-d');
+ }
+
+
PVE.Utils.API2Request({
url: me.url,
- params: {
- start: start,
- limit: me.pageSize
- },
+ params: req_params,
method: 'GET',
success: function(response) {
PVE.Utils.setErrorMask(me, false);
@@ -159,6 +168,11 @@ Ext.define('PVE.panel.LogView', {
throw "no url specified";
}
+ // show logs from today back to 3 days ago per default
+ me.until_date = new Date();
+ me.since_date = new Date();
+ me.since_date.setDate(me.until_date.getDate() - 3);
+
me.dataCmp = Ext.create('Ext.Component', {
style: 'font:normal 11px tahoma, arial, verdana, sans-serif;' +
'line-height: ' + me.lineHeight.toString() + 'px; white-space: pre;'
@@ -205,6 +219,64 @@ Ext.define('PVE.panel.LogView', {
}
});
+ if (me.log_select_timespan) {
+ me.tbar = ['->','Since: ',
+ {
+ xtype: 'datefield',
+ maxValue: me.until_date,
+ value: me.since_date,
+ name: 'since_date',
+ format: 'Y-m-d',
+ listeners: {
+ select: function(field, date) {
+ me.since_date_selected = date;
+ var until_field = field.up().down('field[name=until_date]');
+ if (date > until_field.getValue()) {
+ until_field.setValue(date);
+ }
+ }
+ }
+ },
+ 'Until: ',
+ {
+ xtype: 'datefield',
+ maxValue: me.until_date,
+ value: me.until_date,
+ name: 'until_date',
+ format: 'Y-m-d',
+ listeners: {
+ select: function(field, date) {
+ var since_field = field.up().down('field[name=since_date]');
+ if (date < since_field.getValue()) {
+ since_field.setValue(date);
+ }
+ }
+ }
+ },
+ {
+ xtype: 'button',
+ text: 'Update',
+ handler: function() {
+ var until_field = me.down('field[name=until_date]');
+ var since_field = me.down('field[name=since_date]');
+
+ if (until_field.getValue() < since_field.getValue()) {
+ Ext.Msg.alert('Error',
+ 'Since date must be less equal than Until date.');
+ until_field.setValue(me.until_date);
+ since_field.setValue(me.since_date);
+ } else {
+ me.until_date = until_field.getValue();
+ me.since_date = since_field.getValue();
+ me.requestUpdate();
+ }
+ }
+ }
+ ];
+ }
+
+
+
me.callParent();
}
});
--
2.1.4
More information about the pve-devel
mailing list