Commit 1ade470d authored by Dietmar Maurer's avatar Dietmar Maurer

add startup option to GUI

parent ab71c272
......@@ -96,6 +96,7 @@ JSSRC= \
qemu/DisplayEdit.js \
qemu/KeyboardEdit.js \
qemu/HardwareView.js \
qemu/StartupEdit.js \
qemu/Options.js \
qemu/Config.js \
qemu/CreateWizard.js \
......
......@@ -185,5 +185,55 @@ Ext.define('PVE.Parser', { statics: {
});
return netarray.join(';');
},
parseStartup: function(value) {
if (value === undefined) {
return;
}
var res = {};
var errors = false;
Ext.Array.each(value.split(','), function(p) {
if (!p || p.match(/^\s*$/)) {
return; // continue
}
var match_res;
if ((match_res = p.match(/^(order)?=(\d+)$/)) !== null) {
res.order = match_res[2];
} else if ((match_res = p.match(/^up=(\d+)$/)) !== null) {
res.up = match_res[1];
} else if ((match_res = p.match(/^down=(\d+)$/)) !== null) {
res.down = match_res[1];
} else {
errors = true;
return false; // break
}
});
if (errors) {
return;
}
return res;
},
printStartup: function(startup) {
var arr = [];
if (startup.order !== undefined && startup.order !== '') {
arr.push('order=' + startup.order);
}
if (startup.up !== undefined && startup.up !== '') {
arr.push('up=' + startup.up);
}
if (startup.down !== undefined && startup.down !== '') {
arr.push('down=' + startup.down);
}
return arr.join(',');
}
}});
......@@ -244,6 +244,25 @@ Ext.define('PVE.Utils', { statics: {
return data;
},
render_kvm_startup: function(value) {
var startup = PVE.Parser.parseStartup(value);
var res = 'order=';
if (startup.order === undefined) {
res += 'any';
} else {
res += startup.order;
}
if (startup.up !== undefined) {
res += ',up=' + startup.up;
}
if (startup.down !== undefined) {
res += ',down=' + startup.down;
}
return res;
},
authOK: function() {
return Ext.util.Cookies.get('PVEAuthCookie');
},
......@@ -419,7 +438,9 @@ Ext.define('PVE.Utils', { statics: {
imgcopy: ['', gettext('Copy data') ],
imgdel: ['', gettext('Erase data') ],
download: ['', gettext('Download') ],
vzdump: ['', gettext('Backup') ]
vzdump: ['', gettext('Backup') ],
startall: [ '', gettext('Start all VMs and Containers') ],
stopall: [ '', gettext('Stop all VMs and Containers') ]
},
format_task_description: function(type, id) {
......
......@@ -54,6 +54,13 @@ Ext.define('PVE.qemu.Options', {
}
} : undefined
},
startup: {
header: gettext('Start/Shutdown order'),
defaultValue: '',
renderer: PVE.Utils.render_kvm_startup,
editor: caps.vms['VM.Config.Options'] && caps.nodes['Sys.Modify'] ?
'PVE.qemu.StartupEdit' : undefined
},
ostype: {
header: 'OS Type',
editor: caps.vms['VM.Config.Options'] ? 'PVE.qemu.OSTypeEdit' : undefined,
......
Ext.define('PVE.qemu.StartupInputPanel', {
extend: 'PVE.panel.InputPanel',
onGetValues: function(values) {
var me = this;
var res = PVE.Parser.printStartup(values);
if (res === undefined || res === '') {
return { 'delete': 'startup' };
}
return { startup: res };
},
setStartup: function(value) {
var me = this;
var startup = PVE.Parser.parseStartup(value);
if (startup) {
console.dir(startup);
me.setValues(startup);
}
},
initComponent : function() {
var me = this;
me.items = [
{
xtype: 'textfield',
name: 'order',
defaultValue: '',
emptyText: 'any',
fieldLabel: gettext('Start order')
},
{
xtype: 'textfield',
name: 'up',
defaultValue: '',
emptyText: 'default',
fieldLabel: gettext('Startup delay')
},
{
xtype: 'textfield',
name: 'down',
defaultValue: '',
emptyText: 'default',
fieldLabel: gettext('Shutdown timeout')
}
];
me.callParent();
}
});
Ext.define('PVE.qemu.StartupEdit', {
extend: 'PVE.window.Edit',
initComponent : function() {
/*jslint confusion: true */
var me = this;
var ipanel = Ext.create('PVE.qemu.StartupInputPanel', {});
Ext.applyIf(me, {
subject: gettext('Start/Shutdown order'),
fieldDefaults: {
labelWidth: 120
},
items: ipanel
});
me.callParent();
me.load({
success: function(response, options) {
var i, confid;
me.vmconfig = response.result.data;
ipanel.setStartup(me.vmconfig.startup);
}
});
}
});
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