diff options
Diffstat (limited to 'client/src/app/+admin/users')
3 files changed, 24 insertions, 37 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts index dd8e4efd5..137ecfcbd 100644 --- a/client/src/app/+admin/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/users/user-edit/user-create.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { Router } from '@angular/router' | 2 | import { Router } from '@angular/router' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { Notifier, ServerService } from '@app/core' |
4 | import { ServerService } from '../../../core' | ||
5 | import { UserCreate, UserRole } from '../../../../../../shared' | 4 | import { UserCreate, UserRole } from '../../../../../../shared' |
6 | import { UserEdit } from './user-edit' | 5 | import { UserEdit } from './user-edit' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -24,7 +23,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { | |||
24 | protected configService: ConfigService, | 23 | protected configService: ConfigService, |
25 | private userValidatorsService: UserValidatorsService, | 24 | private userValidatorsService: UserValidatorsService, |
26 | private router: Router, | 25 | private router: Router, |
27 | private notificationsService: NotificationsService, | 26 | private notifier: Notifier, |
28 | private userService: UserService, | 27 | private userService: UserService, |
29 | private i18n: I18n | 28 | private i18n: I18n |
30 | ) { | 29 | ) { |
@@ -60,10 +59,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { | |||
60 | 59 | ||
61 | this.userService.addUser(userCreate).subscribe( | 60 | this.userService.addUser(userCreate).subscribe( |
62 | () => { | 61 | () => { |
63 | this.notificationsService.success( | 62 | this.notifier.success(this.i18n('User {{username}} created.', { username: userCreate.username })) |
64 | this.i18n('Success'), | ||
65 | this.i18n('User {{username}} created.', { username: userCreate.username }) | ||
66 | ) | ||
67 | this.router.navigate([ '/admin/users/list' ]) | 63 | this.router.navigate([ '/admin/users/list' ]) |
68 | }, | 64 | }, |
69 | 65 | ||
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts index cd3885a99..61e641823 100644 --- a/client/src/app/+admin/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/users/user-edit/user-update.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { Subscription } from 'rxjs' | 3 | import { Subscription } from 'rxjs' |
4 | import { NotificationsService } from 'angular2-notifications' | 4 | import { Notifier } from '@app/core' |
5 | import { ServerService } from '../../../core' | 5 | import { ServerService } from '../../../core' |
6 | import { UserEdit } from './user-edit' | 6 | import { UserEdit } from './user-edit' |
7 | import { User, UserUpdate } from '../../../../../../shared' | 7 | import { User, UserUpdate } from '../../../../../../shared' |
@@ -30,7 +30,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
30 | private userValidatorsService: UserValidatorsService, | 30 | private userValidatorsService: UserValidatorsService, |
31 | private route: ActivatedRoute, | 31 | private route: ActivatedRoute, |
32 | private router: Router, | 32 | private router: Router, |
33 | private notificationsService: NotificationsService, | 33 | private notifier: Notifier, |
34 | private userService: UserService, | 34 | private userService: UserService, |
35 | private i18n: I18n | 35 | private i18n: I18n |
36 | ) { | 36 | ) { |
@@ -73,10 +73,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
73 | 73 | ||
74 | this.userService.updateUser(this.userId, userUpdate).subscribe( | 74 | this.userService.updateUser(this.userId, userUpdate).subscribe( |
75 | () => { | 75 | () => { |
76 | this.notificationsService.success( | 76 | this.notifier.success(this.i18n('User {{username}} updated.', { username: this.username })) |
77 | this.i18n('Success'), | ||
78 | this.i18n('User {{username}} updated.', { username: this.username }) | ||
79 | ) | ||
80 | this.router.navigate([ '/admin/users/list' ]) | 77 | this.router.navigate([ '/admin/users/list' ]) |
81 | }, | 78 | }, |
82 | 79 | ||
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts index fb085c133..66ab796f9 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/users/user-list/user-list.component.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Component, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, OnInit, ViewChild } from '@angular/core' |
2 | import { NotificationsService } from 'angular2-notifications' | 2 | import { Notifier } from '@app/core' |
3 | import { SortMeta } from 'primeng/components/common/sortmeta' | 3 | import { SortMeta } from 'primeng/components/common/sortmeta' |
4 | import { ConfirmService, ServerService } from '../../../core' | 4 | import { ConfirmService, ServerService } from '../../../core' |
5 | import { RestPagination, RestTable, UserService } from '../../../shared' | 5 | import { RestPagination, RestTable, UserService } from '../../../shared' |
@@ -26,7 +26,7 @@ export class UserListComponent extends RestTable implements OnInit { | |||
26 | bulkUserActions: DropdownAction<User[]>[] = [] | 26 | bulkUserActions: DropdownAction<User[]>[] = [] |
27 | 27 | ||
28 | constructor ( | 28 | constructor ( |
29 | private notificationsService: NotificationsService, | 29 | private notifier: Notifier, |
30 | private confirmService: ConfirmService, | 30 | private confirmService: ConfirmService, |
31 | private serverService: ServerService, | 31 | private serverService: ServerService, |
32 | private userService: UserService, | 32 | private userService: UserService, |
@@ -68,7 +68,7 @@ export class UserListComponent extends RestTable implements OnInit { | |||
68 | openBanUserModal (users: User[]) { | 68 | openBanUserModal (users: User[]) { |
69 | for (const user of users) { | 69 | for (const user of users) { |
70 | if (user.username === 'root') { | 70 | if (user.username === 'root') { |
71 | this.notificationsService.error(this.i18n('Error'), this.i18n('You cannot ban root.')) | 71 | this.notifier.error(this.i18n('You cannot ban root.')) |
72 | return | 72 | return |
73 | } | 73 | } |
74 | } | 74 | } |
@@ -91,18 +91,18 @@ export class UserListComponent extends RestTable implements OnInit { | |||
91 | () => { | 91 | () => { |
92 | const message = this.i18n('{{num}} users unbanned.', { num: users.length }) | 92 | const message = this.i18n('{{num}} users unbanned.', { num: users.length }) |
93 | 93 | ||
94 | this.notificationsService.success(this.i18n('Success'), message) | 94 | this.notifier.success(message) |
95 | this.loadData() | 95 | this.loadData() |
96 | }, | 96 | }, |
97 | 97 | ||
98 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 98 | err => this.notifier.error(err.message) |
99 | ) | 99 | ) |
100 | } | 100 | } |
101 | 101 | ||
102 | async removeUsers (users: User[]) { | 102 | async removeUsers (users: User[]) { |
103 | for (const user of users) { | 103 | for (const user of users) { |
104 | if (user.username === 'root') { | 104 | if (user.username === 'root') { |
105 | this.notificationsService.error(this.i18n('Error'), this.i18n('You cannot delete root.')) | 105 | this.notifier.error(this.i18n('You cannot delete root.')) |
106 | return | 106 | return |
107 | } | 107 | } |
108 | } | 108 | } |
@@ -113,28 +113,22 @@ export class UserListComponent extends RestTable implements OnInit { | |||
113 | 113 | ||
114 | this.userService.removeUser(users).subscribe( | 114 | this.userService.removeUser(users).subscribe( |
115 | () => { | 115 | () => { |
116 | this.notificationsService.success( | 116 | this.notifier.success(this.i18n('{{num}} users deleted.', { num: users.length })) |
117 | this.i18n('Success'), | ||
118 | this.i18n('{{num}} users deleted.', { num: users.length }) | ||
119 | ) | ||
120 | this.loadData() | 117 | this.loadData() |
121 | }, | 118 | }, |
122 | 119 | ||
123 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 120 | err => this.notifier.error(err.message) |
124 | ) | 121 | ) |
125 | } | 122 | } |
126 | 123 | ||
127 | async setEmailsAsVerified (users: User[]) { | 124 | async setEmailsAsVerified (users: User[]) { |
128 | this.userService.updateUsers(users, { emailVerified: true }).subscribe( | 125 | this.userService.updateUsers(users, { emailVerified: true }).subscribe( |
129 | () => { | 126 | () => { |
130 | this.notificationsService.success( | 127 | this.notifier.success(this.i18n('{{num}} users email set as verified.', { num: users.length })) |
131 | this.i18n('Success'), | ||
132 | this.i18n('{{num}} users email set as verified.', { num: users.length }) | ||
133 | ) | ||
134 | this.loadData() | 128 | this.loadData() |
135 | }, | 129 | }, |
136 | 130 | ||
137 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 131 | err => this.notifier.error(err.message) |
138 | ) | 132 | ) |
139 | } | 133 | } |
140 | 134 | ||
@@ -146,13 +140,13 @@ export class UserListComponent extends RestTable implements OnInit { | |||
146 | this.selectedUsers = [] | 140 | this.selectedUsers = [] |
147 | 141 | ||
148 | this.userService.getUsers(this.pagination, this.sort, this.search) | 142 | this.userService.getUsers(this.pagination, this.sort, this.search) |
149 | .subscribe( | 143 | .subscribe( |
150 | resultList => { | 144 | resultList => { |
151 | this.users = resultList.data | 145 | this.users = resultList.data |
152 | this.totalRecords = resultList.total | 146 | this.totalRecords = resultList.total |
153 | }, | 147 | }, |
154 | 148 | ||
155 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 149 | err => this.notifier.error(err.message) |
156 | ) | 150 | ) |
157 | } | 151 | } |
158 | } | 152 | } |