Commit 31cd039b authored by Dietmar Maurer's avatar Dietmar Maurer

improve handling of migrated VMs

parent ffb1b69b
......@@ -188,6 +188,12 @@ Ext.define('PVE.StdWorkspace', {
tree.selectById(nodeid);
},
check_vm_migration: function(record) {
var me = this;
var tree = me.down('pveResourceTree');
tree.check_vm_migration(record);
},
onLogin: function(loginData) {
var me = this;
......@@ -257,6 +263,7 @@ Ext.define('PVE.StdWorkspace', {
showSearch: (n.data.id === 'root') ||
Ext.isDefined(n.data.groupbyid),
pveSelNode: n,
workspace: me,
viewFilter: selview.getViewFilter()
};
}
......
......@@ -22,10 +22,11 @@ Ext.define('PVE.panel.Config', {
defaults: {}
});
// pass rstore, pveSelNode and viewFilter to all children
// pass workspace, pveSelNode and viewFilter to all children
Ext.apply(me.defaults, {
pveSelNode: me.pveSelNode,
viewFilter: me.viewFilter,
workspace: me.workspace,
border: false
});
......
......@@ -21,8 +21,6 @@ Ext.define('PVE.qemu.Migrate', {
});
win.show();
me.close();
me.workspace.selectById('root');
}
});
},
......@@ -40,10 +38,6 @@ Ext.define('PVE.qemu.Migrate', {
throw "no VM ID specified";
}
if (!me.workspace) {
throw "no Workspace specified";
}
me.formPanel = Ext.create('Ext.form.Panel', {
bodyPadding: 10,
border: false,
......
......@@ -15,6 +15,10 @@ Ext.define('PVE.qemu.Summary', {
throw "no VM ID specified";
}
if (!me.workspace) {
throw "no workspace specified";
}
var statusview = Ext.create('PVE.qemu.StatusView', {
title: 'Status',
pveSelNode: me.pveSelNode,
......@@ -65,7 +69,6 @@ Ext.define('PVE.qemu.Summary', {
handler: function() {
var win = Ext.create('PVE.qemu.Migrate', {
pveSelNode: me.pveSelNode,
workspace: me.up('pveStdWorkspace')
});
win.show();
}
......@@ -138,8 +141,14 @@ Ext.define('PVE.qemu.Summary', {
});
me.mon(rstore, 'load', function(s, records, success) {
var rec = s.data.get('status');
var status = rec ? rec.data.value : 'unknown';
var status;
if (!success) {
me.workspace.check_vm_migration(me.pveSelNode);
status = 'unknown';
} else {
var rec = s.data.get('status');
status = rec ? rec.data.value : 'unknown';
}
tbar.down('#start').setDisabled(status === 'running');
tbar.down('#reset').setDisabled(status !== 'running');
......
......@@ -330,6 +330,18 @@ Ext.define('PVE.tree.ResourceTree', {
pdata.dataIndex = {};
me.getSelectionModel().deselectAll();
},
selectExpand: function(node) {
var sm = me.getSelectionModel();
if (!sm.isSelected(node)) {
sm.select(node);
var cn = node;
while (!!(cn = cn.parentNode)) {
if (!cn.isExpanded()) {
cn.expand();
}
}
}
},
selectById: function(nodeid) {
var rootnode = me.store.getRootNode();
var sm = me.getSelectionModel();
......@@ -340,15 +352,21 @@ Ext.define('PVE.tree.ResourceTree', {
node = rootnode.findChild('id', nodeid, true);
}
if (node) {
if (!sm.isSelected(node)) {
sm.select(node);
var cn = node;
while (!!(cn = cn.parentNode)) {
if (!cn.isExpanded()) {
cn.expand();
}
}
}
me.selectExpand(node);
}
},
check_vm_migration: function(record) {
if (!(record.data.type === 'qemu' || record.data.type === 'openvz')) {
throw "not a vm type";
}
var rootnode = me.store.getRootNode();
var node = rootnode.findChild('id', record.data.id, true);
if (node && node.data.type === record.data.type &&
node.data.node !== record.data.node) {
// defer select (else we get strange errors)
Ext.defer(function() { me.selectExpand(node)}, 100, me);
}
},
applyState : function(state) {
......
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