Re: [Freeipa-devel] [PATCH] 073 Automember UI

2012-02-01 Thread Endi Sukma Dewata

On 1/31/2012 9:33 AM, Petr Vobornik wrote:

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 (will follow):
* label translations
* UI for defining default rules

Note: depends on my patch #72


ACK. Pushed to master and ipa-2-2.

As you mentioned in the earlier patch, the automember is one entity but 
it behaves like two separate entities for group and hostgroup. And the 
navigation map is composed of entities so that's why you had to fix the 
navigation code to be able to distinguish the facets for automember 
group and hostgroup.


I've been thinking we might want to detach the 1-1 relationship between 
the server plugin and the UI entity. This way we could define an entity 
that can encapsulate the interactions with multiple server plugins, or 
multiple entities using the same plugins like automember. So instead of 
calling IPA.command directly, the facet will call a method in the entity 
and it will execute the appropriate command(s). The command could be a 
batch and the entity could merge the results into a single object which 
can be handled by the facet more easily. In other words the entity will 
become the persistent layer.


Another thing, right now in the fields spec we specify the widgets that 
the fields going to use (I know I suggested it :)). Maybe it should have 
been the other way around. So in the widgets spec we specify the fields 
that the widgets are mapped to. This is related to the above point, the 
field will be part of persistent layer too. The facets and widgets are 
the clients of the persistent layer. The fields could later be moved 
into the entity definition. The facets will only contain widgets.


About the navigation map and entities, we could probably detach them 
too, but it can be discussed later.


--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 073 Automember UI

2012-01-31 Thread Petr Vobornik

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 (will follow):
 * label translations
 * UI for defining default rules

Note: depends on my patch #72
--
Petr Vobornik
From c268e263dad36df5dd8ed0c6582a84f816e5d556 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Voborn=C3=ADk?= 
Date: Wed, 25 Jan 2012 13:06:15 +0100
Subject: [PATCH] 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

diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index 822a6282f3a447e24282e4112df2e63457890fa7..d87a0944ca47e1885a9a2781e6ed03e30c662fe6 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 ..d6c3c7ee730b7e2d260aadda179b867dbe12610c
--- /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',
+