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