Commit c0e19158 authored by Dietmar Maurer's avatar Dietmar Maurer

use new LogViewer inside TaskViewer

parent 7ae2cba5
Ext.define('PVE.LogView', {
Ext.define('PVE.panel.LogView', {
extend: 'Ext.panel.Panel',
alias: ['widget.pveLogView'],
......@@ -102,6 +102,32 @@ Ext.define('PVE.LogView', {
me.loadTask.delay(200, me.doAttemptLoad, me, [start]);
},
requestUpdate: function(top, force) {
var me = this;
if (top === undefined) {
var target = me.getTargetEl();
top = target.dom.scrollTop;
}
var viewStart = parseInt((top / me.lineHeight) - 1);
if (viewStart < 0) {
viewStart = 0;
}
var viewEnd = parseInt(((top + me.getHeight())/ me.lineHeight) + 1);
var info = me.viewInfo;
if (info && !force) {
if (viewStart >= info.start && viewEnd <= info.end) {
return;
}
}
var line = parseInt((top / me.lineHeight) - (me.pageSize / 2) + 10);
if (line < 0) {
line = 0;
}
me.attemptLoad(line);
},
initComponent : function() {
var me = this;
......@@ -115,25 +141,6 @@ Ext.define('PVE.LogView', {
'line-height: ' + me.lineHeight + 'px; white-space: pre;'
});
var requestUpdate = function(top, force) {
var viewStart = parseInt((top / me.lineHeight) - 1);
if (viewStart < 0) {
viewStart = 0;
}
var viewEnd = parseInt(((top + me.getHeight())/ me.lineHeight) + 1);
var info = me.viewInfo;
if (info && !force) {
if (viewStart >= info.start && viewEnd <= info.end) {
return;
}
}
var line = parseInt((top / me.lineHeight) - (me.pageSize / 2) + 10);
if (line < 0) {
line = 0;
}
me.attemptLoad(line);
};
var autoScrollTask = {
run: function() {
......@@ -141,16 +148,12 @@ Ext.define('PVE.LogView', {
return;
}
var target = me.getTargetEl();
var dom = target.dom;
var maxDown = dom.scrollHeight - dom.clientHeight -
dom.scrollTop;
var maxDown = me.getMaxDown();
if (maxDown > 0) {
return;
}
requestUpdate(dom.scrollTop, true);
me.requestUpdate(undefined, true);
},
interval: 1000
};
......@@ -167,9 +170,9 @@ Ext.define('PVE.LogView', {
afterrender: Ext.Function.createDelayed(function() {
var target = me.getTargetEl();
target.on('scroll', function(e) {
requestUpdate(target.dom.scrollTop);
me.requestUpdate();
});
requestUpdate(0);
me.requestUpdate(0);
}, 20),
show: function() {
var target = me.getTargetEl();
......
......@@ -48,18 +48,6 @@ Ext.define('PVE.window.TaskViewer', {
}
};
var store = Ext.create('Ext.data.Store', {
model: 'pve-string-list',
pageSize: 200,
buffered: true,
proxy: {
type: 'pve',
startParam: 'start',
limitParam: 'limit',
url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/log"
}
});
var statstore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/status",
interval: 1000,
......@@ -75,9 +63,6 @@ Ext.define('PVE.window.TaskViewer', {
method: 'DELETE',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
},
callback: function() {
store.load();
}
});
};
......@@ -103,12 +88,19 @@ Ext.define('PVE.window.TaskViewer', {
border: false
});
var logView = Ext.create('PVE.panel.LogView', {
title: 'Output',
tbar: [ stop_btn2 ],
border: false,
url: "/api2/extjs/nodes/" + task.node + "/tasks/" + me.upid + "/log"
});
me.mon(statstore, 'load', function() {
var status = statgrid.getObjectValue('status');
store.load();
if (status === 'stopped') {
logView.requestUpdate(undefined, true);
logView.scrollToEnd = false;
statstore.stopUpdate();
}
......@@ -128,37 +120,11 @@ Ext.define('PVE.window.TaskViewer', {
items: [{
xtype: 'tabpanel',
region: 'center',
items: [
{
title: 'Output',
tbar: [ stop_btn2 ],
border: false,
xtype: 'gridpanel',
features: [ {ftype: 'selectable'}],
store: store,
stateful: false,
verticalScrollerType: 'paginggridscroller',
disableSelection: true,
invalidateScrollerOnRefresh: false,
viewConfig: {
loadMask: false,
trackOver: false,
stripeRows: false
},
hideHeaders: true,
columns: [
//{ header: "Line", dataIndex: 'n', width: 50 },
{ header: "Text", dataIndex: 't', flex: 1 }
]
},
statgrid
]
items: [ logView, statgrid ]
}]
});
me.callParent();
store.guaranteeRange(0, store.pageSize - 1);
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment