]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/storage/RBDEdit.js
22efef1002fefca1501010a65e3f338d3f981ef2
1 /*jslint confusion: true*/
2 Ext
.define('PVE.storage.Ceph.Model', {
3 extend
: 'Ext.app.ViewModel',
4 alias
: 'viewmodel.cephstorage',
12 Ext
.define('PVE.storage.Ceph.Controller', {
13 extend
: 'Ext.app.ViewController',
14 alias
: 'controller.cephstorage',
18 afterrender
: 'queryMonitors'
20 'textfield[name=username]': {
23 'displayfield[name=monhost]': {
24 enable
: 'queryMonitors'
26 'textfield[name=monhost]': {
27 disable
: 'resetField',
31 resetField: function(field
) {
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
) {
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
48 var monhostField
= this.lookupReference('monhost');
50 Proxmox
.Utils
.API2Request({
51 url
: '/api2/json/nodes/localhost/ceph/mon',
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();
62 vm
.set('pvecephPossible', true);
65 vm
.set('pveceph', false);
68 vm
.set('pveceph', false);
69 vm
.set('pvecephPossible', false);
76 Ext
.define('PVE.storage.RBDInputPanel', {
77 extend
: 'PVE.panel.StorageBase',
78 controller
: 'cephstorage',
84 setValues: function(values
) {
86 this.viewModel
.set('pveceph', false);
87 this.lookupReference('pvecephRef').setValue(false);
88 this.lookupReference('pvecephRef').resetOriginalValue();
90 this.callParent([values
]);
93 initComponent : function() {
97 me
.nodename
= 'localhost';
101 var getBinds = function (activeIfPVECeph
, hide
) {
103 disabled
: activeIfPVECeph
? '{!pveceph}' : '{pveceph}'
106 // displayfield has no submitValue and bind mixin cannot handle that
108 bind
.submitValue
= activeIfPVECeph
? '{pveceph}' : '{!pveceph}';
111 bind
.hidden
= activeIfPVECeph
? '{!pveceph}' : '{pveceph}';
119 xtype
: me
.isCreate
? 'pveCephPoolSelector' : 'displayfield',
120 nodename
: me
.nodename
,
122 bind
: getBinds(true, true),
123 fieldLabel
: gettext('Pool'),
127 xtype
: me
.isCreate
? 'textfield' : 'displayfield',
130 bind
: getBinds(false, true),
131 fieldLabel
: gettext('Pool'),
138 bind
: getBinds(false, true),
140 fieldLabel
: 'Monitor(s)',
144 xtype
: 'displayfield',
145 reference
: 'monhost',
147 disabled
: '{!pveceph}',
151 fieldLabel
: 'Monitor(s)'
154 xtype
: me
.isCreate
? 'textfield' : 'displayfield',
156 bind
: me
.isCreate
? getBinds(false) : {},
158 fieldLabel
: gettext('User name'),
165 xtype
: 'pveContentTypeSelector',
166 cts
: ['images', 'rootdir'],
167 fieldLabel
: gettext('Content'),
174 xtype
: 'proxmoxcheckbox',
182 xtype
: 'proxmoxcheckbox',
184 reference
: 'pvecephRef',
186 disabled
: '{!pvecephPossible}',
192 hidden
: !me
.isCreate
,
193 boxLabel
: gettext('Use Proxmox VE managed hyper-converged ceph pool')