]> git.proxmox.com Git - pmg-gui.git/commitdiff
implement LDAP group who object
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 23 Mar 2017 09:36:35 +0000 (10:36 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 23 Mar 2017 09:36:35 +0000 (10:36 +0100)
js/LDAPGroupEditor.js [new file with mode: 0644]
js/LDAPGroupSelector.js [new file with mode: 0644]
js/LDAPProfileSelector.js [new file with mode: 0644]
js/Makefile
js/ObjectGroup.js
js/ObjectGroupConfiguration.js
js/SpamDetectorLanguages.js
js/Utils.js

diff --git a/js/LDAPGroupEditor.js b/js/LDAPGroupEditor.js
new file mode 100644 (file)
index 0000000..ac7d49d
--- /dev/null
@@ -0,0 +1,100 @@
+Ext.define('PMG.LDAPGroupInputPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+    alias: 'widget.pmgLDAPGroupInputPanel',
+
+    onGetValues: function(values) {
+       if (values.mode === 'profile-any') {
+           values.mode = 'any';
+       } else if (values.mode === 'profile-none') {
+           values.mode = 'none';
+       }
+
+       return values;
+    },
+
+    setValues: function(values) {
+       var me = this;
+
+       if (values.profile !== undefined) {
+           if (values.mode === 'any') {
+               values.mode = 'profile-any';
+           } else if (values.mode === 'none') {
+               values.mode = 'profile-none';
+           }
+       }
+
+       if (values.profile !== undefined) {
+           var groupField = this.lookupReference('groupField');
+           groupField.setProfile(values.profile);
+       }
+
+       me.callParent([values]);
+    },
+
+    controller: {
+
+       xclass: 'Ext.app.ViewController',
+
+       changeMode: function(f, value) {
+           var groupField = this.lookupReference('groupField');
+           groupField.setDisabled(value !== 'group');
+           groupField.setVisible(value === 'group');
+           var profileField = this.lookupReference('profileField');
+           var enabled = ((value != 'any') && (value != 'none'));
+           profileField.setDisabled(!enabled);
+           profileField.setVisible(enabled);
+       },
+
+       changeProfile: function(f, value) {
+           var groupField = this.lookupReference('groupField');
+           groupField.setProfile(value);
+       },
+
+       control: {
+           'field[name=mode]': {
+               change: 'changeMode'
+           },
+           'field[name=profile]': {
+               change: 'changeProfile'
+           }
+       },
+    },
+
+    items: [
+       {
+           xtype: 'proxmoxKVComboBox',
+           name: 'mode',
+           comboItems: [
+               [ 'group', gettext('Group member') ],
+               [ 'profile-any', gettext('Existing LDAP address')],
+               [ 'any', gettext('Existing LDAP address') +
+                 ' (' +  PMG.Utils.anyProfileText + ')'],
+               [ 'profile-none', gettext('Unknown LDAP address')],
+               [ 'none', gettext('Unknown LDAP address') +
+                 ' (' +  PMG.Utils.anyProfileText + ')'],
+           ],
+           fieldLabel: gettext("Match")
+       },
+       {
+           xtype: 'pmgLDAPProfileSelector',
+           name: 'profile',
+           reference: 'profileField',
+           fieldLabel: gettext("Profile")
+       },
+       {
+           xtype: 'pmgLDAPGroupSelector',
+           name: 'group',
+           reference: 'groupField',
+           fieldLabel: gettext("Group")
+       }
+    ]
+});
+
+Ext.define('PMG.LDAPGroupEditor', {
+    extend: 'Proxmox.window.Edit',
+    alias: 'widget.pmgLDAPGroupEditor',
+
+    width: 500,
+
+    items: { xtype: 'pmgLDAPGroupInputPanel' }
+});
diff --git a/js/LDAPGroupSelector.js b/js/LDAPGroupSelector.js
new file mode 100644 (file)
index 0000000..0fcb4fb
--- /dev/null
@@ -0,0 +1,54 @@
+Ext.define('PMG.LDAPGroupSelector', {
+    extend: 'Ext.form.ComboBox',
+    alias: 'widget.pmgLDAPGroupSelector',
+
+    profile: undefined,
+    
+    queryMode: 'local',
+
+    store: {
+       fields: [ 'dn' ],
+       filterOnLoad: true,
+       sorters: [
+           {
+               property : 'dn',
+               direction: 'ASC'
+           }
+       ]
+    },
+
+    valueField: 'dn',
+    displayField: 'dn',
+
+    allowBlank: false,
+
+    setProfile: function(profile, force) {
+       var me = this;
+
+       if (!force && (profile === undefined || (me.profile === profile))) {
+           return;
+       }
+
+       me.profile = profile;
+
+       me.setValue('');
+
+       me.store.setProxy({
+           type: 'proxmox',
+           url: '/api2/json/config/ldap/' + me.profile + '/groups'
+       });
+
+       me.store.load();
+    },
+    
+    initComponent: function() {
+       var me = this;
+
+       me.callParent();
+
+       if (me.profile !== undefined) {
+           me.setProfile(profile, true);
+       }
+    }
+});
+
diff --git a/js/LDAPProfileSelector.js b/js/LDAPProfileSelector.js
new file mode 100644 (file)
index 0000000..102c663
--- /dev/null
@@ -0,0 +1,57 @@
+Ext.define('PMG.LDAPProfileSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    alias: 'widget.pmgLDAPProfileSelector',
+
+    store: {
+       fields: [ 'profile', 'disable', 'comment' ],
+       proxy: {
+           type: 'proxmox',
+           url: '/api2/json/config/ldap',
+       },
+       filterOnLoad: true,
+       sorters: [
+           {
+               property : 'profile',
+               direction: 'ASC'
+           }
+       ]
+    },
+
+    valueField: 'profile',
+    displayField: 'profile',
+
+    allowBlank: false,
+
+    listConfig: {
+       columns: [
+           {
+               header: gettext('Profile'),
+               dataIndex: 'profile',
+               hideable: false,
+               width: 100
+           },
+           {
+               header: gettext('Enabled'),
+               width: 80,
+               sortable: true,
+               dataIndex: 'disable',
+               renderer: Proxmox.Utils.format_neg_boolean
+           },
+           {
+               header: gettext('Comment'),
+               sortable: false,
+               renderer: Ext.String.htmlEncode,
+               dataIndex: 'comment',
+               flex: 1
+           }
+       ]
+    },
+
+    initComponent: function() {
+       var me = this;
+
+       me.callParent();
+
+       me.store.load();
+    }
+});
index dbfed8fef82afee5ab442a6915f8d1c4e27bfbd9..e5432632f8617346a4626e20c3e13b38abec2b0d 100644 (file)
@@ -3,6 +3,9 @@ JSSRC=                                                  \
        LoginWindow.js                                  \
        ServerStatus.js                                 \
        ServerAdministration.js                         \
+       LDAPProfileSelector.js                          \
+       LDAPGroupSelector.js                            \
+       LDAPGroupEditor.js                              \
        ObjectGroupList.js                              \
        ObjectGroup.js                                  \
        ObjectGroupSelector.js                          \
index ce6935851db7f8d4931c7e8df6b6ee1a772e28ea..2f84d3d065510c2beb597f0eff4d98fa4d19461b 100644 (file)
@@ -139,7 +139,7 @@ Ext.define('PMG.ObjectGroup', {
            config.subject = full_subject(editor.subject, rec.data.receivertest);
            config.url = me.baseurl + '/' + editor.subdir + '/' + rec.data.id;
 
-           var win = Ext.createWidget('proxmoxWindowEdit', config);
+           var win = Ext.createWidget(config);
 
            win.load();
            win.on('destroy', reload);
@@ -162,7 +162,7 @@ Ext.define('PMG.ObjectGroup', {
                        return;
                    }
                    config.url = me.baseurl + '/' + editor.subdir;
-                   var win = Ext.createWidget('proxmoxWindowEdit', config);
+                   var win = Ext.create(config);
                    win.on('destroy', reload);
                    win.show();
                }
index 729e8ce93918d3694f2b5cc8cdf050e34906f41a..962e375f6da83884d1a00efb0fd1663869994a10 100644 (file)
@@ -72,7 +72,7 @@ Ext.define('PMG.WhoConfiguration', {
     alias: 'widget.pmgWhoConfiguration',
 
     ogclass: 'who',
-    otype_list: [1000, 1001, 1002, 1003, 1004]
+    otype_list: [1000, 1001, 1002, 1003, 1004, 1005]
 });
 
 Ext.define('PMG.WhenConfiguration', {
index 39c1f3ffa726099e8e9166c27d1efb702665c19a..cd30107d79cb19153189b464fccd2d476297a34e 100644 (file)
@@ -70,18 +70,12 @@ Ext.define('PMG.SpamDetectorLanguagesInputPanel', {
     ],
 
     onGetValues: function(values) {
-       console.log("on get values");
-
-       console.dir(values);
-
        if (!values.languages) {
            values['delete'] = 'languages';
        } else if (Ext.isArray(values.languages)) {
            values.languages = values.languages.join(' ')
        }
 
-       console.dir(values);
-
        return values;
     },
 
index 9b7d112f37ed99a5ca5bb92785fd317acc16197b..9c5005c661a16d79aea51a970774cd22a24257dc 100644 (file)
@@ -10,6 +10,7 @@ Ext.define('PMG.Utils', {
 
     senderText: gettext('Sender'),
     receiverText: gettext('Receiver'),
+    anyProfileText: gettext('Any Profile'),
 
     oclass_text: {
        who: gettext('Who Objects'),
@@ -45,6 +46,7 @@ Ext.define('PMG.Utils', {
 
     object_editors: {
        1000: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'regex',
            subject: gettext("Regular Expression"),
            width: 400,
@@ -57,7 +59,13 @@ Ext.define('PMG.Utils', {
                }
            ]
        },
+       1005: {
+           xtype: 'pmgLDAPGroupEditor',
+           subdir: 'ldap',
+           subject: gettext("LDAP Group")
+       },
        1009: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'receiver_regex',
            subject: gettext("Regular Expression"),
            receivertest: true,
@@ -72,6 +80,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1001: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'email',
            subject: gettext("Email"),
            width: 400,
@@ -84,6 +93,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1007: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'receiver',
            subject: gettext("Email"),
            receivertest: true,
@@ -97,6 +107,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1002: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'domain',
            subject: gettext("Domain"),
            width: 400,
@@ -109,6 +120,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1008: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'receiver_domain',
            subject: gettext("Domain"),
            receivertest: true,
@@ -122,6 +134,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1003: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'ip',
            subject: gettext("IP Address"),
            width: 400,
@@ -134,6 +147,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        1004: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'network',
            subject: gettext("IP Network"),
            width: 400,
@@ -146,6 +160,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        2000: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'timeframe',
            subject: gettext("TimeFrame"),
            items: [
@@ -164,6 +179,7 @@ Ext.define('PMG.Utils', {
            ]
        },
        4005: {
+           xtype: 'proxmoxWindowEdit',
            subdir: 'bcc',
            subject: gettext('BCC'),
            width: 400,