Commit 67c60602 authored by Wolfgang Link's avatar Wolfgang Link Committed by Dietmar Maurer

add resize LXC Mountpoint at the GUI

parent 21ba6546
......@@ -150,6 +150,7 @@ JSSRC= \
lxc/SnapshotTree.js \
lxc/Snapshot.js \
lxc/ResourceEdit.js \
lxc/MPResize.js \
pool/StatusView.js \
pool/Summary.js \
pool/Config.js \
......
Ext.define('PVE.window.MPResize', {
extend: 'Ext.window.Window',
resizable: false,
resize_disk: function(disk, size) {
var me = this;
var params = { disk: disk, size: '+' + size + 'G' };
PVE.Utils.API2Request({
params: params,
url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/resize',
waitMsgTarget: me,
method: 'PUT',
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, opts) {
var upid = response.result.data;
var win = Ext.create('PVE.window.TaskViewer', { upid: upid });
win.show();
me.close();
}
});
},
initComponent : function() {
var me = this;
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: gettext('Disk'),
vtype: 'StorageId',
allowBlank: false
}
];
me.hdsizesel = Ext.createWidget('numberfield', {
name: 'size',
minValue: 0,
maxValue: 128*1024,
decimalPrecision: 3,
value: '0',
fieldLabel: gettext('Size Increment') + ' (GB)',
allowBlank: false
});
items.push(me.hdsizesel);
me.formPanel = Ext.create('Ext.form.Panel', {
bodyPadding: 10,
border: false,
fieldDefaults: {
labelWidth: 120,
anchor: '100%'
},
items: items
});
var form = me.formPanel.getForm();
var submitBtn;
me.title = gettext('Resize disk');
submitBtn = Ext.create('Ext.Button', {
text: gettext('Resize disk'),
handler: function() {
if (form.isValid()) {
var values = form.getValues();
me.resize_disk(me.disk, values.size);
}
}
});
Ext.apply(me, {
modal: true,
width: 250,
height: 150,
border: false,
layout: 'fit',
buttons: [ submitBtn ],
items: [ me.formPanel ]
});
me.callParent();
if (!me.disk) {
return;
}
}
});
......@@ -112,6 +112,23 @@ Ext.define('PVE.lxc.RessourceView', {
win.on('destroy', reload);
};
var run_resize = function() {
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var win = Ext.create('PVE.window.MPResize', {
disk: rec.data.key,
nodename: nodename,
vmid: vmid
});
win.show();
win.on('destroy', reload);
};
var edit_btn = new PVE.button.Button({
text: gettext('Edit'),
selModel: sm,
......@@ -126,15 +143,45 @@ Ext.define('PVE.lxc.RessourceView', {
handler: run_editor
});
var resize_btn = new PVE.button.Button({
text: gettext('Resize disk'),
selModel: sm,
disabled: true,
handler: run_resize
});
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
edit_btn.disable();
resize_btn.disable();
return;
}
var key = rec.data.key;
var value = rec.data.value;
var rowdef = rows[key];
var isDisk = (rowdef.tdCls == 'pve-itype-icon-storage');
edit_btn.setDisabled(rec.data['delete'] || !rowdef.editor);
resize_btn.setDisabled(!isDisk);
};
Ext.applyIf(me, {
url: '/api2/json/' + baseurl,
selModel: sm,
cwidth1: 170,
tbar: [ edit_btn ],
tbar: [ edit_btn,
resize_btn],
rows: rows,
listeners: {
show: reload,
itemdblclick: run_editor
itemdblclick: run_editor,
selectionchange: set_button_status
}
});
......
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