]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/storage/RBDEdit.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / storage / RBDEdit.js
CommitLineData
b42d008b
TL
1Ext.define('PVE.storage.Ceph.Model', {
2 extend: 'Ext.app.ViewModel',
3 alias: 'viewmodel.cephstorage',
c0dee88e 4
b42d008b
TL
5 data: {
6 pveceph: true,
f6710aac
TL
7 pvecephPossible: true,
8 },
b42d008b 9});
0d1ac958 10
b42d008b 11Ext.define('PVE.storage.Ceph.Controller', {
39f2b04f 12 extend: 'PVE.controller.StorageEdit',
b42d008b
TL
13 alias: 'controller.cephstorage',
14
15 control: {
16 '#': {
f6710aac 17 afterrender: 'queryMonitors',
0d1ac958 18 },
b42d008b 19 'textfield[name=username]': {
f6710aac 20 disable: 'resetField',
0d1ac958 21 },
b42d008b 22 'displayfield[name=monhost]': {
f6710aac 23 enable: 'queryMonitors',
b42d008b
TL
24 },
25 'textfield[name=monhost]': {
26 disable: 'resetField',
f6710aac
TL
27 enable: 'resetField',
28 },
b42d008b
TL
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 }
0d1ac958 46
b42d008b 47 var monhostField = this.lookupReference('monhost');
0d1ac958 48
b42d008b
TL
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);
0d1ac958
TL
62 }
63 } else {
64 vm.set('pveceph', false);
0d1ac958 65 }
b42d008b
TL
66 } else {
67 vm.set('pveceph', false);
68 vm.set('pvecephPossible', false);
0d1ac958 69 }
f6710aac 70 },
b42d008b 71 });
f6710aac 72 },
b42d008b
TL
73});
74
75Ext.define('PVE.storage.RBDInputPanel', {
76 extend: 'PVE.panel.StorageBase',
77 controller: 'cephstorage',
78
96988dfa
DC
79 onlineHelp: 'ceph_rados_block_devices',
80
b42d008b 81 viewModel: {
f6710aac 82 type: 'cephstorage',
0d1ac958
TL
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
8058410f 94 initComponent: function() {
c0dee88e
DM
95 var me = this;
96
3c23c025
DC
97 if (!me.nodename) {
98 me.nodename = 'localhost';
99 }
f28ec3e4 100 me.type = 'rbd';
c0dee88e 101
4e7585f5
DC
102 me.column1 = [];
103
104 if (me.isCreate) {
105 me.column1.push({
106 xtype: 'pveCephPoolSelector',
0d1ac958
TL
107 nodename: me.nodename,
108 name: 'pool',
8c93faf9
TL
109 bind: {
110 disabled: '{!pveceph}',
111 submitValue: '{pveceph}',
f6710aac 112 hidden: '{!pveceph}',
8c93faf9 113 },
0d1ac958 114 fieldLabel: gettext('Pool'),
f6710aac
TL
115 allowBlank: false,
116 }, {
4e7585f5 117 xtype: 'textfield',
0d1ac958
TL
118 name: 'pool',
119 value: 'rbd',
8c93faf9
TL
120 bind: {
121 disabled: '{pveceph}',
122 submitValue: '{!pveceph}',
f6710aac 123 hidden: '{pveceph}',
8c93faf9 124 },
0d1ac958 125 fieldLabel: gettext('Pool'),
f6710aac 126 allowBlank: false,
4e7585f5
DC
127 });
128 } else {
129 me.column1.push({
130 xtype: 'displayfield',
131 nodename: me.nodename,
132 name: 'pool',
133 fieldLabel: gettext('Pool'),
f6710aac 134 allowBlank: false,
4e7585f5
DC
135 });
136 }
137
138 me.column1.push(
0d1ac958
TL
139 {
140 xtype: 'textfield',
141 name: 'monhost',
142 vtype: 'HostList',
8c93faf9
TL
143 bind: {
144 disabled: '{pveceph}',
145 submitValue: '{!pveceph}',
f6710aac 146 hidden: '{pveceph}',
8c93faf9 147 },
0d1ac958
TL
148 value: '',
149 fieldLabel: 'Monitor(s)',
f6710aac 150 allowBlank: false,
0d1ac958
TL
151 },
152 {
153 xtype: 'displayfield',
154 reference: 'monhost',
155 bind: {
156 disabled: '{!pveceph}',
f6710aac 157 hidden: '{!pveceph}',
3c23c025 158 },
0d1ac958 159 value: '',
f6710aac 160 fieldLabel: 'Monitor(s)',
0d1ac958
TL
161 },
162 {
163 xtype: me.isCreate ? 'textfield' : 'displayfield',
164 name: 'username',
8c93faf9
TL
165 bind: {
166 disabled: '{pveceph}',
f6710aac 167 submitValue: '{!pveceph}',
8c93faf9 168 },
0d1ac958
TL
169 value: 'admin',
170 fieldLabel: gettext('User name'),
f6710aac
TL
171 allowBlank: true,
172 },
4e7585f5 173 );
3c23c025 174
c0dee88e 175 me.column2 = [
c0dee88e
DM
176 {
177 xtype: 'pveContentTypeSelector',
178 cts: ['images', 'rootdir'],
179 fieldLabel: gettext('Content'),
180 name: 'content',
181 value: ['images'],
182 multiSelect: true,
f6710aac 183 allowBlank: false,
c0dee88e
DM
184 },
185 {
896c0d50 186 xtype: 'proxmoxcheckbox',
c0dee88e
DM
187 name: 'krbd',
188 uncheckedValue: 0,
f6710aac
TL
189 fieldLabel: 'KRBD',
190 },
c0dee88e 191 ];
0d1ac958
TL
192
193 me.columnB = [{
194 xtype: 'proxmoxcheckbox',
195 name: 'pveceph',
196 reference: 'pvecephRef',
8058410f 197 bind: {
0d1ac958 198 disabled: '{!pvecephPossible}',
f6710aac 199 value: '{pveceph}',
0d1ac958
TL
200 },
201 checked: true,
202 uncheckedValue: 0,
203 submitValue: false,
204 hidden: !me.isCreate,
f6710aac 205 boxLabel: gettext('Use Proxmox VE managed hyper-converged ceph pool'),
0d1ac958 206 }];
c0dee88e 207
c0dee88e 208 me.callParent();
f6710aac 209 },
c0dee88e 210});