Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/app/users/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module.constant('users.Constants', {

MSG_CLIPBOARD_COPIED: "Copied",

LABEL_EMAIL_STATUS_VERIFIED: "Verified",

LABEL_EMAIL_STATUS_UNVERIFIED: "Unverified",

DICT_USER_STATUS: {
'A': 'Active',
'U': 'Unverified',
Expand Down
4 changes: 4 additions & 0 deletions src/app/users/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.factory('User', ['$log', 'users.Constants', 'API_URL',
User.prototype.statusDesc = function() {
return $const.DICT_USER_STATUS[this.status];
};

User.prototype.emailStatusDesc = function() {
return !!this.emailActive ? $const.LABEL_EMAIL_STATUS_VERIFIED : $const.LABEL_EMAIL_STATUS_UNVERIFIED;
};

User.prototype.createdAtLabel = function() {
return this.formatDate(this.createdAt);
Expand Down
40 changes: 25 additions & 15 deletions src/app/users/users.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ module.controller('users.UserSearchController', [
// footable
angular.element(document).ready(function () {
$('.footable').footable({
addRowToggle: true
addRowToggle: true
});
});

$scope.$on('users.TableDataUpdated', function(event){
$timeout(function(){
$('.footable').trigger('footable_redraw');
}, 100);
});


// auth
$scope.authorized = function() {
Expand Down Expand Up @@ -70,9 +77,7 @@ module.controller('users.UserSearchController', [
function(users) {
$scope.users = users;
$scope.formSearch.setLoading(false);
$timeout(function(){
$('.footable').trigger('footable_redraw');
}, 100);
$scope.$broadcast('users.TableDataUpdated');
},
function(error) {
$alert.error(error.error, $scope);
Expand Down Expand Up @@ -106,13 +111,18 @@ module.controller('users.UserSearchController', [
$alert.error('The user \'' + user.handle + '\' is invalid. Unable to activate it.', $scope);
return;
};
if(window.confirm('Are you sure you want to activate user \'' + user.handle + '\'?')) {

var confirmation = 'Are you sure you want to activate user \'' + user.handle + '\'?';
if(!user.emailActive) {
confirmation += '\nEmail address is also verified by the operation. Please confirm it\'s valid.';
}
if(window.confirm(confirmation)) {
$scope.formSearch.setLoading(true);
$userService.updateStatus(user.id, 'A').then(
function(responseUser) {
user.active = responseUser.active;
user.status = responseUser.status;
angular.copy(responseUser, user);
$scope.formSearch.setLoading(false);
$scope.$broadcast('users.TableDataUpdated');
},
function(error) {
$alert.error(error.error, $scope);
Expand Down Expand Up @@ -170,8 +180,8 @@ module.controller('users.UserSearchController', [
]);

module.controller('users.UserEditDialogController', [
'$scope', '$modalInstance', 'UserService', 'Alert', 'user',
function ($scope, $modalInstance, $userService, $alert, user) {
'$scope', '$rootScope', '$modalInstance', 'UserService', 'Alert', 'user',
function ($scope, $rootScope, $modalInstance, $userService, $alert, user) {

$scope.user = user;

Expand Down Expand Up @@ -242,8 +252,8 @@ module.controller('users.UserEditDialogController', [
]);

module.controller('users.StatusUpdateDialogController', [
'$scope', '$modalInstance', 'UserService', 'users.Constants', 'Alert', 'user',
function ($scope, $modalInstance, $userService, $const, $alert, user) {
'$scope', '$rootScope', '$modalInstance', 'UserService', 'users.Constants', 'Alert', 'user',
function ($scope, $rootScope, $modalInstance, $userService, $const, $alert, user) {

$scope.form = {
status : user.status,
Expand All @@ -268,9 +278,9 @@ module.controller('users.StatusUpdateDialogController', [
$scope.form.setLoading(true);
$userService.updateStatus(user.id, $scope.form.status, $scope.form.comment).then(
function(responseUser) {
user.active = responseUser.active;
user.status = responseUser.status;
angular.copy(responseUser, user);
$scope.form.setLoading(false);
$rootScope.$broadcast('users.TableDataUpdated');
$modalInstance.close();
},
function(error) {
Expand All @@ -285,8 +295,8 @@ module.controller('users.StatusUpdateDialogController', [
]);

module.controller('users.StatusHistoryDialogController', [
'$scope', '$modalInstance', 'UserService', 'users.Constants', 'Alert', 'user',
function ($scope, $modalInstance, $userService, $const, $alert, user) {
'$scope', '$rootScope', '$modalInstance', 'UserService', 'users.Constants', 'Alert', 'user',
function ($scope, $rootScope, $modalInstance, $userService, $const, $alert, user) {

$scope.init = function() {
$scope.achievements = [];
Expand Down
8 changes: 5 additions & 3 deletions src/app/users/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ <h2>Members</h2>
<tr>
<th data-toggle="true" data-type="numeric">User ID</th>
<th>Handle</th>
<th>Email</th>
<th>Primary Email</th>
<th data-hide="all">Name</th>
<th data-hide="all">Status</th>
<th data-hide="all">User Status</th>
<th data-hide="all">Email Status</th>
<th data-hide="all">Created at</th>
<th data-hide="all">Modified at</th>
<th data-hide="all">Activation Code</th>
<th>Active</th>
<th>User Active</th>
<th data-sort-ignore="true">Action</th>
</tr>
</thead>
Expand All @@ -83,6 +84,7 @@ <h2>Members</h2>
<i class="fa fa-list-alt text-primary"></i>
</span>
</td>
<td>{{user.emailStatusDesc()}}</td>
<td>{{user.createdAtLabel()}}</td>
<td>{{user.modifiedAtLabel()}}</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion src/app/users/users.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ angular.module('supportAdminApp')
var opts = options || {};
var query = "";
angular.forEach({
"fields": opts.fields || "id,handle,email,active,status,credential,firstName,lastName,createdAt,modifiedAt",
"fields": opts.fields || "id,handle,email,active,emailActive,status,credential,firstName,lastName,createdAt,modifiedAt",
"filter": opts.filter
//"limit" : null,
//"offset": null,
Expand Down