diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 12b5d27a..df6a6a6a 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -416,6 +416,8 @@ SET_ROLE_FAILED: 'set user role failed', SET_STATUS_SUCCESSFULLY: 'set user status successfully', SET_STATUS_FAILED: 'set user status failed', + SET_IMAGE_SUCCESSFULLY: 'set user image successfully', + SET_IMAGE_FAILED: 'set user image failed', SCORE_NUMBER: 'Score number', SCORE_TITLE: 'Edit user score', @@ -478,6 +480,7 @@ DOWNLOADING_LIST_ERROR: 'Get downloading list info failed', STATUS_FIELD: { PICTURE: 'Profile picture', + RESET_DEFAULT_PICTURE: 'Reset to default picture', USERNAME: 'Username', FIRST_NAME: 'First name', LAST_NAME: 'Last name', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 9e04a941..f6abbee0 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -478,6 +478,7 @@ DOWNLOADING_LIST_ERROR: '获取我正下载的列表失败', STATUS_FIELD: { PICTURE: '头像', + RESET_DEFAULT_PICTURE: '重置为默认图片', USERNAME: '用户名', FIRST_NAME: '姓', LAST_NAME: '名', diff --git a/modules/users/client/controllers/admin/user.client.controller.js b/modules/users/client/controllers/admin/user.client.controller.js index ad783eb4..3aae791b 100644 --- a/modules/users/client/controllers/admin/user.client.controller.js +++ b/modules/users/client/controllers/admin/user.client.controller.js @@ -107,6 +107,29 @@ return vm.user ? vm.user.username === vm.authentication.user.username : false; } + /** + * resetDefaultProfileImage + */ + vm.resetDefaultProfileImage = function () { + var user = vm.user; + AdminService.resetUserProfileImage({ + userId: user._id + }) + .then(onSetRoleSuccess) + .catch(onSetRoleError); + + function onSetRoleSuccess(response) { + vm.user = response; + + NotifycationService.showSuccessNotify('SET_IMAGE_SUCCESSFULLY'); + } + + function onSetRoleError(response) { + NotifycationService.showErrorNotify(response.data.message, 'SET_IMAGE_FAILED'); + } + + }; + /** * onUserRoleChanged * admin set user`s role diff --git a/modules/users/client/services/users.client.service.js b/modules/users/client/services/users.client.service.js index 122eb25a..b3dd51c0 100644 --- a/modules/users/client/services/users.client.service.js +++ b/modules/users/client/services/users.client.service.js @@ -144,6 +144,13 @@ params: { userId: '@userId' } + }, + setDefaultProfileImage: { + method: 'PUT', + url: '/api/users/:userId/resetImage', + params: { + userId: '@userId' + } } }); @@ -165,6 +172,9 @@ }, countUserUploaded: function (params) { return this.getUserUploadedTotal(params).$promise; + }, + resetUserProfileImage: function (params) { + return this.setDefaultProfileImage(params).$promise; } }); diff --git a/modules/users/client/views/admin/view-user.client.view.html b/modules/users/client/views/admin/view-user.client.view.html index 05bd8138..24dae13b 100644 --- a/modules/users/client/views/admin/view-user.client.view.html +++ b/modules/users/client/views/admin/view-user.client.view.html @@ -25,6 +25,9 @@