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