]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/storage/RBDEdit.js
ui: fixup jslint warnings
[pve-manager.git] / www / manager6 / storage / RBDEdit.js
CommitLineData
0d1ac958 1/*jslint confusion: true*/
b42d008b
TL
2Ext.define('PVE.storage.Ceph.Model', {
3 extend: 'Ext.app.ViewModel',
4 alias: 'viewmodel.cephstorage',
c0dee88e 5
b42d008b
TL
6 data: {
7 pveceph: true,
8 pvecephPossible: true
9 }
10});
0d1ac958 11
b42d008b
TL
12Ext.define('PVE.storage.Ceph.Controller', {
13 extend: 'Ext.app.ViewController',
14 alias: 'controller.cephstorage',
15
16 control: {
17 '#': {
18 afterrender: 'queryMonitors'
0d1ac958 19 },
b42d008b
TL
20 'textfield[name=username]': {
21 disable: 'resetField'
0d1ac958 22 },
b42d008b
TL
23 'displayfield[name=monhost]': {
24 enable: 'queryMonitors'
25 },
26 'textfield[name=monhost]': {
27 disable: 'resetField',
28 enable: 'resetField'
29 }
30 },
31 resetField: function(field) {
32 field.reset();
33 },
34 queryMonitors: function(field, newVal, oldVal) {
35 // we get called with two signatures, the above one for a field
36 // change event and the afterrender from the view, this check only
37 // can be true for the field change one and omit the API request if
38 // pveceph got unchecked - as it's not needed there.
39 if (field && !newVal && oldVal) {
40 return;
41 }
42 var view = this.getView();
43 var vm = this.getViewModel();
44 if (!(view.isCreate || vm.get('pveceph'))) {
45 return; // only query on create or if editing a pveceph store
46 }
0d1ac958 47
b42d008b 48 var monhostField = this.lookupReference('monhost');
0d1ac958 49
b42d008b
TL
50 Proxmox.Utils.API2Request({
51 url: '/api2/json/nodes/localhost/ceph/mon',
52 method: 'GET',
53 scope: this,
54 callback: function(options, success, response) {
55 var data = response.result.data;
56 if (response.status === 200) {
57 if (data.length > 0) {
58 var monhost = Ext.Array.pluck(data, 'name').sort().join(',');
59 monhostField.setValue(monhost);
60 monhostField.resetOriginalValue();
61 if (view.isCreate) {
62 vm.set('pvecephPossible', true);
0d1ac958
TL
63 }
64 } else {
65 vm.set('pveceph', false);
0d1ac958 66 }
b42d008b
TL
67 } else {
68 vm.set('pveceph', false);
69 vm.set('pvecephPossible', false);
0d1ac958 70 }
b42d008b
TL
71 }
72 });
73 }
74});
75
76Ext.define('PVE.storage.RBDInputPanel', {
77 extend: 'PVE.panel.StorageBase',
78 controller: 'cephstorage',
79
80 viewModel: {
81 type: 'cephstorage'
0d1ac958
TL
82 },
83
84 setValues: function(values) {
85 if (values.monhost) {
86 this.viewModel.set('pveceph', false);
87 this.lookupReference('pvecephRef').setValue(false);
88 this.lookupReference('pvecephRef').resetOriginalValue();
89 }
90 this.callParent([values]);
91 },
92
c0dee88e
DM
93 initComponent : function() {
94 var me = this;
95
3c23c025
DC
96 if (!me.nodename) {
97 me.nodename = 'localhost';
98 }
f28ec3e4 99 me.type = 'rbd';
c0dee88e 100
0d1ac958
TL
101 me.column1 = [
102 {
103 xtype: me.isCreate ? 'pveCephPoolSelector' : 'displayfield',
104 nodename: me.nodename,
105 name: 'pool',
8c93faf9
TL
106 bind: {
107 disabled: '{!pveceph}',
108 submitValue: '{pveceph}',
109 hidden: '{!pveceph}'
110 },
0d1ac958
TL
111 fieldLabel: gettext('Pool'),
112 allowBlank: false
113 },
114 {
115 xtype: me.isCreate ? 'textfield' : 'displayfield',
116 name: 'pool',
117 value: 'rbd',
8c93faf9
TL
118 bind: {
119 disabled: '{pveceph}',
120 submitValue: '{!pveceph}',
121 hidden: '{pveceph}'
122 },
0d1ac958
TL
123 fieldLabel: gettext('Pool'),
124 allowBlank: false
125 },
126 {
127 xtype: 'textfield',
128 name: 'monhost',
129 vtype: 'HostList',
8c93faf9
TL
130 bind: {
131 disabled: '{pveceph}',
132 submitValue: '{!pveceph}',
133 hidden: '{pveceph}'
134 },
0d1ac958
TL
135 value: '',
136 fieldLabel: 'Monitor(s)',
137 allowBlank: false
138 },
139 {
140 xtype: 'displayfield',
141 reference: 'monhost',
142 bind: {
143 disabled: '{!pveceph}',
144 hidden: '{!pveceph}'
3c23c025 145 },
0d1ac958
TL
146 value: '',
147 fieldLabel: 'Monitor(s)'
148 },
149 {
150 xtype: me.isCreate ? 'textfield' : 'displayfield',
151 name: 'username',
8c93faf9
TL
152 bind: {
153 disabled: '{pveceph}',
154 submitValue: '{!pveceph}'
155 },
0d1ac958
TL
156 value: 'admin',
157 fieldLabel: gettext('User name'),
158 allowBlank: true
159 }
160 ];
3c23c025 161
c0dee88e 162 me.column2 = [
c0dee88e
DM
163 {
164 xtype: 'pveContentTypeSelector',
165 cts: ['images', 'rootdir'],
166 fieldLabel: gettext('Content'),
167 name: 'content',
168 value: ['images'],
169 multiSelect: true,
170 allowBlank: false
171 },
172 {
896c0d50 173 xtype: 'proxmoxcheckbox',
c0dee88e
DM
174 name: 'krbd',
175 uncheckedValue: 0,
ed9896e2 176 fieldLabel: 'KRBD'
c0dee88e
DM
177 }
178 ];
0d1ac958
TL
179
180 me.columnB = [{
181 xtype: 'proxmoxcheckbox',
182 name: 'pveceph',
183 reference: 'pvecephRef',
184 bind : {
185 disabled: '{!pvecephPossible}',
186 value: '{pveceph}'
187 },
188 checked: true,
189 uncheckedValue: 0,
190 submitValue: false,
191 hidden: !me.isCreate,
192 boxLabel: gettext('Use Proxmox VE managed hyper-converged ceph pool')
193 }];
c0dee88e 194
c0dee88e
DM
195 me.callParent();
196 }
197});