diff options
| author | Endi S. Dewata <edewata@redhat.com> | 2016-05-20 19:31:45 +0200 |
|---|---|---|
| committer | Endi S. Dewata <edewata@redhat.com> | 2016-05-24 02:34:36 +0200 |
| commit | c6c1d96a4454ffc3849e8e89c48a1ae74cc345a7 (patch) | |
| tree | 8a50c0d6c331e72b5adaeef138820dcb9f593ee9 /base/tps/shared/webapps | |
| parent | 8c90be84038d8504f2163f4d467cfd886e238a04 (diff) | |
| download | pki-c6c1d96a4454ffc3849e8e89c48a1ae74cc345a7.tar.gz pki-c6c1d96a4454ffc3849e8e89c48a1ae74cc345a7.tar.xz pki-c6c1d96a4454ffc3849e8e89c48a1ae74cc345a7.zip | |
Added TPS UI for managing user certificates.
The TPS UI has been modified to provide an interface to manage the
user certificates.
The UserService has been modified to provide better error messages.
https://fedorahosted.org/pki/ticket/1434
Diffstat (limited to 'base/tps/shared/webapps')
| -rw-r--r-- | base/tps/shared/webapps/tps/js/user.js | 113 | ||||
| -rw-r--r-- | base/tps/shared/webapps/tps/ui/index.html | 8 | ||||
| -rw-r--r-- | base/tps/shared/webapps/tps/ui/user-certs.html | 106 | ||||
| -rw-r--r-- | base/tps/shared/webapps/tps/ui/user.html | 1 |
4 files changed, 228 insertions, 0 deletions
diff --git a/base/tps/shared/webapps/tps/js/user.js b/base/tps/shared/webapps/tps/js/user.js index 49835f004..e8ed7fc7b 100644 --- a/base/tps/shared/webapps/tps/js/user.js +++ b/base/tps/shared/webapps/tps/js/user.js @@ -150,6 +150,83 @@ var UserRoleCollection = Collection.extend({ } }); +var UserCertModel = Model.extend({ + url: function() { + var self = this; + + var userID = self.get("userID"); + var url = "/tps/rest/admin/users/" + userID + "/certs"; + + if (self.id) url = url + "/" + encodeURIComponent(self.id); + + return url; + }, + parseResponse: function(response) { + return { + id: response.id, + certID: response.id, + serialNumber: response.SerialNumber, + subjectDN: response.SubjectDN, + issuerDN: response.IssuerDN, + userID: response.UserID + }; + }, + createRequest: function(entry) { + return { + Encoded: entry.encoded + }; + }, + save: function(attributes, options) { + var self = this; + var request = self.createRequest(attributes); + $.ajax({ + type: "POST", + url: self.url(), + dataType: "json", + contentType: "application/json", + data: JSON.stringify(request), + }).done(function(data, textStatus, response) { + self.set(self.parseResponse(data)); + if (options.success) options.success.call(self, self, response, options); + }).fail(function(response, textStatus, errorThrown) { + if (options.error) options.error.call(self, self, response, options); + }); + } +}); + +var UserCertCollection = Collection.extend({ + initialize: function(models, options) { + var self = this; + UserCertCollection.__super__.initialize.call(self, models, options); + options = options || {}; + self.userID = options.userID; + self.urlRoot = "/tps/rest/admin/users/" + self.userID + "/certs"; + }, + getEntries: function(response) { + return response.Cert; + }, + getLinks: function(response) { + return response.Link; + }, + model: function(attrs, options) { + var self = this; + return new UserCertModel({ + userID: self.userID + }); + }, + parseEntry: function(entry) { + var self = this; + return new UserCertModel({ + id: entry.id, + certID: entry.id, + serialNumber: entry.SerialNumber, + subjectDN: entry.SubjectDN, + issuerDN: entry.IssuerDN, + userID: self.userID + }); + } +}); + var UserProfilesTableItem = TableItem.extend({ initialize: function(options) { var self = this; @@ -289,6 +366,13 @@ var UserPage = EntryPage.extend({ e.preventDefault(); window.location.hash = window.location.hash + "/roles"; }); + + self.showCertsAction = $("[name='showCerts']", self.viewMenu); + + $("a", self.showCertsAction).click(function(e) { + e.preventDefault(); + window.location.hash = window.location.hash + "/certs"; + }); }, saveFields: function() { var self = this; @@ -403,3 +487,32 @@ var UserRolesPage = Page.extend({ table.render(); } }); + +var UserCertsPage = Page.extend({ + load: function() { + var self = this; + + if (self.collection && self.collection.options && self.collection.options.userID) { + $(".breadcrumb li[name='user'] a") + .attr("href", "#users/" + self.collection.options.userID) + .text("User " + self.collection.options.userID); + $(".pki-title").text("Certificates for User " + self.collection.options.userID); + } + + var addCertDialog = new Dialog({ + el: self.$("#user-cert-dialog"), + title: "Add Cert", + readonly: ["userID"], + actions: ["cancel", "add"] + }); + + var table = new ModelTable({ + el: self.$("table[name='certs']"), + pageSize: 10, + addDialog: addCertDialog, + collection: self.collection + }); + + table.render(); + } +}); diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html index 9446cfbf4..f2a9d7584 100644 --- a/base/tps/shared/webapps/tps/ui/index.html +++ b/base/tps/shared/webapps/tps/ui/index.html @@ -354,6 +354,14 @@ $(function() { }).open(); }); + router.route("users/:id/certs", "user-certs", function(id) { + new UserCertsPage({ + el: content, + url: "user-certs.html", + collection: new UserCertCollection(null, { userID: id }) + }).open(); + }); + router.route("new-user", "new-user", function() { new UserPage({ el: content, diff --git a/base/tps/shared/webapps/tps/ui/user-certs.html b/base/tps/shared/webapps/tps/ui/user-certs.html new file mode 100644 index 000000000..049583e97 --- /dev/null +++ b/base/tps/shared/webapps/tps/ui/user-certs.html @@ -0,0 +1,106 @@ +<!-- --- BEGIN COPYRIGHT BLOCK --- + 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; version 2 of the License. + + 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, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Copyright (C) 2013 Red Hat, Inc. + All rights reserved. + --- END COPYRIGHT BLOCK --- --> +<div class="pki-header"> +<ol class="breadcrumb"> + <li><a href="#">Home</a></li> + <li><a href="#users">Users</a></li> + <li name="user"><a href="#users/${userID}">User ${id}</a></li> + <li class="active"><strong>Certificates</strong></li> +</ol> + +<span class="pki-title">User Certificates</span> +</div> + +<table name="certs"> +<thead> + <tr> + <th class="pki-table-actions" colspan="10"> + <span name="search"> + <input name="search" type="text" placeholder="Search..."> + </span> + <span class="pki-table-buttons"> + <button name="add">Add</button> + <button name="remove">Remove</button> + </span> + </th> + </tr> + <tr> + <th class="pki-select-column"><input id="certs-selectall" type="checkbox"><label for="certs-selectall"> </label></tdh> + <th>Serial Number</th> + <th>Subject DN</th> + <th>Issuer DN</th> + </tr> +</thead> +<tbody> + <tr> + <td class="pki-select-column"><input id="certs-select" type="checkbox"><label for="certs-select"> </label></td> + <td name="serialNumber">${serialNumber}</td> + <td name="subjectDN">${subjectDN}</td> + <td name="issuerDN">${issuerDN}</td> + </tr> +</tbody> +<tfoot> + <tr> + <th class="pki-table-actions" colspan="10"> + <div class="pki-table-info"> + Total: <span name="totalEntries">0</span> entries + </div> + <div class="pki-page-controls"> + <ul class="pagination"> + <li><a href="#" name="first"><span class="i fa fa-angle-double-left"></span></a></li> + <li><a href="#" name="prev"><span class="i fa fa-angle-left"></span></a></li> + </ul> + <span class="pki-page-jump"> + <input name="page" type="text" value="1"> of <span name="totalPages">1</span> + </span> + <ul class="pagination"> + <li><a href="#" name="next"><span class="i fa fa-angle-right"></span></a></li> + <li><a href="#" name="last"><span class="i fa fa-angle-double-right"></span></a></li> + </ul> + </div> + </th> + </tr> +</tfoot> +</table> + +<div id="user-cert-dialog" class="modal"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> + <span class="pficon pficon-close"></span> + </button> + <h4 class="modal-title">User Certificate</h4> + </div> + <div class="modal-body"> + <fieldset> + <label>User ID</label> + <input name="userID" readonly="readonly"><br> + <label>Certificate</label> + <textarea name="encoded" rows="20" cols="80"></textarea><br> + Enter a PEM certificate or PKCS #7 data. + </fieldset> + </div> + <div class="modal-footer"> + <button name="add" class="btn btn-primary">Add</button> + <button name="close" class="btn btn-primary">Close</button> + <button name="cancel" class="btn btn-default" data-dismiss="modal">Cancel</button> + </div> + </div> + </div> +</div> diff --git a/base/tps/shared/webapps/tps/ui/user.html b/base/tps/shared/webapps/tps/ui/user.html index 22ca2575a..792c9703f 100644 --- a/base/tps/shared/webapps/tps/ui/user.html +++ b/base/tps/shared/webapps/tps/ui/user.html @@ -29,6 +29,7 @@ <ul name="view" class="pki-actions-menu"> <li name="edit"><a href="#">Edit</a></li> <li name="showRoles"><a href="#">Show Roles</a></li> +<li name="showCerts"><a href="#">Show Certificates</a></li> </ul> <span name="edit" class="pki-actions-menu" style="display: none;"> |
