[pve-devel] [RFC pve-manager] add_cifs
Wolfgang Link
w.link at proxmox.com
Wed Oct 5 14:48:07 CEST 2016
---
www/manager6/Makefile | 1 +
www/manager6/Utils.js | 2 +
www/manager6/dc/StorageView.js | 11 ++
www/manager6/storage/CIFSEdit.js | 234 +++++++++++++++++++++++++++++++++++++++
4 files changed, 248 insertions(+)
create mode 100644 www/manager6/storage/CIFSEdit.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 558ddfd..3ee4091 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -178,6 +178,7 @@ JSSRC= \
storage/SheepdogEdit.js \
storage/ZFSEdit.js \
storage/ZFSPoolEdit.js \
+ storage/CIFSEdit.js \
ha/StatusView.js \
ha/GroupSelector.js \
ha/ResourceEdit.js \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 3c15135..212ab4f 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -808,6 +808,8 @@ Ext.define('PVE.Utils', { statics: {
return 'iSCSIDirect';
} else if (value === 'drbd') {
return 'DRBD';
+ } else if (value === 'cifs') {
+ return 'CIFS';
} else {
return PVE.Utils.unknownText;
}
diff --git a/www/manager6/dc/StorageView.js b/www/manager6/dc/StorageView.js
index 86d23bd..4e6e367 100644
--- a/www/manager6/dc/StorageView.js
+++ b/www/manager6/dc/StorageView.js
@@ -37,6 +37,8 @@ Ext.define('PVE.dc.StorageView', {
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') {
@@ -144,6 +146,15 @@ Ext.define('PVE.dc.StorageView', {
}
},
{
+ 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();
+ }
+ },
+ {
text: PVE.Utils.format_storage_type('iscsi'),
iconCls: 'fa fa-fw fa-building',
handler: function() {
diff --git a/www/manager6/storage/CIFSEdit.js b/www/manager6/storage/CIFSEdit.js
new file mode 100644
index 0000000..5477d10
--- /dev/null
+++ b/www/manager6/storage/CIFSEdit.js
@@ -0,0 +1,234 @@
+Ext.define('PVE.storage.CIFSScan', {
+ extend: 'Ext.form.field.ComboBox',
+ alias: 'widget.pveCIFSScan',
+
+ queryParam: 'server',
+
+ valueField: 'share',
+ displayField: 'share',
+ matchFieldWidth: false,
+ listConfig: {
+ loadingText: gettext('Scanning...'),
+ width: 350
+ },
+ doRawQuery: function() {
+ },
+
+ onTriggerClick: function() {
+ var me = this;
+
+ if (!me.queryCaching || me.lastQuery !== me.cifsServer) {
+ me.store.removeAll();
+ }
+
+ me.allQuery = me.cifsServer;
+
+ me.callParent();
+ },
+
+ setServer: function(server) {
+ var me = this;
+
+ me.cifsServer = server;
+ },
+
+ initComponent : function() {
+ var me = this;
+
+ if (!me.nodename) {
+ me.nodename = 'localhost';
+ }
+
+ var store = Ext.create('Ext.data.Store', {
+ fields: [ 'path', 'options' ],
+ proxy: {
+ type: 'pve',
+ url: '/api2/json/nodes/' + me.nodename + '/scan/cifs'
+ }
+ });
+ store.sort('share', 'ASC');
+
+ Ext.apply(me, {
+ store: store
+ });
+
+ me.callParent();
+ }
+});
+
+Ext.define('PVE.storage.CIFSInputPanel', {
+ extend: 'PVE.panel.InputPanel',
+
+ onGetValues: function(values) {
+ var me = this;
+
+ if (me.create) {
+ values.type = 'cifs';
+ } else {
+ delete values.storage;
+ }
+
+ values.disable = values.enable ? 0 : 1;
+ delete values.enable;
+
+ return values;
+ },
+
+ initComponent : function() {
+ var me = this;
+
+ var passwordfield = Ext.createWidget('textfield', {
+ inputType: 'password',
+ name: 'password',
+ value: '',
+ fieldLabel: gettext('Password'),
+ allowBlank: true,
+ minLength: 1,
+ });
+
+ me.column1 = [
+ {
+ xtype: me.create ? 'textfield' : 'displayfield',
+ name: 'storage',
+ value: me.storageId || '',
+ fieldLabel: 'ID',
+ vtype: 'StorageId',
+ allowBlank: false
+ },
+ {
+ xtype: me.create ? 'textfield' : 'displayfield',
+ name: 'server',
+ value: '',
+ fieldLabel: gettext('Server'),
+ allowBlank: false,
+ listeners: {
+ change: function(f, value) {
+ if (me.create) {
+ var exportField = me.down('field[name=share]');
+ exportField.setServer(value);
+ exportField.setValue('');
+ }
+ }
+ }
+ },
+ {
+ xtype: me.create ? 'pveCIFSScan' : 'displayfield',
+ name: 'share',
+ value: '',
+ fieldLabel: 'Share',
+ allowBlank: false,
+ },
+ {
+ xtype: 'pveContentTypeSelector',
+ name: 'content',
+ value: 'images',
+ multiSelect: true,
+ fieldLabel: gettext('Content'),
+ allowBlank: false
+ },
+ {
+ xtype: 'textfield',
+ name: 'username',
+ value: '',
+ fieldLabel: gettext('Username'),
+ allowBlank: true,
+ listeners: {
+ change: function(f, value) {
+ if (value == "") {
+ passwordfield.allowBlank = true;
+ } else {
+ passwordfield.allowBlank = false;
+ }
+ passwordfield.validate();
+ }
+ }
+ },
+ ];
+
+ me.column2 = [
+ {
+ xtype: 'pveNodeSelector',
+ name: 'nodes',
+ fieldLabel: gettext('Nodes'),
+ emptyText: gettext('All') + ' (' +
+ gettext('No restrictions') +')',
+ multiSelect: true,
+ autoSelect: false
+ },
+ {
+ xtype: 'pvecheckbox',
+ name: 'enable',
+ checked: true,
+ uncheckedValue: 0,
+ fieldLabel: gettext('Enable')
+ },
+ {
+ xtype: 'numberfield',
+ fieldLabel: gettext('Max Backups'),
+ name: 'maxfiles',
+ minValue: 0,
+ maxValue: 365,
+ value: me.create ? '1' : undefined,
+ allowBlank: false
+ },
+ passwordfield,
+ {
+ xtype: 'textfield',
+ name: 'domain',
+ value: '',
+ fieldLabel: gettext('Domain'),
+ allowBlank: true,
+ },
+ ];
+
+ me.callParent();
+ }
+});
+
+Ext.define('PVE.storage.CIFSEdit', {
+ extend: 'PVE.window.Edit',
+
+ initComponent : function() {
+ var me = this;
+
+ me.create = !me.storageId;
+
+ if (me.create) {
+ 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', {
+ create: me.create,
+ storageId: me.storageId
+ });
+
+ Ext.apply(me, {
+ subject: 'CIFS',
+ isAdd: true,
+ items: [ ipanel ]
+ });
+
+ me.callParent();
+
+ if (!me.create) {
+ 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.1.4
More information about the pve-devel
mailing list