Commit 8ac30d82 authored by Alexandre Derumier's avatar Alexandre Derumier Committed by Dietmar Maurer

add hdmove panel

Signed-off-by: 's avatarAlexandre Derumier <aderumier@odiso.com>
parent 0428106c
...@@ -97,6 +97,7 @@ JSSRC= \ ...@@ -97,6 +97,7 @@ JSSRC= \
qemu/CDEdit.js \ qemu/CDEdit.js \
qemu/HDEdit.js \ qemu/HDEdit.js \
qemu/HDResize.js \ qemu/HDResize.js \
qemu/HDMove.js \
qemu/DisplayEdit.js \ qemu/DisplayEdit.js \
qemu/KeyboardEdit.js \ qemu/KeyboardEdit.js \
qemu/HardwareView.js \ qemu/HardwareView.js \
......
Ext.define('PVE.window.HDMove', {
extend: 'Ext.window.Window',
resizable: false,
move_disk: function(disk, storage, format) {
var me = this;
params = { disk: disk, storage: storage };
if (format) {
params.format = format;
}
PVE.Utils.API2Request({
params: params,
url: '/nodes/' + me.nodename + '/qemu/' + me.vmid + '/move',
waitMsgTarget: me,
method: 'PUT',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
},
success: function(response, options) {
me.close();
}
});
},
initComponent : function() {
var me = this;
var diskarray = [];
if (!me.nodename) {
throw "no node name specified";
}
if (!me.vmid) {
throw "no VM ID specified";
}
var items = [
{
xtype: 'displayfield',
name: 'disk',
value: me.disk,
fieldLabel: 'Disk',
vtype: 'StorageId',
allowBlank: false
},
];
me.hdstoragesel = Ext.create('PVE.form.StorageSelector', {
name: 'hdstorage',
nodename: me.nodename,
fieldLabel: 'Target Storage',
storageContent: 'images',
autoSelect: me.insideWizard,
allowBlank: true,
disabled: false,
hidden: false,
listeners: {
change: function(f, value) {
var rec = f.store.getById(value);
if (rec.data.type === 'iscsi') {
me.formatsel.setValue('raw');
me.formatsel.setDisabled(true);
} else if (rec.data.type === 'lvm' ||
rec.data.type === 'rbd' ||
rec.data.type === 'sheepdog' ||
rec.data.type === 'nexenta'
) {
me.formatsel.setValue('raw');
me.formatsel.setDisabled(true);
} else {
me.formatsel.setDisabled(false);
}
}
}
});
me.formatsel = Ext.create('PVE.form.DiskFormatSelector', {
name: 'diskformat',
fieldLabel: gettext('Format'),
value: 'raw',
disabled: true,
hidden: false,
allowBlank: false
});
items.push(me.hdstoragesel);
items.push(me.formatsel);
me.formPanel = Ext.create('Ext.form.Panel', {
bodyPadding: 10,
border: false,
fieldDefaults: {
labelWidth: 100,
anchor: '100%'
},
items: items
});
var form = me.formPanel.getForm();
var submitBtn;
me.title = "Move disk";
submitBtn = Ext.create('Ext.Button', {
text: gettext('Move'),
handler: function() {
if (form.isValid()) {
var values = form.getValues();
me.move_disk(me.disk, values.hdstorage, values.diskformat);
}
}
});
Ext.apply(me, {
modal: true,
width: 350,
border: false,
layout: 'fit',
buttons: [ submitBtn ],
items: [ me.formPanel ]
});
me.callParent();
}
});
...@@ -234,6 +234,28 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -234,6 +234,28 @@ Ext.define('PVE.qemu.HardwareView', {
win.on('destroy', reload); win.on('destroy', reload);
}; };
var run_move = function() {
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var rowdef = rows[rec.data.key];
if (!rowdef.editor) {
return;
}
var win = Ext.create('PVE.window.HDMove', {
disk: rec.data.key,
nodename: nodename,
vmid: vmid
});
win.show();
win.on('destroy', reload);
};
var edit_btn = new PVE.button.Button({ var edit_btn = new PVE.button.Button({
text: gettext('Edit'), text: gettext('Edit'),
selModel: sm, selModel: sm,
...@@ -262,6 +284,21 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -262,6 +284,21 @@ Ext.define('PVE.qemu.HardwareView', {
handler: run_resize handler: run_resize
}); });
var move_btn = new PVE.button.Button({
text: gettext('Move disk'),
selModel: sm,
disabled: true,
enableFn: function(rec) {
if (!rec) {
return false;
}
var rowdef = rows[rec.data.key];
return rowdef.tdCls == 'pve-itype-icon-storage' && !rec.data.value.match(/media=cdrom/)
},
handler: run_move
});
var remove_btn = new PVE.button.Button({ var remove_btn = new PVE.button.Button({
text: gettext('Remove'), text: gettext('Remove'),
selModel: sm, selModel: sm,
...@@ -355,7 +392,8 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -355,7 +392,8 @@ Ext.define('PVE.qemu.HardwareView', {
}, },
remove_btn, remove_btn,
edit_btn, edit_btn,
resize_btn resize_btn,
move_btn
], ],
rows: rows, rows: rows,
sorterFn: sorterFn, sorterFn: sorterFn,
......
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