Commit 59428c5c authored by Dietmar Maurer's avatar Dietmar Maurer

fix bug #115: simplify GUI for users without permissions

parent 28e0dddd
pve-manager (2.0-62) unstable; urgency=low
* fix bug #115: simplify GUI for users without permissions.
-- Proxmox Support Team <support@proxmox.com> Tue, 17 Apr 2012 10:37:05 +0200
pve-manager (2.0-61) unstable; urgency=low pve-manager (2.0-61) unstable; urgency=low
* add Italian translation * add Italian translation
......
...@@ -2,7 +2,7 @@ RELEASE=2.0 ...@@ -2,7 +2,7 @@ RELEASE=2.0
VERSION=2.0 VERSION=2.0
PACKAGE=pve-manager PACKAGE=pve-manager
PACKAGERELEASE=61 PACKAGERELEASE=62
BINDIR=${DESTDIR}/usr/bin BINDIR=${DESTDIR}/usr/bin
PERLLIBDIR=${DESTDIR}/usr/share/perl5 PERLLIBDIR=${DESTDIR}/usr/share/perl5
......
...@@ -188,6 +188,7 @@ Ext.define('PVE.StateProvider', { ...@@ -188,6 +188,7 @@ Ext.define('PVE.StateProvider', {
}, },
get: function(name, defaultValue){ get: function(name, defaultValue){
/*jslint confusion: true */
var me = this; var me = this;
var data; var data;
...@@ -195,6 +196,9 @@ Ext.define('PVE.StateProvider', { ...@@ -195,6 +196,9 @@ Ext.define('PVE.StateProvider', {
data = { value: me.UIState[name] }; data = { value: me.UIState[name] };
} else { } else {
data = me.callParent(arguments); data = me.callParent(arguments);
if (!data && name === 'GuiCap') {
data = { vms: {}, storage: {}, access: {}, nodes: {}, dc: {} };
}
} }
//console.log("GET " + name + " " + Ext.encode(data)); //console.log("GET " + name + " " + Ext.encode(data));
......
...@@ -21,6 +21,11 @@ Ext.define('PVE.Workspace', { ...@@ -21,6 +21,11 @@ Ext.define('PVE.Workspace', {
me.loginData = loginData; me.loginData = loginData;
PVE.CSRFPreventionToken = loginData.CSRFPreventionToken; PVE.CSRFPreventionToken = loginData.CSRFPreventionToken;
PVE.UserName = loginData.username; PVE.UserName = loginData.username;
if (loginData.cap) {
Ext.state.Manager.set('GuiCap', loginData.cap);
}
// creates a session cookie (expire = null) // creates a session cookie (expire = null)
// that way the cookie gets deleted after browser window close // that way the cookie gets deleted after browser window close
Ext.util.Cookies.set('PVEAuthCookie', loginData.ticket, null, '/', null, true); Ext.util.Cookies.set('PVEAuthCookie', loginData.ticket, null, '/', null, true);
...@@ -229,6 +234,8 @@ Ext.define('PVE.StdWorkspace', { ...@@ -229,6 +234,8 @@ Ext.define('PVE.StdWorkspace', {
Ext.History.init(); Ext.History.init();
Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider')); Ext.state.Manager.setProvider(Ext.create('PVE.StateProvider'));
var caps = Ext.state.Manager.get('GuiCap');
var selview = new PVE.form.ViewSelector({}); var selview = new PVE.form.ViewSelector({});
var rtree = Ext.createWidget('pveResourceTree', { var rtree = Ext.createWidget('pveResourceTree', {
...@@ -328,6 +335,7 @@ Ext.define('PVE.StdWorkspace', { ...@@ -328,6 +335,7 @@ Ext.define('PVE.StdWorkspace', {
xtype: 'button', xtype: 'button',
baseCls: 'x-btn', baseCls: 'x-btn',
text: gettext("Create VM"), text: gettext("Create VM"),
disabled: !caps.vms['VM.Allocate'],
handler: function() { handler: function() {
var wiz = Ext.create('PVE.qemu.CreateWizard', {}); var wiz = Ext.create('PVE.qemu.CreateWizard', {});
wiz.show(); wiz.show();
...@@ -339,6 +347,7 @@ Ext.define('PVE.StdWorkspace', { ...@@ -339,6 +347,7 @@ Ext.define('PVE.StdWorkspace', {
xtype: 'button', xtype: 'button',
baseCls: 'x-btn', baseCls: 'x-btn',
text: gettext("Create CT"), text: gettext("Create CT"),
disabled: !caps.vms['VM.Allocate'],
handler: function() { handler: function() {
var wiz = Ext.create('PVE.openvz.CreateWizard', {}); var wiz = Ext.create('PVE.openvz.CreateWizard', {});
wiz.show(); wiz.show();
......
...@@ -5,10 +5,17 @@ Ext.define('PVE.dc.Config', { ...@@ -5,10 +5,17 @@ Ext.define('PVE.dc.Config', {
initComponent: function() { initComponent: function() {
var me = this; var me = this;
var caps = Ext.state.Manager.get('GuiCap');
me.items = [];
Ext.apply(me, { Ext.apply(me, {
title: gettext("Datacenter"), title: gettext("Datacenter"),
hstateid: 'dctab', hstateid: 'dctab'
items: [ });
if (caps.dc['Sys.Audit']) {
me.items.push([
{ {
title: gettext('Summary'), title: gettext('Summary'),
xtype: 'pveDcSummary', xtype: 'pveDcSummary',
...@@ -18,22 +25,34 @@ Ext.define('PVE.dc.Config', { ...@@ -18,22 +25,34 @@ Ext.define('PVE.dc.Config', {
xtype: 'pveDcOptionView', xtype: 'pveDcOptionView',
title: gettext('Options'), title: gettext('Options'),
itemId: 'options' itemId: 'options'
}, }
{ ]);
}
if (caps.storage['Datastore.Allocate'] || caps.dc['Sys.Audit']) {
me.items.push({
xtype: 'pveStorageView', xtype: 'pveStorageView',
title: gettext('Storage'), title: gettext('Storage'),
itemId: 'storage' itemId: 'storage'
}, });
{ }
if (caps.dc['Sys.Audit']) {
me.items.push({
xtype: 'pveDcBackupView', xtype: 'pveDcBackupView',
title: gettext('Backup'), title: gettext('Backup'),
itemId: 'backup' itemId: 'backup'
}, });
{ }
me.items.push({
xtype: 'pveUserView', xtype: 'pveUserView',
title: gettext('Users'), title: gettext('Users'),
itemId: 'users' itemId: 'users'
}, });
if (caps.dc['Sys.Audit']) {
me.items.push([
{ {
xtype: 'pveGroupView', xtype: 'pveGroupView',
title: gettext('Groups'), title: gettext('Groups'),
...@@ -63,14 +82,15 @@ Ext.define('PVE.dc.Config', { ...@@ -63,14 +82,15 @@ Ext.define('PVE.dc.Config', {
xtype: 'pveDcHAConfig', xtype: 'pveDcHAConfig',
title: 'HA', title: 'HA',
itemId: 'ha' itemId: 'ha'
}, }
{ ]);
me.items.push({
xtype: 'pveDcSupport', xtype: 'pveDcSupport',
title: gettext('Support'), title: gettext('Support'),
itemId: 'support' itemId: 'support'
}
]
}); });
}
me.callParent(); me.callParent();
} }
......
...@@ -59,6 +59,8 @@ Ext.define('PVE.dc.UserView', { ...@@ -59,6 +59,8 @@ Ext.define('PVE.dc.UserView', {
initComponent : function() { initComponent : function() {
var me = this; var me = this;
var caps = Ext.state.Manager.get('GuiCap');
var store = new Ext.data.Store({ var store = new Ext.data.Store({
id: "users", id: "users",
model: 'pve-users', model: 'pve-users',
...@@ -79,6 +81,9 @@ Ext.define('PVE.dc.UserView', { ...@@ -79,6 +81,9 @@ Ext.define('PVE.dc.UserView', {
disabled: true, disabled: true,
selModel: sm, selModel: sm,
enableFn: function(rec) { enableFn: function(rec) {
if (!caps.access['User.Modify']) {
return false;
}
return rec.data.userid !== 'root@pam'; return rec.data.userid !== 'root@pam';
}, },
confirmMsg: function (rec) { confirmMsg: function (rec) {
...@@ -104,7 +109,7 @@ Ext.define('PVE.dc.UserView', { ...@@ -104,7 +109,7 @@ Ext.define('PVE.dc.UserView', {
var run_editor = function() { var run_editor = function() {
var rec = sm.getSelection()[0]; var rec = sm.getSelection()[0];
if (!rec) { if (!rec || !caps.access['User.Modify']) {
return; return;
} }
...@@ -118,6 +123,9 @@ Ext.define('PVE.dc.UserView', { ...@@ -118,6 +123,9 @@ Ext.define('PVE.dc.UserView', {
var edit_btn = new PVE.button.Button({ var edit_btn = new PVE.button.Button({
text: gettext('Edit'), text: gettext('Edit'),
disabled: true, disabled: true,
enableFn: function(rec) {
return !!caps.access['User.Modify'];
},
selModel: sm, selModel: sm,
handler: run_editor handler: run_editor
}); });
...@@ -138,6 +146,7 @@ Ext.define('PVE.dc.UserView', { ...@@ -138,6 +146,7 @@ Ext.define('PVE.dc.UserView', {
var tbar = [ var tbar = [
{ {
text: gettext('Add'), text: gettext('Add'),
disabled: !caps.access['User.Modify'],
handler: function() { handler: function() {
var win = Ext.create('PVE.dc.UserEdit',{ var win = Ext.create('PVE.dc.UserEdit',{
}); });
......
...@@ -10,6 +10,8 @@ Ext.define('PVE.node.Config', { ...@@ -10,6 +10,8 @@ Ext.define('PVE.node.Config', {
throw "no node name specified"; throw "no node name specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
me.statusStore = Ext.create('PVE.data.ObjectStore', { me.statusStore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + nodename + "/status", url: "/api2/json/nodes/" + nodename + "/status",
interval: 1000 interval: 1000
...@@ -29,6 +31,7 @@ Ext.define('PVE.node.Config', { ...@@ -29,6 +31,7 @@ Ext.define('PVE.node.Config', {
var restartBtn = Ext.create('PVE.button.Button', { var restartBtn = Ext.create('PVE.button.Button', {
text: gettext('Restart'), text: gettext('Restart'),
disabled: !caps.nodes['Sys.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to restart node {0}?"), nodename), confirmMsg: Ext.String.format(gettext("Do you really want to restart node {0}?"), nodename),
handler: function() { handler: function() {
node_command('reboot'); node_command('reboot');
...@@ -37,6 +40,7 @@ Ext.define('PVE.node.Config', { ...@@ -37,6 +40,7 @@ Ext.define('PVE.node.Config', {
var shutdownBtn = Ext.create('PVE.button.Button', { var shutdownBtn = Ext.create('PVE.button.Button', {
text: gettext('Shutdown'), text: gettext('Shutdown'),
disabled: !caps.nodes['Sys.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to shutdown node {0}?"), nodename), confirmMsg: Ext.String.format(gettext("Do you really want to shutdown node {0}?"), nodename),
handler: function() { handler: function() {
node_command('shutdown'); node_command('shutdown');
...@@ -45,6 +49,7 @@ Ext.define('PVE.node.Config', { ...@@ -45,6 +49,7 @@ Ext.define('PVE.node.Config', {
var shellBtn = Ext.create('Ext.Button', { var shellBtn = Ext.create('Ext.Button', {
text: gettext('Shell'), text: gettext('Shell'),
disabled: !caps.nodes['Sys.Console'],
handler: function() { handler: function() {
var url = Ext.urlEncode({ var url = Ext.urlEncode({
console: 'shell', console: 'shell',
...@@ -56,12 +61,17 @@ Ext.define('PVE.node.Config', { ...@@ -56,12 +61,17 @@ Ext.define('PVE.node.Config', {
} }
}); });
me.items = [];
Ext.apply(me, { Ext.apply(me, {
title: gettext('Node') + " '" + nodename + "'", title: gettext('Node') + " '" + nodename + "'",
hstateid: 'nodetab', hstateid: 'nodetab',
defaults: { statusStore: me.statusStore }, defaults: { statusStore: me.statusStore },
tbar: [ restartBtn, shutdownBtn, shellBtn ], tbar: [ restartBtn, shutdownBtn, shellBtn ]
items: [ });
if (caps.nodes['Sys.Audit']) {
me.items.push([
{ {
title: gettext('Summary'), title: gettext('Summary'),
itemId: 'summary', itemId: 'summary',
...@@ -86,41 +96,60 @@ Ext.define('PVE.node.Config', { ...@@ -86,41 +96,60 @@ Ext.define('PVE.node.Config', {
title: gettext('Time'), title: gettext('Time'),
itemId: 'time', itemId: 'time',
xtype: 'pveNodeTimeView' xtype: 'pveNodeTimeView'
}, }
]);
}
if (caps.nodes['Sys.Syslog']) {
me.items.push([
{ {
title: 'Syslog', title: 'Syslog',
itemId: 'syslog', itemId: 'syslog',
xtype: 'pveLogView', xtype: 'pveLogView',
url: "/api2/extjs/nodes/" + nodename + "/syslog" url: "/api2/extjs/nodes/" + nodename + "/syslog"
}, }
]);
}
me.items.push([
{ {
title: 'Task History', title: 'Task History',
itemId: 'tasks', itemId: 'tasks',
xtype: 'pveNodeTasks' xtype: 'pveNodeTasks'
}, }
]);
if (caps.nodes['Sys.Audit']) {
me.items.push([
{ {
title: 'UBC', title: 'UBC',
itemId: 'ubc', itemId: 'ubc',
xtype: 'pveNodeBCFailCnt' xtype: 'pveNodeBCFailCnt'
}, }
]);
}
me.items.push([
{ {
title: 'Subscription', title: 'Subscription',
itemId: 'support', itemId: 'support',
xtype: 'pveNodeSubscription', xtype: 'pveNodeSubscription',
nodename: nodename nodename: nodename
} }
] ]);
});
me.callParent(); me.callParent();
me.statusStore.on('load', function(s, records, success) { me.statusStore.on('load', function(s, records, success) {
var uptimerec = s.data.get('uptime'); var uptimerec = s.data.get('uptime');
var uptime = uptimerec ? uptimerec.data.value : false; var powermgmt = uptimerec ? uptimerec.data.value : false;
if (!caps.nodes['Sys.PowerMgmt']) {
restartBtn.setDisabled(!uptime); powermgmt = false;
shutdownBtn.setDisabled(!uptime); }
shellBtn.setDisabled(!uptime); restartBtn.setDisabled(!powermgmt);
shutdownBtn.setDisabled(!powermgmt);
shellBtn.setDisabled(!powermgmt);
}); });
me.on('afterrender', function() { me.on('afterrender', function() {
......
...@@ -15,6 +15,8 @@ Ext.define('PVE.openvz.Config', { ...@@ -15,6 +15,8 @@ Ext.define('PVE.openvz.Config', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
me.statusStore = Ext.create('PVE.data.ObjectStore', { me.statusStore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + nodename + "/openvz/" + vmid + "/status/current", url: "/api2/json/nodes/" + nodename + "/openvz/" + vmid + "/status/current",
interval: 1000 interval: 1000
...@@ -34,6 +36,7 @@ Ext.define('PVE.openvz.Config', { ...@@ -34,6 +36,7 @@ Ext.define('PVE.openvz.Config', {
var startBtn = Ext.create('Ext.Button', { var startBtn = Ext.create('Ext.Button', {
text: gettext('Start'), text: gettext('Start'),
disabled: !caps.vms['VM.PowerMgmt'],
handler: function() { handler: function() {
vm_command('start'); vm_command('start');
} }
...@@ -50,6 +53,7 @@ Ext.define('PVE.openvz.Config', { ...@@ -50,6 +53,7 @@ Ext.define('PVE.openvz.Config', {
var stopBtn = Ext.create('PVE.button.Button', { var stopBtn = Ext.create('PVE.button.Button', {
text: gettext('Stop'), text: gettext('Stop'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid), confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid),
handler: function() { handler: function() {
vm_command("stop"); vm_command("stop");
...@@ -58,6 +62,7 @@ Ext.define('PVE.openvz.Config', { ...@@ -58,6 +62,7 @@ Ext.define('PVE.openvz.Config', {
var shutdownBtn = Ext.create('PVE.button.Button', { var shutdownBtn = Ext.create('PVE.button.Button', {
text: gettext('Shutdown'), text: gettext('Shutdown'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid), confirmMsg: Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid),
handler: function() { handler: function() {
vm_command('shutdown'); vm_command('shutdown');
...@@ -66,6 +71,7 @@ Ext.define('PVE.openvz.Config', { ...@@ -66,6 +71,7 @@ Ext.define('PVE.openvz.Config', {
var migrateBtn = Ext.create('Ext.Button', { var migrateBtn = Ext.create('Ext.Button', {
text: gettext('Migrate'), text: gettext('Migrate'),
disabled: !caps.vms['VM.Migrate'],
handler: function() { handler: function() {
var win = Ext.create('PVE.window.Migrate', { var win = Ext.create('PVE.window.Migrate', {
vmtype: 'openvz', vmtype: 'openvz',
...@@ -78,6 +84,7 @@ Ext.define('PVE.openvz.Config', { ...@@ -78,6 +84,7 @@ Ext.define('PVE.openvz.Config', {
var removeBtn = Ext.create('PVE.button.Button', { var removeBtn = Ext.create('PVE.button.Button', {
text: gettext('Remove'), text: gettext('Remove'),
disabled: !caps.vms['VM.Allocate'],
confirmMsg: Ext.String.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid), confirmMsg: Ext.String.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid),
handler: function() { handler: function() {
PVE.Utils.API2Request({ PVE.Utils.API2Request({
...@@ -95,6 +102,7 @@ Ext.define('PVE.openvz.Config', { ...@@ -95,6 +102,7 @@ Ext.define('PVE.openvz.Config', {
var consoleBtn = Ext.create('Ext.Button', { var consoleBtn = Ext.create('Ext.Button', {
text: gettext('Console'), text: gettext('Console'),
disabled: !caps.vms['VM.Console'],
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('openvz', vmid, nodename, vmname); PVE.Utils.openConoleWindow('openvz', vmid, nodename, vmname);
} }
...@@ -139,26 +147,36 @@ Ext.define('PVE.openvz.Config', { ...@@ -139,26 +147,36 @@ Ext.define('PVE.openvz.Config', {
itemId: 'ubc', itemId: 'ubc',
xtype: 'pveBeanCounterGrid', xtype: 'pveBeanCounterGrid',
url: '/api2/json/nodes/' + nodename + '/openvz/' + vmid + '/status/ubc' url: '/api2/json/nodes/' + nodename + '/openvz/' + vmid + '/status/ubc'
}, }
{ ]
});
if (caps.vms['VM.Console']) {
me.items.push({
title: "InitLog", title: "InitLog",
itemId: 'initlog', itemId: 'initlog',
xtype: 'pveLogView', xtype: 'pveLogView',
url: '/api2/extjs/nodes/' + nodename + '/openvz/' + vmid + '/initlog' url: '/api2/extjs/nodes/' + nodename + '/openvz/' + vmid + '/initlog'
}, });
{ }
if (caps.vms['VM.Backup']) {
me.items.push({
title: gettext('Backup'), title: gettext('Backup'),
xtype: 'pveBackupView', xtype: 'pveBackupView',
itemId: 'backup' itemId: 'backup'
}, });
{ }
if (caps.vms['Permissions.Modify']) {
me.items.push({
xtype: 'pveACLView', xtype: 'pveACLView',
title: gettext('Permissions'), title: gettext('Permissions'),
itemId: 'permissions', itemId: 'permissions',
path: '/vms/' + vmid path: '/vms/' + vmid
}
]
}); });
}
me.callParent(); me.callParent();
...@@ -171,10 +189,10 @@ Ext.define('PVE.openvz.Config', { ...@@ -171,10 +189,10 @@ Ext.define('PVE.openvz.Config', {
var rec = s.data.get('status'); var rec = s.data.get('status');
status = rec ? rec.data.value : 'unknown'; status = rec ? rec.data.value : 'unknown';
} }
startBtn.setDisabled(status === 'running'); startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running');
shutdownBtn.setDisabled(status !== 'running'); shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
stopBtn.setDisabled(status === 'stopped'); stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');
removeBtn.setDisabled(status !== 'stopped'); removeBtn.setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
if (status === 'mounted') { if (status === 'mounted') {
umountBtn.setDisabled(false); umountBtn.setDisabled(false);
......
...@@ -17,12 +17,14 @@ Ext.define('PVE.openvz.DNS', { ...@@ -17,12 +17,14 @@ Ext.define('PVE.openvz.DNS', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
var rows = { var rows = {
hostname: { hostname: {
required: true, required: true,
defaultValue: me.pveSelNode.data.name, defaultValue: me.pveSelNode.data.name,
header: 'Hostname', header: 'Hostname',
editor: { editor: caps.vms['VM.Config.Network'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'Hostname', subject: 'Hostname',
items: { items: {
...@@ -33,12 +35,12 @@ Ext.define('PVE.openvz.DNS', { ...@@ -33,12 +35,12 @@ Ext.define('PVE.openvz.DNS', {
allowBlank: true, allowBlank: true,
emptyText: me.pveSelNode.data.name emptyText: me.pveSelNode.data.name
} }
} } : undefined
}, },
searchdomain: { searchdomain: {
header: 'DNS domain', header: 'DNS domain',
defaultValue: '', defaultValue: '',
editor: { editor: caps.vms['VM.Config.Network'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'DNS domain', subject: 'DNS domain',
items: { items: {
...@@ -47,12 +49,12 @@ Ext.define('PVE.openvz.DNS', { ...@@ -47,12 +49,12 @@ Ext.define('PVE.openvz.DNS', {
fieldLabel: 'DNS domain', fieldLabel: 'DNS domain',
allowBlank: false allowBlank: false
} }
} } : undefined
}, },
nameserver: { nameserver: {
header: gettext('DNS server'), header: gettext('DNS server'),
defaultValue: '', defaultValue: '',
editor: { editor: caps.vms['VM.Config.Network'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: gettext('DNS server'), subject: gettext('DNS server'),
items: { items: {
...@@ -61,7 +63,7 @@ Ext.define('PVE.openvz.DNS', { ...@@ -61,7 +63,7 @@ Ext.define('PVE.openvz.DNS', {
fieldLabel: gettext('DNS server'), fieldLabel: gettext('DNS server'),
allowBlank: false allowBlank: false
} }
} } : undefined
} }
}; };
......
...@@ -242,6 +242,8 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -242,6 +242,8 @@ Ext.define('PVE.openvz.NetworkView', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
me.url = '/nodes/' + nodename + '/openvz/' + vmid + '/config'; me.url = '/nodes/' + nodename + '/openvz/' + vmid + '/config';
var store = new Ext.data.Store({ var store = new Ext.data.Store({
...@@ -254,6 +256,9 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -254,6 +256,9 @@ Ext.define('PVE.openvz.NetworkView', {
text: gettext('Remove'), text: gettext('Remove'),
disabled: true, disabled: true,
selModel: sm, selModel: sm,
enableFn: function(rec) {
return !!caps.vms['VM.Config.Network'];
},
confirmMsg: function (rec) { confirmMsg: function (rec) {
var idtext = rec.id; var idtext = rec.id;
if (rec.data.type === 'ip') { if (rec.data.type === 'ip') {
...@@ -304,6 +309,10 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -304,6 +309,10 @@ Ext.define('PVE.openvz.NetworkView', {
return; return;
} }
if (!caps.vms['VM.Config.Network']) {
return false;
}
var win = Ext.create('PVE.OpenVZ.NetIfEdit', { var win = Ext.create('PVE.OpenVZ.NetIfEdit', {
url: me.url, url: me.url,
nodename: nodename, nodename: nodename,
...@@ -319,6 +328,9 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -319,6 +328,9 @@ Ext.define('PVE.openvz.NetworkView', {
selModel: sm, selModel: sm,
disabled: true, disabled: true,
enableFn: function(rec) { enableFn: function(rec) {
if (!caps.vms['VM.Config.Network']) {
return false;
}
return rec.data.type === 'veth'; return rec.data.type === 'veth';
}, },
handler: run_editor handler: run_editor
...@@ -336,6 +348,7 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -336,6 +348,7 @@ Ext.define('PVE.openvz.NetworkView', {
items: [ items: [
{ {
text: gettext('IP address') + ' (venet)', text: gettext('IP address') + ' (venet)',
disabled: !caps.vms['VM.Config.Network'],
//plain: true, //plain: true,
//iconCls: 'pve-itype-icon-storage', //iconCls: 'pve-itype-icon-storage',
handler: function() { handler: function() {
...@@ -349,6 +362,7 @@ Ext.define('PVE.openvz.NetworkView', { ...@@ -349,6 +362,7 @@ Ext.define('PVE.openvz.NetworkView', {
}, },
{ {
text: gettext('Network Device') + ' (veth)', text: gettext('Network Device') + ' (veth)',
disabled: !caps.vms['VM.Config.Network'],
//plain: true, //plain: true,
//iconCls: 'pve-itype-icon-storage', //iconCls: 'pve-itype-icon-storage',
handler: function() { handler: function() {
......
...@@ -17,12 +17,14 @@ Ext.define('PVE.openvz.Options', { ...@@ -17,12 +17,14 @@ Ext.define('PVE.openvz.Options', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
var rows = { var rows = {
onboot: { onboot: {
header: gettext('Start at boot'), header: gettext('Start at boot'),
defaultValue: '', defaultValue: '',
renderer: PVE.Utils.format_boolean, renderer: PVE.Utils.format_boolean,
editor: { editor: caps.vms['VM.Config.Options'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: gettext('Start at boot'), subject: gettext('Start at boot'),
items: { items: {
...@@ -32,7 +34,7 @@ Ext.define('PVE.openvz.Options', { ...@@ -32,7 +34,7 @@ Ext.define('PVE.openvz.Options', {
defaultValue: 0, defaultValue: 0,
fieldLabel: gettext('Start at boot') fieldLabel: gettext('Start at boot')
} }
} } : undefined
}, },
ostemplate: { ostemplate: {
header: gettext('Template'), header: gettext('Template'),
...@@ -45,7 +47,7 @@ Ext.define('PVE.openvz.Options', { ...@@ -45,7 +47,7 @@ Ext.define('PVE.openvz.Options', {
cpuunits: { cpuunits: {
header: 'CPU units', header: 'CPU units',
defaultValue: '1000', defaultValue: '1000',
editor: { editor: caps.vms['VM.Config.CPU'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'CPU units', subject: 'CPU units',
items: { items: {
...@@ -56,7 +58,7 @@ Ext.define('PVE.openvz.Options', { ...@@ -56,7 +58,7 @@ Ext.define('PVE.openvz.Options', {
maxValue: 500000, maxValue: 500000,
allowBlank: false allowBlank: false
} }
} } : undefined
}, },
quotaugidlimit: { quotaugidlimit: {
header: 'Quota UGID limit', header: 'Quota UGID limit',
...@@ -67,7 +69,7 @@ Ext.define('PVE.openvz.Options', { ...@@ -67,7 +69,7 @@ Ext.define('PVE.openvz.Options', {
} }
return value; return value;
}, },
editor: { editor: caps.vms['VM.Config.Disk'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'Quota UGID limit (0 to disable user quotas)', subject: 'Quota UGID limit (0 to disable user quotas)',
items: { items: {
...@@ -77,12 +79,12 @@ Ext.define('PVE.openvz.Options', { ...@@ -77,12 +79,12 @@ Ext.define('PVE.openvz.Options', {
minValue: 0, minValue: 0,
allowBlank: false allowBlank: false
} }
} } : undefined
}, },
quotatime: { quotatime: {
header: 'Quota Grace period', header: 'Quota Grace period',
defaultValue: '0', defaultValue: '0',
editor: { editor: caps.vms['VM.Config.Disk'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'Quota Grace period (seconds)', subject: 'Quota Grace period (seconds)',
items: { items: {
...@@ -92,7 +94,7 @@ Ext.define('PVE.openvz.Options', { ...@@ -92,7 +94,7 @@ Ext.define('PVE.openvz.Options', {
allowBlank: false, allowBlank: false,
fieldLabel: 'Grace period' fieldLabel: 'Grace period'
} }
} } : undefined
} }
}; };
......
...@@ -18,10 +18,16 @@ Ext.define('PVE.openvz.RessourceView', { ...@@ -18,10 +18,16 @@ Ext.define('PVE.openvz.RessourceView', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
var resEditor = (caps.vms['VM.Config.Memory'] || caps.vms['VM.Config.Disk'] ||
caps.vms['VM.Config.CPU']) ? 'PVE.openvz.RessourceEdit' : undefined;
var rows = { var rows = {
memory: { memory: {
header: gettext('Memory'), header: gettext('Memory'),
editor: 'PVE.openvz.RessourceEdit', editor: resEditor,
never_delete: true, never_delete: true,
renderer: function(value) { renderer: function(value) {
return PVE.Utils.format_size(value*1024*1024); return PVE.Utils.format_size(value*1024*1024);
...@@ -29,7 +35,7 @@ Ext.define('PVE.openvz.RessourceView', { ...@@ -29,7 +35,7 @@ Ext.define('PVE.openvz.RessourceView', {
}, },
swap: { swap: {
header: gettext('Swap'), header: gettext('Swap'),
editor: 'PVE.openvz.RessourceEdit', editor: resEditor,
never_delete: true, never_delete: true,
renderer: function(value) { renderer: function(value) {
return PVE.Utils.format_size(value*1024*1024); return PVE.Utils.format_size(value*1024*1024);
...@@ -38,12 +44,12 @@ Ext.define('PVE.openvz.RessourceView', { ...@@ -38,12 +44,12 @@ Ext.define('PVE.openvz.RessourceView', {
cpus: { cpus: {
header: gettext('Processors'), header: gettext('Processors'),
never_delete: true, never_delete: true,
editor: 'PVE.openvz.RessourceEdit', editor: resEditor,
defaultValue: 1 defaultValue: 1
}, },
disk: { disk: {
header: gettext('Disk size'), header: gettext('Disk size'),
editor: 'PVE.openvz.RessourceEdit', editor: resEditor,
never_delete: true, never_delete: true,
renderer: function(value) { renderer: function(value) {
return PVE.Utils.format_size(value*1024*1024*1024); return PVE.Utils.format_size(value*1024*1024*1024);
......
...@@ -15,6 +15,8 @@ Ext.define('PVE.qemu.Config', { ...@@ -15,6 +15,8 @@ Ext.define('PVE.qemu.Config', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
me.statusStore = Ext.create('PVE.data.ObjectStore', { me.statusStore = Ext.create('PVE.data.ObjectStore', {
url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status/current", url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status/current",
interval: 1000 interval: 1000
...@@ -34,6 +36,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -34,6 +36,7 @@ Ext.define('PVE.qemu.Config', {
var startBtn = Ext.create('Ext.Button', { var startBtn = Ext.create('Ext.Button', {
text: gettext('Start'), text: gettext('Start'),
disabled: !caps.vms['VM.PowerMgmt'],
handler: function() { handler: function() {
vm_command('start'); vm_command('start');
} }
...@@ -41,6 +44,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -41,6 +44,7 @@ Ext.define('PVE.qemu.Config', {
var stopBtn = Ext.create('PVE.button.Button', { var stopBtn = Ext.create('PVE.button.Button', {
text: gettext('Stop'), text: gettext('Stop'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid), confirmMsg: Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid),
handler: function() { handler: function() {
vm_command("stop", { timeout: 30 }); vm_command("stop", { timeout: 30 });
...@@ -49,6 +53,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -49,6 +53,7 @@ Ext.define('PVE.qemu.Config', {
var migrateBtn = Ext.create('Ext.Button', { var migrateBtn = Ext.create('Ext.Button', {
text: gettext('Migrate'), text: gettext('Migrate'),
disabled: !caps.vms['VM.Migrate'],
handler: function() { handler: function() {
var win = Ext.create('PVE.window.Migrate', { var win = Ext.create('PVE.window.Migrate', {
vmtype: 'qemu', vmtype: 'qemu',
...@@ -61,6 +66,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -61,6 +66,7 @@ Ext.define('PVE.qemu.Config', {
var resetBtn = Ext.create('PVE.button.Button', { var resetBtn = Ext.create('PVE.button.Button', {
text: gettext('Reset'), text: gettext('Reset'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to reset VM {0}?"), vmid), confirmMsg: Ext.String.format(gettext("Do you really want to reset VM {0}?"), vmid),
handler: function() { handler: function() {
vm_command("reset"); vm_command("reset");
...@@ -69,6 +75,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -69,6 +75,7 @@ Ext.define('PVE.qemu.Config', {
var shutdownBtn = Ext.create('PVE.button.Button', { var shutdownBtn = Ext.create('PVE.button.Button', {
text: gettext('Shutdown'), text: gettext('Shutdown'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid), confirmMsg: Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid),
handler: function() { handler: function() {
vm_command('shutdown', { timeout: 30 }); vm_command('shutdown', { timeout: 30 });
...@@ -77,6 +84,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -77,6 +84,7 @@ Ext.define('PVE.qemu.Config', {
var removeBtn = Ext.create('PVE.button.Button', { var removeBtn = Ext.create('PVE.button.Button', {
text: gettext('Remove'), text: gettext('Remove'),
disabled: !caps.vms['VM.Allocate'],
confirmMsg: Ext.String.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid), confirmMsg: Ext.String.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid),
handler: function() { handler: function() {
PVE.Utils.API2Request({ PVE.Utils.API2Request({
...@@ -94,6 +102,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -94,6 +102,7 @@ Ext.define('PVE.qemu.Config', {
var consoleBtn = Ext.create('Ext.Button', { var consoleBtn = Ext.create('Ext.Button', {
text: gettext('Console'), text: gettext('Console'),
disabled: !caps.vms['VM.Console'],
handler: function() { handler: function() {
PVE.Utils.openConoleWindow('kvm', vmid, nodename, vmname); PVE.Utils.openConoleWindow('kvm', vmid, nodename, vmname);
} }
...@@ -122,25 +131,34 @@ Ext.define('PVE.qemu.Config', { ...@@ -122,25 +131,34 @@ Ext.define('PVE.qemu.Config', {
title: gettext('Options'), title: gettext('Options'),
itemId: 'options', itemId: 'options',
xtype: 'PVE.qemu.Options' xtype: 'PVE.qemu.Options'
}, }
{ ]
});
if (caps.vms['VM.Monitor']) {
me.items.push({
title: gettext('Monitor'), title: gettext('Monitor'),
itemId: 'monitor', itemId: 'monitor',
xtype: 'pveQemuMonitor' xtype: 'pveQemuMonitor'
}, });
{ }
if (caps.vms['VM.Backup']) {
me.items.push({
title: gettext('Backup'), title: gettext('Backup'),
xtype: 'pveBackupView', xtype: 'pveBackupView',
itemId: 'backup' itemId: 'backup'
}, });
{ }
if (caps.vms['Permissions.Modify']) {
me.items.push({
xtype: 'pveACLView', xtype: 'pveACLView',
title: gettext('Permissions'), title: gettext('Permissions'),
itemId: 'permissions', itemId: 'permissions',
path: '/vms/' + vmid path: '/vms/' + vmid
}
]
}); });
}
me.callParent(); me.callParent();
...@@ -154,11 +172,11 @@ Ext.define('PVE.qemu.Config', { ...@@ -154,11 +172,11 @@ Ext.define('PVE.qemu.Config', {
status = rec ? rec.data.value : 'unknown'; status = rec ? rec.data.value : 'unknown';
} }
startBtn.setDisabled(status === 'running'); startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running');
resetBtn.setDisabled(status !== 'running'); resetBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
shutdownBtn.setDisabled(status !== 'running'); shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
stopBtn.setDisabled(status === 'stopped'); stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');
removeBtn.setDisabled(status !== 'stopped'); removeBtn.setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
}); });
me.on('afterrender', function() { me.on('afterrender', function() {
......
...@@ -35,11 +35,14 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -35,11 +35,14 @@ Ext.define('PVE.qemu.HardwareView', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
var rows = { var rows = {
memory: { memory: {
header: gettext('Memory'), header: gettext('Memory'),
editor: 'PVE.qemu.MemoryEdit', editor: caps.vms['VM.Config.Memory'] ? 'PVE.qemu.MemoryEdit' : undefined,
never_delete: true, never_delete: true,
defaultValue: 512,
tdCls: 'pve-itype-icon-memory', tdCls: 'pve-itype-icon-memory',
renderer: function(value) { renderer: function(value) {
return PVE.Utils.format_size(value*1024*1024); return PVE.Utils.format_size(value*1024*1024);
...@@ -48,7 +51,8 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -48,7 +51,8 @@ Ext.define('PVE.qemu.HardwareView', {
sockets: { sockets: {
header: gettext('Processors'), header: gettext('Processors'),
never_delete: true, never_delete: true,
editor: 'PVE.qemu.ProcessorEdit', editor: (caps.vms['VM.Config.CPU'] || caps.vms['VM.Config.HWType']) ?
'PVE.qemu.ProcessorEdit' : undefined,
tdCls: 'pve-itype-icon-processor', tdCls: 'pve-itype-icon-processor',
defaultValue: 1, defaultValue: 1,
renderer: function(value, metaData, record, rowIndex, colIndex, store) { renderer: function(value, metaData, record, rowIndex, colIndex, store) {
...@@ -69,14 +73,14 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -69,14 +73,14 @@ Ext.define('PVE.qemu.HardwareView', {
keyboard: { keyboard: {
header: gettext('Keyboard Layout'), header: gettext('Keyboard Layout'),
never_delete: true, never_delete: true,
editor: 'PVE.qemu.KeyboardEdit', editor: caps.vms['VM.Config.Options'] ? 'PVE.qemu.KeyboardEdit' : undefined,
tdCls: 'pve-itype-icon-keyboard', tdCls: 'pve-itype-icon-keyboard',
defaultValue: '', defaultValue: '',
renderer: PVE.Utils.render_kvm_language renderer: PVE.Utils.render_kvm_language
}, },
vga: { vga: {
header: gettext('Display'), header: gettext('Display'),
editor: 'PVE.qemu.DisplayEdit', editor: caps.vms['VM.Config.HWType'] ? 'PVE.qemu.DisplayEdit' : undefined,
never_delete: true, never_delete: true,
tdCls: 'pve-itype-icon-display', tdCls: 'pve-itype-icon-display',
defaultValue: '', defaultValue: '',
...@@ -96,6 +100,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -96,6 +100,7 @@ Ext.define('PVE.qemu.HardwareView', {
group: 1, group: 1,
tdCls: 'pve-itype-icon-storage', tdCls: 'pve-itype-icon-storage',
editor: 'PVE.qemu.HDEdit', editor: 'PVE.qemu.HDEdit',
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
header: gettext('Hard Disk') + ' (' + confid +')', header: gettext('Hard Disk') + ' (' + confid +')',
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')' cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
}; };
...@@ -106,6 +111,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -106,6 +111,7 @@ Ext.define('PVE.qemu.HardwareView', {
group: 1, group: 1,
tdCls: 'pve-itype-icon-storage', tdCls: 'pve-itype-icon-storage',
editor: 'PVE.qemu.HDEdit', editor: 'PVE.qemu.HDEdit',
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
header: gettext('Hard Disk') + ' (' + confid +')', header: gettext('Hard Disk') + ' (' + confid +')',
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')' cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
}; };
...@@ -116,6 +122,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -116,6 +122,7 @@ Ext.define('PVE.qemu.HardwareView', {
group: 1, group: 1,
tdCls: 'pve-itype-icon-storage', tdCls: 'pve-itype-icon-storage',
editor: 'PVE.qemu.HDEdit', editor: 'PVE.qemu.HDEdit',
never_delete: caps.vms['VM.Config.Disk'] ? false : true,
header: gettext('Hard Disk') + ' (' + confid +')', header: gettext('Hard Disk') + ' (' + confid +')',
cdheader: gettext('CD/DVD Drive') + ' (' + confid +')' cdheader: gettext('CD/DVD Drive') + ' (' + confid +')'
}; };
...@@ -125,7 +132,8 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -125,7 +132,8 @@ Ext.define('PVE.qemu.HardwareView', {
rows[confid] = { rows[confid] = {
group: 2, group: 2,
tdCls: 'pve-itype-icon-network', tdCls: 'pve-itype-icon-network',
editor: 'PVE.qemu.NetworkEdit', editor: caps.vms['VM.Config.Network'] ? 'PVE.qemu.NetworkEdit' : undefined,
never_delete: caps.vms['VM.Config.Network'] ? false : true,
header: gettext('Network Device') + ' (' + confid +')' header: gettext('Network Device') + ' (' + confid +')'
}; };
} }
...@@ -133,7 +141,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -133,7 +141,7 @@ Ext.define('PVE.qemu.HardwareView', {
rows["unused" + i] = { rows["unused" + i] = {
group: 3, group: 3,
tdCls: 'pve-itype-icon-storage', tdCls: 'pve-itype-icon-storage',
editor: 'PVE.qemu.HDEdit', editor: caps.vms['VM.Config.Disk'] ? 'PVE.qemu.HDEdit' : undefined,
header: gettext('Unused Disk') + ' ' + i header: gettext('Unused Disk') + ' ' + i
}; };
} }
...@@ -249,6 +257,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -249,6 +257,7 @@ Ext.define('PVE.qemu.HardwareView', {
{ {
text: gettext('Hard Disk'), text: gettext('Hard Disk'),
iconCls: 'pve-itype-icon-storage', iconCls: 'pve-itype-icon-storage',
disabled: !caps.vms['VM.Config.Disk'],
handler: function() { handler: function() {
var win = Ext.create('PVE.qemu.HDEdit', { var win = Ext.create('PVE.qemu.HDEdit', {
url: '/api2/extjs/' + baseurl, url: '/api2/extjs/' + baseurl,
...@@ -261,6 +270,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -261,6 +270,7 @@ Ext.define('PVE.qemu.HardwareView', {
{ {
text: gettext('CD/DVD Drive'), text: gettext('CD/DVD Drive'),
iconCls: 'pve-itype-icon-cdrom', iconCls: 'pve-itype-icon-cdrom',
disabled: !caps.vms['VM.Config.Disk'],
handler: function() { handler: function() {
var win = Ext.create('PVE.qemu.CDEdit', { var win = Ext.create('PVE.qemu.CDEdit', {
url: '/api2/extjs/' + baseurl, url: '/api2/extjs/' + baseurl,
...@@ -273,6 +283,7 @@ Ext.define('PVE.qemu.HardwareView', { ...@@ -273,6 +283,7 @@ Ext.define('PVE.qemu.HardwareView', {
{ {
text: gettext('Network Device'), text: gettext('Network Device'),
iconCls: 'pve-itype-icon-network', iconCls: 'pve-itype-icon-network',
disabled: !caps.vms['VM.Config.Network'],
handler: function() { handler: function() {
var win = Ext.create('PVE.qemu.NetworkEdit', { var win = Ext.create('PVE.qemu.NetworkEdit', {
url: '/api2/extjs/' + baseurl, url: '/api2/extjs/' + baseurl,
......
...@@ -17,12 +17,14 @@ Ext.define('PVE.qemu.Options', { ...@@ -17,12 +17,14 @@ Ext.define('PVE.qemu.Options', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var caps = Ext.state.Manager.get('GuiCap');
var rows = { var rows = {
name: { name: {
required: true, required: true,
defaultValue: me.pveSelNode.data.name, defaultValue: me.pveSelNode.data.name,
header: gettext('Name'), header: gettext('Name'),
editor: { editor: caps.vms['VM.Config.Options'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: gettext('Name'), subject: gettext('Name'),
items: { items: {
...@@ -33,13 +35,13 @@ Ext.define('PVE.qemu.Options', { ...@@ -33,13 +35,13 @@ Ext.define('PVE.qemu.Options', {
fieldLabel: gettext('Name'), fieldLabel: gettext('Name'),
allowBlank: true allowBlank: true
} }
} } : undefined
}, },
onboot: { onboot: {
header: gettext('Start at boot'), header: gettext('Start at boot'),
defaultValue: '', defaultValue: '',
renderer: PVE.Utils.format_boolean, renderer: PVE.Utils.format_boolean,
editor: { editor: caps.vms['VM.Config.Options'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: gettext('Start at boot'), subject: gettext('Start at boot'),
items: { items: {
...@@ -50,11 +52,11 @@ Ext.define('PVE.qemu.Options', { ...@@ -50,11 +52,11 @@ Ext.define('PVE.qemu.Options', {
deleteDefaultValue: true, deleteDefaultValue: true,
fieldLabel: gettext('Start at boot') fieldLabel: gettext('Start at boot')
} }
} } : undefined
}, },
ostype: { ostype: {
header: 'OS Type', header: 'OS Type',
editor: 'PVE.qemu.OSTypeEdit', editor: caps.vms['VM.Config.Options'] ? 'PVE.qemu.OSTypeEdit' : undefined,
renderer: PVE.Utils.render_kvm_ostype, renderer: PVE.Utils.render_kvm_ostype,
defaultValue: 'other' defaultValue: 'other'
}, },
...@@ -64,7 +66,7 @@ Ext.define('PVE.qemu.Options', { ...@@ -64,7 +66,7 @@ Ext.define('PVE.qemu.Options', {
boot: { boot: {
header: gettext('Boot order'), header: gettext('Boot order'),
defaultValue: 'cdn', defaultValue: 'cdn',
editor: 'PVE.qemu.BootOrderEdit', editor: caps.vms['VM.Config.Disk'] ? 'PVE.qemu.BootOrderEdit' : undefined,
renderer: function(order) { renderer: function(order) {
var i; var i;
var text = ''; var text = '';
...@@ -98,7 +100,7 @@ Ext.define('PVE.qemu.Options', { ...@@ -98,7 +100,7 @@ Ext.define('PVE.qemu.Options', {
header: 'ACPI support', header: 'ACPI support',
defaultValue: true, defaultValue: true,
renderer: PVE.Utils.format_boolean, renderer: PVE.Utils.format_boolean,
editor: { editor: caps.vms['VM.Config.HWType'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'ACPI support', subject: 'ACPI support',
items: { items: {
...@@ -110,13 +112,13 @@ Ext.define('PVE.qemu.Options', { ...@@ -110,13 +112,13 @@ Ext.define('PVE.qemu.Options', {
deleteDefaultValue: true, deleteDefaultValue: true,
fieldLabel: gettext('Enabled') fieldLabel: gettext('Enabled')
} }
} } : undefined
}, },
kvm: { kvm: {
header: 'KVM hardware virtualization', header: 'KVM hardware virtualization',
defaultValue: true, defaultValue: true,
renderer: PVE.Utils.format_boolean, renderer: PVE.Utils.format_boolean,
editor: { editor: caps.vms['VM.Config.HWType'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'KVM hardware virtualization', subject: 'KVM hardware virtualization',
items: { items: {
...@@ -128,13 +130,13 @@ Ext.define('PVE.qemu.Options', { ...@@ -128,13 +130,13 @@ Ext.define('PVE.qemu.Options', {
deleteDefaultValue: true, deleteDefaultValue: true,
fieldLabel: gettext('Enabled') fieldLabel: gettext('Enabled')
} }
} } : undefined
}, },
freeze: { freeze: {
header: 'Freeze CPU at startup', header: 'Freeze CPU at startup',
defaultValue: false, defaultValue: false,
renderer: PVE.Utils.format_boolean, renderer: PVE.Utils.format_boolean,
editor: { editor: caps.vms['VM.PowerMgmt'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'Freeze CPU at startup', subject: 'Freeze CPU at startup',
items: { items: {
...@@ -146,13 +148,13 @@ Ext.define('PVE.qemu.Options', { ...@@ -146,13 +148,13 @@ Ext.define('PVE.qemu.Options', {
labelWidth: 140, labelWidth: 140,
fieldLabel: 'Freeze CPU at startup' fieldLabel: 'Freeze CPU at startup'
} }
} } : undefined
}, },
localtime: { localtime: {
header: 'Use local time for RTC', header: 'Use local time for RTC',
defaultValue: false, defaultValue: false,
renderer: PVE.Utils.format_boolean, renderer: PVE.Utils.format_boolean,
editor: { editor: caps.vms['VM.Config.Options'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'Use local time for RTC', subject: 'Use local time for RTC',
items: { items: {
...@@ -164,13 +166,12 @@ Ext.define('PVE.qemu.Options', { ...@@ -164,13 +166,12 @@ Ext.define('PVE.qemu.Options', {
labelWidth: 140, labelWidth: 140,
fieldLabel: 'Use local time for RTC' fieldLabel: 'Use local time for RTC'
} }
} } : undefined
}, },
startdate: { startdate: {
header: 'RTC start date', header: 'RTC start date',
defaultValue: 'now', defaultValue: 'now',
editor: { editor: caps.vms['VM.Config.Options'] ? {
xtype: 'pveWindowEdit', xtype: 'pveWindowEdit',
subject: 'RTC start date', subject: 'RTC start date',
items: { items: {
...@@ -182,7 +183,7 @@ Ext.define('PVE.qemu.Options', { ...@@ -182,7 +183,7 @@ Ext.define('PVE.qemu.Options', {
vtype: 'QemuStartDate', vtype: 'QemuStartDate',
allowBlank: true allowBlank: true
} }
} } : undefined
} }
}; };
......
...@@ -15,29 +15,38 @@ Ext.define('PVE.storage.Browser', { ...@@ -15,29 +15,38 @@ Ext.define('PVE.storage.Browser', {
throw "no storage ID specified"; throw "no storage ID specified";
} }
Ext.apply(me, { var caps = Ext.state.Manager.get('GuiCap');
title: Ext.String.format(gettext("Storage {0} on node {1}"),
"'" + storeid + "'", "'" + nodename + "'"), me.items = [
hstateid: 'storagetab',
items: [
{ {
title: gettext('Summary'), title: gettext('Summary'),
xtype: 'pveStorageSummary', xtype: 'pveStorageSummary',
itemId: 'summary' itemId: 'summary'
}, }
{ ];
Ext.apply(me, {
title: Ext.String.format(gettext("Storage {0} on node {1}"),
"'" + storeid + "'", "'" + nodename + "'"),
hstateid: 'storagetab'
});
if (caps.storage['Datastore.Allocate']) {
me.items.push({
xtype: 'pveStorageContentView', xtype: 'pveStorageContentView',
title: gettext('Content'), title: gettext('Content'),
itemId: 'content' itemId: 'content'
}, });
{ }
if (caps.storage['Permissions.Modify']) {
me.items.push({
xtype: 'pveACLView', xtype: 'pveACLView',
title: gettext('Permissions'), title: gettext('Permissions'),
itemId: 'permissions', itemId: 'permissions',
path: '/storage/' + storeid path: '/storage/' + storeid
}
]
}); });
}
me.callParent(); me.callParent();
} }
......
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