fix service generation

This commit is contained in:
Athou
2013-03-29 22:18:27 +01:00
parent 578583da59
commit a66e2dff4d
7 changed files with 30 additions and 19 deletions

View File

@@ -1,16 +1,13 @@
package com.commafeed.frontend.model; package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Set;
import com.google.common.collect.Sets;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class UserModel implements Serializable { public class UserModel implements Serializable {
private String name; private String name;
private Set<String> roles = Sets.newHashSet();
private boolean enabled; private boolean enabled;
private boolean admin;
public String getName() { public String getName() {
return name; return name;
@@ -20,12 +17,12 @@ public class UserModel implements Serializable {
this.name = name; this.name = name;
} }
public Set<String> getRoles() { public boolean isAdmin() {
return roles; return admin;
} }
public void setRoles(Set<String> roles) { public void setAdmin(boolean admin) {
this.roles = roles; this.admin = admin;
} }
public boolean isEnabled() { public boolean isEnabled() {

View File

@@ -31,7 +31,9 @@ public class AdminUsersREST extends AbstractREST {
userModel.setEnabled(!user.isDisabled()); userModel.setEnabled(!user.isDisabled());
users.put(key, userModel); users.put(key, userModel);
} }
userModel.getRoles().add(role.getRole()); if (Role.ADMIN.equals(role.getRole())) {
userModel.setAdmin(true);
}
} }
return users.values(); return users.values();
} }

View File

@@ -138,3 +138,8 @@
#feed-accordion .entry-body h4 { #feed-accordion .entry-body h4 {
margin-top: 5px; margin-top: 5px;
} }
/* admin */
.admin .users-table {
height: 400px;
}

View File

@@ -20,7 +20,6 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
}); });
$stateProvider.state('admin.users', { $stateProvider.state('admin.users', {
url : '/users', url : '/users',
controller : 'ManageUsersCtrl',
templateUrl : 'templates/admin.users.html' templateUrl : 'templates/admin.users.html'
}); });

View File

@@ -112,11 +112,11 @@ module.factory('EntryService', [ '$resource', '$http',
} }
} }
}; };
res = $resource('rest/entries/:_method', {}, actions); var res = $resource('rest/entries/:_method', {}, actions);
return res; return res;
} ]); } ]);
module.service('SettingsService', function($resource) { module.factory('SettingsService', function($resource) {
var s = {} var s = {}
s.settings = {}; s.settings = {};
$resource('rest/settings/get').get(function(data) { $resource('rest/settings/get').get(function(data) {
@@ -128,16 +128,16 @@ module.service('SettingsService', function($resource) {
return s; return s;
}); });
module.service('AdminUsersService', function($resource) { module.factory('AdminUsersService', function($resource) {
var actions = { var actions = {
get : { get : {
method : 'GET', method : 'GET',
params : { params : {
_method : 'get' _method : 'get'
}, },
isArray : true isArray: true
} }
}; };
var res = $resource('rest/admin/:_method', {}, actions); var res = $resource('rest/admin/users/:_method', {}, actions);
return res; return res;
}) });

View File

@@ -1 +1,3 @@
<div ui-view></div> <div class="container">
<div class="admin" ui-view></div>
</div>

View File

@@ -1,3 +1,9 @@
Manage users <div class="row">
<div class="page-header">
<h1>Manage users</h1>
</div>
<div ng-grid="gridOptions"></div> <div ng-controller="ManageUsersCtrl">
<div class="users-table" ng-grid="gridOptions"></div>
</div>
</div>