[pve-devel] [RFC manager 3/3] ui: add storage plugin base class
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Mar 22 16:27:06 CET 2018
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
RFC! lightly tested...
This removes *a lot* of code duplication.
I add a base class for the storage edit window and for its containing
input panel, they implement the shared stuff. Especially the window was
mostly a 1:1 copy...
I see additional reduction potential, but before I start to do the work
I'd like some feedback. For example, the dc/StorageView tbar menu could
be generated from an extended "storage type to plugin" map.
The RBD ext/pve needs some tweaking (window title, ...) I'll rename the
types probably to a better name, I'll have also an idea for getting the
different windows on editing an existing RBD storage entry.
There's also some potential to split this patch up, will do that when
out of RFC state, for now just look more at the end result.
www/manager6/Makefile | 1 +
www/manager6/dc/StorageView.js | 114 +++++++++++++---------------------
www/manager6/storage/Base.js | 107 +++++++++++++++++++++++++++++++
www/manager6/storage/CIFSEdit.js | 89 +-------------------------
www/manager6/storage/DirEdit.js | 94 +---------------------------
www/manager6/storage/GlusterFsEdit.js | 90 +--------------------------
www/manager6/storage/IScsiEdit.js | 92 ++-------------------------
www/manager6/storage/LVMEdit.js | 93 +--------------------------
www/manager6/storage/LvmThinEdit.js | 96 +---------------------------
www/manager6/storage/NFSEdit.js | 82 +-----------------------
www/manager6/storage/RBDEdit.js | 98 ++---------------------------
www/manager6/storage/SheepdogEdit.js | 87 +-------------------------
www/manager6/storage/ZFSEdit.js | 87 +++-----------------------
www/manager6/storage/ZFSPoolEdit.js | 95 +---------------------------
14 files changed, 183 insertions(+), 1042 deletions(-)
create mode 100644 www/manager6/storage/Base.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index ac9f6481..a01880f7 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -148,6 +148,7 @@ JSSRC= \
pool/StatusView.js \
pool/Summary.js \
pool/Config.js \
+ storage/Base.js \
storage/ContentView.js \
storage/StatusView.js \
storage/Summary.js \
diff --git a/www/manager6/dc/StorageView.js b/www/manager6/dc/StorageView.js
index bebc69d5..db1cb271 100644
--- a/www/manager6/dc/StorageView.js
+++ b/www/manager6/dc/StorageView.js
@@ -1,4 +1,3 @@
-
Ext.define('PVE.dc.StorageView', {
extend: 'Ext.grid.GridPanel',
@@ -9,6 +8,34 @@ Ext.define('PVE.dc.StorageView', {
stateful: true,
stateId: 'grid-dc-storage',
+ type2editor_map: {
+ dir: 'PVE.storage.DirInputPanel',
+ nfs: 'PVE.storage.NFSInputPanel',
+ cifs: 'PVE.storage.CIFSInputPanel',
+ lvm: 'PVE.storage.LVMInputPanel',
+ lvmthin: 'PVE.storage.LvmThinInputPanel',
+ glusterfs: 'PVE.storage.GlusterFsInputPanel',
+ iscsi: 'PVE.storage.IScsiInputPanel',
+ sheepdog: 'PVE.storage.SheepdogInputPanel',
+ rbd: 'PVE.storage.RBDInputPanel',
+ pverbd: 'PVE.storage.PVERBDInputPanel',
+ zfs: 'PVE.storage.ZFSInputPanel',
+ zfspool: 'PVE.storage.ZFSPoolInputPanel'
+ },
+
+ createStorageEditWindow: function(type, sid) {
+ var editor = this.type2editor_map[type];
+
+ var win = Ext.create('PVE.storage.BaseEdit', {
+ paneltype: editor,
+ type: type,
+ storageId: sid
+ });
+
+ win.on('destroy', this.reload);
+ win.show();
+ },
+
initComponent : function() {
var me = this;
@@ -37,39 +64,7 @@ Ext.define('PVE.dc.StorageView', {
}
var type = rec.data.type;
- var editor;
- if (type === 'dir') {
- editor = 'PVE.storage.DirEdit';
- } else if (type === 'nfs') {
- editor = 'PVE.storage.NFSEdit';
- } else if (type === 'cifs') {
- editor = 'PVE.storage.CIFSEdit';
- } else if (type === 'glusterfs') {
- editor = 'PVE.storage.GlusterFsEdit';
- } else if (type === 'lvm') {
- editor = 'PVE.storage.LVMEdit';
- } else if (type === 'lvmthin') {
- editor = 'PVE.storage.LvmThinEdit';
- } else if (type === 'iscsi') {
- editor = 'PVE.storage.IScsiEdit';
- } else if (type === 'rbd') {
- editor = 'PVE.storage.RBDEdit';
- } else if (type === 'sheepdog') {
- editor = 'PVE.storage.SheepdogEdit';
- } else if (type === 'zfs') {
- editor = 'PVE.storage.ZFSEdit';
- } else if (type === 'zfspool') {
- editor = 'PVE.storage.ZFSPoolEdit';
- } else {
- return;
- }
- var win = Ext.create(editor, {
- storageId: rec.data.storage,
- pveceph: !rec.data.monhost
- });
-
- win.show();
- win.on('destroy', reload);
+ me.createStorageEditWindow(type, rec.data.storage, !rec.data.monhost);
};
var edit_btn = new Proxmox.button.Button({
@@ -82,13 +77,12 @@ Ext.define('PVE.dc.StorageView', {
var remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
selModel: sm,
baseurl: '/storage/',
- callback: function() {
- reload();
- }
+ callback: reload
});
Ext.apply(me, {
store: store,
+ reload: reload,
selModel: sm,
viewConfig: {
trackOver: false
@@ -102,9 +96,7 @@ Ext.define('PVE.dc.StorageView', {
text: PVE.Utils.format_storage_type('dir'),
iconCls: 'fa fa-fw fa-folder',
handler: function() {
- var win = Ext.create('PVE.storage.DirEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('dir');
}
},
@@ -112,92 +104,70 @@ Ext.define('PVE.dc.StorageView', {
text: PVE.Utils.format_storage_type('lvm'),
iconCls: 'fa fa-fw fa-folder',
handler: function() {
- var win = Ext.create('PVE.storage.LVMEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('lvm');
}
},
{
text: PVE.Utils.format_storage_type('lvmthin'),
iconCls: 'fa fa-fw fa-folder',
handler: function() {
- var win = Ext.create('PVE.storage.LvmThinEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('lvmthin');
}
},
{
text: PVE.Utils.format_storage_type('nfs'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.NFSEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('nfs');
}
},
{
text: PVE.Utils.format_storage_type('cifs'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.CIFSEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('cifs');
}
},
{
text: PVE.Utils.format_storage_type('iscsi'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.IScsiEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('iscsi');
}
},
{
text: PVE.Utils.format_storage_type('glusterfs'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.GlusterFsEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('glusterfs');
}
},
{
text: PVE.Utils.format_storage_type('pveceph'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.RBDEdit', {
- pveceph: 1
- });
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('pverbd');
}
},
{
text: PVE.Utils.format_storage_type('rbd_ext'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.RBDEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('rbd');
}
},
{
text: PVE.Utils.format_storage_type('zfs'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
- var win = Ext.create('PVE.storage.ZFSEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('zfs');
}
},
{
text: PVE.Utils.format_storage_type('zfspool'),
iconCls: 'fa fa-fw fa-folder',
handler: function() {
- var win = Ext.create('PVE.storage.ZFSPoolEdit', {});
- win.on('destroy', reload);
- win.show();
+ me.createStorageEditWindow('zfspool');
}
}
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
new file mode 100644
index 00000000..6387b373
--- /dev/null
+++ b/www/manager6/storage/Base.js
@@ -0,0 +1,107 @@
+// TODO: rename
+Ext.define('PVE.panel.StorageBase', {
+ extend: 'Proxmox.panel.InputPanel',
+ controller: 'storageEdit',
+
+ type: '',
+
+ onGetValues: function(values) {
+ var me = this;
+
+ if (me.isCreate) {
+ values.type = me.type;
+ } else {
+ delete values.storage;
+ }
+
+ values.disable = values.enable ? 0 : 1;
+ delete values.enable;
+
+ return values;
+ },
+
+ initComponent : function() {
+ var me = this;
+
+ me.column1.unshift({
+ xtype: me.isCreate ? 'textfield' : 'displayfield',
+ name: 'storage',
+ value: me.storageId || '',
+ fieldLabel: 'ID',
+ vtype: 'StorageId',
+ allowBlank: false
+ });
+
+ me.column2.unshift(
+ {
+ xtype: 'pveNodeSelector',
+ name: 'nodes',
+ disabled: me.storageId === 'local',
+ fieldLabel: gettext('Nodes'),
+ emptyText: gettext('All') + ' (' + gettext('No restrictions') +')',
+ multiSelect: true,
+ autoSelect: false
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'enable',
+ checked: true,
+ uncheckedValue: 0,
+ fieldLabel: gettext('Enable')
+ }
+ );
+
+ me.callParent();
+ }
+});
+
+Ext.define('PVE.storage.BaseEdit', {
+ extend: 'Proxmox.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(me.paneltype, {
+ type: me.type,
+ isCreate: me.isCreate,
+ storageId: me.storageId
+ });
+
+ Ext.apply(me, {
+ // TODO: ceph?!
+ subject: PVE.Utils.format_storage_type(me.type),
+ 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);
+ }
+ });
+ }
+ }
+});
diff --git a/www/manager6/storage/CIFSEdit.js b/www/manager6/storage/CIFSEdit.js
index 83f5c664..f75745b4 100644
--- a/www/manager6/storage/CIFSEdit.js
+++ b/www/manager6/storage/CIFSEdit.js
@@ -86,24 +86,9 @@ Ext.define('PVE.storage.CIFSScan', {
});
Ext.define('PVE.storage.CIFSInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
controller: 'storageEdit',
- onGetValues: function(values) {
- var me = this;
-
- if (me.isCreate) {
- values.type = 'cifs';
- } else {
- delete values.storage;
- }
-
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
-
- return values;
- },
-
initComponent : function() {
var me = this;
@@ -126,14 +111,6 @@ Ext.define('PVE.storage.CIFSInputPanel', {
});
me.column1 = [
- {
- xtype: me.isCreate ? 'textfield' : 'displayfield',
- name: 'storage',
- value: me.storageId || '',
- fieldLabel: 'ID',
- vtype: 'StorageId',
- allowBlank: false
- },
{
xtype: me.isCreate ? 'textfield' : 'displayfield',
name: 'server',
@@ -189,22 +166,6 @@ Ext.define('PVE.storage.CIFSInputPanel', {
];
me.column2 = [
- {
- xtype: 'pveNodeSelector',
- name: 'nodes',
- fieldLabel: gettext('Nodes'),
- emptyText: gettext('All') + ' (' +
- gettext('No restrictions') +')',
- multiSelect: true,
- autoSelect: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'proxmoxintegerfield',
fieldLabel: gettext('Max Backups'),
@@ -237,51 +198,3 @@ Ext.define('PVE.storage.CIFSInputPanel', {
me.callParent();
}
});
-
-Ext.define('PVE.storage.CIFSEdit', {
- extend: 'Proxmox.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.CIFSInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: 'CIFS',
- 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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/DirEdit.js b/www/manager6/storage/DirEdit.js
index f17a3689..fd02f13f 100644
--- a/www/manager6/storage/DirEdit.js
+++ b/www/manager6/storage/DirEdit.js
@@ -1,35 +1,11 @@
Ext.define('PVE.storage.DirInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
controller: 'storageEdit',
- onGetValues: function(values) {
- var me = this;
-
- if (me.isCreate) {
- values.type = 'dir';
- } 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: 'path',
@@ -48,13 +24,6 @@ Ext.define('PVE.storage.DirInputPanel', {
];
me.column2 = [
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'proxmoxcheckbox',
name: 'shared',
@@ -74,67 +43,6 @@ Ext.define('PVE.storage.DirInputPanel', {
}
];
- 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.DirEdit', {
- extend: 'Proxmox.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.DirInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type('dir'),
- 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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/GlusterFsEdit.js b/www/manager6/storage/GlusterFsEdit.js
index 11ff3223..f02bc6e8 100644
--- a/www/manager6/storage/GlusterFsEdit.js
+++ b/www/manager6/storage/GlusterFsEdit.js
@@ -58,37 +58,13 @@ Ext.define('PVE.storage.GlusterFsScan', {
});
Ext.define('PVE.storage.GlusterFsInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
controller: 'storageEdit',
- onGetValues: function(values) {
- var me = this;
-
- if (me.isCreate) {
- values.type = 'glusterfs';
- } 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: 'server',
@@ -131,22 +107,6 @@ Ext.define('PVE.storage.GlusterFsInputPanel', {
];
me.column2 = [
- {
- xtype: 'pveNodeSelector',
- name: 'nodes',
- fieldLabel: gettext('Nodes'),
- emptyText: gettext('All') + ' (' +
- gettext('No restrictions') +')',
- multiSelect: true,
- autoSelect: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'proxmoxintegerfield',
fieldLabel: gettext('Max Backups'),
@@ -163,51 +123,3 @@ Ext.define('PVE.storage.GlusterFsInputPanel', {
me.callParent();
}
});
-
-Ext.define('PVE.storage.GlusterFsEdit', {
- extend: 'Proxmox.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.GlusterFsInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type('glusterfs'),
- 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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/IScsiEdit.js b/www/manager6/storage/IScsiEdit.js
index b673bc3a..6616e8b7 100644
--- a/www/manager6/storage/IScsiEdit.js
+++ b/www/manager6/storage/IScsiEdit.js
@@ -57,39 +57,26 @@ Ext.define('PVE.storage.IScsiScan', {
});
Ext.define('PVE.storage.IScsiInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
onGetValues: function(values) {
var me = this;
- if (me.isCreate) {
- values.type = 'iscsi';
- } else {
- delete values.storage;
- }
-
values.content = values.luns ? 'images' : 'none';
delete values.luns;
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
+ me.callParent();
+ },
- return values;
+ setValues: function(values) {
+ values.luns = (values.content === 'images') ? true : false;
+ this.callParent();
},
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',
@@ -117,22 +104,6 @@ Ext.define('PVE.storage.IScsiInputPanel', {
];
me.column2 = [
- {
- xtype: 'pveNodeSelector',
- name: 'nodes',
- fieldLabel: gettext('Nodes'),
- emptyText: gettext('All') + ' (' +
- gettext('No restrictions') +')',
- multiSelect: true,
- autoSelect: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'checkbox',
name: 'luns',
@@ -144,54 +115,3 @@ Ext.define('PVE.storage.IScsiInputPanel', {
me.callParent();
}
});
-
-Ext.define('PVE.storage.IScsiEdit', {
- extend: 'Proxmox.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.IScsiInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type('iscsi'),
- isAdd: true,
- items: [ ipanel ]
- });
-
- me.callParent();
-
- if (!me.isCreate) {
- me.load({
- success: function(response, options) {
- var values = response.result.data;
- var ctypes = values.content || '';
-
- if (values.storage === 'local') {
- values.content = ctypes.split(',');
- }
- if (values.nodes) {
- values.nodes = values.nodes.split(',');
- }
- values.enable = values.disable ? 0 : 1;
- values.luns = (values.content === 'images') ? true : false;
-
- ipanel.setValues(values);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/LVMEdit.js b/www/manager6/storage/LVMEdit.js
index b822d226..af79c527 100644
--- a/www/manager6/storage/LVMEdit.js
+++ b/www/manager6/storage/LVMEdit.js
@@ -84,37 +84,12 @@ Ext.define('PVE.storage.BaseStorageSelector', {
});
Ext.define('PVE.storage.LVMInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
-
- onGetValues: function(values) {
- var me = this;
-
- if (me.isCreate) {
- values.type = 'lvm';
- } else {
- delete values.storage;
- }
-
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
-
- return values;
- },
+ extend: 'PVE.panel.StorageBase',
initComponent : function() {
var me = this;
- me.column1 = [
- {
- xtype: me.isCreate ? 'textfield' : 'displayfield',
- name: 'storage',
- value: me.storageId || '',
- fieldLabel: 'ID',
- vtype: 'StorageId',
- submitValue: !!me.isCreate,
- allowBlank: false
- }
- ];
+ me.column1 = [];
var vgnameField = Ext.createWidget(me.isCreate ? 'textfield' : 'displayfield', {
name: 'vgname',
@@ -191,22 +166,6 @@ Ext.define('PVE.storage.LVMInputPanel', {
/*jslint confusion: false*/
me.column2 = [
- {
- xtype: 'pveNodeSelector',
- name: 'nodes',
- fieldLabel: gettext('Nodes'),
- emptyText: gettext('All') + ' (' +
- gettext('No restrictions') +')',
- multiSelect: true,
- autoSelect: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'proxmoxcheckbox',
name: 'shared',
@@ -218,51 +177,3 @@ Ext.define('PVE.storage.LVMInputPanel', {
me.callParent();
}
});
-
-Ext.define('PVE.storage.LVMEdit', {
- extend: 'Proxmox.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.LVMInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type('lvm'),
- 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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/LvmThinEdit.js b/www/manager6/storage/LvmThinEdit.js
index bb9a4f1e..6ec51ed8 100644
--- a/www/manager6/storage/LvmThinEdit.js
+++ b/www/manager6/storage/LvmThinEdit.js
@@ -92,37 +92,12 @@ Ext.define('PVE.storage.BaseVGSelector', {
});
Ext.define('PVE.storage.LvmThinInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
-
- onGetValues: function(values) {
- var me = this;
-
- if (me.isCreate) {
- values.type = 'lvmthin';
- } else {
- delete values.storage;
- }
-
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
-
- return values;
- },
+ extend: 'PVE.panel.StorageBase',
initComponent : function() {
var me = this;
- me.column1 = [
- {
- xtype: me.isCreate ? 'textfield' : 'displayfield',
- name: 'storage',
- value: me.storageId || '',
- fieldLabel: 'ID',
- vtype: 'StorageId',
- submitValue: !!me.isCreate,
- allowBlank: false
- }
- ];
+ me.column1 = [];
var vgnameField = Ext.createWidget(me.isCreate ? 'textfield' : 'displayfield', {
name: 'vgname',
@@ -184,73 +159,8 @@ Ext.define('PVE.storage.LvmThinInputPanel', {
});
/*jslint confusion: false*/
- me.column2 = [
- {
- xtype: 'pveNodeSelector',
- name: 'nodes',
- fieldLabel: gettext('Nodes'),
- emptyText: gettext('All') + ' (' +
- gettext('No restrictions') +')',
- multiSelect: true,
- autoSelect: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- }
- ];
+ me.column2 = [];
me.callParent();
}
});
-
-Ext.define('PVE.storage.LvmThinEdit', {
- extend: 'Proxmox.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.LvmThinInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type('lvmthin'),
- 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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/NFSEdit.js b/www/manager6/storage/NFSEdit.js
index b230ec34..dec0a197 100644
--- a/www/manager6/storage/NFSEdit.js
+++ b/www/manager6/storage/NFSEdit.js
@@ -58,25 +58,19 @@ Ext.define('PVE.storage.NFSScan', {
});
Ext.define('PVE.storage.NFSInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
controller: 'storageEdit',
onGetValues: function(values) {
var me = this;
if (me.isCreate) {
- values.type = 'nfs';
// hack: for now we always create nvf v3
// fixme: make this configurable
values.options = 'vers=3';
- } else {
- delete values.storage;
}
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
-
- return values;
+ me.callParent();
},
initComponent : function() {
@@ -84,14 +78,6 @@ Ext.define('PVE.storage.NFSInputPanel', {
me.column1 = [
- {
- xtype: me.isCreate ? 'textfield' : 'displayfield',
- name: 'storage',
- value: me.storageId || '',
- fieldLabel: 'ID',
- vtype: 'StorageId',
- allowBlank: false
- },
{
xtype: me.isCreate ? 'textfield' : 'displayfield',
name: 'server',
@@ -126,22 +112,6 @@ Ext.define('PVE.storage.NFSInputPanel', {
];
me.column2 = [
- {
- xtype: 'pveNodeSelector',
- name: 'nodes',
- fieldLabel: gettext('Nodes'),
- emptyText: gettext('All') + ' (' +
- gettext('No restrictions') +')',
- multiSelect: true,
- autoSelect: false
- },
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'proxmoxintegerfield',
fieldLabel: gettext('Max Backups'),
@@ -158,51 +128,3 @@ Ext.define('PVE.storage.NFSInputPanel', {
me.callParent();
}
});
-
-Ext.define('PVE.storage.NFSEdit', {
- extend: 'Proxmox.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.NFSInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: 'NFS',
- 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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/RBDEdit.js b/www/manager6/storage/RBDEdit.js
index 1e46f9ee..f6e9202e 100644
--- a/www/manager6/storage/RBDEdit.js
+++ b/www/manager6/storage/RBDEdit.js
@@ -1,20 +1,5 @@
Ext.define('PVE.storage.RBDInputPanel', {
- extend: 'Proxmox.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;
- },
+ extend: 'PVE.panel.StorageBase',
initComponent : function() {
var me = this;
@@ -23,16 +8,7 @@ Ext.define('PVE.storage.RBDInputPanel', {
me.nodename = 'localhost';
}
- me.column1 = [
- {
- xtype: me.isCreate ? 'textfield' : 'displayfield',
- name: 'storage',
- value: me.storageId || '',
- fieldLabel: 'ID',
- vtype: 'StorageId',
- allowBlank: false
- }
- ];
+ me.column1 = [];
if (me.pveceph) {
me.column1.push(
@@ -75,13 +51,6 @@ Ext.define('PVE.storage.RBDInputPanel', {
// while before it was a string
/*jslint confusion: true*/
me.column2 = [
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'pveContentTypeSelector',
cts: ['images', 'rootdir'],
@@ -100,69 +69,12 @@ Ext.define('PVE.storage.RBDInputPanel', {
];
/*jslint confusion: false*/
- if (me.isCreate) {
- 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: 'Proxmox.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,
- nodename: me.nodename,
- pveceph: me.pveceph
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type(me.pveceph?'pveceph':'rbd'),
- isAdd: true,
- items: [ ipanel ]
- });
+Ext.define('PVE.storage.PVERBDInputPanel', {
+ extend: 'PVE.storage.RBDInputPanel',
- 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);
- }
- });
- }
- }
+ pveceph: 1
});
diff --git a/www/manager6/storage/SheepdogEdit.js b/www/manager6/storage/SheepdogEdit.js
index 90d87337..445d2d0e 100644
--- a/www/manager6/storage/SheepdogEdit.js
+++ b/www/manager6/storage/SheepdogEdit.js
@@ -1,36 +1,20 @@
Ext.define('PVE.storage.SheepdogInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
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;
+ me.callParent();
},
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',
@@ -39,73 +23,8 @@ Ext.define('PVE.storage.SheepdogInputPanel', {
allowBlank: false
}
];
-
- me.column2 = [
- {
- xtype: 'proxmoxcheckbox',
- 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.column2 = [];
me.callParent();
}
});
-
-Ext.define('PVE.storage.SheepdogEdit', {
- extend: 'Proxmox.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);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/ZFSEdit.js b/www/manager6/storage/ZFSEdit.js
index ac85b359..290a17ca 100644
--- a/www/manager6/storage/ZFSEdit.js
+++ b/www/manager6/storage/ZFSEdit.js
@@ -1,37 +1,28 @@
Ext.define('PVE.storage.ZFSInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
+ extend: 'PVE.panel.StorageBase',
onGetValues: function(values) {
var me = this;
if (me.isCreate) {
- values.type = 'zfs';
values.content = 'images';
- } else {
- delete values.storage;
}
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
-
values.nowritecache = values.writecache ? 0 : 1;
delete values.writecache;
- return values;
+ me.callParent();
+ },
+
+ setValues: function diff(values) {
+ values.writecache = values.nowritecache ? 0 : 1;
+ this.callParent();
},
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',
@@ -70,13 +61,6 @@ Ext.define('PVE.storage.ZFSInputPanel', {
];
me.column2 = [
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: me.isCreate ? 'pveiScsiProviderSelector' : 'displayfield',
name: 'iscsiprovider',
@@ -107,63 +91,6 @@ Ext.define('PVE.storage.ZFSInputPanel', {
}
];
- 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.ZFSEdit', {
- extend: 'Proxmox.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.ZFSInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: 'ZFS Storage',
- 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;
- values.writecache = values.nowritecache ? 0 : 1;
- ipanel.setValues(values);
- }
- });
- }
- }
-});
diff --git a/www/manager6/storage/ZFSPoolEdit.js b/www/manager6/storage/ZFSPoolEdit.js
index 56ed0f84..69d03817 100644
--- a/www/manager6/storage/ZFSPoolEdit.js
+++ b/www/manager6/storage/ZFSPoolEdit.js
@@ -35,36 +35,12 @@ Ext.define('PVE.storage.ZFSPoolSelector', {
});
Ext.define('PVE.storage.ZFSPoolInputPanel', {
- extend: 'Proxmox.panel.InputPanel',
-
- onGetValues: function(values) {
- var me = this;
-
- if (me.isCreate) {
- values.type = 'zfspool';
- } else {
- delete values.storage;
- }
-
- values.disable = values.enable ? 0 : 1;
- delete values.enable;
-
- return values;
- },
+ extend: 'PVE.panel.StorageBase',
initComponent : function() {
var me = this;
- me.column1 = [
- {
- xtype: me.isCreate ? 'textfield' : 'displayfield',
- name: 'storage',
- value: me.storageId || '',
- fieldLabel: 'ID',
- vtype: 'StorageId',
- allowBlank: false
- }
- ];
+ me.column1 = [];
if (me.isCreate) {
me.column1.push(Ext.create('PVE.storage.ZFSPoolSelector', {
@@ -95,13 +71,6 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
});
/*jslint confusion: false*/
me.column2 = [
- {
- xtype: 'proxmoxcheckbox',
- name: 'enable',
- checked: true,
- uncheckedValue: 0,
- fieldLabel: gettext('Enable')
- },
{
xtype: 'proxmoxcheckbox',
name: 'sparse',
@@ -118,66 +87,6 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
}
];
- 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.ZFSPoolEdit', {
- extend: 'Proxmox.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.ZFSPoolInputPanel', {
- isCreate: me.isCreate,
- storageId: me.storageId
- });
-
- Ext.apply(me, {
- subject: PVE.Utils.format_storage_type('zfspool'),
- 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);
- }
- });
- }
- }
-});
--
2.14.2
More information about the pve-devel
mailing list