diff options
author | Petr VobornÃk <pvoborni@redhat.com> | 2012-02-02 17:55:36 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2012-02-07 00:48:07 -0600 |
commit | fccea2dca4d384ab2992103916cfe8801be53edd (patch) | |
tree | 22ba0f8f4bde3d55ee9ad23d251a0991fec787eb | |
parent | e6cdcad8df8712a5f452a74a3f3186146ef1e04b (diff) | |
download | freeipa-fccea2dca4d384ab2992103916cfe8801be53edd.tar.gz freeipa-fccea2dca4d384ab2992103916cfe8801be53edd.tar.xz freeipa-fccea2dca4d384ab2992103916cfe8801be53edd.zip |
Automember UI - default groups
In this patch was implemented and added a control for defining default automember groups.
There is a difference from UXD spec. In the spec the control was placed below table in the search facet. This was not working well with the combobox in the control. Open combobox requires some space below it. As it was placed at the bottom of the page it created unwanted blank space and forced showing scrollbars. Moving the control above the table solves the problem without rewriting combobox logic. It can be rewritten and moved down later.
https://fedorahosted.org/freeipa/ticket/2195
-rw-r--r-- | install/ui/automember.js | 186 | ||||
-rw-r--r-- | install/ui/ipa.css | 34 | ||||
-rw-r--r-- | install/ui/test/data/automembergroup_default_group_remove.json | 14 | ||||
-rw-r--r-- | install/ui/test/data/automembergroup_default_group_set.json | 16 | ||||
-rw-r--r-- | install/ui/test/data/automembergroup_default_group_show.json | 17 | ||||
-rw-r--r-- | install/ui/test/data/automemberhostgroup_default_group_remove.json | 14 | ||||
-rw-r--r-- | install/ui/test/data/automemberhostgroup_default_group_set.json | 16 | ||||
-rw-r--r-- | install/ui/test/data/automemberhostgroup_default_group_show.json | 15 | ||||
-rw-r--r-- | install/ui/widget.js | 5 |
9 files changed, 315 insertions, 2 deletions
diff --git a/install/ui/automember.js b/install/ui/automember.js index d6c3c7ee7..e9b48dc87 100644 --- a/install/ui/automember.js +++ b/install/ui/automember.js @@ -106,6 +106,21 @@ IPA.automember.rule_search_facet = function(spec) { that.group_type = spec.group_type; + var init = function() { + + that.default_group_widget = IPA.automember.default_group_widget({ + entity: that.entity, + group_type: that.group_type + }); + }; + + that.refresh = function() { + + that.search_facet_refresh(); + that.default_group_widget.refresh(); + }; + + that.get_records_command_name = function() { return that.managed_entity.name + that.group_type+'_get_records'; }; @@ -139,6 +154,23 @@ IPA.automember.rule_search_facet = function(spec) { return command; }; + that.create_content = function(container) { + + var header = $('<div/>', { + 'class': 'automember-header' + }).appendTo(container); + + var content = $('<div/>', { + 'class': 'automember-content' + }).appendTo(container); + + that.default_group_widget.create(header); + that.table.create(content); + + }; + + init(); + return that; }; @@ -458,4 +490,158 @@ IPA.automember.condition_widget = function(spec) { IPA.widget_factories['automember_condition'] = IPA.automember.condition_widget; +IPA.automember.default_group_widget = function(spec) { + + spec = spec || {}; + + var that = IPA.widget(spec); + that.group_type = spec.group_type; + that.group = ''; + + var init = function() { + + that.group_select = IPA.entity_select_widget({ + name: 'automemberdefaultgroup', + other_entity: that.group_type, + other_field: 'cn', + show_undo: false + }); + + that.group_select.value_changed.attach(that.group_changed); + }; + + that.get_group = function() { + + var group = that.group_select.save(); + group = group.length === 0 ? '' : group[0]; + return group; + }; + + that.set_group = function(group) { + + if (group === that.group) return; + + that.group = group; + that.group_select.update([group]); + }; + + that.group_changed = function() { + + var group = that.get_group(); + + if (group === that.group) return; + + if (group === '') { + that.remove_default_group(); + } else { + that.set_default_group(group); + } + }; + + that.load = function(data) { + + var group = data.result.result.automemberdefaultgroup; + + if (group) group = group[0]; + + if (!group || group.indexOf('cn=') === -1) { + group = ''; + } else { + //extract from dn + var i1 = group.indexOf('='); + var i2 = group.indexOf(','); + if (i1 > -1 && i2 > -1) { + group = group.substring(i1 + 1,i2); + } + } + + that.update(group); + }; + + that.update = function(group) { + + group = group || ''; + + that.set_group(group); + }; + + that.create_command = function(method) { + + method = 'default_group_' + method; + var command_name = that.entity.name + that.group_type + '_' + method; + + var command = IPA.command({ + name: command_name, + entity: that.entity.name, + method: method, + options: { + type: that.group_type + } + }); + + return command; + }; + + that.refresh = function() { + + var command = that.create_command('show'); + command.on_success = that.load; + + command.execute(); + }; + + that.remove_default_group = function() { + + var command = that.create_command('remove'); + + command.on_success = function() { + that.update(''); + }; + command.on_error = that.refresh; + + command.execute(); + }; + + that.set_default_group = function(group) { + + var command = that.create_command('set'); + command.on_success = that.load; + command.on_error = that.refresh; + command.set_option('automemberdefaultgroup', group); + + command.execute(); + }; + + + that.create = function(container) { + + var title = that.get_title(); + + var default_group = $('<div />', { + 'class': 'default_group' + }).appendTo(container); + + that.header = $('<h2/>', { + name: 'header', + text: title, + title: title + }).appendTo(default_group); + + that.group_select.create(default_group); + }; + + that.get_title = function() { + if (that.group_type === 'group') { + return 'Default user group'; //TODO: translate + } else { + return 'Default host group'; //TODO: translate + } + }; + + init(); + + return that; +}; + + IPA.register('automember', IPA.automember.entity);
\ No newline at end of file diff --git a/install/ui/ipa.css b/install/ui/ipa.css index ab61e8672..94ae1f778 100644 --- a/install/ui/ipa.css +++ b/install/ui/ipa.css @@ -1485,4 +1485,38 @@ div.entity[name=hbactest] div.facet[name=run_test] .hbac-test-content { .dnstype-table td { font-weight: normal; +} + +/* --- Automember --- */ + +.automember-header { + position: absolute; + top: 0; + left: 3px; + right: 3px; + height: 52px; +} + +.automember-content { + position: absolute; + top: 52px; + left: 0; + right: 0; + bottom: 0px; +} + +.automember-header .default_group { + border-bottom: 1px solid #DFDFDF; + border-top: 1px solid #DFDFDF; + padding-bottom: 5px; + padding-top: 8px; +} + +.automember-header .default_group h2 { + display: inline-block; + margin: 0 15px 0 20px; +} + +.automember-header .default_group label { + margin-right: 20px; }
\ No newline at end of file diff --git a/install/ui/test/data/automembergroup_default_group_remove.json b/install/ui/test/data/automembergroup_default_group_remove.json new file mode 100644 index 000000000..6df1dfe86 --- /dev/null +++ b/install/ui/test/data/automembergroup_default_group_remove.json @@ -0,0 +1,14 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberdefaultgroup": "No default group set", + "cn": [ + "Group" + ] + }, + "summary": "Removed default group for automember \"group\"", + "value": "group" + } +}
\ No newline at end of file diff --git a/install/ui/test/data/automembergroup_default_group_set.json b/install/ui/test/data/automembergroup_default_group_set.json new file mode 100644 index 000000000..2516c74ec --- /dev/null +++ b/install/ui/test/data/automembergroup_default_group_set.json @@ -0,0 +1,16 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberdefaultgroup": [ + "cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "Group" + ] + }, + "summary": "Set default group for automember \"group\"", + "value": "group" + } +}
\ No newline at end of file diff --git a/install/ui/test/data/automembergroup_default_group_show.json b/install/ui/test/data/automembergroup_default_group_show.json new file mode 100644 index 000000000..148bb4728 --- /dev/null +++ b/install/ui/test/data/automembergroup_default_group_show.json @@ -0,0 +1,17 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberdefaultgroup": [ + "cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "Group" + ], + "dn": "cn=group,cn=automember,cn=etc,dc=dev,dc=example,dc=com" + }, + "summary": null, + "value": "group" + } +}
\ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_default_group_remove.json b/install/ui/test/data/automemberhostgroup_default_group_remove.json new file mode 100644 index 000000000..4bd8a4a94 --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_default_group_remove.json @@ -0,0 +1,14 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberdefaultgroup": "No default group set", + "cn": [ + "Hostgroup" + ] + }, + "summary": "Removed default group for automember \"hostgroup\"", + "value": "hostgroup" + } +}
\ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_default_group_set.json b/install/ui/test/data/automemberhostgroup_default_group_set.json new file mode 100644 index 000000000..7837653e8 --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_default_group_set.json @@ -0,0 +1,16 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberdefaultgroup": [ + "cn=foohostgroup,cn=hostgroups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "Hostgroup" + ] + }, + "summary": "Set default group for automember \"hostgroup\"", + "value": "hostgroup" + } +}
\ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_default_group_show.json b/install/ui/test/data/automemberhostgroup_default_group_show.json new file mode 100644 index 000000000..2203f249f --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_default_group_show.json @@ -0,0 +1,15 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberdefaultgroup": "No default group set", + "cn": [ + "Hostgroup" + ], + "dn": "cn=hostgroup,cn=automember,cn=etc,dc=dev,dc=example,dc=com" + }, + "summary": null, + "value": "hostgroup" + } +}
\ No newline at end of file diff --git a/install/ui/widget.js b/install/ui/widget.js index 807191e53..2617487f7 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -2064,7 +2064,7 @@ IPA.combobox_widget = function(spec) { type: 'text', name: that.name, title: that.tooltip, - readonly: !that.editable, + readonly: !that.editable || that.read_only, keyup: function() { that.input_field_changed.notify([], that); }, @@ -2147,7 +2147,8 @@ IPA.combobox_widget = function(spec) { }; that.open = function() { - that.list_container.css('visibility', 'visible'); + if (!that.read_only) + that.list_container.css('visibility', 'visible'); }; that.close = function() { |