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