]> git.proxmox.com Git - pmg-gui.git/commitdiff
SMTPWhitelist.js: implement add menu
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Feb 2017 09:53:17 +0000 (10:53 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Feb 2017 09:53:17 +0000 (10:53 +0100)
js/SMTPWhitelist.js
js/Utils.js

index ebb342cc5db3eff72f5dd4382f3c930e64d367ce..3e03e4b388d51a8b8d48ad7d62fc7a3d4e4d995d 100644 (file)
@@ -1,7 +1,7 @@
 Ext.define('pmg-object-list', {
     extend: 'Ext.data.Model',
     fields: [
-       'id', 'descr', 'otype_text',
+       'id', 'descr',
        { name: 'otype', type: 'integer' },
        { name: 'receivertest', type: 'boolean' }
     ],
@@ -16,11 +16,13 @@ Ext.define('PMG.SMTPWhitelist', {
     extend: 'Ext.grid.GridPanel',
     alias: ['widget.pmgSMTPWhitelist'],
 
-    
+
     columns: [
        {
            header: gettext('Type'),
-           dataIndex: 'otype_text'
+           dataIndex: 'otype',
+           renderer: PMG.Utils.format_otype,
+           width: 200
        },
        {
            header: gettext('Direction'),
@@ -102,8 +104,8 @@ Ext.define('PMG.SMTPWhitelist', {
                PMG.Utils.receiverText : PMG.Utils.senderText;
 
            var config = Ext.apply({ method: 'PUT' }, editor);
-           config.subject = editor.subject + ' (' + direction + ')'; 
-           
+           config.subject = editor.subject + ' (' + direction + ')';
+
            config.url = "/config/whitelist/" + editor.subdir +
                '/' + rec.data.id;
 
@@ -113,9 +115,38 @@ Ext.define('PMG.SMTPWhitelist', {
            win.on('destroy', reload);
            win.show();
        };
-       
+
+       var menu_items = [];
+
+       Ext.Array.each([1000, 1009, 1001, 1007, 1002, 1008, 1003, 1004], function(otype) {
+
+           var editor = PMG.Utils.object_editors[otype];
+
+           var direction = editor.receivertest ?
+               PMG.Utils.receiverText : PMG.Utils.senderText;
+
+           var config = Ext.apply({ method: 'POST' }, editor);
+           config.subject = editor.subject + ' (' + direction + ')';
+
+           config.url = "/config/whitelist/" + editor.subdir;
+           menu_items.push({
+               text: config.subject,
+               handler: function() {
+                   var win = Ext.createWidget('proxmoxWindowEdit', config);
+                   win.on('destroy', reload);
+                   win.show();
+               }
+           });
+       });
+
        me.tbar = [
-            {
+           {
+               text: gettext('Add'),
+               menu: new Ext.menu.Menu({
+                   items: menu_items
+               })
+           },
+           {
                xtype: 'proxmoxButton',
                text: gettext('Edit'),
                disabled: true,
@@ -124,7 +155,7 @@ Ext.define('PMG.SMTPWhitelist', {
             },
            remove_btn
         ];
-       
+
        Proxmox.Utils.monStoreErrors(me, me.store);
 
        Ext.apply(me, {
index 8563de876a1ef974e09c4e77ea1e543a81ea9e15..027d8d7074098dca790ff721cce9add99c4c71a3 100644 (file)
@@ -23,10 +23,12 @@ Ext.define('PMG.Utils', {
        1000: {
            subdir: 'regex',
            subject: gettext("Regular Expression"),
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
                    name: 'regex',
+                   labelWidth: 150,
                    fieldLabel: gettext("Regular Expression")
                }
            ]
@@ -34,10 +36,13 @@ Ext.define('PMG.Utils', {
        1009: {
            subdir: 'receiver_regex',
            subject: gettext("Regular Expression"),
+           receivertest: true,
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
                    name: 'regex',
+                   labelWidth: 150,
                    fieldLabel: gettext("Regular Expression")
                }
            ]
@@ -45,6 +50,7 @@ Ext.define('PMG.Utils', {
        1001: {
            subdir: 'email',
            subject: gettext("Email"),
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
@@ -56,6 +62,8 @@ Ext.define('PMG.Utils', {
        1007: {
            subdir: 'receiver',
            subject: gettext("Email"),
+           receivertest: true,
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
@@ -67,6 +75,7 @@ Ext.define('PMG.Utils', {
        1002: {
            subdir: 'domain',
            subject: gettext("Domain"),
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
@@ -78,6 +87,8 @@ Ext.define('PMG.Utils', {
        1008: {
            subdir: 'receiver_domain',
            subject: gettext("Domain"),
+           receivertest: true,
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
@@ -89,6 +100,7 @@ Ext.define('PMG.Utils', {
        1003: {
            subdir: 'ip',
            subject: gettext("IP Address"),
+           width: 400,
            items: [
                {
                    xtype: 'textfield',
@@ -100,6 +112,7 @@ Ext.define('PMG.Utils', {
        1004: {
            subdir: 'network',
            subject: gettext("IP Network"),
+           width: 400,
            items: [
                {
                    xtype: 'textfield',