mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-13 17:45:15 +00:00
manager6: web-syslog: add date span selection
This is the ExtJS 6 version from commit
59e6da2d44
Same code as there.
A issue with the date picker which can be triggered by scrolling up
and then selecting a date will be fixed in ExtJS 6.0.2 (not yet
released), a workaround is in the next patch.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
9a55d9a21a
commit
561312ff62
@ -160,7 +160,8 @@ 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
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -73,12 +73,20 @@ Ext.define('PVE.panel.LogView', {
|
||||
doAttemptLoad: function(start) {
|
||||
var me = this;
|
||||
|
||||
PVE.Utils.API2Request({
|
||||
url: me.url,
|
||||
params: {
|
||||
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: req_params,
|
||||
method: 'GET',
|
||||
success: function(response) {
|
||||
PVE.Utils.setErrorMask(me, false);
|
||||
@ -169,6 +177,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;'
|
||||
@ -199,6 +212,62 @@ 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();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user