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-import-torrent.component.ts | 9 ++++----- .../video-add-components/video-import-url.component.ts | 9 ++++----- .../videos/+video-edit/video-add-components/video-send.ts | 5 ++--- .../video-add-components/video-upload.component.ts | 15 +++++++-------- 4 files changed, 17 insertions(+), 21 deletions(-) (limited to 'client/src/app/videos/+video-edit/video-add-components') 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 ]) }, -- cgit v1.2.3