summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models/admin-dashboard/user-management
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-ui/src/app/view-models/admin-dashboard/user-management
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/view-models/admin-dashboard/user-management')
-rw-r--r--catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts39
-rw-r--r--catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html4
2 files changed, 21 insertions, 22 deletions
diff --git a/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts
index e1f3a50b44..db94a475d1 100644
--- a/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts
+++ b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts
@@ -20,8 +20,8 @@
'use strict';
import {ModalsHandler} from "app/utils";
-import {IUserResource, IUserResourceClass} from "app/services";
import {User, IUserProperties, IUser, IAppConfigurtaion} from "app/models";
+import {UserService} from "../../../ng2/services/user.service";
interface IUserManagementViewModelScope extends ng.IScope {
sdcConfig:IAppConfigurtaion;
@@ -33,7 +33,7 @@ interface IUserManagementViewModelScope extends ng.IScope {
tableHeadersList:any;
roles:Array<string>;
newUser:IUser;
- currentUser:IUserResource;
+ currentUser:IUserProperties;
userIdValidationPattern:RegExp;
editForm:ng.IFormController;
getAllUsers():void;
@@ -53,7 +53,7 @@ export class UserManagementViewModel {
static '$inject' = [
'$scope',
'sdcConfig',
- 'Sdc.Services.UserResourceService',
+ 'UserServiceNg2',
'UserIdValidationPattern',
'$filter',
'ModalsHandler'
@@ -61,7 +61,7 @@ export class UserManagementViewModel {
constructor(private $scope:IUserManagementViewModelScope,
private sdcConfig:IAppConfigurtaion,
- private userResourceService:IUserResourceClass,
+ private userService:UserService,
private UserIdValidationPattern:RegExp,
private $filter:ng.IFilterService,
private ModalsHandler:ModalsHandler) {
@@ -85,7 +85,7 @@ export class UserManagementViewModel {
});
this.$scope.isLoading = false;
};
- this.userResourceService.getAllUsers(onSuccess, onError);
+ this.userService.getAllUsers().subscribe(onSuccess, onError);
};
private updateUserFilterTerm = (user:IUserProperties):void => {
@@ -111,11 +111,11 @@ export class UserManagementViewModel {
this.$scope.reverse = false;
this.$scope.roles = this.sdcConfig.roles;
this.$scope.isNewUser = false;
- this.$scope.currentUser = this.userResourceService.getLoggedinUser();
+ this.$scope.currentUser = this.userService.getLoggedinUser();
this.getAllUsers();
- let resource:IUserResource = <IUserResource>{};
- this.$scope.newUser = new User(resource);
+ let userInfo:IUserProperties = <IUserProperties>{};
+ this.$scope.newUser = new User(userInfo);
this.$scope.sort = (sortBy:string):void => {//default sort by descending last update. default for alphabetical = ascending
this.$scope.isNewUser = false;
@@ -131,13 +131,12 @@ export class UserManagementViewModel {
};
let onSuccess = (response:IUserProperties) => {
- this.$scope.newUser.resource['index'] = this.$scope.usersList.length;
- this.$scope.newUser.resource.lastLoginTime = "0";
- this.$scope.newUser.resource.status = response.status;
- this.updateUserFilterTerm(this.$scope.newUser.resource);
- this.$scope.usersList.unshift(this.$scope.newUser.resource);
+ this.$scope.newUser.userInfo.lastLoginTime = "0";
+ this.$scope.newUser.userInfo.status = response.status;
+ this.updateUserFilterTerm(this.$scope.newUser.userInfo);
+ this.$scope.usersList.push(this.$scope.newUser.userInfo);
this.$scope.isNewUser = true;
- this.$scope.sortBy = 'index';
+ this.$scope.sortBy = null;
this.$scope.reverse = true;
this.$scope.isLoading = false;
this.$scope.newUser = new User(null);
@@ -147,10 +146,10 @@ export class UserManagementViewModel {
_self.$scope.isNewUser = false;
}, 7000);
};
- this.userResourceService.createUser({
- userId: this.$scope.newUser.resource.userId,
- role: this.$scope.newUser.resource.role
- }, onSuccess, onError);
+ this.userService.createUser({
+ userId: this.$scope.newUser.userInfo.userId,
+ role: this.$scope.newUser.userInfo.role
+ }).subscribe(onSuccess, onError);
};
@@ -174,7 +173,7 @@ export class UserManagementViewModel {
this.updateUserFilterTerm(user);
};
- this.userResourceService.editUserRole({id: user.userId, role: user.role}, onSuccess, onError);
+ this.userService.editUserRole(user.userId, user.role).subscribe(onSuccess, onError);
};
this.$scope.saveUserChanges = (user:IUserProperties):void => {
@@ -198,7 +197,7 @@ export class UserManagementViewModel {
_.remove(this.$scope.usersList, {userId: userId});
this.$scope.isLoading = false;
};
- this.userResourceService.deleteUser({id: userId}, onSuccess, onError);
+ this.userService.deleteUser(userId).subscribe(onSuccess, onError);
};
let title:string = this.$filter('translate')("USER_MANAGEMENT_VIEW_DELETE_MODAL_TITLE");
diff --git a/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html
index d2983873cc..2f94fb4aee 100644
--- a/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html
+++ b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html
@@ -14,7 +14,7 @@
<div class="sdc-user-management-top-bar-wrapper">
<div class="i-sdc-form-item sdc-user-management-top-bar-form-container" data-ng-class="{error:(editForm.contactId.$dirty && editForm.contactId.$invalid)}">
<input ng-focus="search.filterTerm=''" type="text"
- data-ng-model="newUser.resource.userId"
+ data-ng-model="newUser.userInfo.userId"
class="i-sdc-form-input"
placeholder="{{ USER_MANAGEMENT_SEARCH_TEXT | translate}}"
data-ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 750, 'blur': 0 } }"
@@ -36,7 +36,7 @@
data-required
name="role"
data-tests-id="selectrole"
- data-ng-model = "newUser.resource.role"
+ data-ng-model = "newUser.userInfo.role"
data-ng-options="role as (getTitle(role)) for role in roles | orderBy:'role'"
ng-focus="search.filterTerm=''">
<option value="">Select Role</option>