Commit 6b478975 authored by Dietmar Maurer's avatar Dietmar Maurer

clone: add target node selector

parent 085f9d9b
...@@ -7,6 +7,9 @@ Ext.define('PVE.form.NodeSelector', { ...@@ -7,6 +7,9 @@ Ext.define('PVE.form.NodeSelector', {
selectCurNode: false, selectCurNode: false,
// only allow those nodes (array)
allowedNodes: undefined,
initComponent: function() { initComponent: function() {
var me = this; var me = this;
...@@ -66,19 +69,26 @@ Ext.define('PVE.form.NodeSelector', { ...@@ -66,19 +69,26 @@ Ext.define('PVE.form.NodeSelector', {
} }
var offline = []; var offline = [];
var notAllowed = [];
Ext.Array.each(value.split(/\s*,\s*/), function(node) { Ext.Array.each(value.split(/\s*,\s*/), function(node) {
var rec = me.store.findRecord(me.valueField, node); var rec = me.store.findRecord(me.valueField, node);
if (!(rec && rec.data) || !Ext.isNumeric(rec.data.mem)) { if (!(rec && rec.data) || !Ext.isNumeric(rec.data.mem)) {
offline.push(node); offline.push(node);
} else if (me.allowedNodes && !Ext.Array.contains(me.allowedNodes, node)) {
notAllowed.push(node);
} }
}); });
if (offline.length == 0) { if (notAllowed.length !== 0) {
return true; return "Node " + offline.join(', ') + " is disabled (not allowed for this action)!";
} }
if (offline.length !== 0) {
return "Node " + offline.join(', ') + " seems to be offline!"; return "Node " + offline.join(', ') + " seems to be offline!";
} }
return true;
}
}); });
if (me.selectCurNode && PVE.curSelectedNode.data.node) { if (me.selectCurNode && PVE.curSelectedNode.data.node) {
......
...@@ -18,6 +18,10 @@ Ext.define('PVE.window.Clone', { ...@@ -18,6 +18,10 @@ Ext.define('PVE.window.Clone', {
params.name = values.name; params.name = values.name;
} }
if (values.target) {
params.target = values.target;
}
if (values.clonemode === 'copy') { if (values.clonemode === 'copy') {
params.full = 1; params.full = 1;
if (values.storage) { if (values.storage) {
...@@ -64,7 +68,11 @@ Ext.define('PVE.window.Clone', { ...@@ -64,7 +68,11 @@ Ext.define('PVE.window.Clone', {
Ext.Msg.alert('Error', response.htmlStatus); Ext.Msg.alert('Error', response.htmlStatus);
}, },
success: function(response, options) { success: function(response, options) {
me.submitBtn.setDisabled(response.result.data !== 1); var res = response.result.data;
me.submitBtn.setDisabled(res.hasFeature !== 1);
me.targetSel.allowedNodes = res.nodes;
me.targetSel.validate();
} }
}); });
}, },
...@@ -88,6 +96,16 @@ Ext.define('PVE.window.Clone', { ...@@ -88,6 +96,16 @@ Ext.define('PVE.window.Clone', {
var col1 = []; var col1 = [];
var col2 = []; var col2 = [];
me.targetSel = Ext.create('PVE.form.NodeSelector', {
name: 'target',
fieldLabel: 'Target node',
selectCurNode: true,
allowBlank: false,
onlineValidator: true
});
col1.push(me.targetSel);
var modelist = [['copy', 'Full Clone']]; var modelist = [['copy', 'Full Clone']];
if (me.isTemplate) { if (me.isTemplate) {
modelist.push(['clone', 'Linked Clone']); modelist.push(['clone', 'Linked Clone']);
...@@ -112,7 +130,7 @@ Ext.define('PVE.window.Clone', { ...@@ -112,7 +130,7 @@ Ext.define('PVE.window.Clone', {
me.verifyFeature(); me.verifyFeature();
}); });
col1.push(me.kv1); col2.push(me.kv1);
me.snapshotSel = Ext.create('PVE.form.SnapshotSelector', { me.snapshotSel = Ext.create('PVE.form.SnapshotSelector', {
name: 'snapname', name: 'snapname',
...@@ -130,7 +148,7 @@ Ext.define('PVE.window.Clone', { ...@@ -130,7 +148,7 @@ Ext.define('PVE.window.Clone', {
} }
}); });
col1.push(me.snapshotSel); col2.push(me.snapshotSel);
col1.push( col1.push(
{ {
......
...@@ -78,7 +78,7 @@ Ext.define('PVE.qemu.SnapshotTree', { ...@@ -78,7 +78,7 @@ Ext.define('PVE.qemu.SnapshotTree', {
method: 'GET', method: 'GET',
success: function(response, options) { success: function(response, options) {
var res = response.result.data; var res = response.result.data;
if (res === 1) { if (res.hasFeature) {
Ext.getCmp('snapshotBtn').enable(); Ext.getCmp('snapshotBtn').enable();
} }
} }
......
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