From 51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Sun, 10 Dec 2017 18:55:03 +0200 Subject: Final commit to master merge from Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman --- .../admin-dashboard/admin-dashboard-view.html | 1 - .../user-management/user-management-view-model.ts | 39 +++++++++++----------- .../user-management/user-management-view.html | 4 +-- 3 files changed, 21 insertions(+), 23 deletions(-) (limited to 'catalog-ui/src/app/view-models/admin-dashboard') diff --git a/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view.html b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view.html index 150f7c2554..924d46e932 100644 --- a/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view.html +++ b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view.html @@ -22,5 +22,4 @@ - 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; 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 = {}; - this.$scope.newUser = new User(resource); + let userInfo: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 @@
-- cgit 1.2.3-korg