-import { Component, OnInit } from '@angular/core'
-import { SortMeta } from 'primeng/primeng'
+import { Component } from '@angular/core'
import { NotificationsService } from 'angular2-notifications'
+import { SortMeta } from 'primeng/components/common/sortmeta'
import { ConfirmService } from '../../../core'
-import { RestTable, RestPagination, User } from '../../../shared'
+import { RestPagination, RestTable, User } from '../../../shared'
import { UserService } from '../shared'
@Component({
templateUrl: './user-list.component.html',
styleUrls: [ './user-list.component.scss' ]
})
-export class UserListComponent extends RestTable implements OnInit {
+export class UserListComponent extends RestTable {
users: User[] = []
totalRecords = 0
rowsPerPage = 10
super()
}
- ngOnInit () {
- this.loadData()
- }
-
- removeUser (user: User) {
+ async removeUser (user: User) {
if (user.username === 'root') {
this.notificationsService.error('Error', 'You cannot delete root.')
return
}
- this.confirmService.confirm('Do you really want to delete this user?', 'Delete').subscribe(
- res => {
- if (res === false) return
+ const res = await this.confirmService.confirm('Do you really want to delete this user?', 'Delete')
+ if (res === false) return
- this.userService.removeUser(user).subscribe(
- () => {
- this.notificationsService.success('Success', `User ${user.username} deleted.`)
- this.loadData()
- },
+ this.userService.removeUser(user).subscribe(
+ () => {
+ this.notificationsService.success('Success', `User ${user.username} deleted.`)
+ this.loadData()
+ },
- err => this.notificationsService.error('Error', err.message)
- )
- }
+ err => this.notificationsService.error('Error', err.message)
)
}