]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/FeaturesEdit.js
ui: lxc/network: fix initial empty text on edit
[pve-manager.git] / www / manager6 / lxc / FeaturesEdit.js
1 /*jslint confusion: true*/
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
11 viewModel: {
12 parent: null,
13 data: {
14 unprivileged: false
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
26 items: [
27 {
28 xtype: 'proxmoxcheckbox',
29 fieldLabel: gettext('keyctl'),
30 name: 'keyctl',
31 bind: {
32 disabled: '{!unprivileged}',
33 boxLabel: '{unprivilegedOnly}'
34 }
35 },
36 {
37 xtype: 'proxmoxcheckbox',
38 fieldLabel: gettext('Nesting'),
39 name: 'nesting'
40 },
41 {
42 xtype: 'proxmoxcheckbox',
43 name: 'nfs',
44 fieldLabel: 'NFS',
45 bind: {
46 disabled: '{unprivileged}',
47 boxLabel: '{privilegedOnly}'
48 }
49 },
50 {
51 xtype: 'proxmoxcheckbox',
52 name: 'cifs',
53 fieldLabel: 'CIFS',
54 bind: {
55 disabled: '{unprivileged}',
56 boxLabel: '{privilegedOnly}'
57 }
58 },
59 {
60 xtype: 'proxmoxcheckbox',
61 name: 'fuse',
62 fieldLabel: 'FUSE'
63 },
64 {
65 xtype: 'proxmoxcheckbox',
66 name: 'mknod',
67 fieldLabel: gettext('Create Device Nodes'),
68 boxLabel: gettext('Experimental'),
69 },
70 ],
71
72 onGetValues: function(values) {
73 var me = this;
74 var mounts = me.mounts;
75 me.fstypes.forEach(function(fs) {
76 if (values[fs]) {
77 mounts.push(fs);
78 }
79 delete values[fs];
80 });
81
82 if (mounts.length) {
83 values.mount = mounts.join(';');
84 }
85
86 var featuresstring = PVE.Parser.printPropertyString(values, undefined);
87 if (featuresstring == '') {
88 return { 'delete': 'features' };
89 }
90 return { features: featuresstring };
91 },
92
93 setValues: function(values) {
94 var me = this;
95
96 me.viewModel.set('unprivileged', values.unprivileged);
97
98 if (values.features) {
99 var res = PVE.Parser.parsePropertyString(values.features);
100 me.mounts = [];
101 if (res.mount) {
102 res.mount.split(/[; ]/).forEach(function(item) {
103 if (me.fstypes.indexOf(item) === -1) {
104 me.mounts.push(item);
105 } else {
106 res[item] = 1;
107 }
108 });
109 }
110 this.callParent([res]);
111 }
112 }
113 });
114
115 Ext.define('PVE.lxc.FeaturesEdit', {
116 extend: 'Proxmox.window.Edit',
117 xtype: 'pveLxcFeaturesEdit',
118
119 subject: gettext('Features'),
120 autoLoad: true,
121 width: 350,
122
123 items: [{
124 xtype: 'pveLxcFeaturesInputPanel'
125 }],
126 });