[Pki-devel] [PATCH] 571 Fixed action links in TPS UI.

Endi Sukma Dewata edewata at redhat.com
Thu Apr 16 13:44:46 UTC 2015


On 4/10/2015 11:27 PM, Endi Sukma Dewata wrote:
> The TPS UI has been modified to display the appropriate action
> links based on the roles of the user. TPS agent can only enable
> and disable profiles, and also approve or reject pending requests.
> TPS admin can only edit disabled profiles, then submit it for
> approval, or cancel the request.
>
> The action links have been updated to display in a more consistent
> way.
>
> https://fedorahosted.org/pki/ticket/1292

New patch attached for some cleanups.

-- 
Endi S. Dewata
-------------- next part --------------
>From 231887797876a8462bb92f5119742a6dc785b819 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata at redhat.com>
Date: Fri, 10 Apr 2015 22:51:22 -0400
Subject: [PATCH] Fixed action menu in TPS UI.

The TPS UI has been modified to display the appropriate actions
menu based on the roles of the user. TPS agent can only enable
and disable profiles, and also approve or reject pending requests.
TPS admin can only edit disabled profiles, then submit it for
approval, or cancel the request.

https://fedorahosted.org/pki/ticket/1292
---
 base/server/share/webapps/pki/css/pki-ui.css       |  20 +++
 base/server/share/webapps/pki/js/pki-ui.js         |  24 ++--
 base/tps/shared/webapps/tps/js/account.js          |  30 ++++-
 base/tps/shared/webapps/tps/js/audit.js            |  41 +++---
 base/tps/shared/webapps/tps/js/authenticator.js    |  17 +--
 base/tps/shared/webapps/tps/js/config.js           |  66 +++++++++-
 base/tps/shared/webapps/tps/js/connector.js        |  17 +--
 base/tps/shared/webapps/tps/js/profile-mapping.js  |  17 +--
 base/tps/shared/webapps/tps/js/profile.js          | 102 ++++++++++++---
 base/tps/shared/webapps/tps/js/token.js            |  12 +-
 base/tps/shared/webapps/tps/js/tps.js              | 145 ++++++++++++++++++---
 base/tps/shared/webapps/tps/ui/audit.html          |   9 +-
 base/tps/shared/webapps/tps/ui/authenticator.html  |  21 ++-
 base/tps/shared/webapps/tps/ui/config.html         |  14 +-
 base/tps/shared/webapps/tps/ui/connector.html      |  21 ++-
 base/tps/shared/webapps/tps/ui/group.html          |   6 +-
 base/tps/shared/webapps/tps/ui/home.html           |  14 +-
 base/tps/shared/webapps/tps/ui/index.html          |   4 +-
 .../tps/shared/webapps/tps/ui/profile-mapping.html |  21 ++-
 base/tps/shared/webapps/tps/ui/profile.html        |  21 ++-
 base/tps/shared/webapps/tps/ui/token.html          |  10 +-
 base/tps/shared/webapps/tps/ui/user.html           |   6 +-
 22 files changed, 452 insertions(+), 186 deletions(-)

diff --git a/base/server/share/webapps/pki/css/pki-ui.css b/base/server/share/webapps/pki/css/pki-ui.css
index 0d5edd7fd59f38c31932473fbe20e51c9bdbd2c6..6042dc3ee97af8e52048a7f14ab8dd2b2a1d1c31 100644
--- a/base/server/share/webapps/pki/css/pki-ui.css
+++ b/base/server/share/webapps/pki/css/pki-ui.css
@@ -42,8 +42,13 @@
 }
 
 .pki-menu {
+  display: inline-block;
+}
+
+.pki-menu ul {
   padding: 0;
   list-style-type: none;
+  list-style-position: inside;
 }
 
 .pki-actions {
@@ -51,6 +56,13 @@
   display: inline-block;
 }
 
+.pki-actions ul {
+  padding: 0;
+  list-style-type: none;
+  list-style-position: inside;
+  text-align: right;
+}
+
 .pki-fields {
   margin-bottom: 5px;
 }
@@ -79,6 +91,14 @@ input[readonly="readonly"]:enabled:hover {
   border-color: #FFFFFF;
 }
 
+textarea {
+  background-color: #FFFFFF;
+}
+
+textarea[readonly="readonly"] {
+  background-color: #F8F8F8;
+}
+
 table tfoot tr th {
   padding: 6px 15px;
   font-size: 11.5px;
diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js
index 98e3330c0bcba248e0ee76dacf1839e19927eb94..c1c57793ce4605ced961c8f06453fd89d71a3d51 100644
--- a/base/server/share/webapps/pki/js/pki-ui.js
+++ b/base/server/share/webapps/pki/js/pki-ui.js
@@ -485,6 +485,8 @@ var Table = Backbone.View.extend({
 
         self.thead = $("thead", self.$el);
         self.buttons = $(".pki-table-buttons", self.thead);
+        self.addButton = $("[name='add']", self.buttons);
+        self.removeButton = $("[name='remove']", self.buttons);
 
         // setup search field handler
         self.searchField = $("input[name='search']", self.thead);
@@ -497,12 +499,12 @@ var Table = Backbone.View.extend({
         });
 
         // setup add button handler
-        $("button[name='add']", self.buttons).click(function(e) {
+        self.addButton.click(function(e) {
             self.add();
         });
 
         // setup remove button handler
-        $("button[name='remove']", self.buttons).click(function(e) {
+        self.removeButton.click(function(e) {
             var items = [];
             var message = "Are you sure you want to remove the following entries?\n";
 
@@ -625,10 +627,12 @@ var Table = Backbone.View.extend({
         var self = this;
 
         if (self.mode == "view") {
-            self.buttons.hide();
+            self.addButton.hide();
+            self.removeButton.hide();
 
         } else { // self.mode == "edit"
-            self.buttons.show();
+            self.addButton.show();
+            self.removeButton.show();
         }
 
         // clear selection
@@ -928,27 +932,27 @@ var EntryPage = Page.extend({
         self.actions = self.$(".pki-actions");
 
         self.viewMenu = $(".pki-actions-menu[name='view']", self.actions);
-        self.editLink = $("a[name='edit']", self.viewMenu);
+        self.editAction = $("[name='edit']", self.viewMenu);
 
         self.editMenu = $(".pki-actions-menu[name='edit']", self.actions);
-        self.cancelButton = $("button[name='cancel']", self.editMenu);
-        self.saveButton = $("button[name='save']", self.editMenu);
+        self.cancelAction = $("[name='cancel']", self.editMenu);
+        self.saveAction = $("[name='save']", self.editMenu);
 
         self.idField = self.$("input[name='id']");
         self.statusField = self.$("input[name='status']");
 
-        self.editLink.click(function(e) {
+        $("a", self.editAction).click(function(e) {
             self.mode = "edit";
             self.render();
             e.preventDefault();
         });
 
-        self.cancelButton.click(function(e) {
+        self.cancelAction.click(function(e) {
             self.cancel();
             e.preventDefault();
         });
 
-        self.saveButton.click(function(e) {
+        self.saveAction.click(function(e) {
             self.save();
             e.preventDefault();
         });
diff --git a/base/tps/shared/webapps/tps/js/account.js b/base/tps/shared/webapps/tps/js/account.js
index 97b222aaa07b42056395ddb9baaec4d85381a252..8960ff731d1faec646dac0763a35aa2c40b3eb9a 100644
--- a/base/tps/shared/webapps/tps/js/account.js
+++ b/base/tps/shared/webapps/tps/js/account.js
@@ -24,14 +24,30 @@ function Account() {
     this.url = "/tps/rest/account";
 
     this.login = function(options) {
-        var jqxhr = $.get(this.url + "/login", null, null, "json");
-        jqxhr.done(options.success);
-        jqxhr.fail(options.error);
+        var self = this;
+
+        $.ajax({
+            type: "GET",
+            url: self.url + "/login",
+            dataType: "json"
+        }).done(function(data, textStatus, jqXHR) {
+            if (options.success) options.success.call(self, data, textStatus, jqXHR);
+        }).fail(function(jqXHR, textStatus, errorThrown) {
+            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
+        });
     };
 
     this.logout = function(options) {
-        var jqxhr = $.get(this.url + "/logout");
-        jqxhr.done(options.success);
-        jqxhr.fail(options.error);
+        var self = this;
+
+        $.ajax({
+            type: "GET",
+            url: self.url + "/logout",
+            dataType: "json"
+        }).done(function(data, textStatus, jqXHR) {
+            if (options.success) options.success.call(self, data, textStatus, jqXHR);
+        }).fail(function(jqXHR, textStatus, errorThrown) {
+            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
+        });
     };
-};
\ No newline at end of file
+};
diff --git a/base/tps/shared/webapps/tps/js/audit.js b/base/tps/shared/webapps/tps/js/audit.js
index 62e6b099e72f5ca48ab4c3b2decd01fa3c5c818b..cc0be46280f15aff14fa5aee8229af5b9f2756ef 100644
--- a/base/tps/shared/webapps/tps/js/audit.js
+++ b/base/tps/shared/webapps/tps/js/audit.js
@@ -44,24 +44,11 @@ var AuditModel = Model.extend({
             }
         };
     },
-    enable: function(options) {
+    changeStatus: function(action, options) {
         var self = this;
         $.ajax({
             type: "POST",
-            url: self.url() + "?action=enable",
-            dataType: "json"
-        }).done(function(data, textStatus, jqXHR) {
-            self.set(self.parseResponse(data));
-            if (options.success) options.success.call(self, data, textStatus, jqXHR);
-        }).fail(function(jqXHR, textStatus, errorThrown) {
-            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
-        });
-    },
-    disable: function(options) {
-        var self = this;
-        $.ajax({
-            type: "POST",
-            url: self.url() + "?action=disable",
+            url: self.url() + "?action=" + action,
             dataType: "json"
         }).done(function(data, textStatus, jqXHR) {
             self.set(self.parseResponse(data));
@@ -142,16 +129,16 @@ var AuditPage = EntryPage.extend({
 
         AuditPage.__super__.setup.call(self);
 
-        self.enableLink = $("a[name='enable']", self.viewMenu);
-        self.disableLink = $("a[name='disable']", self.viewMenu);
+        self.enableAction = $("[name='enable']", self.viewMenu);
+        self.disableAction = $("[name='disable']", self.viewMenu);
 
-        self.enableLink.click(function(e) {
+        $("a", self.enableAction).click(function(e) {
 
             e.preventDefault();
 
             var message = "Are you sure you want to enable this entry?";
             if (!confirm(message)) return;
-            self.model.enable({
+            self.model.changeStatus("enable", {
                 success: function(data, textStatus, jqXHR) {
                     self.entry = _.clone(self.model.attributes);
                     self.render();
@@ -166,13 +153,13 @@ var AuditPage = EntryPage.extend({
             });
         });
 
-        self.disableLink.click(function(e) {
+        $("a", self.disableAction).click(function(e) {
 
             e.preventDefault();
 
             var message = "Are you sure you want to disable this entry?";
             if (!confirm(message)) return;
-            self.model.disable({
+            self.model.changeStatus("disable", {
                 success: function(data, textStatus, jqXHR) {
                     self.entry = _.clone(self.model.attributes);
                     self.render();
@@ -204,12 +191,14 @@ var AuditPage = EntryPage.extend({
 
         var status = self.entry.status;
         if (status == "Disabled") {
-            self.enableLink.show();
-            self.disableLink.hide();
+            self.editAction.show();
+            self.enableAction.show();
+            self.disableAction.hide();
 
-        } else if (status == "Enabled") {
-            self.enableLink.hide();
-            self.disableLink.show();
+        } else {
+            self.editAction.hide();
+            self.enableAction.hide();
+            self.disableAction.show();
         }
 
         if (self.mode == "edit") {
diff --git a/base/tps/shared/webapps/tps/js/authenticator.js b/base/tps/shared/webapps/tps/js/authenticator.js
index f91cf6bfeb3ad7046710cb227bf8c1a253b55926..b83838c67546e6f9c147d6a57bee3f80bc9f9769 100644
--- a/base/tps/shared/webapps/tps/js/authenticator.js
+++ b/base/tps/shared/webapps/tps/js/authenticator.js
@@ -38,24 +38,11 @@ var AuthenticatorModel = Model.extend({
             }
         };
     },
-    enable: function(options) {
+    changeStatus: function(action, options) {
         var self = this;
         $.ajax({
             type: "POST",
-            url: self.url() + "?action=enable",
-            dataType: "json"
-        }).done(function(data, textStatus, jqXHR) {
-            self.set(self.parseResponse(data));
-            if (options.success) options.success.call(self, data, textStatus, jqXHR);
-        }).fail(function(jqXHR, textStatus, errorThrown) {
-            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
-        });
-    },
-    disable: function(options) {
-        var self = this;
-        $.ajax({
-            type: "POST",
-            url: self.url() + "?action=disable",
+            url: self.url() + "?action=" + action,
             dataType: "json"
         }).done(function(data, textStatus, jqXHR) {
             self.set(self.parseResponse(data));
diff --git a/base/tps/shared/webapps/tps/js/config.js b/base/tps/shared/webapps/tps/js/config.js
index 5b651a09d40279eb9d73c9fdf321fea8c67955e4..749821b3c6c8612ae41dc8c390baea9f79854f79 100644
--- a/base/tps/shared/webapps/tps/js/config.js
+++ b/base/tps/shared/webapps/tps/js/config.js
@@ -40,12 +40,72 @@ var ConfigModel = Model.extend({
     }
 });
 
-var ConfigPage = ConfigEntryPage.extend({
+var ConfigPage = EntryPage.extend({
     initialize: function(options) {
         var self = this;
         options.model = new ConfigModel();
-        options.tableItem = PropertiesTableItem;
-        options.tableSize = 15;
         ConfigPage.__super__.initialize.call(self, options);
+        self.tableItem = options.tableItem || PropertiesTableItem;
+        self.tableSize = options.tableSize || 15;
+    },
+    setup: function() {
+        var self = this;
+
+        ConfigPage.__super__.setup.call(self);
+
+        var dialog = self.$("#property-dialog");
+
+        var addDialog = new Dialog({
+            el: dialog,
+            title: "Add Property",
+            actions: ["cancel", "add"]
+        });
+
+        var propertiesSection = self.$("[name='properties']");
+        self.propertiesList = $("[name='list']", propertiesSection);
+
+        self.propertiesTable = new PropertiesTable({
+            el: self.propertiesList,
+            addDialog: addDialog,
+            tableItem: self.tableItem,
+            pageSize: self.tableSize,
+            parent: self
+        });
+    },
+    renderContent: function() {
+        var self = this;
+
+        ConfigPage.__super__.renderContent.call(self);
+
+        if (self.mode == "add") {
+            self.propertiesTable.mode = "edit";
+            self.setProperties([]);
+
+        } else if (self.mode == "edit") {
+            self.propertiesTable.mode = "edit";
+            self.setProperties(self.entry.properties);
+
+        } else { // self.mode == "view"
+            self.propertiesTable.mode = "view";
+            self.setProperties(self.entry.properties);
+        }
+    },
+    saveFields: function() {
+        var self = this;
+
+        ConfigPage.__super__.saveFields.call(self);
+
+        self.entry.properties = self.getProperties();
+    },
+    setProperties: function(properties) {
+        var self = this;
+
+        self.propertiesTable.entries = properties;
+        self.propertiesTable.render();
+    },
+    getProperties: function() {
+        var self = this;
+
+        return self.propertiesTable.entries;
     }
 });
diff --git a/base/tps/shared/webapps/tps/js/connector.js b/base/tps/shared/webapps/tps/js/connector.js
index bc7e4c2bd371f2b6fa210bea39302d7cd21aaaa8..1095ecd741cd1f2d44bab9f56c625a32f4be44f8 100644
--- a/base/tps/shared/webapps/tps/js/connector.js
+++ b/base/tps/shared/webapps/tps/js/connector.js
@@ -38,24 +38,11 @@ var ConnectorModel = Model.extend({
             }
         };
     },
-    enable: function(options) {
+    changeStatus: function(action, options) {
         var self = this;
         $.ajax({
             type: "POST",
-            url: self.url() + "?action=enable",
-            dataType: "json"
-        }).done(function(data, textStatus, jqXHR) {
-            self.set(self.parseResponse(data));
-            if (options.success) options.success.call(self, data, textStatus, jqXHR);
-        }).fail(function(jqXHR, textStatus, errorThrown) {
-            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
-        });
-    },
-    disable: function(options) {
-        var self = this;
-        $.ajax({
-            type: "POST",
-            url: self.url() + "?action=disable",
+            url: self.url() + "?action=" + action,
             dataType: "json"
         }).done(function(data, textStatus, jqXHR) {
             self.set(self.parseResponse(data));
diff --git a/base/tps/shared/webapps/tps/js/profile-mapping.js b/base/tps/shared/webapps/tps/js/profile-mapping.js
index 54c04256279b5e4fcb92e12cb5cb202644aa62f8..8df3b393ff149c5d51799e632a9cae95e3386146 100644
--- a/base/tps/shared/webapps/tps/js/profile-mapping.js
+++ b/base/tps/shared/webapps/tps/js/profile-mapping.js
@@ -38,24 +38,11 @@ var ProfileMappingModel = Model.extend({
             }
         };
     },
-    enable: function(options) {
+    changeStatus: function(action, options) {
         var self = this;
         $.ajax({
             type: "POST",
-            url: self.url() + "?action=enable",
-            dataType: "json"
-        }).done(function(data, textStatus, jqXHR) {
-            self.set(self.parseResponse(data));
-            if (options.success) options.success.call(self, data, textStatus, jqXHR);
-        }).fail(function(jqXHR, textStatus, errorThrown) {
-            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
-        });
-    },
-    disable: function(options) {
-        var self = this;
-        $.ajax({
-            type: "POST",
-            url: self.url() + "?action=disable",
+            url: self.url() + "?action=" + action,
             dataType: "json"
         }).done(function(data, textStatus, jqXHR) {
             self.set(self.parseResponse(data));
diff --git a/base/tps/shared/webapps/tps/js/profile.js b/base/tps/shared/webapps/tps/js/profile.js
index 0454686a9993560909cd4d350488a2ac823fc769..0182a80632b61289e56a22da31ee8328a07853f8 100644
--- a/base/tps/shared/webapps/tps/js/profile.js
+++ b/base/tps/shared/webapps/tps/js/profile.js
@@ -38,24 +38,11 @@ var ProfileModel = Model.extend({
             }
         };
     },
-    enable: function(options) {
+    changeStatus: function(action, options) {
         var self = this;
         $.ajax({
             type: "POST",
-            url: self.url() + "?action=enable",
-            dataType: "json"
-        }).done(function(data, textStatus, jqXHR) {
-            self.set(self.parseResponse(data));
-            if (options.success) options.success.call(self, data, textStatus, jqXHR);
-        }).fail(function(jqXHR, textStatus, errorThrown) {
-            if (options.error) options.error.call(self, jqXHR, textStatus, errorThrown);
-        });
-    },
-    disable: function(options) {
-        var self = this;
-        $.ajax({
-            type: "POST",
-            url: self.url() + "?action=disable",
+            url: self.url() + "?action=" + action,
             dataType: "json"
         }).done(function(data, textStatus, jqXHR) {
             self.set(self.parseResponse(data));
@@ -94,6 +81,91 @@ var ProfilesTable = ModelTable.extend({
     }
 });
 
+var ProfilePage = ConfigEntryPage.extend({
+    renderContent: function() {
+        var self = this;
+
+        ProfilePage.__super__.renderContent.call(self);
+
+        var roles = tps.user.Roles.Role;
+        var status = self.entry.status;
+
+        if (_.contains(roles, "Administrators")) {
+
+            // admins can edit disabled entries
+            if (status == "Disabled") {
+                self.editAction.show();
+            } else {
+                self.editAction.hide();
+            }
+
+        } else {
+            self.editAction.hide();
+        }
+
+        if (_.contains(roles, "TPS Agents")) {
+
+            // agents can enable or disable entries
+            if (status == "Disabled") {
+                self.approveAction.hide();
+                self.rejectAction.hide();
+                self.enableAction.show();
+                self.disableAction.hide();
+
+            } else if (status == "Enabled") {
+                self.approveAction.hide();
+                self.rejectAction.hide();
+                self.enableAction.hide();
+                self.disableAction.show();
+
+            } else if (status == "Pending_Approval") {
+                self.approveAction.show();
+                self.rejectAction.show();
+                self.enableAction.hide();
+                self.disableAction.hide();
+
+            } else {
+                self.approveAction.hide();
+                self.rejectAction.hide();
+                self.enableAction.hide();
+                self.disableAction.hide();
+            }
+
+            self.submitAction.hide();
+            self.cancelAction.hide();
+
+        } else if (_.contains(roles, "Administrators")) {
+
+            // admins can submit or cancel entries
+            if (status == "Disabled") {
+                self.submitAction.show();
+                self.cancelAction.hide();
+
+            } else if (status == "Pending_Approval") {
+                self.submitAction.hide();
+                self.cancelAction.show();
+
+            } else {
+                self.submitAction.hide();
+                self.cancelAction.hide();
+            }
+
+            self.approveAction.hide();
+            self.rejectAction.hide();
+            self.enableAction.hide();
+            self.disableAction.hide();
+
+        } else {
+            self.enableAction.hide();
+            self.disableAction.hide();
+            self.approveAction.hide();
+            self.rejectAction.hide();
+            self.submitAction.hide();
+            self.cancelAction.hide();
+        }
+    }
+});
+
 var ProfilesPage = Page.extend({
     load: function() {
         var self = this;
diff --git a/base/tps/shared/webapps/tps/js/token.js b/base/tps/shared/webapps/tps/js/token.js
index 4cc3b5bcf01c77ca5cc479e5ee5e8bb293999bdd..f4d2d8a78e46b92fd1e0ae9a87136f0e63e3e2c8 100644
--- a/base/tps/shared/webapps/tps/js/token.js
+++ b/base/tps/shared/webapps/tps/js/token.js
@@ -110,9 +110,9 @@ var TokenPage = EntryPage.extend({
 
         TokenPage.__super__.setup.call(self);
 
-        self.changeStatusLink = $("a[name='changeStatus']", self.viewMenu);
+        self.changeStatusAction = $("[name='changeStatus']", self.viewMenu);
 
-        self.changeStatusLink.click(function(e) {
+        $("a", self.changeStatusAction).click(function(e) {
 
             e.preventDefault();
 
@@ -154,9 +154,9 @@ var TokenPage = EntryPage.extend({
             dialog.open();
         });
 
-        self.showCertsLink = $("a[name='showCerts']", self.viewMenu);
+        self.showCertsAction = $("[name='showCerts']", self.viewMenu);
 
-        self.showCertsLink.click(function(e) {
+        $("a", self.showCertsAction).click(function(e) {
 
             e.preventDefault();
             window.location.hash = window.location.hash + "/certs";
@@ -168,9 +168,9 @@ var TokenPage = EntryPage.extend({
         TokenPage.__super__.renderContent.call(self);
 
         if (self.mode == "add") {
-            self.changeStatusLink.hide();
+            self.changeStatusAction.hide();
         } else {
-            self.changeStatusLink.show();
+            self.changeStatusAction.show();
         }
     }
 });
diff --git a/base/tps/shared/webapps/tps/js/tps.js b/base/tps/shared/webapps/tps/js/tps.js
index 85d1751eb7cb0e721f94d8619dc1a914f21464da..35fac3ec9e1cc8e01ccc4d54136ec8d3a29d0f15 100644
--- a/base/tps/shared/webapps/tps/js/tps.js
+++ b/base/tps/shared/webapps/tps/js/tps.js
@@ -146,16 +146,104 @@ var ConfigEntryPage = EntryPage.extend({
 
         ConfigEntryPage.__super__.setup.call(self);
 
-        self.enableLink = $("a[name='enable']", self.viewMenu);
-        self.disableLink = $("a[name='disable']", self.viewMenu);
+        self.submitAction = $("[name='submit']", self.viewMenu);
+        self.cancelAction = $("[name='cancel']", self.viewMenu);
+        self.approveAction = $("[name='approve']", self.viewMenu);
+        self.rejectAction = $("[name='reject']", self.viewMenu);
+        self.enableAction = $("[name='enable']", self.viewMenu);
+        self.disableAction = $("[name='disable']", self.viewMenu);
 
-        self.enableLink.click(function(e) {
+        $("a", self.submitAction).click(function(e) {
+
+            e.preventDefault();
+
+            var message = "Are you sure you want to submit this entry?";
+            if (!confirm(message)) return;
+            self.model.changeStatus("submit", {
+                success: function(data, textStatus, jqXHR) {
+                    self.entry = _.clone(self.model.attributes);
+                    self.render();
+                },
+                error: function(jqXHR, textStatus, errorThrown) {
+                    new ErrorDialog({
+                        el: $("#error-dialog"),
+                        title: "HTTP Error " + jqXHR.responseJSON.Code,
+                        content: jqXHR.responseJSON.Message
+                    }).open();
+                }
+            });
+        });
+
+        $("a", self.cancelAction).click(function(e) {
+
+            e.preventDefault();
+
+            var message = "Are you sure you want to cancel this entry?";
+            if (!confirm(message)) return;
+            self.model.changeStatus("cancel", {
+                success: function(data, textStatus, jqXHR) {
+                    self.entry = _.clone(self.model.attributes);
+                    self.render();
+                },
+                error: function(jqXHR, textStatus, errorThrown) {
+                    new ErrorDialog({
+                        el: $("#error-dialog"),
+                        title: "HTTP Error " + jqXHR.responseJSON.Code,
+                        content: jqXHR.responseJSON.Message
+                    }).open();
+                }
+            });
+        });
+
+        $("a", self.approveAction).click(function(e) {
+
+            e.preventDefault();
+
+            var message = "Are you sure you want to approve this entry?";
+            if (!confirm(message)) return;
+            self.model.changeStatus("approve", {
+                success: function(data, textStatus, jqXHR) {
+                    self.entry = _.clone(self.model.attributes);
+                    self.render();
+                },
+                error: function(jqXHR, textStatus, errorThrown) {
+                    new ErrorDialog({
+                        el: $("#error-dialog"),
+                        title: "HTTP Error " + jqXHR.responseJSON.Code,
+                        content: jqXHR.responseJSON.Message
+                    }).open();
+                }
+            });
+        });
+
+        $("a", self.rejectAction).click(function(e) {
+
+            e.preventDefault();
+
+            var message = "Are you sure you want to reject this entry?";
+            if (!confirm(message)) return;
+            self.model.changeStatus("reject", {
+                success: function(data, textStatus, jqXHR) {
+                    self.entry = _.clone(self.model.attributes);
+                    self.render();
+                },
+                error: function(jqXHR, textStatus, errorThrown) {
+                    new ErrorDialog({
+                        el: $("#error-dialog"),
+                        title: "HTTP Error " + jqXHR.responseJSON.Code,
+                        content: jqXHR.responseJSON.Message
+                    }).open();
+                }
+            });
+        });
+
+        $("a", self.enableAction).click(function(e) {
 
             e.preventDefault();
 
             var message = "Are you sure you want to enable this entry?";
             if (!confirm(message)) return;
-            self.model.enable({
+            self.model.changeStatus("enable", {
                 success: function(data, textStatus, jqXHR) {
                     self.entry = _.clone(self.model.attributes);
                     self.render();
@@ -170,13 +258,13 @@ var ConfigEntryPage = EntryPage.extend({
             });
         });
 
-        self.disableLink.click(function(e) {
+        $("a", self.disableAction).click(function(e) {
 
             e.preventDefault();
 
             var message = "Are you sure you want to disable this entry?";
             if (!confirm(message)) return;
-            self.model.disable({
+            self.model.changeStatus("disable", {
                 success: function(data, textStatus, jqXHR) {
                     self.entry = _.clone(self.model.attributes);
                     self.render();
@@ -199,12 +287,11 @@ var ConfigEntryPage = EntryPage.extend({
             actions: ["cancel", "add"]
         });
 
-        var table = self.$("table[name='properties']");
-        self.addButton = $("button[name='add']", table);
-        self.removeButton = $("button[name='remove']", table);
+        var propertiesSection = self.$("[name='properties']");
+        self.propertiesList = $("[name='list']", propertiesSection);
 
         self.propertiesTable = new PropertiesTable({
-            el: table,
+            el: self.propertiesList,
             addDialog: addDialog,
             tableItem: self.tableItem,
             pageSize: self.tableSize,
@@ -218,34 +305,50 @@ var ConfigEntryPage = EntryPage.extend({
 
         var status = self.entry.status;
         if (status == "Disabled") {
-            self.enableLink.show();
-            self.disableLink.hide();
+            self.editAction.show();
+            self.enableAction.show();
+            self.disableAction.hide();
 
-        } else if (status == "Enabled") {
-            self.enableLink.hide();
-            self.disableLink.show();
+        } else {
+            self.editAction.hide();
+            self.enableAction.hide();
+            self.disableAction.show();
         }
 
+        self.submitAction.hide();
+        self.cancelAction.hide();
+        self.approveAction.hide();
+        self.rejectAction.hide();
+
         if (self.mode == "add") {
             self.propertiesTable.mode = "edit";
-            self.propertiesTable.entries = [];
+            self.setProperties([]);
 
         } else if (self.mode == "edit") {
             self.propertiesTable.mode = "edit";
-            self.propertiesTable.entries = self.entry.properties;
+            self.setProperties(self.entry.properties);
 
         } else { // self.mode == "view"
             self.propertiesTable.mode = "view";
-            self.propertiesTable.entries = self.entry.properties;
+            self.setProperties(self.entry.properties);
         }
-
-        self.propertiesTable.render();
     },
     saveFields: function() {
         var self = this;
 
         ConfigEntryPage.__super__.saveFields.call(self);
 
-        self.entry.properties = self.propertiesTable.entries;
+        self.entry.properties = self.getProperties();
+    },
+    setProperties: function(properties) {
+        var self = this;
+
+        self.propertiesTable.entries = properties;
+        self.propertiesTable.render();
+    },
+    getProperties: function() {
+        var self = this;
+
+        return self.propertiesTable.entries;
     }
 });
diff --git a/base/tps/shared/webapps/tps/ui/audit.html b/base/tps/shared/webapps/tps/ui/audit.html
index f9da85196df4a0a01f8ca9ebe0a1da6838ae5658..06457de62a6e2b0c5cb2f32faf7b8f55fac45e17 100644
--- a/base/tps/shared/webapps/tps/ui/audit.html
+++ b/base/tps/shared/webapps/tps/ui/audit.html
@@ -25,10 +25,11 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-<a name="enable" href="#">Enable</a><a name="disable" href="#" style="display: none;">Disable</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit" style="display: none;"><a href="#">Edit</a></li>
+<li name="enable" style="display: none;"><a href="#">Enable</a></li>
+<li name="disable" style="display: none;"><a href="#">Disable</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
diff --git a/base/tps/shared/webapps/tps/ui/authenticator.html b/base/tps/shared/webapps/tps/ui/authenticator.html
index cde9e65c401b0ff3861db4bb8ddffec91c8315a9..60fbf7cfe15c301c7fd16e1e08bdadab87ec2e26 100644
--- a/base/tps/shared/webapps/tps/ui/authenticator.html
+++ b/base/tps/shared/webapps/tps/ui/authenticator.html
@@ -26,10 +26,15 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-<a name="enable" href="#">Enable</a><a name="disable" href="#" style="display: none;">Disable</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit" style="display: none;"><a href="#">Edit</a></li>
+<li name="submit" style="display: none;"><a href="#">Submit</a></li>
+<li name="cancel" style="display: none;"><a href="#">Cancel</a></li>
+<li name="approve" style="display: none;"><a href="#">Approve</a></li>
+<li name="reject" style="display: none;"><a href="#">Reject</a></li>
+<li name="enable" style="display: none;"><a href="#">Enable</a></li>
+<li name="disable" style="display: none;"><a href="#">Disable</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
@@ -51,16 +56,18 @@
 </fieldset>
 </div>
 
+<div name="properties">
+
 <h2>Properties</h2>
 
-<table name="properties">
+<table name="list">
 <thead>
     <tr>
          <th class="pki-table-actions" colspan="3">
              <span name="search">
                  <input name="search" type="text" placeholder="Search...">
              </span>
-             <span class="pki-table-buttons" style="display: none;">
+             <span class="pki-table-buttons">
                  <button name="add">Add</button>
                  <button name="remove">Remove</button>
              </span>
@@ -103,6 +110,8 @@
 </tfoot>
 </table>
 
+</div>
+
 <div id="property-dialog" class="modal">
     <div class="modal-dialog">
         <div class="modal-content">
diff --git a/base/tps/shared/webapps/tps/ui/config.html b/base/tps/shared/webapps/tps/ui/config.html
index 2a8e85902b8807aabc21b0b2afa1229f3f0b89db..2246975516c7e05ec9eaa9c4c231f401ef4e0d9d 100644
--- a/base/tps/shared/webapps/tps/ui/config.html
+++ b/base/tps/shared/webapps/tps/ui/config.html
@@ -25,9 +25,9 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit"><a href="#">Edit</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
@@ -38,14 +38,16 @@
 
 </div>
 
-<table name="properties">
+<div name="properties">
+
+<table name="list">
 <thead>
     <tr>
          <th class="pki-table-actions" colspan="3">
              <span name="search">
                  <input name="search" type="text" placeholder="Search...">
              </span>
-             <span class="pki-table-buttons" style="display: none;">
+             <span class="pki-table-buttons">
                  <button name="add">Add</button>
                  <button name="remove">Remove</button>
              </span>
@@ -88,6 +90,8 @@
 </tfoot>
 </table>
 
+</div>
+
 <div id="property-dialog" class="modal">
     <div class="modal-dialog">
         <div class="modal-content">
diff --git a/base/tps/shared/webapps/tps/ui/connector.html b/base/tps/shared/webapps/tps/ui/connector.html
index 782c6d2458161ea575aaa319b97b911cced4c6da..bb10f7219e60dce5c352a253e91c9c5bfff74b84 100644
--- a/base/tps/shared/webapps/tps/ui/connector.html
+++ b/base/tps/shared/webapps/tps/ui/connector.html
@@ -26,10 +26,15 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-<a name="enable" href="#">Enable</a><a name="disable" href="#" style="display: none;">Disable</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit" style="display: none;"><a href="#">Edit</a></li>
+<li name="submit" style="display: none;"><a href="#">Submit</a></li>
+<li name="cancel" style="display: none;"><a href="#">Cancel</a></li>
+<li name="approve" style="display: none;"><a href="#">Approve</a></li>
+<li name="reject" style="display: none;"><a href="#">Reject</a></li>
+<li name="enable" style="display: none;"><a href="#">Enable</a></li>
+<li name="disable" style="display: none;"><a href="#">Disable</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
@@ -51,16 +56,18 @@
 </fieldset>
 </div>
 
+<div name="properties">
+
 <h2>Properties</h2>
 
-<table name="properties">
+<table name="list">
 <thead>
     <tr>
          <th class="pki-table-actions" colspan="3">
              <span name="search">
                  <input name="search" type="text" placeholder="Search...">
              </span>
-             <span class="pki-table-buttons" style="display: none;">
+             <span class="pki-table-buttons">
                  <button name="add">Add</button>
                  <button name="remove">Remove</button>
              </span>
@@ -103,6 +110,8 @@
 </tfoot>
 </table>
 
+</div>
+
 <div id="property-dialog" class="modal">
     <div class="modal-dialog">
         <div class="modal-content">
diff --git a/base/tps/shared/webapps/tps/ui/group.html b/base/tps/shared/webapps/tps/ui/group.html
index 11c9944b281602213d66c569a997e13f4b714f7f..df933815f05d77ea4487a6b7e17269561aac0192 100644
--- a/base/tps/shared/webapps/tps/ui/group.html
+++ b/base/tps/shared/webapps/tps/ui/group.html
@@ -26,9 +26,9 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit"><a href="#">Edit</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
diff --git a/base/tps/shared/webapps/tps/ui/home.html b/base/tps/shared/webapps/tps/ui/home.html
index 08c4672558003da4bc0cc380cefadd381b6b530e..eb6874e50840be1081be91e9402972ce34f58684 100644
--- a/base/tps/shared/webapps/tps/ui/home.html
+++ b/base/tps/shared/webapps/tps/ui/home.html
@@ -27,8 +27,8 @@
     <div class="panel-heading">
         <h3 class="panel-title">Token Management</h3>
     </div>
-    <div class="panel-body">
-        <ul class="pki-menu">
+    <div class="panel-body pki-menu">
+        <ul>
         <li><a href="#tokens">Tokens</a></li>
         <li><a href="#certs">Certificates</a></li>
         <li><a href="#activities">Activities</a></li>
@@ -40,10 +40,10 @@
     <div class="panel-heading">
         <h3 class="panel-title">Account Management</h3>
     </div>
-    <div class="panel-body">
-        <ul class="pki-menu">
+    <div class="panel-body pki-menu">
+        <ul>
         <li><a href="#users">Users</a></li>
-        </li><a href="#groups">Groups</a></li>
+        <li><a href="#groups">Groups</a></li>
         </ul>
     </div>
 </div>
@@ -52,8 +52,8 @@
     <div class="panel-heading">
         <h3 class="panel-title">System Management</h3>
     </div>
-    <div class="panel-body">
-        <ul class="pki-menu">
+    <div class="panel-body pki-menu">
+        <ul>
         <li name="config" style="display: none;"><a href="#config">General Configuration</a></li>
         <li name="authenticators" style="display: none;"><a href="#authenticators">Authentication Sources</a></li>
         <li name="connectors" style="display: none;"><a href="#connectors">Subsystem Connections</a></li>
diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html
index 3bda3cb40f764b1cb8d5adb4069aa829b25e8caa..357ade514c4835cb672a016bff155ead206bf562 100644
--- a/base/tps/shared/webapps/tps/ui/index.html
+++ b/base/tps/shared/webapps/tps/ui/index.html
@@ -217,7 +217,7 @@ $(function() {
     });
 
     router.route("profiles/:id", "profile", function(id) {
-        new ConfigEntryPage({
+        new ProfilePage({
             el: content,
             url: "profile.html",
             model: new ProfileModel({ id: id })
@@ -225,7 +225,7 @@ $(function() {
     });
 
     router.route("new-profile", "new-profile", function() {
-        new ConfigEntryPage({
+        new ProfilePage({
             el: content,
             url: "profile.html",
             model: new ProfileModel(),
diff --git a/base/tps/shared/webapps/tps/ui/profile-mapping.html b/base/tps/shared/webapps/tps/ui/profile-mapping.html
index fea71ce9d9cda3c8bd8c215e06815c4eead10c97..2dfbf2aa8553dc4f491b15fec14d091ea1eed2de 100644
--- a/base/tps/shared/webapps/tps/ui/profile-mapping.html
+++ b/base/tps/shared/webapps/tps/ui/profile-mapping.html
@@ -26,10 +26,15 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-<a name="enable" href="#">Enable</a><a name="disable" href="#" style="display: none;">Disable</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit" style="display: none;"><a href="#">Edit</a></li>
+<li name="submit" style="display: none;"><a href="#">Submit</a></li>
+<li name="cancel" style="display: none;"><a href="#">Cancel</a></li>
+<li name="approve" style="display: none;"><a href="#">Approve</a></li>
+<li name="reject" style="display: none;"><a href="#">Reject</a></li>
+<li name="enable" style="display: none;"><a href="#">Enable</a></li>
+<li name="disable" style="display: none;"><a href="#">Disable</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
@@ -51,16 +56,18 @@
 </fieldset>
 </div>
 
+<div name="properties">
+
 <h2>Properties</h2>
 
-<table name="properties">
+<table name="list">
 <thead>
     <tr>
          <th class="pki-table-actions" colspan="3">
              <span name="search">
                  <input name="search" type="text" placeholder="Search...">
              </span>
-             <span class="pki-table-buttons" style="display: none;">
+             <span class="pki-table-buttons">
                  <button name="add">Add</button>
                  <button name="remove">Remove</button>
              </span>
@@ -103,6 +110,8 @@
 </tfoot>
 </table>
 
+</div>
+
 <div id="property-dialog" class="modal">
     <div class="modal-dialog">
         <div class="modal-content">
diff --git a/base/tps/shared/webapps/tps/ui/profile.html b/base/tps/shared/webapps/tps/ui/profile.html
index 1720d48507cc40ac4a117e39e5dc4c77a2a0a164..b2e90856c01fa94a635fb0a4b52b4e7aeebb502b 100644
--- a/base/tps/shared/webapps/tps/ui/profile.html
+++ b/base/tps/shared/webapps/tps/ui/profile.html
@@ -26,10 +26,15 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-<a name="enable" href="#">Enable</a><a name="disable" href="#" style="display: none;">Disable</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit" style="display: none;"><a href="#">Edit</a></li>
+<li name="submit" style="display: none;"><a href="#">Submit</a></li>
+<li name="cancel" style="display: none;"><a href="#">Cancel</a></li>
+<li name="approve" style="display: none;"><a href="#">Approve</a></li>
+<li name="reject" style="display: none;"><a href="#">Reject</a></li>
+<li name="enable" style="display: none;"><a href="#">Enable</a></li>
+<li name="disable" style="display: none;"><a href="#">Disable</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
@@ -51,16 +56,18 @@
 </fieldset>
 </div>
 
+<div name="properties">
+
 <h2>Properties</h2>
 
-<table name="properties">
+<table name="list">
 <thead>
     <tr>
          <th class="pki-table-actions" colspan="3">
              <span name="search">
                  <input name="search" type="text" placeholder="Search...">
              </span>
-             <span class="pki-table-buttons" style="display: none;">
+             <span class="pki-table-buttons">
                  <button name="add">Add</button>
                  <button name="remove">Remove</button>
              </span>
@@ -103,6 +110,8 @@
 </tfoot>
 </table>
 
+</div>
+
 <div id="property-dialog" class="modal">
     <div class="modal-dialog">
         <div class="modal-content">
diff --git a/base/tps/shared/webapps/tps/ui/token.html b/base/tps/shared/webapps/tps/ui/token.html
index 39d54c6cd09ddb175685da4da07e00ba2e1b92bb..ad681e9a0aef72310fd419ca2491e8f742a68031 100644
--- a/base/tps/shared/webapps/tps/ui/token.html
+++ b/base/tps/shared/webapps/tps/ui/token.html
@@ -26,11 +26,11 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-<a name="changeStatus" href="#">Change Status</a><br>
-<a name="showCerts" href="#">Show Certificates</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit"><a href="#">Edit</a></li>
+<li name="changeStatus"><a href="#">Change Status</a></li>
+<li name="showCerts"><a href="#">Show Certificates</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
diff --git a/base/tps/shared/webapps/tps/ui/user.html b/base/tps/shared/webapps/tps/ui/user.html
index 9d6b0597ac400f110de3ecd0153a327e00f30f52..9a9f9505b3e07a9a62ef6de17a956a03376e17f2 100644
--- a/base/tps/shared/webapps/tps/ui/user.html
+++ b/base/tps/shared/webapps/tps/ui/user.html
@@ -26,9 +26,9 @@
 
 <span class="pki-actions">
 
-<span name="view" class="pki-actions-menu">
-<a name="edit" href="#">Edit</a><br>
-</span>
+<ul name="view" class="pki-actions-menu">
+<li name="edit"><a href="#">Edit</a></li>
+</ul>
 
 <span name="edit" class="pki-actions-menu" style="display: none;">
 <button name="cancel">Cancel</button>
-- 
1.9.3



More information about the Pki-devel mailing list