Skip to content

Commit

Permalink
[enhancement] refactoring admin done w directives (close #58)
Browse files Browse the repository at this point in the history
  • Loading branch information
SylTi committed Nov 30, 2014
1 parent 54d8168 commit 605a82e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 72 deletions.
5 changes: 1 addition & 4 deletions client/app/admin/admin.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ angular.module('bitCrowdFundsApp')
$scope.message = 'Something wrong happend';
});
});
$scope.projects = ProjectRes.query(function (err)
{
$scope.$broadcast("Data_Ready");
});
$scope.projects = ProjectRes.query();
};

$scope.isAdmin = function ()
Expand Down
57 changes: 15 additions & 42 deletions client/app/admin/admin.jade
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,28 @@ div(ng-include='"components/navbar/navbar.html"')
b Users Management
ul.list-group.well
li.list-group-item(ng-repeat='user in users | orderBy:"role"')
span.pull-left
a.text-muted(href="/profile/{{user.name}}")
img.avatar(gravatar-src="'{{user.email}}'", width=40)
|    
span
strong
a.text-muted(href="/profile/{{user.name}}") {{user.name}}
|  
span.label.label-danger(ng-show="user.role == 'admin'") Admin
span.label.label-info(ng-show="user.role == 'user'") User
br
small.text-warning {{user.balance | toBTC}} BTC
small.text-muted
|   
| {{user.email}}
div.pull-right
a.trash(ng-href='/admin/{{user._id}}/editUser' title='Edit user')
span.glyphicon.glyphicon-edit  
a.trash(ng-click='delete(user)', ng-show="user.active" title='Desactivate user')
span.glyphicon.glyphicon-trash
a(ng-click='activate(user)', ng-show="!user.active" title='Activate user')
span.glyphicon.glyphicon-check
admin-user-list(user='user')
div.pull-right
a.trash(ng-href='/admin/{{user._id}}/editUser' title='Edit user')
span.glyphicon.glyphicon-edit  
a.trash(ng-click='delete(user)', ng-show="user.active" title='Desactivate user')
span.glyphicon.glyphicon-trash
a(ng-click='activate(user)', ng-show="!user.active" title='Activate user')
span.glyphicon.glyphicon-check

tab
tab-heading
span.glyphicon.glyphicon-user.text-muted
|  
b Refunds Management
ul.list-group.well
li.list-group-item(ng-repeat='refund in refunds | orderBy:"role"' ng-if='refund.active')
span.pull-left
a.text-muted(href="/profile/{{refund.userInfos.name}}")
img.avatar(gravatar-src="'{{refund.userInfos.email}}'", width=40)
|    
span
strong
a.text-muted(href="/profile/{{refund.userInfos.name}}") {{refund.userInfos.name}}
|  
span.label.label-danger(ng-show="refund.userInfos.role == 'admin'") Admin
span.label.label-info(ng-show="refund.userInfos.role == 'user'") User
br
small.text-warning {{refund.userInfos.balance | toBTC}} BTC
small.text-muted
|   
| {{refund.userInfos.email}}
div.pull-right
a(ng-click='acceptRefund(refund)' title='Validate Refund')
span.glyphicon.glyphicon-check  
a.trash(ng-click='refuseRefund(refund)' title='Reject Refund')
span.glyphicon.glyphicon-remove  
admin-user-list(user='refund.userInfos')
div.pull-right
a(ng-click='acceptRefund(refund)' title='Validate Refund')
span.glyphicon.glyphicon-check  
a.trash(ng-click='refuseRefund(refund)' title='Reject Refund')
span.glyphicon.glyphicon-remove  

tab
tab-heading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/*jshint unused:false*/

angular.module('bitCrowdFundsApp')
.directive('adminProjectList', function ($timeout) {
Expand Down
8 changes: 6 additions & 2 deletions client/components/adminUserList/adminUserList.directive.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
'use strict';
/*jshint unused:false*/

angular.module('bitCrowdFundsApp')
.directive('adminUserList', function () {
return {
templateUrl: 'app/components/adminUserList/adminUserList.html',
templateUrl: 'components/adminUserList/adminUserList.html',
restrict: 'EA',
scope: {
user: '='
},
link: function (scope, element, attrs) {
}
};
});
});
39 changes: 15 additions & 24 deletions client/components/adminUserList/adminUserList.jade
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
ul.list-group.well
li.list-group-item(ng-repeat='user in users | orderBy:"role"')
span.pull-left
a.text-muted(href="/profile/{{user.name}}")
img.avatar(gravatar-src="'{{user.email}}'", width=40)
|    
span
strong
a.text-muted(href="/profile/{{user.name}}") {{user.name}}
|  
span.label.label-danger(ng-show="user.role == 'admin'") Admin
span.label.label-info(ng-show="user.role == 'user'") User
br
small.text-warning {{user.balance | toBTC}} BTC
small.text-muted
|   
| {{user.email}}
div.pull-right
a.trash(ng-href='/admin/{{user._id}}/editUser' title='Edit user')
span.glyphicon.glyphicon-edit  
a.trash(ng-click='delete(user)', ng-show="user.active" title='Desactivate user')
span.glyphicon.glyphicon-trash
a(ng-click='activate(user)', ng-show="!user.active" title='Activate user')
span.glyphicon.glyphicon-check
span.pull-left
a.text-muted(href="/profile/{{user.name}}")
img.avatar(gravatar-src="'{{user.email}}'", width=40, title='gravatar of {{user.name}}')
|    
span
strong
a.text-muted(href="/profile/{{user.name}}") {{user.name}}
|  
span.label.label-danger(ng-show="user.role == 'admin'") Admin
span.label.label-info(ng-show="user.role == 'user'") User
br
small.text-warning {{user.balance | toBTC}} BTC
small.text-muted
|   
| {{user.email}}

0 comments on commit 605a82e

Please sign in to comment.