Hi Adam,

Thanks for the review. Attached is the revised patch.

----- "Adam Young" <ayo...@redhat.com> wrote:
> I get an error
> "associate failure" when clicking the Enroll Button on the
> associations page. You need to add sampledata/service_add_host.json

This is fixed, I forgot to do git add.

> Whitespace issues in b/install/static/sampledata/service_add.json

This is fixed, they are coming from the IPA server.

> When I tested on the live server, add failed silently. We need to
> report to the user the error message. This is something that we don't
> do on other pages yet, but we need to. The success closure needs to
> have code along the lines of:
> 
> if (result.error){
> // report errors
> }else{
> //current functionality
> }
> 
> For now just populate an alert message. I'll add a task to integrate
> per field error reporting into the add and details pages.

This is fixed in add.js.

> Since the principal is of the form service/host, we should use two
> fields for these. I think that the service tab should be a combo-box:
> free form text is allowed, but it should be prepopulated with known
> services like httpd, ftpd ,etc. Since the host portion of the
> principal has to be a registered host in the system, I suspect we need
> to use the association style finder for that. For now make it a text
> box with the label of Host name.

Per our discussion, I'm submitting a patch with a single text field for
principal. I will create another patch to refactor the EntityBuilder
class and subclass it to combine the service & host fields into principal.

As we discovered, the standard HTML combobox is not editable and 3rd party
editable comboboxes have some issues. We will address this next time.

> Pavel and I have been using a patch labeling scheme
> <username>-freeipa-<sequence>-description.patch. I've renamed this one
> to:
> 
> edewata-freeipa-0001-Added-Services-tab.patch
> 
> When you update it, please name the new one:
> edewata-freeipa-0001-2-Added-Services-tab.patch

The new patch has been renamed as such.

Thanks!

--
Endi S. Dewata
>From 5811592834890584bdc5f42e58f8e767fb71278f 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/add.js                            |   10 ++-
 install/static/index.xhtml                       |    1 +
 install/static/navigation.js                     |    7 +-
 install/static/sampledata/service_add.json       |   29 +++++++
 install/static/sampledata/service_add_host.json  |   22 +++++
 install/static/sampledata/service_del.json       |    9 ++
 install/static/sampledata/service_find.json      |   48 +++++++++++
 install/static/sampledata/service_remove_host.sh |   18 ++++
 install/static/sampledata/service_show.json      |   18 ++++
 install/static/service.js                        |   96 ++++++++++++++++++++++
 11 files changed, 256 insertions(+), 3 deletions(-)
 create mode 100644 install/static/sampledata/service_add.json
 create mode 100644 install/static/sampledata/service_add_host.json
 create mode 100644 install/static/sampledata/service_del.json
 create mode 100644 install/static/sampledata/service_find.json
 create mode 100644 install/static/sampledata/service_remove_host.sh
 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/add.js b/install/static/add.js
index 4af6a8e..97f7666 100644
--- a/install/static/add.js
+++ b/install/static/add.js
@@ -96,15 +96,23 @@ function EntityBuilder(obj,addProperties,addOptionsFunction ){
 
 
 function addAnother(response){
+    if (response.error){
+        alert("error adding entry");
+        return;
+    }
     var params = ipa_parse_qs();
     builders[params["tab"]].setup();
 }
 
 function addEdit(response){
+    if (response.error){
+        alert("error adding entry");
+        return;
+    }
     var params = ipa_parse_qs();
     var hash= "tab="
         + params["tab"]
         +"&facet=details&pkey="
         +$("#pkey").val();
     window.location.hash = hash;
-}
\ No newline at end of file
+}
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_add.json b/install/static/sampledata/service_add.json
new file mode 100644
index 0000000..4275d9b
--- /dev/null
+++ b/install/static/sampledata/service_add.json
@@ -0,0 +1,29 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com",
+            "ipauniqueid": [
+                "5b314ad9-bae4-11df-b82f-00163e72f2d9"
+            ],
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ],
+            "managedby_host": [
+                "dev.example.com"
+            ],
+            "objectclass": [
+                "krbprincipal",
+                "krbprincipalaux",
+                "krbticketpolicyaux",
+                "ipaobject",
+                "ipaservice",
+                "pkiuser",
+                "top"
+            ]
+        },
+        "summary": "Added service \"test/dev.example....@dev.example.com\"",
+        "value": "test/dev.example....@dev.example.com"
+    }
+}
diff --git a/install/static/sampledata/service_add_host.json b/install/static/sampledata/service_add_host.json
new file mode 100644
index 0000000..a07afe3
--- /dev/null
+++ b/install/static/sampledata/service_add_host.json
@@ -0,0 +1,21 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "completed": 1,
+        "failed": {
+            "managedby": {
+                "host": []
+            }
+        },
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com",
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ],
+            "managedby_host": [
+                "dev.example.com"
+            ]
+        }
+    }
+}
diff --git a/install/static/sampledata/service_del.json b/install/static/sampledata/service_del.json
new file mode 100644
index 0000000..326625b
--- /dev/null
+++ b/install/static/sampledata/service_del.json
@@ -0,0 +1,9 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "result": true,
+        "summary": "Deleted service \"test/dev.example....@dev.example.com\"",
+        "value": "test/dev.example....@dev.example.com"
+    }
+}
diff --git a/install/static/sampledata/service_find.json b/install/static/sampledata/service_find.json
new file mode 100644
index 0000000..dc95b9b
--- /dev/null
+++ b/install/static/sampledata/service_find.json
@@ -0,0 +1,48 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "count": 3,
+        "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="
+                    }
+                ]
+            },
+            {
+                "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="
+                    }
+                ]
+            },
+            {
+                "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com",
+                "has_keytab": false,
+                "krbprincipalname": [
+                    "test/dev.example....@dev.example.com"
+                ],
+                "managedby_host": [
+                    "dev.example.com"
+                ]
+            }
+        ],
+        "summary": "3 services matched",
+        "truncated": false
+    }
+}
diff --git a/install/static/sampledata/service_remove_host.sh b/install/static/sampledata/service_remove_host.sh
new file mode 100644
index 0000000..cc56169
--- /dev/null
+++ b/install/static/sampledata/service_remove_host.sh
@@ -0,0 +1,18 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "completed": 1,
+        "failed": {
+            "managedby": {
+                "host": []
+            }
+        },
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com",
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ]
+        }
+    }
+}
diff --git a/install/static/sampledata/service_show.json b/install/static/sampledata/service_show.json
new file mode 100644
index 0000000..879bc58
--- /dev/null
+++ b/install/static/sampledata/service_show.json
@@ -0,0 +1,18 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "result": {
+            "dn": "krbprincipalname=test/dev.example....@dev.example.com,cn=services,cn=accounts,dc=dev,dc=example,dc=com",
+            "has_keytab": false,
+            "krbprincipalname": [
+                "test/dev.example....@dev.example.com"
+            ],
+            "managedby_host": [
+                "dev.example.com"
+            ]
+        },
+        "summary": null,
+        "value": "test/dev.example....@dev.example.com"
+    }
+}
diff --git a/install/static/service.js b/install/static/service.js
new file mode 100644
index 0000000..467e56a
--- /dev/null
+++ b/install/static/service.js
@@ -0,0 +1,96 @@
+function setupService(facet) {
+    serviceForms.setup(facet);
+}
+
+var serviceForms = new ServiceForms();
+
+function ServiceForms() {
+
+    this.obj = "service";
+
+    this.facets = ['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.facets
+    );
+
+    this.assignhosts = new AssociationForm(
+        this.obj,
+        "host",
+        "assignhosts",
+        this.facets,
+        "fqdn",
+        function() {
+            return 'Add Hosts to service : ' + qs['pkey'];
+        },
+        BulkAssociator,
+        "add_host"
+    );
+
+    this.detailsList = [
+        ['identity', 'Service Details', [
+            ['krbprincipalname', 'Kerberos Principal']
+        ]]
+    ];
+
+    this.details = new DetailsForm(
+        "service",
+        this.detailsList,
+        "krbprincipalname",
+        this.facets
+    );
+
+    this.addProperties = [
+        {title: 'Principal', id: 'pkey', type: 'text'}
+    ];
+
+    this.addOptionsFunction = function() {
+        var options = {
+            name: $('#pkey').val()
+        };
+        return options;
+    };
+
+    this.add = new EntityBuilder(
+        "service",
+        this.addProperties,
+        this.addOptionsFunction
+    );
+
+    this.searchColumns = [
+        {
+            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.searchColumns
+    );
+
+    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