diff options
author | Endi S. Dewata <edewata@redhat.com> | 2013-12-18 02:25:36 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2014-01-30 10:47:45 -0500 |
commit | 6fb9d2b318f9629f432c8a00d02c6b006dbe5dfb (patch) | |
tree | d42d05a3e53683c1b231928094d22012b2793ab2 /base | |
parent | cd7a937200592038c2eff3253497e1eea68a1224 (diff) | |
download | pki-6fb9d2b318f9629f432c8a00d02c6b006dbe5dfb.tar.gz pki-6fb9d2b318f9629f432c8a00d02c6b006dbe5dfb.tar.xz pki-6fb9d2b318f9629f432c8a00d02c6b006dbe5dfb.zip |
Fixed edit dialog to enable/disable TPS resources.
The edit dialogs for authenticators, connections, and profiles, have
been modified to show the available action (i.e. enable or disable)
based on the resource status.
Ticket #654
Diffstat (limited to 'base')
-rw-r--r-- | base/server/share/webapps/pki/css/pki-ui.css | 4 | ||||
-rw-r--r-- | base/server/share/webapps/pki/js/pki-ui.js | 5 | ||||
-rw-r--r-- | base/tps-tomcat/shared/webapps/tps/authenticators.html | 9 | ||||
-rw-r--r-- | base/tps-tomcat/shared/webapps/tps/connections.html | 9 | ||||
-rw-r--r-- | base/tps-tomcat/shared/webapps/tps/js/authenticator.js | 73 | ||||
-rw-r--r-- | base/tps-tomcat/shared/webapps/tps/js/connection.js | 73 | ||||
-rw-r--r-- | base/tps-tomcat/shared/webapps/tps/js/profile.js | 59 | ||||
-rw-r--r-- | base/tps-tomcat/shared/webapps/tps/profiles.html | 7 |
8 files changed, 228 insertions, 11 deletions
diff --git a/base/server/share/webapps/pki/css/pki-ui.css b/base/server/share/webapps/pki/css/pki-ui.css index 4d79d531d..3f1729f13 100644 --- a/base/server/share/webapps/pki/css/pki-ui.css +++ b/base/server/share/webapps/pki/css/pki-ui.css @@ -34,6 +34,10 @@ body { display: none; } +.rcue-dialog footer { + right: 0; +} + input[readonly="readonly"] { background-image: none; border: 1px solid #FFFFFF; diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js index 0ac313952..62bd2a2bf 100644 --- a/base/server/share/webapps/pki/js/pki-ui.js +++ b/base/server/share/webapps/pki/js/pki-ui.js @@ -328,6 +328,9 @@ var TableItemView = Backbone.View.extend({ click: function(e) { var dialog = self.table.editDialog; dialog.model = self.model; + dialog.once("close", function(event) { + self.render(); + }); dialog.open(); e.preventDefault(); } @@ -357,7 +360,7 @@ var TableView = Backbone.View.extend({ $("button[name=add]", self.thead).click(function(e) { var dialog = self.addDialog; dialog.model = new self.collection.model(); - dialog.on("close", function(event) { + dialog.once("close", function(event) { self.render(); }); dialog.open(); diff --git a/base/tps-tomcat/shared/webapps/tps/authenticators.html b/base/tps-tomcat/shared/webapps/tps/authenticators.html index 81e2c53ec..a13f21c6c 100644 --- a/base/tps-tomcat/shared/webapps/tps/authenticators.html +++ b/base/tps-tomcat/shared/webapps/tps/authenticators.html @@ -25,10 +25,10 @@ <script src="/tps/js/authenticator.js"></script> <script> $(function() { - var editDialog = new Dialog({ + var editDialog = new AuthenticatorDialog({ el: $("#authenticator-dialog"), title: "Edit Authenticator", - readonly: ["id"] + readonly: ["id", "status"] }); new TableView({ @@ -85,7 +85,10 @@ $(function() { <label>Status</label><input name="status" type="text"><br> </fieldset> <footer> - <button name="save" class="primary">Save</button> + <button name="approve">Approve</button> + <button name="reject">Reject</button> + <button name="enable" class="primary">Enable</button> + <button name="disable" class="primary">Disable</button> <button name="cancel">Cancel</button> </footer> </div> diff --git a/base/tps-tomcat/shared/webapps/tps/connections.html b/base/tps-tomcat/shared/webapps/tps/connections.html index 0f26e3301..ba5a45331 100644 --- a/base/tps-tomcat/shared/webapps/tps/connections.html +++ b/base/tps-tomcat/shared/webapps/tps/connections.html @@ -25,10 +25,10 @@ <script src="/tps/js/connection.js"></script> <script> $(function() { - var editDialog = new Dialog({ + var editDialog = new ConnectionDialog({ el: $("#connection-dialog"), title: "Edit Connection", - readonly: ["id"] + readonly: ["id", "status"] }); new TableView({ @@ -85,7 +85,10 @@ $(function() { <label>Status</label><input name="status" type="text"><br> </fieldset> <footer> - <button name="save" class="primary">Save</button> + <button name="approve">Approve</button> + <button name="reject">Reject</button> + <button name="enable" class="primary">Enable</button> + <button name="disable" class="primary">Disable</button> <button name="cancel">Cancel</button> </footer> </div> diff --git a/base/tps-tomcat/shared/webapps/tps/js/authenticator.js b/base/tps-tomcat/shared/webapps/tps/js/authenticator.js index 89ebb282a..8e67a5983 100644 --- a/base/tps-tomcat/shared/webapps/tps/js/authenticator.js +++ b/base/tps-tomcat/shared/webapps/tps/js/authenticator.js @@ -27,6 +27,15 @@ var AuthenticatorModel = Model.extend({ status: response.Authenticator.Status }; }, + parseXML: function(data) { + var xml = $(data); + var entry = $("Authenticator", xml); + var status = $("Status", entry); + return { + id: entry.attr("id"), + status: status.text() + }; + }, createRequest: function(attributes) { return { Authenticator: { @@ -34,6 +43,28 @@ var AuthenticatorModel = Model.extend({ Status: attributes.status } }; + }, + enable: function(options) { + var self = this; + $.post(self.url() + "?action=enable") + .done(function(data, textStatus, jqXHR) { + self.set(self.parseXML(data)); + options.success.call(self, data, textStatus, jqXHR); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + options.error.call(self, jqXHR, textStatus, errorThrown); + }); + }, + disable: function(options) { + var self = this; + $.post(self.url() + "?action=disable") + .done(function(data, textStatus, jqXHR) { + self.set(self.parseXML(data)); + options.success.call(self, data, textStatus, jqXHR); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + options.error.call(self, jqXHR, textStatus, errorThrown); + }); } }); @@ -52,3 +83,45 @@ var AuthenticatorCollection = Collection.extend({ }); } }); + +var AuthenticatorDialog = Dialog.extend({ + render: function() { + var self = this; + var status = self.model.get("status"); + if (status == "Enabled") { + self.actions = ["disable", "cancel"]; + } else if (status == "Disabled") { + self.actions = ["enable", "cancel"]; + } else { + alert("ERROR: Invalid status: " + status); + } + AuthenticatorDialog.__super__.render.call(self); + }, + performAction: function(action) { + var self = this; + + if (action == "enable") { + self.model.enable({ + success: function(data,textStatus, jqXHR) { + self.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("ERROR: " + textStatus); + } + }); + + } else if (action == "disable") { + self.model.disable({ + success: function(data,textStatus, jqXHR) { + self.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("ERROR: " + textStatus); + } + }); + + } else { + AuthenticatorDialog.__super__.performAction.call(self, action); + } + } +}); diff --git a/base/tps-tomcat/shared/webapps/tps/js/connection.js b/base/tps-tomcat/shared/webapps/tps/js/connection.js index bf97cc0c8..4ad7a9849 100644 --- a/base/tps-tomcat/shared/webapps/tps/js/connection.js +++ b/base/tps-tomcat/shared/webapps/tps/js/connection.js @@ -27,6 +27,15 @@ var ConnectionModel = Model.extend({ status: response.Connection.Status }; }, + parseXML: function(data) { + var xml = $(data); + var entry = $("Connection", xml); + var status = $("Status", entry); + return { + id: entry.attr("id"), + status: status.text() + }; + }, createRequest: function(attributes) { return { Connection: { @@ -34,6 +43,28 @@ var ConnectionModel = Model.extend({ Status: attributes.status } }; + }, + enable: function(options) { + var self = this; + $.post(self.url() + "?action=enable") + .done(function(data, textStatus, jqXHR) { + self.set(self.parseXML(data)); + options.success.call(self, data, textStatus, jqXHR); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + options.error.call(self, jqXHR, textStatus, errorThrown); + }); + }, + disable: function(options) { + var self = this; + $.post(self.url() + "?action=disable") + .done(function(data, textStatus, jqXHR) { + self.set(self.parseXML(data)); + options.success.call(self, data, textStatus, jqXHR); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + options.error.call(self, jqXHR, textStatus, errorThrown); + }); } }); @@ -52,3 +83,45 @@ var ConnectionCollection = Collection.extend({ }); } }); + +var ConnectionDialog = Dialog.extend({ + render: function() { + var self = this; + var status = self.model.get("status"); + if (status == "Enabled") { + self.actions = ["disable", "cancel"]; + } else if (status == "Disabled") { + self.actions = ["enable", "cancel"]; + } else { + alert("ERROR: Invalid status: " + status); + } + ConnectionDialog.__super__.render.call(self); + }, + performAction: function(action) { + var self = this; + + if (action == "enable") { + self.model.enable({ + success: function(data,textStatus, jqXHR) { + self.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("ERROR: " + textStatus); + } + }); + + } else if (action == "disable") { + self.model.disable({ + success: function(data,textStatus, jqXHR) { + self.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("ERROR: " + textStatus); + } + }); + + } else { + ConnectionDialog.__super__.performAction.call(self, action); + } + } +}); diff --git a/base/tps-tomcat/shared/webapps/tps/js/profile.js b/base/tps-tomcat/shared/webapps/tps/js/profile.js index 25ed88110..b847e12ec 100644 --- a/base/tps-tomcat/shared/webapps/tps/js/profile.js +++ b/base/tps-tomcat/shared/webapps/tps/js/profile.js @@ -27,6 +27,15 @@ var ProfileModel = Model.extend({ status: response.Profile.Status }; }, + parseXML: function(data) { + var xml = $(data); + var entry = $("Profile", xml); + var status = $("Status", entry); + return { + id: entry.attr("id"), + status: status.text() + }; + }, createRequest: function(attributes) { return { Profile: { @@ -34,6 +43,28 @@ var ProfileModel = Model.extend({ Status: attributes.status } }; + }, + enable: function(options) { + var self = this; + $.post(self.url() + "?action=enable") + .done(function(data, textStatus, jqXHR) { + self.set(self.parseXML(data)); + options.success.call(self, data, textStatus, jqXHR); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + options.error.call(self, jqXHR, textStatus, errorThrown); + }); + }, + disable: function(options) { + var self = this; + $.post(self.url() + "?action=disable") + .done(function(data, textStatus, jqXHR) { + self.set(self.parseXML(data)); + options.success.call(self, data, textStatus, jqXHR); + }) + .fail(function(jqXHR, textStatus, errorThrown) { + options.error.call(self, jqXHR, textStatus, errorThrown); + }); } }); @@ -54,12 +85,40 @@ var ProfileCollection = Collection.extend({ }); var ProfileDialog = Dialog.extend({ + render: function() { + var self = this; + var status = self.model.get("status"); + if (status == "Enabled") { + self.actions = ["disable", "cancel"]; + } else if (status == "Disabled") { + self.actions = ["enable", "cancel"]; + } else { + alert("ERROR: Invalid status: " + status); + } + ProfileDialog.__super__.render.call(self); + }, performAction: function(action) { var self = this; if (action == "enable") { + self.model.enable({ + success: function(data,textStatus, jqXHR) { + self.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("ERROR: " + textStatus); + } + }); } else if (action == "disable") { + self.model.disable({ + success: function(data,textStatus, jqXHR) { + self.close(); + }, + error: function(jqXHR, textStatus, errorThrown) { + alert("ERROR: " + textStatus); + } + }); } else { ProfileDialog.__super__.performAction.call(self, action); diff --git a/base/tps-tomcat/shared/webapps/tps/profiles.html b/base/tps-tomcat/shared/webapps/tps/profiles.html index 9f00ac543..1ccc44346 100644 --- a/base/tps-tomcat/shared/webapps/tps/profiles.html +++ b/base/tps-tomcat/shared/webapps/tps/profiles.html @@ -28,8 +28,7 @@ $(function() { var editDialog = new ProfileDialog({ el: $("#profile-dialog"), title: "Edit Profile", - readonly: ["id", "status"], - actions: ["enable", "disable", "cancel"] + readonly: ["id", "status"] }); new TableView({ @@ -88,8 +87,8 @@ $(function() { <footer> <button name="approve">Approve</button> <button name="reject">Reject</button> - <button name="enable">Enable</button> - <button name="disable">Disable</button> + <button name="enable" class="primary">Enable</button> + <button name="disable" class="primary">Disable</button> <button name="cancel">Cancel</button> </footer> </div> |