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