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', extend: 'Ext.panel.Panel',
alias: ['widget.pveLogView'], alias: ['widget.pveLogView'],
...@@ -102,6 +102,32 @@ Ext.define('PVE.LogView', { ...@@ -102,6 +102,32 @@ Ext.define('PVE.LogView', {
me.loadTask.delay(200, me.doAttemptLoad, me, [start]); 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() { initComponent : function() {
var me = this; var me = this;
...@@ -115,25 +141,6 @@ Ext.define('PVE.LogView', { ...@@ -115,25 +141,6 @@ Ext.define('PVE.LogView', {
'line-height: ' + me.lineHeight + 'px; white-space: pre;' '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 = { var autoScrollTask = {
run: function() { run: function() {
...@@ -141,16 +148,12 @@ Ext.define('PVE.LogView', { ...@@ -141,16 +148,12 @@ Ext.define('PVE.LogView', {
return; return;
} }
var target = me.getTargetEl(); var maxDown = me.getMaxDown();
var dom = target.dom;
var maxDown = dom.scrollHeight - dom.clientHeight -
dom.scrollTop;
if (maxDown > 0) { if (maxDown > 0) {
return; return;
} }
requestUpdate(dom.scrollTop, true); me.requestUpdate(undefined, true);
}, },
interval: 1000 interval: 1000
}; };
...@@ -167,9 +170,9 @@ Ext.define('PVE.LogView', { ...@@ -167,9 +170,9 @@ Ext.define('PVE.LogView', {
afterrender: Ext.Function.createDelayed(function() { afterrender: Ext.Function.createDelayed(function() {
var target = me.getTargetEl(); var target = me.getTargetEl();
target.on('scroll', function(e) { target.on('scroll', function(e) {
requestUpdate(target.dom.scrollTop); me.requestUpdate();
}); });
requestUpdate(0); me.requestUpdate(0);
}, 20), }, 20),
show: function() { show: function() {
var target = me.getTargetEl(); var target = me.getTargetEl();
......
...@@ -48,18 +48,6 @@ Ext.define('PVE.window.TaskViewer', { ...@@ -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', { var statstore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/status", url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/status",
interval: 1000, interval: 1000,
...@@ -75,9 +63,6 @@ Ext.define('PVE.window.TaskViewer', { ...@@ -75,9 +63,6 @@ Ext.define('PVE.window.TaskViewer', {
method: 'DELETE', method: 'DELETE',
failure: function(response, opts) { failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus); Ext.Msg.alert('Error', response.htmlStatus);
},
callback: function() {
store.load();
} }
}); });
}; };
...@@ -103,12 +88,19 @@ Ext.define('PVE.window.TaskViewer', { ...@@ -103,12 +88,19 @@ Ext.define('PVE.window.TaskViewer', {
border: false 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() { me.mon(statstore, 'load', function() {
var status = statgrid.getObjectValue('status'); var status = statgrid.getObjectValue('status');
store.load();
if (status === 'stopped') { if (status === 'stopped') {
logView.requestUpdate(undefined, true);
logView.scrollToEnd = false;
statstore.stopUpdate(); statstore.stopUpdate();
} }
...@@ -128,37 +120,11 @@ Ext.define('PVE.window.TaskViewer', { ...@@ -128,37 +120,11 @@ Ext.define('PVE.window.TaskViewer', {
items: [{ items: [{
xtype: 'tabpanel', xtype: 'tabpanel',
region: 'center', region: 'center',
items: [ items: [ logView, statgrid ]
{
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
]
}] }]
}); });
me.callParent(); 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