]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/FeaturesEdit.js
ui: lxc/features: disable nfs and cifs for unprivileged
[pve-manager.git] / www / manager6 / lxc / FeaturesEdit.js
1 Ext.define('PVE.lxc.FeaturesInputPanel', {
2 extend: 'Proxmox.panel.InputPanel',
3 xtype: 'pveLxcFeaturesInputPanel',
4
5 // used to save the mounts fstypes until sending
6 mounts: [],
7
8 fstypes: ['nfs', 'cifs'],
9
10 viewModel: {
11 parent: null,
12 data: {
13 unprivileged: false,
14 },
15 formulas: {
16 privilegedOnly: function(get) {
17 return (get('unprivileged') ? gettext('privileged only') : '');
18 },
19 unprivilegedOnly: function(get) {
20 return (!get('unprivileged') ? gettext('unprivileged only') : '');
21 }
22 }
23 },
24
25 items: [
26 {
27 xtype: 'proxmoxcheckbox',
28 fieldLabel: gettext('keyctl'),
29 name: 'keyctl',
30 bind: {
31 disabled: '{!unprivileged}',
32 boxLabel: '{unprivilegedOnly}',
33 }
34 },
35 {
36 xtype: 'proxmoxcheckbox',
37 fieldLabel: gettext('Nesting'),
38 name: 'nesting'
39 },
40 {
41 xtype: 'proxmoxcheckbox',
42 name: 'nfs',
43 fieldLabel: 'NFS',
44 bind: {
45 disabled: '{unprivileged}',
46 boxLabel: '{privilegedOnly}',
47 }
48 },
49 {
50 xtype: 'proxmoxcheckbox',
51 name: 'cifs',
52 fieldLabel: 'CIFS',
53 bind: {
54 disabled: '{unprivileged}',
55 boxLabel: '{privilegedOnly}',
56 }
57 }
58 ],
59
60 onGetValues: function(values) {
61 var me = this;
62 var mounts = me.mounts;
63 me.fstypes.forEach(function(fs) {
64 if (values[fs]) {
65 mounts.push(fs);
66 }
67 delete values[fs];
68 });
69
70 if (mounts.length) {
71 values.mount = mounts.join(';');
72 }
73
74 var featuresstring = PVE.Parser.printPropertyString(values, undefined);
75 if (featuresstring == '') {
76 return { 'delete': 'features' };
77 }
78 return { features: featuresstring };
79 },
80
81 setValues: function(values) {
82 var me = this;
83
84 me.viewModel.set({ unprivileged: values.unprivileged });
85
86 if (values.features) {
87 var res = PVE.Parser.parsePropertyString(values.features);
88 me.mounts = [];
89 if (res.mount) {
90 res.mount.split(/[; ]/).forEach(function(item) {
91 if (me.fstypes.indexOf(item) === -1) {
92 me.mounts.push(item);
93 } else {
94 res[item] = 1;
95 }
96 });
97 }
98 this.callParent([res]);
99 }
100 }
101 });
102
103 Ext.define('PVE.lxc.FeaturesEdit', {
104 extend: 'Proxmox.window.Edit',
105 xtype: 'pveLxcFeaturesEdit',
106
107 subject: gettext('Features'),
108
109 items: [{
110 xtype: 'pveLxcFeaturesInputPanel'
111 }],
112
113 initComponent : function() {
114 var me = this;
115
116 me.callParent();
117
118 me.load();
119 }
120 });