mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-14 07:03:23 +00:00

This fixes around 20 jslint type confusion warnings. Also reduce the scope and document jslint warnings along the way. No functional changes.
149 lines
3.0 KiB
JavaScript
149 lines
3.0 KiB
JavaScript
Ext.define('PVE.storage.RBDInputPanel', {
|
|
extend: 'PVE.panel.InputPanel',
|
|
|
|
onGetValues: function(values) {
|
|
var me = this;
|
|
|
|
if (me.isCreate) {
|
|
values.type = 'rbd';
|
|
} else {
|
|
delete values.storage;
|
|
}
|
|
|
|
values.disable = values.enable ? 0 : 1;
|
|
delete values.enable;
|
|
|
|
return values;
|
|
},
|
|
|
|
initComponent : function() {
|
|
var me = this;
|
|
|
|
|
|
me.column1 = [
|
|
{
|
|
xtype: me.isCreate ? 'textfield' : 'displayfield',
|
|
name: 'storage',
|
|
value: me.storageId || '',
|
|
fieldLabel: 'ID',
|
|
vtype: 'StorageId',
|
|
allowBlank: false
|
|
},
|
|
{
|
|
xtype: me.isCreate ? 'textfield' : 'displayfield',
|
|
name: 'pool',
|
|
value: 'rbd',
|
|
fieldLabel: gettext('Pool'),
|
|
allowBlank: false
|
|
},
|
|
{
|
|
xtype: me.isCreate ? 'textfield' : 'displayfield',
|
|
name: 'monhost',
|
|
vtype: 'HostList',
|
|
value: '',
|
|
fieldLabel: 'Monitor(s)',
|
|
allowBlank: false
|
|
},
|
|
{
|
|
xtype: me.isCreate ? 'textfield' : 'displayfield',
|
|
name: 'username',
|
|
value: 'admin',
|
|
fieldLabel: gettext('User name'),
|
|
allowBlank: true
|
|
}
|
|
];
|
|
|
|
// here value is an array,
|
|
// while before it was a string
|
|
/*jslint confusion: true*/
|
|
me.column2 = [
|
|
{
|
|
xtype: 'pvecheckbox',
|
|
name: 'enable',
|
|
checked: true,
|
|
uncheckedValue: 0,
|
|
fieldLabel: gettext('Enable')
|
|
},
|
|
{
|
|
xtype: 'pveContentTypeSelector',
|
|
cts: ['images', 'rootdir'],
|
|
fieldLabel: gettext('Content'),
|
|
name: 'content',
|
|
value: ['images'],
|
|
multiSelect: true,
|
|
allowBlank: false
|
|
},
|
|
{
|
|
xtype: 'pvecheckbox',
|
|
name: 'krbd',
|
|
uncheckedValue: 0,
|
|
fieldLabel: 'KRBD'
|
|
}
|
|
];
|
|
/*jslint confusion: false*/
|
|
|
|
if (me.isCreate || me.storageId !== 'local') {
|
|
me.column2.unshift({
|
|
xtype: 'pveNodeSelector',
|
|
name: 'nodes',
|
|
fieldLabel: gettext('Nodes'),
|
|
emptyText: gettext('All') + ' (' +
|
|
gettext('No restrictions') +')',
|
|
multiSelect: true,
|
|
autoSelect: false
|
|
});
|
|
}
|
|
|
|
me.callParent();
|
|
}
|
|
});
|
|
|
|
Ext.define('PVE.storage.RBDEdit', {
|
|
extend: 'PVE.window.Edit',
|
|
|
|
initComponent : function() {
|
|
var me = this;
|
|
|
|
me.isCreate = !me.storageId;
|
|
|
|
if (me.isCreate) {
|
|
me.url = '/api2/extjs/storage';
|
|
me.method = 'POST';
|
|
} else {
|
|
me.url = '/api2/extjs/storage/' + me.storageId;
|
|
me.method = 'PUT';
|
|
}
|
|
|
|
var ipanel = Ext.create('PVE.storage.RBDInputPanel', {
|
|
isCreate: me.isCreate,
|
|
storageId: me.storageId
|
|
});
|
|
|
|
Ext.apply(me, {
|
|
subject: PVE.Utils.format_storage_type('rbd'),
|
|
isAdd: true,
|
|
items: [ ipanel ]
|
|
});
|
|
|
|
me.callParent();
|
|
|
|
if (!me.isCreate) {
|
|
me.load({
|
|
success: function(response, options) {
|
|
var values = response.result.data;
|
|
|
|
var ctypes = values.content || '';
|
|
|
|
values.content = ctypes.split(',');
|
|
|
|
if (values.nodes) {
|
|
values.nodes = values.nodes.split(',');
|
|
}
|
|
values.enable = values.disable ? 0 : 1;
|
|
ipanel.setValues(values);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|