]> git.proxmox.com Git - pmg-gui.git/commitdiff
Fetchmail - implement create
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 23 Oct 2017 08:57:35 +0000 (10:57 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 23 Oct 2017 08:57:35 +0000 (10:57 +0200)
js/FetchmailEdit.js
js/FetchmailView.js

index e80add777ed2e8b5ce9460a48c19fb8fd5d9d752..455552f88e10d87a99f6c52060cdaadaf498f9ad 100644 (file)
@@ -10,6 +10,23 @@ Ext.define('PMG.FetchmailEdit', {
 
     fieldDefaults: { labelWidth: 120 },
 
+    controller: {
+
+       xclass: 'Ext.app.ViewController',
+
+       onProtocolChange: function() {
+           var protocol = this.lookupReference('protocol').getValue();
+           var ssl = this.lookupReference('ssl').getValue();
+
+           var port_field =  this.lookupReference('port');
+           if (protocol === 'pop3') {
+               port_field.setValue(ssl ? 995 : 110);
+           } else if (protocol === 'imap') {
+               port_field.setValue(ssl ? 993 : 143);
+           }
+       }
+    },
+
     items: {
        xtype: 'inputpanel',
        column1: [
@@ -19,10 +36,21 @@ Ext.define('PMG.FetchmailEdit', {
                fieldLabel: gettext('Server'),
                allowBlank: false
            },
+           {
+               xtype: 'proxmoxKVComboBox',
+               fieldLabel: gettext('Protocol'),
+               name: 'protocol',
+               reference: 'protocol',
+               value: 'pop3',
+               listeners: { change: 'onProtocolChange' },
+               comboItems: [['pop3', 'pop3'], ['imap', 'imap']]
+           },
            {
                xtype: 'proxmoxintegerfield',
                name: 'port',
+               reference: 'port',
                fieldLabel: gettext('Port'),
+               value: 110,
                minValue: 1,
                maxValue: 65535,
                allowBlank: false
@@ -68,7 +96,9 @@ Ext.define('PMG.FetchmailEdit', {
            {
                xtype: 'proxmoxcheckbox',
                fieldLabel: gettext('Use SSL'),
+               listeners: { change: 'onProtocolChange' },
                name: 'ssl',
+               reference: 'ssl',
                uncheckedValue: 0,
                checked: false
            },
index 30c157f023e35957bcf959e506fb3857689ae0be..ae31b81c44ddd7712d978a338af35b5f0f53407b 100644 (file)
@@ -33,6 +33,17 @@ Ext.define('PMG.FetchmailView', {
            Proxmox.Utils.monStoreErrors(view, view.store, true);
        },
 
+       onAdd: function() {
+           var view = this.getView();
+
+            var win = Ext.create('PMG.FetchmailEdit', {
+               url: view.baseurl,
+               method: 'POST',
+            });
+            win.on('destroy', function() { view.store.load() });
+            win.show();
+       },
+
        onEdit: function() {
            var view = this.getView();
 
@@ -55,6 +66,17 @@ Ext.define('PMG.FetchmailView', {
     },
 
     tbar: [
+        {
+           text: gettext('Add'),
+           reference: 'addBtn',
+           handler: 'onAdd'
+       },
+       {
+           xtype: 'proxmoxButton',
+           text: gettext('Edit'),
+           disabled: true,
+           handler: 'onEdit'
+       },
        {
            xtype: 'proxmoxStdRemoveButton',
            baseurl: '/config/fetchmail',
@@ -76,6 +98,10 @@ Ext.define('PMG.FetchmailView', {
            renderer: Ext.String.htmlEncode,
            dataIndex: 'server'
        },
+       {
+           header: gettext('Protocol'),
+           dataIndex: 'protocol'
+       },
        {
            header: gettext('User name'),
            flex: 1,