forked from Archives/Athou_commafeed
partial user administration
This commit is contained in:
@@ -140,7 +140,8 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
|
||||
}, function(data) {
|
||||
for ( var i = 0; i < data.entries.length; i++) {
|
||||
$scope.entries.push(data.entries[i]);
|
||||
};
|
||||
}
|
||||
;
|
||||
$scope.name = data.name;
|
||||
$scope.busy = false;
|
||||
$scope.hasMore = data.entries.length == limit
|
||||
@@ -249,9 +250,46 @@ module.controller('FeedListCtrl', function($scope, $stateParams, $http, $route,
|
||||
});
|
||||
});
|
||||
|
||||
module.controller('ManageUsersCtrl', function($scope, AdminUsersService) {
|
||||
$scope.users = AdminUsersService.get();
|
||||
$scope.gridOptions = {
|
||||
data : 'users'
|
||||
module.controller('ManageUsersCtrl',
|
||||
function($scope, $state, AdminUsersService) {
|
||||
$scope.users = AdminUsersService.getAll();
|
||||
$scope.selection = [];
|
||||
$scope.gridOptions = {
|
||||
data : 'users',
|
||||
selectedItems : $scope.selection,
|
||||
multiSelect : false,
|
||||
afterSelectionChange : function(item) {
|
||||
$state.transitionTo('admin.useredit', {
|
||||
_id : item.entity.id
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.addUser = function() {
|
||||
$state.transitionTo('admin.useradd');
|
||||
};
|
||||
});
|
||||
|
||||
module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
|
||||
AdminUsersService) {
|
||||
$scope.user = $stateParams._id ? AdminUsersService.get({
|
||||
id : $stateParams._id
|
||||
}) : {};
|
||||
$scope.alerts = [];
|
||||
$scope.closeAlert = function(index) {
|
||||
$scope.alerts.splice(index, 1);
|
||||
};
|
||||
|
||||
$scope.cancel = function(){
|
||||
$state.transitionTo('admin.userlist');
|
||||
}
|
||||
$scope.save = function() {
|
||||
AdminUsersService.save($scope.user, function() {
|
||||
$state.transitionTo('admin.userlist');
|
||||
}, function(data) {
|
||||
$scope.alerts.push({
|
||||
msg : data.data
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -10,7 +10,8 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
|
||||
});
|
||||
$stateProvider.state('feeds.view', {
|
||||
url : '/view/:_type/:_id',
|
||||
templateUrl : 'templates/feeds.view.html'
|
||||
templateUrl : 'templates/feeds.view.html',
|
||||
controller : 'FeedListCtrl'
|
||||
});
|
||||
|
||||
$stateProvider.state('admin', {
|
||||
@@ -18,13 +19,24 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
|
||||
url : '/admin',
|
||||
templateUrl : 'templates/admin.html'
|
||||
});
|
||||
$stateProvider.state('admin.users', {
|
||||
url : '/users',
|
||||
templateUrl : 'templates/admin.users.html'
|
||||
$stateProvider.state('admin.userlist', {
|
||||
url : '/user/list',
|
||||
templateUrl : 'templates/admin.userlist.html',
|
||||
controller : 'ManageUsersCtrl'
|
||||
});
|
||||
$stateProvider.state('admin.useradd', {
|
||||
url : '/user/add',
|
||||
templateUrl : 'templates/admin.useradd.html',
|
||||
controller : 'ManageUserCtrl'
|
||||
});
|
||||
$stateProvider.state('admin.useredit', {
|
||||
url : '/user/edit/:_id',
|
||||
templateUrl : 'templates/admin.useredit.html',
|
||||
controller : 'ManageUserCtrl'
|
||||
});
|
||||
|
||||
$urlRouterProvider.when('/', '/feeds/view/category/all');
|
||||
$urlRouterProvider.when('/admin', '/admin/users');
|
||||
$urlRouterProvider.when('/admin', '/admin/user/list');
|
||||
$urlRouterProvider.otherwise('/');
|
||||
|
||||
});
|
||||
@@ -134,8 +134,20 @@ module.factory('AdminUsersService', function($resource) {
|
||||
method : 'GET',
|
||||
params : {
|
||||
_method : 'get'
|
||||
}
|
||||
},
|
||||
getAll : {
|
||||
method : 'GET',
|
||||
params : {
|
||||
_method : 'getAll'
|
||||
},
|
||||
isArray: true
|
||||
isArray : true
|
||||
},
|
||||
save : {
|
||||
method : 'POST',
|
||||
params : {
|
||||
_method : 'save'
|
||||
}
|
||||
}
|
||||
};
|
||||
var res = $resource('rest/admin/users/:_method', {}, actions);
|
||||
|
||||
Reference in New Issue
Block a user