From 6fbcd46a761b14fb0209bdf05cbe15adc62edb97 Mon Sep 17 00:00:00 2001 From: jendib Date: Tue, 16 Feb 2016 01:12:27 +0100 Subject: [PATCH] #70: Init user profiles UI --- .../docs/rest/resource/UserResource.java | 2 -- docs-web/src/main/webapp/src/app/docs/app.js | 20 ++++++++++++++++++- .../webapp/src/app/docs/controller/User.js | 7 +++++++ .../src/app/docs/controller/UserProfile.js | 11 ++++++++++ docs-web/src/main/webapp/src/index.html | 5 +++++ .../main/webapp/src/partial/docs/user.html | 3 +++ .../webapp/src/partial/docs/user.profile.html | 1 + 7 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/User.js create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/UserProfile.js create mode 100644 docs-web/src/main/webapp/src/partial/docs/user.html create mode 100644 docs-web/src/main/webapp/src/partial/docs/user.profile.html diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java index aed31171..8cad2785 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/UserResource.java @@ -484,7 +484,6 @@ public class UserResource extends BaseResource { if (!authenticate()) { throw new ForbiddenClientException(); } - checkBaseFunction(BaseFunction.ADMIN); UserDao userDao = new UserDao(); User user = userDao.getActiveByUsername(username); @@ -519,7 +518,6 @@ public class UserResource extends BaseResource { if (!authenticate()) { throw new ForbiddenClientException(); } - checkBaseFunction(BaseFunction.ADMIN); JsonArrayBuilder users = Json.createArrayBuilder(); PaginatedList paginatedList = PaginatedLists.create(limit, offset); diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 4a1f981e..1d29aee4 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -216,7 +216,25 @@ angular.module('docs', controller: 'Login' } } - }); + }) + .state('user', { + url: '/user', + views: { + 'page': { + templateUrl: 'partial/docs/user.html', + controller: 'User' + } + } + }) + .state('user.profile', { + url: '/:username', + views: { + 'user': { + templateUrl: 'partial/docs/user.profile.html', + controller: 'UserProfile' + } + } + }); // Configuring Restangular RestangularProvider.setBaseUrl('../api'); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/User.js b/docs-web/src/main/webapp/src/app/docs/controller/User.js new file mode 100644 index 00000000..085e13b4 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/User.js @@ -0,0 +1,7 @@ +'use strict'; + +/** + * User controller. + */ +angular.module('docs').controller('User', function() { +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/UserProfile.js b/docs-web/src/main/webapp/src/app/docs/controller/UserProfile.js new file mode 100644 index 00000000..c783a13a --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/UserProfile.js @@ -0,0 +1,11 @@ +'use strict'; + +/** + * User profile controller. + */ +angular.module('docs').controller('UserProfile', function($stateParams, Restangular, $scope) { + // Load user + Restangular.one('user', $stateParams.username).get().then(function(data) { + $scope.user = data; + }); +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index a49b177c..a2b48b69 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -61,6 +61,8 @@ + + @@ -104,6 +106,9 @@
  • Tags
  • +
  • + Users +