]> git.proxmox.com Git - pmg-gui.git/commitdiff
move object editor configuration to PMG.Utils.object_editors
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Feb 2017 09:25:19 +0000 (10:25 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Feb 2017 09:25:19 +0000 (10:25 +0100)
js/SMTPWhitelist.js
js/Utils.js

index 46958860904d4b7a03d5d12f0f7dcef154c9f098..ebb342cc5db3eff72f5dd4382f3c930e64d367ce 100644 (file)
@@ -87,104 +87,13 @@ Ext.define('PMG.SMTPWhitelist', {
            }
        });
 
-       var editors = {
-           1000: {
-               subdir: 'regex',
-               subject: gettext("Regular Expression"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'regex',
-                       fieldLabel: gettext("Regular Expression")
-                   }
-               ]
-           },
-           1009: {
-               subdir: 'receiver_regex',
-               subject: gettext("Regular Expression"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'regex',
-                       fieldLabel: gettext("Regular Expression")
-                   }
-               ]
-           },
-           1001: {
-               subdir: 'email',
-               subject: gettext("Email"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'email',
-                       fieldLabel: gettext("Email")
-                   }
-               ]
-           },
-           1007: {
-               subdir: 'receiver',
-               subject: gettext("Email"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'email',
-                       fieldLabel: gettext("Email")
-                   }
-               ]
-           },
-           1002: {
-               subdir: 'domain',
-               subject: gettext("Domain"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'domain',
-                       fieldLabel: gettext("Domain")
-                   }
-               ]
-           },
-           1008: {
-               subdir: 'receiver_domain',
-               subject: gettext("Domain"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'domain',
-                       fieldLabel: gettext("Domain")
-                   }
-               ]
-           },
-           1003: {
-               subdir: 'ip',
-               subject: gettext("IP Address"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'ip',
-                       fieldLabel: gettext("IP Address")
-                   }
-               ]
-           },
-           1004: {
-               subdir: 'network',
-               subject: gettext("IP Network"),
-               items: [
-                   {
-                       xtype: 'textfield',
-                       name: 'cidr',
-                       fieldLabel: gettext("IP Network")
-                   }
-               ]
-           }
-       };
-       
        var run_editor = function() {
            var rec = me.selModel.getSelection()[0];
            if (!rec) {
                return;
            }
 
-           var editor = editors[rec.data.otype];
+           var editor = PMG.Utils.object_editors[rec.data.otype];
            if (!editor) {
                return;
            }
@@ -196,7 +105,7 @@ Ext.define('PMG.SMTPWhitelist', {
            config.subject = editor.subject + ' (' + direction + ')'; 
            
            config.url = "/config/whitelist/" + editor.subdir +
-               '/' + rec.data.id,
+               '/' + rec.data.id;
 
            var win = Ext.createWidget('proxmoxWindowEdit', config);
 
index 0f6b4215057d2473efb8bec7fab3b2b090cf869c..8563de876a1ef974e09c4e77ea1e543a81ea9e15 100644 (file)
@@ -10,6 +10,105 @@ Ext.define('PMG.Utils', {
 
     senderText: gettext('Sender'),
     receiverText: gettext('Receiver'),
+
+    format_otype: function(otype) {
+       var editor = PMG.Utils.object_editors[otype];
+       if (editor) {
+           return editor.subject;
+       }
+       return 'unknown';
+    },
+
+    object_editors: {
+       1000: {
+           subdir: 'regex',
+           subject: gettext("Regular Expression"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'regex',
+                   fieldLabel: gettext("Regular Expression")
+               }
+           ]
+       },
+       1009: {
+           subdir: 'receiver_regex',
+           subject: gettext("Regular Expression"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'regex',
+                   fieldLabel: gettext("Regular Expression")
+               }
+           ]
+       },
+       1001: {
+           subdir: 'email',
+           subject: gettext("Email"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'email',
+                   fieldLabel: gettext("Email")
+               }
+           ]
+       },
+       1007: {
+           subdir: 'receiver',
+           subject: gettext("Email"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'email',
+                   fieldLabel: gettext("Email")
+               }
+           ]
+       },
+       1002: {
+           subdir: 'domain',
+           subject: gettext("Domain"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'domain',
+                   fieldLabel: gettext("Domain")
+               }
+           ]
+       },
+       1008: {
+           subdir: 'receiver_domain',
+           subject: gettext("Domain"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'domain',
+                   fieldLabel: gettext("Domain")
+               }
+           ]
+       },
+       1003: {
+           subdir: 'ip',
+           subject: gettext("IP Address"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'ip',
+                   fieldLabel: gettext("IP Address")
+               }
+           ]
+       },
+       1004: {
+           subdir: 'network',
+           subject: gettext("IP Network"),
+           items: [
+               {
+                   xtype: 'textfield',
+                   name: 'cidr',
+                   fieldLabel: gettext("IP Network")
+               }
+           ]
+       }
+    },
                          
     constructor: function() {
        var me = this;