pve-manager/www/manager6/storage/SheepdogEdit.js
Emmanuel Kasper d5e771ce51 Rename 'create' to 'isCreate' in pveWindowEdit and subclasses
This fixes around 20 jslint type confusion warnings.
Also reduce the scope and document jslint warnings along the way.
No functional changes.
2017-03-02 10:36:35 +01:00

112 lines
2.3 KiB
JavaScript

Ext.define('PVE.storage.SheepdogInputPanel', {
extend: 'PVE.panel.InputPanel',
onGetValues: function(values) {
var me = this;
if (me.isCreate) {
values.type = 'sheepdog';
values.content = 'images';
} 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: 'portal',
value: '127.0.0.1:7000',
fieldLabel: gettext('Gateway'),
allowBlank: false
}
];
me.column2 = [
{
xtype: 'pvecheckbox',
name: 'enable',
checked: true,
uncheckedValue: 0,
fieldLabel: gettext('Enable')
}
];
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.SheepdogEdit', {
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.SheepdogInputPanel', {
isCreate: me.isCreate,
storageId: me.storageId
});
Ext.apply(me, {
subject: PVE.Utils.format_storage_type('sheepdog'),
isAdd: true,
items: [ ipanel ]
});
me.callParent();
if (!me.isCreate) {
me.load({
success: function(response, options) {
var values = response.result.data;
if (values.nodes) {
values.nodes = values.nodes.split(',');
}
values.enable = values.disable ? 0 : 1;
ipanel.setValues(values);
}
});
}
}
});