Hi Adam,

Thanks for the update. I found a problem, the "this.pkey" in the
callback function below is undefined so it won't load the values back
in the details page.

diff --git a/install/static/associate.js b/install/static/associate.js
index dabc76c..ae1f4af 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -90,10 +90,10 @@ function BulkAssociator(form, pkey, manyObjPkeys){
                  function(response){
                      var qs = ipa_parse_qs();
                      if (response.error){
-                         alert("error adding memeber");
+                         alert("error adding member");
                      }else{
                          location.hash="tab=" +form.oneObj
-                             +"&facet=details&pkey="+this.pkey;
+                             +"&facet=details&pkey="+pkey;
                      }
                  },
                  function(response){

Attached is the service tab I've been working on. Sometimes the
enrollment page doesn't work quite right. When I click "Find" it
will show the available hosts, but sometimes it would replace the
list immediately with the list of available users. Probably the
previous "click" handler still got called somehow.

--
Endi S. Dewata

----- "Adam Young" <ayo...@redhat.com> wrote:

> Updated version that provides the means to overload the method called.
>  
> This was requested by edewata to support services.  I also simplified
> 
> some of the internal code .
> 
> https://fedorahosted.org/freeipa/attachment/ticket/104/admiyo-freeipa-0019-2-associations.patch
> 
> _______________________________________________
> Freeipa-devel mailing list
> Freeipa-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel
>From 08623db1acd6a5b890abf5f9d401a3dedb3c3829 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Thu, 2 Sep 2010 04:14:57 -0400
Subject: [PATCH] Added Services tab.

---
 install/static/Makefile.am                  |    1 +
 install/static/index.xhtml                  |    1 +
 install/static/navigation.js                |    7 ++-
 install/static/sampledata/service_find.json |   35 ++++++++++
 install/static/sampledata/service_show.json |   23 ++++++
 install/static/service.js                   |   97 +++++++++++++++++++++++++++
 6 files changed, 162 insertions(+), 2 deletions(-)
 create mode 100644 install/static/sampledata/service_find.json
 create mode 100644 install/static/sampledata/service_show.json
 create mode 100644 install/static/service.js

diff --git a/install/static/Makefile.am b/install/static/Makefile.am
index 63e5894..b0c4c7f 100644
--- a/install/static/Makefile.am
+++ b/install/static/Makefile.am
@@ -19,6 +19,7 @@ app_DATA =                              \
 	jquery.cookie.js 		\
 	navigation.js			\
 	netgroup.js 			\
+	service.js 			\
 	pageparams.js 			\
 	search.js 			\
 	details.js 			\
diff --git a/install/static/index.xhtml b/install/static/index.xhtml
index 4077d4f..6e1d043 100644
--- a/install/static/index.xhtml
+++ b/install/static/index.xhtml
@@ -20,6 +20,7 @@
     <script type="text/javascript" src="host.js"></script>
     <script type="text/javascript" src="hostgroup.js"></script>
     <script type="text/javascript" src="netgroup.js"></script>
+    <script type="text/javascript" src="service.js"></script>
 
     <script type="text/javascript">
 
diff --git a/install/static/navigation.js b/install/static/navigation.js
index 94fe47a..ed19077 100644
--- a/install/static/navigation.js
+++ b/install/static/navigation.js
@@ -24,6 +24,7 @@ function getParentTabs(){
         host     : "identity",
         hostgroup: "identity",
         netgroup : "identity",
+        service  : "identity",
         policy   : "policy",
         config   : "config"
     };
@@ -54,7 +55,8 @@ function buildNavigation(){
             {name:"Hostgroups",
              tab:"hostgroup",
              setup:  setupHostgroup},
-            {name:"Netgroups",tab:"netgroup", setup:setupNetgroup}
+            {name:"Netgroups",tab:"netgroup", setup:setupNetgroup},
+            {name:"Services",tab:"service", setup:setupService}
             ]},
            {name:"POLICY",  tab:"policy", setup: unimplemented},
            {name:"CONFIG",  tab:"config", setup: unimplemented }];
@@ -139,6 +141,7 @@ function getSetupFunctions(){
         host:     setupHost,
         hostgroup:setupHostgroup,
         netgroup:setupNetgroup,
+        service:setupService,
     };
     }
     return setupFunctions;
@@ -236,4 +239,4 @@ function showDetails(){
 function showAssociations(){
     clearOld();
     $('#associations').css("display","block");
-}
\ No newline at end of file
+}
diff --git a/install/static/sampledata/service_find.json b/install/static/sampledata/service_find.json
new file mode 100644
index 0000000..a4b0548
--- /dev/null
+++ b/install/static/sampledata/service_find.json
@@ -0,0 +1,35 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "count": 2, 
+        "result": [
+            {
+                "dn": "krbprincipalname=ldap/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+                "has_keytab": true, 
+                "krbprincipalname": [
+                    "ldap/dev.example....@dev.example.com"
+                ], 
+                "usercertificate": [
+                    {
+                        "__base64__": "MIICbjCCAdegAwIBAgICA+0wDQYJKoZIhvcNAQEFBQAwKTEnMCUGA1UEAxMeSVBBIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTEwMDkwMjA2NTYzMloXDTIwMDkwMjA2NTYzMlowKDEMMAoGA1UEChMDSVBBMRgwFgYDVQQDEw9kZXYuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDc63RjpqUCI84j9kjn0XYmpAOjkYbLddT9F0UUanASg1iIhscwWjvp/Mf5ZIzEYoB+dloI9gvEUWb8CU/x42QZr4lgEK4m/vCSDA0CkAnWvU/DHdtcAgpdZeBOQ1CMynyvNvN/ajyaA8dPwRcs9yJDrWXMa7LzMuw+ct5HA7HRdDdvUeIFr8YZEd/Mt1N96BmlVf3GA3P89cWfCKr1iVnmyewanjKuwcws1GCxawCnp0w1GHbKct4PPhB3k6EN8ZipFDGZmSeDVsa3gF7y2reLAYTS1/RwWPAHNeQ0cpOMe155cF3uHGSoX+RWtgo0BZ1+wgLMU5sf9W3ZMln3WmoFAgMBAAGjIjAgMBEGCWCGSAGG+EIBAQQEAwIGQDALBgNVHQ8EBAMCBSAwDQYJKoZIhvcNAQEFBQADgYEAbSYTU+IQvfppQE7setcpO/PiFNnMaZ3Ss7UGjm6XoPem9X0ktQOfWhBuhfH/7MbPdg2zn+55soaRpd8rOThr187G40GAMM5I3Jr+8386Q4zwCvED7B09pzBhQd/4ecVTIYFc82EytsM6I1aBrG9cLLuT+RL2dK5efOymCf/zjsw="
+                    }
+                ]
+            }, 
+            {
+                "dn": "krbprincipalname=http/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+                "has_keytab": true, 
+                "krbprincipalname": [
+                    "HTTP/dev.example....@dev.example.com"
+                ], 
+                "usercertificate": [
+                    {
+                        "__base64__": "MIICbjCCAdegAwIBAgICA+4wDQYJKoZIhvcNAQEFBQAwKTEnMCUGA1UEAxMeSVBBIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTEwMDkwMjA2NTY1MFoXDTIwMDkwMjA2NTY1MFowKDEMMAoGA1UEChMDSVBBMRgwFgYDVQQDEw9kZXYuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2g0DTtC0f7StYfbVqc3bZ6niWHCBZp9SVEgD1lGY9+efQnO1Z6dqbUxLI+oUcVqA2aoeWVSTQ1KZLglF0pYUJcMVfUAQaFbwhY05rLtKya0+6DgYbnJ187fSHNOLQ71v/6pFt9THyLFICFJgKX64ouQYxV7+UY/vyqaKCjonWBJznJHaw07cEYj6tFkQxwNIhQRWZP2yLrSEay1cDLtA7Rm6AYRKIhiBKwFVewi4VEo6HbgfKpeZRZ2G8w1UErxTuPom2WymByoOg1Z8Xn23OiW+CkcrwRFhDYyp3LRiIT+86fPYkF4TBqO9lWbxKy4ZtcHXfMcGBmQSc3yjN+IctAgMBAAGjIjAgMBEGCWCGSAGG+EIBAQQEAwIGQDALBgNVHQ8EBAMCBSAwDQYJKoZIhvcNAQEFBQADgYEAi1vdSKmUUPdkwxv6tnabo6sEpTCdyV33Jops5hMkdtIKsvOG+CeXuvPYIwZpvwozAppL3tcXsh6t35YklpjeoX8qX5gYTZvuusCUAQHfJC4H/ggU+TrjQW5GnGOLTpgew/NtLKj7LACp/YrwMNA5ktdsBbj2kESIEVlokLvITy4="
+                    }
+                ]
+            }
+        ], 
+        "summary": "2 services matched", 
+        "truncated": false
+    }
+}
\ No newline at end of file
diff --git a/install/static/sampledata/service_show.json b/install/static/sampledata/service_show.json
new file mode 100644
index 0000000..e1fc3c2
--- /dev/null
+++ b/install/static/sampledata/service_show.json
@@ -0,0 +1,23 @@
+{
+    "error": null, 
+    "id": 0, 
+    "result": {
+        "result": {
+            "dn": "krbprincipalname=ldap/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com", 
+            "has_keytab": true, 
+            "krbprincipalname": [
+                "ldap/dev.example....@dev.example.com"
+            ], 
+            "managedby_host": [
+                "dev.example.com"
+            ], 
+            "usercertificate": [
+                {
+                    "__base64__": "MIICbjCCAdegAwIBAgICA+0wDQYJKoZIhvcNAQEFBQAwKTEnMCUGA1UEAxMeSVBBIFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTEwMDkwMjA2NTYzMloXDTIwMDkwMjA2NTYzMlowKDEMMAoGA1UEChMDSVBBMRgwFgYDVQQDEw9kZXYuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDc63RjpqUCI84j9kjn0XYmpAOjkYbLddT9F0UUanASg1iIhscwWjvp/Mf5ZIzEYoB+dloI9gvEUWb8CU/x42QZr4lgEK4m/vCSDA0CkAnWvU/DHdtcAgpdZeBOQ1CMynyvNvN/ajyaA8dPwRcs9yJDrWXMa7LzMuw+ct5HA7HRdDdvUeIFr8YZEd/Mt1N96BmlVf3GA3P89cWfCKr1iVnmyewanjKuwcws1GCxawCnp0w1GHbKct4PPhB3k6EN8ZipFDGZmSeDVsa3gF7y2reLAYTS1/RwWPAHNeQ0cpOMe155cF3uHGSoX+RWtgo0BZ1+wgLMU5sf9W3ZMln3WmoFAgMBAAGjIjAgMBEGCWCGSAGG+EIBAQQEAwIGQDALBgNVHQ8EBAMCBSAwDQYJKoZIhvcNAQEFBQADgYEAbSYTU+IQvfppQE7setcpO/PiFNnMaZ3Ss7UGjm6XoPem9X0ktQOfWhBuhfH/7MbPdg2zn+55soaRpd8rOThr187G40GAMM5I3Jr+8386Q4zwCvED7B09pzBhQd/4ecVTIYFc82EytsM6I1aBrG9cLLuT+RL2dK5efOymCf/zjsw="
+                }
+            ]
+        }, 
+        "summary": null, 
+        "value": "ldap/dev.example....@dev.example.com"
+    }
+}
\ No newline at end of file
diff --git a/install/static/service.js b/install/static/service.js
new file mode 100644
index 0000000..87a0ab4
--- /dev/null
+++ b/install/static/service.js
@@ -0,0 +1,97 @@
+function setupService(facet) {
+    serviceForms.setup(facet);
+}
+
+var serviceForms = new ServiceForms();
+
+function ServiceForms() {
+
+    this.obj = "service";
+
+    this.serviceFacets = ['details', 'hosts', 'assignhosts'];
+
+    this.setup = function(facet) {
+        if (this[facet]) {
+            this[facet].setup();
+        } else {
+            this.unspecified.setup();
+        }
+    };
+
+    this.hostListColumns = [ {title:"host",column:"managedby_host"} ];
+
+    this.hosts = new AssociationList(
+        this.obj,
+        "hosts",
+        "assignhosts",
+        this.hostListColumns,
+        this.serviceFacets
+    );
+
+    this.assignhosts = new AssociationForm(
+        this.obj,
+        "host",
+        "assignhosts",
+        this.serviceFacets,
+        "fqdn",
+        function() {
+            return 'Add Hosts to service : ' + qs['pkey'];
+        },
+        BulkAssociator,
+        "add_host"
+    );
+
+    this.serviceDetailsList = [
+        ['identity', 'Service Details', [
+            ['krbprincipalname', 'Kerberos Principal'],
+            ['has_keytab', 'Has Keytab']
+        ]]
+    ];
+
+    this.details = new DetailsForm(
+        "service",
+        this.serviceDetailsList,
+        "krbprincipalname",
+        this.serviceFacets
+    );
+
+    this.serviceAddProperties = [
+        {title: 'Principal', id: 'pkey', type: 'text'}
+    ];
+
+    this.serviceAddOptionsFunction = function() {
+        var options = {
+            name: $('#pkey').val()
+        };
+        return options;
+    };
+
+    this.add = new EntityBuilder(
+        "service",
+        this.serviceAddProperties,
+        this.serviceAddOptionsFunction
+    );
+
+    this.serviceSearchColumns = [
+        {
+            title: "Service",
+            column: "krbprincipalname",
+            render: function (current, cell) {
+                renderPkeyColumn2('service', 'krbprincipalname', current, cell);
+            }
+        },
+        {
+            title: "Has Keytab",
+            column: "has_keytab",
+            render: renderSimpleColumn
+        }
+    ];
+
+    this.search = new SearchForm(
+        "service",
+        "find",
+        this.serviceSearchColumns
+    );
+
+    this.unspecified = this.search;
+}
-- 
1.7.2.2

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

Reply via email to