From f8b2c1b4f509c037b9650cca2c5befd21f056df3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Dec 2018 16:04:34 +0100 Subject: Refractor notification service Shorter name and use primeng component --- .../+video-edit/shared/video-edit.component.ts | 4 +-- .../video-import-torrent.component.ts | 9 +++---- .../video-import-url.component.ts | 9 +++---- .../+video-edit/video-add-components/video-send.ts | 5 ++-- .../video-add-components/video-upload.component.ts | 15 +++++------ .../videos/+video-edit/video-update.component.ts | 10 +++---- .../comment/video-comment-add.component.ts | 6 ++--- .../comment/video-comments.component.ts | 13 +++++---- .../modal/video-blacklist.component.ts | 9 +++---- .../+video-watch/modal/video-download.component.ts | 6 ++--- .../+video-watch/modal/video-report.component.ts | 8 +++--- .../+video-watch/modal/video-share.component.ts | 6 ++--- .../videos/+video-watch/video-watch.component.ts | 31 +++++++++------------- .../app/videos/video-list/video-local.component.ts | 4 +-- .../videos/video-list/video-overview.component.ts | 10 +++---- .../video-list/video-recently-added.component.ts | 4 +-- .../videos/video-list/video-trending.component.ts | 4 +-- .../video-user-subscriptions.component.ts | 4 +-- 18 files changed, 70 insertions(+), 87 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index 1d35b4ba8..85e015901 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts @@ -2,7 +2,7 @@ import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core' import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' import { ActivatedRoute, Router } from '@angular/router' import { FormReactiveValidationMessages, VideoValidatorsService } from '@app/shared' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { ServerService } from '../../../core/server' import { VideoEdit } from '../../../shared/video/video-edit.model' import { map } from 'rxjs/operators' @@ -59,7 +59,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { private videoCaptionService: VideoCaptionService, private route: ActivatedRoute, private router: Router, - private notificationsService: NotificationsService, + private notifier: Notifier, private serverService: ServerService, private i18nPrimengCalendarService: I18nPrimengCalendarService ) { diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts index 13776ae36..63db06919 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -1,8 +1,7 @@ import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' import { Router } from '@angular/router' -import { NotificationsService } from 'angular2-notifications' import { VideoPrivacy, VideoUpdate } from '../../../../../../shared/models/videos' -import { AuthService, ServerService } from '../../../core' +import { AuthService, Notifier, ServerService } from '../../../core' import { VideoService } from '../../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { LoadingBarService } from '@ngx-loading-bar/core' @@ -41,7 +40,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca constructor ( protected formValidatorService: FormValidatorService, protected loadingBar: LoadingBarService, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected serverService: ServerService, protected videoService: VideoService, @@ -107,7 +106,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca this.loadingBar.complete() this.isImportingVideo = false this.firstStepError.emit() - this.notificationsService.error(this.i18n('Error'), err.message) + this.notifier.error(err.message) } ) } @@ -126,7 +125,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca .subscribe( () => { this.isUpdatingVideo = false - this.notificationsService.success(this.i18n('Success'), this.i18n('Video to import updated.')) + this.notifier.success(this.i18n('Video to import updated.')) this.router.navigate([ '/my-account', 'video-imports' ]) }, diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts index 9cdface75..a1810b7a0 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts @@ -1,8 +1,7 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core' import { Router } from '@angular/router' -import { NotificationsService } from 'angular2-notifications' import { VideoPrivacy, VideoUpdate } from '../../../../../../shared/models/videos' -import { AuthService, ServerService } from '../../../core' +import { AuthService, Notifier, ServerService } from '../../../core' import { VideoService } from '../../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { LoadingBarService } from '@ngx-loading-bar/core' @@ -40,7 +39,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom constructor ( protected formValidatorService: FormValidatorService, protected loadingBar: LoadingBarService, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected serverService: ServerService, protected videoService: VideoService, @@ -99,7 +98,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom this.loadingBar.complete() this.isImportingVideo = false this.firstStepError.emit() - this.notificationsService.error(this.i18n('Error'), err.message) + this.notifier.error(err.message) } ) } @@ -118,7 +117,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom .subscribe( () => { this.isUpdatingVideo = false - this.notificationsService.success(this.i18n('Success'), this.i18n('Video to import updated.')) + this.notifier.success(this.i18n('Video to import updated.')) this.router.navigate([ '/my-account', 'video-imports' ]) }, diff --git a/client/src/app/videos/+video-edit/video-add-components/video-send.ts b/client/src/app/videos/+video-edit/video-add-components/video-send.ts index 71d2544d8..580c123a0 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-send.ts @@ -1,10 +1,9 @@ import { EventEmitter, OnInit } from '@angular/core' import { LoadingBarService } from '@ngx-loading-bar/core' -import { NotificationsService } from 'angular2-notifications' +import { AuthService, Notifier, ServerService } from '@app/core' import { catchError, switchMap, tap } from 'rxjs/operators' import { FormReactive } from '@app/shared' import { VideoConstant, VideoPrivacy } from '../../../../../../shared' -import { AuthService, ServerService } from '@app/core' import { VideoService } from '@app/shared/video/video.service' import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' import { VideoCaptionService } from '@app/shared/video-caption' @@ -25,7 +24,7 @@ export abstract class VideoSend extends FormReactive implements OnInit { protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy protected loadingBar: LoadingBarService - protected notificationsService: NotificationsService + protected notifier: Notifier protected authService: AuthService protected serverService: ServerService protected videoService: VideoService diff --git a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts index 2180e22ab..aa40f8781 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts @@ -2,11 +2,10 @@ import { HttpEventType, HttpResponse } from '@angular/common/http' import { Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' import { Router } from '@angular/router' import { LoadingBarService } from '@ngx-loading-bar/core' -import { NotificationsService } from 'angular2-notifications' import { BytesPipe } from 'ngx-pipes' import { Subscription } from 'rxjs' import { VideoPrivacy } from '../../../../../../shared/models/videos' -import { AuthService, ServerService } from '../../../core' +import { AuthService, Notifier, ServerService } from '../../../core' import { VideoEdit } from '../../../shared/video/video-edit.model' import { VideoService } from '../../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' @@ -53,7 +52,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy constructor ( protected formValidatorService: FormValidatorService, protected loadingBar: LoadingBarService, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected serverService: ServerService, protected videoService: VideoService, @@ -110,7 +109,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.isUploadingVideo = false this.videoUploadPercents = 0 this.videoUploadObservable = null - this.notificationsService.info(this.i18n('Info'), this.i18n('Upload cancelled')) + this.notifier.info(this.i18n('Upload cancelled')) } } @@ -130,7 +129,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy videoQuota: bytePipes.transform(videoQuota, 0) } ) - this.notificationsService.error(this.i18n('Error'), msg) + this.notifier.error(msg) return } @@ -145,7 +144,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy quotaDaily: bytePipes.transform(videoQuotaDaily, 0) } ) - this.notificationsService.error(this.i18n('Error'), msg) + this.notifier.error(msg) return } @@ -209,7 +208,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.videoUploadPercents = 0 this.videoUploadObservable = null this.firstStepError.emit() - this.notificationsService.error(this.i18n('Error'), err.message) + this.notifier.error(err.message) } ) } @@ -238,7 +237,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy this.isUpdatingVideo = false this.isUploadingVideo = false - this.notificationsService.success(this.i18n('Success'), this.i18n('Video published.')) + this.notifier.success(this.i18n('Video published.')) this.router.navigate([ '/videos/watch', video.uuid ]) }, diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index d99a02b18..d22ee540a 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -2,7 +2,7 @@ import { map, switchMap } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { LoadingBarService } from '@ngx-loading-bar/core' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos' import { ServerService } from '../../core' import { FormReactive } from '../../shared' @@ -35,7 +35,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { protected formValidatorService: FormValidatorService, private route: ActivatedRoute, private router: Router, - private notificationsService: NotificationsService, + private notifier: Notifier, private serverService: ServerService, private videoService: VideoService, private loadingBar: LoadingBarService, @@ -78,7 +78,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { err => { console.error(err) - this.notificationsService.error(this.i18n('Error'), err.message) + this.notifier.error(err.message) } ) } @@ -121,14 +121,14 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.updateDone = true this.isUpdatingVideo = false this.loadingBar.complete() - this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.')) + this.notifier.success(this.i18n('Video updated.')) this.router.navigate([ '/videos/watch', this.video.uuid ]) }, err => { this.loadingBar.complete() this.isUpdatingVideo = false - this.notificationsService.error(this.i18n('Error'), err.message) + this.notifier.error(err.message) console.error(err) } ) diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index 7f582c950..6b7e62042 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -1,6 +1,6 @@ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { Router } from '@angular/router' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { Observable } from 'rxjs' import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' import { FormReactive } from '../../../shared' @@ -36,7 +36,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { constructor ( protected formValidatorService: FormValidatorService, private videoCommentValidatorsService: VideoCommentValidatorsService, - private notificationsService: NotificationsService, + private notifier: Notifier, private videoCommentService: VideoCommentService, private authService: AuthService, private modalService: NgbModal, @@ -115,7 +115,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { err => { this.addingComment = false - this.notificationsService.error(this.i18n('Error'), err.text) + this.notifier.error(err.text) } ) } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 8850eccd8..957c17bbf 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -1,7 +1,6 @@ -import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, ElementRef } from '@angular/core' +import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { ConfirmService } from '@app/core' -import { NotificationsService } from 'angular2-notifications' +import { ConfirmService, Notifier } from '@app/core' import { Subscription } from 'rxjs' import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' import { AuthService } from '../../../core/auth' @@ -42,7 +41,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { constructor ( private authService: AuthService, - private notificationsService: NotificationsService, + private notifier: Notifier, private confirmService: ConfirmService, private videoCommentService: VideoCommentService, private activatedRoute: ActivatedRoute, @@ -92,7 +91,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { } }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -104,7 +103,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.componentPagination.totalItems = res.totalComments }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -155,7 +154,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { if (this.highlightedThread.id === commentToDelete.id) this.highlightedThread = undefined }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } diff --git a/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts b/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts index 2c123ebed..357ce39ce 100644 --- a/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-blacklist.component.ts @@ -1,12 +1,11 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' +import { Notifier, RedirectService } from '@app/core' import { FormReactive, VideoBlacklistService, VideoBlacklistValidatorsService } from '../../../shared/index' import { VideoDetails } from '../../../shared/video/video-details.model' import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' -import { RedirectService } from '@app/core' @Component({ selector: 'my-video-blacklist', @@ -27,7 +26,7 @@ export class VideoBlacklistComponent extends FormReactive implements OnInit { private modalService: NgbModal, private videoBlacklistValidatorsService: VideoBlacklistValidatorsService, private videoBlacklistService: VideoBlacklistService, - private notificationsService: NotificationsService, + private notifier: Notifier, private redirectService: RedirectService, private i18n: I18n ) { @@ -55,12 +54,12 @@ export class VideoBlacklistComponent extends FormReactive implements OnInit { this.videoBlacklistService.blacklistVideo(this.video.id, reason) .subscribe( () => { - this.notificationsService.success(this.i18n('Success'), this.i18n('Video blacklisted.')) + this.notifier.success(this.i18n('Video blacklisted.')) this.hide() this.redirectService.redirectToHomepage() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } } diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.ts b/client/src/app/videos/+video-watch/modal/video-download.component.ts index b1b2c0623..834385771 100644 --- a/client/src/app/videos/+video-watch/modal/video-download.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-download.component.ts @@ -2,7 +2,7 @@ import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core' import { VideoDetails } from '../../../shared/video/video-details.model' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { I18n } from '@ngx-translate/i18n-polyfill' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' @Component({ selector: 'my-video-download', @@ -18,7 +18,7 @@ export class VideoDownloadComponent implements OnInit { resolutionId: number | string = -1 constructor ( - private notificationsService: NotificationsService, + private notifier: Notifier, private modalService: NgbModal, private i18n: I18n ) { } @@ -63,6 +63,6 @@ export class VideoDownloadComponent implements OnInit { } activateCopiedMessage () { - this.notificationsService.success(this.i18n('Success'), this.i18n('Copied')) + this.notifier.success(this.i18n('Copied')) } } diff --git a/client/src/app/videos/+video-watch/modal/video-report.component.ts b/client/src/app/videos/+video-watch/modal/video-report.component.ts index 023387984..911f3b447 100644 --- a/client/src/app/videos/+video-watch/modal/video-report.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-report.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { FormReactive, VideoAbuseService } from '../../../shared/index' import { VideoDetails } from '../../../shared/video/video-details.model' import { I18n } from '@ngx-translate/i18n-polyfill' @@ -27,7 +27,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { private modalService: NgbModal, private videoAbuseValidatorsService: VideoAbuseValidatorsService, private videoAbuseService: VideoAbuseService, - private notificationsService: NotificationsService, + private notifier: Notifier, private i18n: I18n ) { super() @@ -66,11 +66,11 @@ export class VideoReportComponent extends FormReactive implements OnInit { this.videoAbuseService.reportVideo(this.video.id, reason) .subscribe( () => { - this.notificationsService.success(this.i18n('Success'), this.i18n('Video reported.')) + this.notifier.success(this.i18n('Video reported.')) this.hide() }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } diff --git a/client/src/app/videos/+video-watch/modal/video-share.component.ts b/client/src/app/videos/+video-watch/modal/video-share.component.ts index 17e2b31e1..c6205e355 100644 --- a/client/src/app/videos/+video-watch/modal/video-share.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-share.component.ts @@ -1,5 +1,5 @@ import { Component, ElementRef, Input, ViewChild } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { VideoDetails } from '../../../shared/video/video-details.model' import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils' import { I18n } from '@ngx-translate/i18n-polyfill' @@ -23,7 +23,7 @@ export class VideoShareComponent { constructor ( private modalService: NgbModal, - private notificationsService: NotificationsService, + private notifier: Notifier, private i18n: I18n ) { } @@ -49,7 +49,7 @@ export class VideoShareComponent { } activateCopiedMessage () { - this.notificationsService.success(this.i18n('Success'), this.i18n('Copied')) + this.notifier.success(this.i18n('Copied')) } getStartCheckboxLabel () { diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index ef0f685c6..7765c4660 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -5,7 +5,7 @@ import { RedirectService } from '@app/core/routing/redirect.service' import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component' import { MetaService } from '@ngx-meta/core' -import { NotificationsService } from 'angular2-notifications' +import { Notifier, ServerService } from '@app/core' import { forkJoin, Subscription } from 'rxjs' // FIXME: something weird with our path definition in tsconfig and typings // @ts-ignore @@ -13,7 +13,7 @@ import videojs from 'video.js' import 'videojs-hotkeys' import { Hotkey, HotkeysService } from 'angular2-hotkeys' import * as WebTorrent from 'webtorrent' -import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared' +import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '../../../../../shared' import '../../../assets/player/peertube-videojs-plugin' import { AuthService, ConfirmService } from '../../core' import { RestExtractor, VideoBlacklistService } from '../../shared' @@ -26,7 +26,6 @@ import { VideoShareComponent } from './modal/video-share.component' import { VideoBlacklistComponent } from './modal/video-blacklist.component' import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component' import { addContextMenu, getVideojsOptions, loadLocaleInVideoJS } from '../../../assets/player/peertube-player' -import { ServerService } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { environment } from '../../../environments/environment' import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' @@ -77,7 +76,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private authService: AuthService, private serverService: ServerService, private restExtractor: RestExtractor, - private notificationsService: NotificationsService, + private notifier: Notifier, private markdownService: MarkdownService, private zone: NgZone, private redirectService: RedirectService, @@ -205,7 +204,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { error => { this.descriptionLoading = false - this.notificationsService.error(this.i18n('Error'), error.message) + this.notifier.error(error.message) } ) } @@ -247,16 +246,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.videoBlacklistService.removeVideoFromBlacklist(this.video.id).subscribe( () => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Video {{name}} removed from the blacklist.', { name: this.video.name }) - ) + this.notifier.success(this.i18n('Video {{name}} removed from the blacklist.', { name: this.video.name })) this.video.blacklisted = false this.video.blacklistedReason = null }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -294,17 +290,14 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.videoService.removeVideo(this.video.id) .subscribe( - status => { - this.notificationsService.success( - this.i18n('Success'), - this.i18n('Video {{videoName}} deleted.', { videoName: this.video.name }) - ) + () => { + this.notifier.success(this.i18n('Video {{videoName}} deleted.', { videoName: this.video.name })) // Go back to the video-list. this.redirectService.redirectToHomepage() }, - error => this.notificationsService.error(this.i18n('Error'), error.message) + error => this.notifier.error(error.message) ) } @@ -354,7 +347,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { return } - this.notificationsService.error(this.i18n('Error'), errorMessage) + this.notifier.error(errorMessage) } private checkUserRating () { @@ -369,7 +362,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } }, - err => this.notificationsService.error(this.i18n('Error'), err.message) + err => this.notifier.error(err.message) ) } @@ -475,7 +468,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.userRating = nextRating }, - (err: { message: string }) => this.notificationsService.error(this.i18n('Error'), err.message) + (err: { message: string }) => this.notifier.error(err.message) ) } diff --git a/client/src/app/videos/video-list/video-local.component.ts b/client/src/app/videos/video-list/video-local.component.ts index 9d000cf2e..c0be4b885 100644 --- a/client/src/app/videos/video-list/video-local.component.ts +++ b/client/src/app/videos/video-list/video-local.component.ts @@ -2,7 +2,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { immutableAssign } from '@app/shared/misc/utils' import { Location } from '@angular/common' -import { NotificationsService } from 'angular2-notifications' import { AuthService } from '../../core/auth' import { AbstractVideoList } from '../../shared/video/abstract-video-list' import { VideoSortField } from '../../shared/video/sort-field.type' @@ -11,6 +10,7 @@ import { VideoFilter } from '../../../../../shared/models/videos/video-query.typ import { I18n } from '@ngx-translate/i18n-polyfill' import { ScreenService } from '@app/shared/misc/screen.service' import { UserRight } from '../../../../../shared/models/users' +import { Notifier } from '@app/core' @Component({ selector: 'my-videos-local', @@ -26,7 +26,7 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On constructor ( protected router: Router, protected route: ActivatedRoute, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected location: Location, protected i18n: I18n, diff --git a/client/src/app/videos/video-list/video-overview.component.ts b/client/src/app/videos/video-list/video-overview.component.ts index 2c6054721..7ff52b259 100644 --- a/client/src/app/videos/video-list/video-overview.component.ts +++ b/client/src/app/videos/video-list/video-overview.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core' -import { AuthService } from '@app/core' -import { NotificationsService } from 'angular2-notifications' +import { AuthService, Notifier } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { VideosOverview } from '@app/shared/overview/videos-overview.model' import { OverviewService } from '@app/shared/overview' @@ -21,7 +20,7 @@ export class VideoOverviewComponent implements OnInit { constructor ( private i18n: I18n, - private notificationsService: NotificationsService, + private notifier: Notifier, private authService: AuthService, private overviewService: OverviewService ) { } @@ -43,10 +42,7 @@ export class VideoOverviewComponent implements OnInit { ) this.notResults = true }, - err => { - console.log(err) - this.notificationsService.error('Error', err.text) - } + err => this.notifier.error(err.message) ) } diff --git a/client/src/app/videos/video-list/video-recently-added.component.ts b/client/src/app/videos/video-list/video-recently-added.component.ts index ac1fcfff3..f99c8abb6 100644 --- a/client/src/app/videos/video-list/video-recently-added.component.ts +++ b/client/src/app/videos/video-list/video-recently-added.component.ts @@ -2,13 +2,13 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { Location } from '@angular/common' import { immutableAssign } from '@app/shared/misc/utils' -import { NotificationsService } from 'angular2-notifications' import { AuthService } from '../../core/auth' import { AbstractVideoList } from '../../shared/video/abstract-video-list' import { VideoSortField } from '../../shared/video/sort-field.type' import { VideoService } from '../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { ScreenService } from '@app/shared/misc/screen.service' +import { Notifier } from '@app/core' @Component({ selector: 'my-videos-recently-added', @@ -24,7 +24,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On protected router: Router, protected route: ActivatedRoute, protected location: Location, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected i18n: I18n, protected screenService: ScreenService, diff --git a/client/src/app/videos/video-list/video-trending.component.ts b/client/src/app/videos/video-list/video-trending.component.ts index 8f3d3842b..accc5bfe5 100644 --- a/client/src/app/videos/video-list/video-trending.component.ts +++ b/client/src/app/videos/video-list/video-trending.component.ts @@ -2,13 +2,13 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { Location } from '@angular/common' import { immutableAssign } from '@app/shared/misc/utils' -import { NotificationsService } from 'angular2-notifications' import { AuthService } from '../../core/auth' import { AbstractVideoList } from '../../shared/video/abstract-video-list' import { VideoSortField } from '../../shared/video/sort-field.type' import { VideoService } from '../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { ScreenService } from '@app/shared/misc/screen.service' +import { Notifier } from '@app/core' @Component({ selector: 'my-videos-trending', @@ -23,7 +23,7 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, constructor ( protected router: Router, protected route: ActivatedRoute, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected location: Location, protected screenService: ScreenService, diff --git a/client/src/app/videos/video-list/video-user-subscriptions.component.ts b/client/src/app/videos/video-list/video-user-subscriptions.component.ts index 6e8959c54..bee828e12 100644 --- a/client/src/app/videos/video-list/video-user-subscriptions.component.ts +++ b/client/src/app/videos/video-list/video-user-subscriptions.component.ts @@ -2,7 +2,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { immutableAssign } from '@app/shared/misc/utils' import { Location } from '@angular/common' -import { NotificationsService } from 'angular2-notifications' import { AuthService } from '../../core/auth' import { AbstractVideoList } from '../../shared/video/abstract-video-list' import { VideoSortField } from '../../shared/video/sort-field.type' @@ -10,6 +9,7 @@ import { VideoService } from '../../shared/video/video.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { ScreenService } from '@app/shared/misc/screen.service' import { OwnerDisplayType } from '@app/shared/video/video-miniature.component' +import { Notifier } from '@app/core' @Component({ selector: 'my-videos-user-subscriptions', @@ -25,7 +25,7 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement constructor ( protected router: Router, protected route: ActivatedRoute, - protected notificationsService: NotificationsService, + protected notifier: Notifier, protected authService: AuthService, protected location: Location, protected i18n: I18n, -- cgit v1.2.3