import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
-import { NotificationsService } from 'angular2-notifications'
+import { Notifier } from '@app/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
styleUrls: [ './user-ban-modal.component.scss' ]
})
export class UserBanModalComponent extends FormReactive implements OnInit {
- @ViewChild('modal') modal: NgbModal
+ @ViewChild('modal', { static: true }) modal: NgbModal
@Output() userBanned = new EventEmitter<User | User[]>()
private usersToBan: User | User[]
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private notificationsService: NotificationsService,
+ private notifier: Notifier,
private userService: UserService,
private userValidatorsService: UserValidatorsService,
private i18n: I18n
openModal (user: User | User[]) {
this.usersToBan = user
- this.openedModal = this.modalService.open(this.modal)
+ this.openedModal = this.modalService.open(this.modal, { centered: true })
}
- hideBanUserModal () {
+ hide () {
this.usersToBan = undefined
this.openedModal.close()
}
? this.i18n('{{num}} users banned.', { num: this.usersToBan.length })
: this.i18n('User {{username}} banned.', { username: this.usersToBan.username })
- this.notificationsService.success(this.i18n('Success'), message)
+ this.notifier.success(message)
this.userBanned.emit(this.usersToBan)
- this.hideBanUserModal()
+ this.hide()
},
- err => this.notificationsService.error(this.i18n('Error'), err.message)
+ err => this.notifier.error(err.message)
)
}