From 199d6815d49617b4b438a93ccf99e1e4e32a6221 Mon Sep 17 00:00:00 2001 From: Petr Voborník Date: Wed, 25 Jan 2012 13:06:15 +0100 Subject: Automember UI New UI for automember. Implemented: * search facet core * rule details facet * attribute_table_widget - new base class for tables which contains multivalued attribute with special add/remove commands * adding/removing conditions in details facet TODO: * label translations * UI for defining default rules https://fedorahosted.org/freeipa/ticket/2195 --- install/ui/Makefile.am | 1 + install/ui/automember.js | 461 +++++++++++++++++++++ install/ui/facet.js | 13 +- install/ui/index.html | 1 + install/ui/jsl.conf | 1 + install/ui/test/data/automembergroup_add.json | 21 + .../ui/test/data/automembergroup_find_pkeys.json | 24 ++ .../ui/test/data/automembergroup_get_records.json | 27 ++ install/ui/test/data/automembergroup_show.json | 31 ++ install/ui/test/data/automemberhostgroup_add.json | 21 + .../test/data/automemberhostgroup_find_pkeys.json | 24 ++ .../test/data/automemberhostgroup_get_records.json | 27 ++ install/ui/test/data/automemberhostgroup_show.json | 30 ++ install/ui/test/data/ipa_init.json | 1 + install/ui/webui.js | 9 +- install/ui/widget.js | 351 +++++++++++++++- 16 files changed, 1039 insertions(+), 4 deletions(-) create mode 100644 install/ui/automember.js create mode 100644 install/ui/test/data/automembergroup_add.json create mode 100644 install/ui/test/data/automembergroup_find_pkeys.json create mode 100644 install/ui/test/data/automembergroup_get_records.json create mode 100644 install/ui/test/data/automembergroup_show.json create mode 100644 install/ui/test/data/automemberhostgroup_add.json create mode 100644 install/ui/test/data/automemberhostgroup_find_pkeys.json create mode 100644 install/ui/test/data/automemberhostgroup_get_records.json create mode 100644 install/ui/test/data/automemberhostgroup_show.json (limited to 'install') diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am index 822a6282..d87a0944 100644 --- a/install/ui/Makefile.am +++ b/install/ui/Makefile.am @@ -11,6 +11,7 @@ app_DATA = \ aci.js \ add.js \ association.js \ + automember.js \ automount.js \ browser.js \ certificate.js \ diff --git a/install/ui/automember.js b/install/ui/automember.js new file mode 100644 index 00000000..d6c3c7ee --- /dev/null +++ b/install/ui/automember.js @@ -0,0 +1,461 @@ +/*jsl:import ipa.js */ + +/* Authors: + * Petr Vobornik + * + * Copyright (C) 2012 Red Hat + * see file 'COPYING' for use and warranty information + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */ + +IPA.automember = {}; + +IPA.automember.entity = function(spec) { + + //HACK: Automember takes_params is missing a cn attribute. This hack + //copies cn from mod command. Also it is set as pkey. + var pkey_attr = IPA.metadata.commands.automember_mod.takes_args[0]; + pkey_attr.primary_key = true; + IPA.metadata.objects.automember.takes_params.push(pkey_attr); + IPA.metadata.objects.automember.primary_key = pkey_attr.name; + + var that = IPA.entity(spec); + + that.init = function() { + + that.entity_init(); + + that.builder.search_facet({ + factory: IPA.automember.rule_search_facet, + name: 'searchgroup', + group_type: 'group', + label: 'User group rules', //TODO: translate + details_facet: 'usergrouprule', + columns: [ + 'cn', + 'description' + ] + }). + search_facet({ + factory: IPA.automember.rule_search_facet, + name: 'searchhostgroup', + group_type: 'hostgroup', + label: 'Host group rules', //TODO: translate + details_facet: 'hostgrouprule', + columns: [ + 'cn', + 'description' + ] + }). + details_facet({ + factory: IPA.automember.rule_details_facet, + name: 'usergrouprule', + group_type: 'group', + label: 'User group rule', //TODO: translate + disable_facet_tabs: true, + redirect_info: { tab: 'amgroup' } + }). + details_facet({ + factory: IPA.automember.rule_details_facet, + name: 'hostgrouprule', + group_type: 'hostgroup', + label: 'Host group rule',//TODO: translate + disable_facet_tabs: true, + redirect_info: { tab: 'amhostgroup' } + }). + adder_dialog({ + factory: IPA.automember.rule_adder_dialog, + fields: [ + { + type: 'entity_select', + name: 'cn', + other_entity: 'group', + other_field: 'cn' + } + ], + height: '300' + }). + deleter_dialog({ + factory: IPA.automember.rule_deleter_dialog + }); + }; + + return that; +}; + + +IPA.automember.rule_search_facet = function(spec) { + + spec = spec || {}; + + var that = IPA.search_facet(spec); + + that.group_type = spec.group_type; + + that.get_records_command_name = function() { + return that.managed_entity.name + that.group_type+'_get_records'; + }; + + that.get_search_command_name = function() { + var name = that.managed_entity.name + that.group_type + '_find'; + if (that.pagination && !that.search_all_entries) { + name += '_pkeys'; + } + return name; + }; + + that.create_get_records_command = function(pkeys, on_success, on_error) { + + var batch = that.table_facet_create_get_records_command(pkeys, on_success, on_error); + + for (var i=0; i= 0) { + if (results[i].completed === 1){ + that.reload_facet({ result: results[i] }); + return; + } + i--; + } + + that.refresh_facet(); + }; + + that.create_remove_command = function(values, on_success, on_error) { + + var batch = IPA.batch_command({ + name: 'automember_remove_condition', + on_success: on_success, + on_error: on_error + }); + + var pkeys = that.get_pkeys(); + + for (var i=0; i + diff --git a/install/ui/jsl.conf b/install/ui/jsl.conf index 7373e987..508897af 100644 --- a/install/ui/jsl.conf +++ b/install/ui/jsl.conf @@ -155,4 +155,5 @@ +process aci.js +process dns.js +process automount.js ++process automember.js +process webui.js diff --git a/install/ui/test/data/automembergroup_add.json b/install/ui/test/data/automembergroup_add.json new file mode 100644 index 00000000..7b896d2a --- /dev/null +++ b/install/ui/test/data/automembergroup_add.json @@ -0,0 +1,21 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automembertargetgroup": [ + "cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foogroup" + ], + "dn": "cn=foogroup,cn=group,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + }, + "summary": "Added automember rule \"foogroup\"", + "value": "foogroup" + } +} \ No newline at end of file diff --git a/install/ui/test/data/automembergroup_find_pkeys.json b/install/ui/test/data/automembergroup_find_pkeys.json new file mode 100644 index 00000000..c8918c6c --- /dev/null +++ b/install/ui/test/data/automembergroup_find_pkeys.json @@ -0,0 +1,24 @@ +{ + "error": null, + "id": null, + "result": { + "count": 1, + "result": [ + { + "automembertargetgroup": [ + "cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foogroup" + ], + "dn": "cn=foogroup,cn=group,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + } + ], + "summary": "1 rules matched", + "truncated": false + } +} \ No newline at end of file diff --git a/install/ui/test/data/automembergroup_get_records.json b/install/ui/test/data/automembergroup_get_records.json new file mode 100644 index 00000000..82bcc710 --- /dev/null +++ b/install/ui/test/data/automembergroup_get_records.json @@ -0,0 +1,27 @@ +{ + "error": null, + "id": null, + "result": { + "count": 1, + "results": [ + { + "error": null, + "result": { + "automembertargetgroup": [ + "cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foogroup" + ], + "dn": "cn=foogroup,cn=group,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + }, + "summary": null, + "value": "foogroup" + } + ] + } +} \ No newline at end of file diff --git a/install/ui/test/data/automembergroup_show.json b/install/ui/test/data/automembergroup_show.json new file mode 100644 index 00000000..4b3f0b91 --- /dev/null +++ b/install/ui/test/data/automembergroup_show.json @@ -0,0 +1,31 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberexclusiveregex": [ + "cn=^user5", + "cn=^user6" + ], + "automemberinclusiveregex": [ + "cn=^user[0-9]+" + ], + "automembertargetgroup": [ + "cn=foogroup,cn=groups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foogroup" + ], + "description": [ + "userrule description" + ], + "dn": "cn=foogroup,cn=group,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + }, + "summary": null, + "value": "foogroup" + } +} \ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_add.json b/install/ui/test/data/automemberhostgroup_add.json new file mode 100644 index 00000000..e58d2188 --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_add.json @@ -0,0 +1,21 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automembertargetgroup": [ + "cn=foohostgroup,cn=hostgroups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foohostgroup" + ], + "dn": "cn=foohostgroup,cn=hostgroup,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + }, + "summary": "Added automember rule \"foohostgroup\"", + "value": "foohostgroup" + } +} \ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_find_pkeys.json b/install/ui/test/data/automemberhostgroup_find_pkeys.json new file mode 100644 index 00000000..90968346 --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_find_pkeys.json @@ -0,0 +1,24 @@ +{ + "error": null, + "id": null, + "result": { + "count": 1, + "result": [ + { + "automembertargetgroup": [ + "cn=foohostgroup,cn=hostgroups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foohostgroup" + ], + "dn": "cn=foohostgroup,cn=hostgroup,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + } + ], + "summary": "1 rules matched", + "truncated": false + } +} \ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_get_records.json b/install/ui/test/data/automemberhostgroup_get_records.json new file mode 100644 index 00000000..6ae23e32 --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_get_records.json @@ -0,0 +1,27 @@ +{ + "error": null, + "id": null, + "result": { + "count": 1, + "results": [ + { + "error": null, + "result": { + "automembertargetgroup": [ + "cn=foohostgroup,cn=hostgroups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foohostgroup" + ], + "dn": "cn=foohostgroup,cn=hostgroup,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + }, + "summary": null, + "value": "foohostgroup" + } + ] + } +} \ No newline at end of file diff --git a/install/ui/test/data/automemberhostgroup_show.json b/install/ui/test/data/automemberhostgroup_show.json new file mode 100644 index 00000000..e3f7814a --- /dev/null +++ b/install/ui/test/data/automemberhostgroup_show.json @@ -0,0 +1,30 @@ +{ + "error": null, + "id": null, + "result": { + "result": { + "automemberexclusiveregex": [ + "fqdn=^web5.example.com" + ], + "automemberinclusiveregex": [ + "fqdn=^web[1-9]+.example.com" + ], + "automembertargetgroup": [ + "cn=foohostgroup,cn=hostgroups,cn=accounts,dc=dev,dc=example,dc=com" + ], + "cn": [ + "foohostgroup" + ], + "description": [ + "hostrule description" + ], + "dn": "cn=foohostgroup,cn=hostgroup,cn=automember,cn=etc,dc=dev,dc=example,dc=com", + "objectclass": [ + "top", + "automemberregexrule" + ] + }, + "summary": null, + "value": "foohostgroup" + } +} \ No newline at end of file diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index fc8ec06b..7b1b0d0a 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -368,6 +368,7 @@ }, "tabs": { "audit": "Audit", + "automember": "Automember", "automount": "Automount", "dns": "DNS", "hbac": "Host Based Access Control", diff --git a/install/ui/webui.js b/install/ui/webui.js index 59609734..42a85369 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -68,7 +68,14 @@ IPA.admin_navigation = function(spec) { {entity: 'automountkey', hidden: true}]}, {entity: 'pwpolicy'}, {entity: 'krbtpolicy'}, - {entity: 'selinuxusermap'} + {entity: 'selinuxusermap'}, + {name: 'automember', label: 'Automember', //TODO: translate IPA.messages.tabs.automember + children: [ + { name: 'amgroup', entity: 'automember', + facet: 'searchgroup', label: 'User group rules'}, //TODO: translate + { name: 'amhostgroup', entity: 'automember', + facet: 'searchhostgroup', label: 'Host group rules'} //TODO: translate + ]} ]}, {name: 'ipaserver', label: IPA.messages.tabs.ipaserver, children: [ {name: 'rolebased', label: IPA.messages.tabs.role, children: [ diff --git a/install/ui/widget.js b/install/ui/widget.js index 04c35bb6..807191e5 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -1678,6 +1678,355 @@ IPA.table_widget = function (spec) { return that; }; + +IPA.attribute_table_widget = function(spec) { + + + spec = spec || {}; + spec.columns = spec.columns || []; + + var that = IPA.table_widget(spec); + + that.attribute_name = spec.attribute_name || that.name; + that.adder_dialog_spec = spec.adder_dialog; + that.css_class = spec.css_class; + + that.add_command = spec.add_command; + that.remove_command = spec.remove_command; + + that.on_add = spec.on_add; + that.on_add_error = spec.on_add_error; + that.on_remove = spec.on_remove; + that.on_remove_error = spec.on_remove_error; + + that.create_column = function(spec) { + + if (typeof spec === 'string') { + spec = { + name: spec + }; + } + + spec.entity = that.entity; + + var factory = spec.factory || IPA.column; + + var column = factory(spec); + that.add_column(column); + return column; + }; + + that.create_columns = function() { + that.clear_columns(); + if (spec.columns) { + for (var i=0; i