From 62e62f118d5da57acd3494fece2e8ed357564ffe Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 9 May 2018 09:26:41 +0200 Subject: Load my-account module lazily --- .../my-account-video-channel-create.component.ts | 89 ---------------- .../my-account-video-channel-edit.component.html | 42 -------- .../my-account-video-channel-edit.component.scss | 27 ----- .../my-account-video-channel-edit.ts | 6 -- .../my-account-video-channel-update.component.ts | 117 --------------------- .../my-account-video-channels.component.html | 30 ------ .../my-account-video-channels.component.scss | 72 ------------- .../my-account-video-channels.component.ts | 59 ----------- 8 files changed, 442 deletions(-) delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channel-create.component.ts delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.html delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.scss delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.ts delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channel-update.component.ts delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.html delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.scss delete mode 100644 client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.ts (limited to 'client/src/app/my-account/my-account-video-channels') diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/my-account/my-account-video-channels/my-account-video-channel-create.component.ts deleted file mode 100644 index 0f03548ad..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-create.component.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { Component, OnInit } from '@angular/core' -import { Router } from '@angular/router' -import { NotificationsService } from 'angular2-notifications' -import 'rxjs/add/observable/from' -import 'rxjs/add/operator/concatAll' -import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' -import { FormBuilder, FormGroup } from '@angular/forms' -import { VideoChannelCreate } from '../../../../../shared/models/videos' -import { - VIDEO_CHANNEL_DESCRIPTION, - VIDEO_CHANNEL_DISPLAY_NAME, - VIDEO_CHANNEL_SUPPORT -} from '@app/shared/forms/form-validators/video-channel' -import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' -import { AuthService } from '@app/core' - -@Component({ - selector: 'my-account-video-channel-create', - templateUrl: './my-account-video-channel-edit.component.html', - styleUrls: [ './my-account-video-channel-edit.component.scss' ] -}) -export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelEdit implements OnInit { - error: string - - form: FormGroup - formErrors = { - 'display-name': '', - 'description': '', - 'support': '' - } - validationMessages = { - 'display-name': VIDEO_CHANNEL_DISPLAY_NAME.MESSAGES, - 'description': VIDEO_CHANNEL_DESCRIPTION.MESSAGES, - 'support': VIDEO_CHANNEL_SUPPORT.MESSAGES - } - - constructor ( - private authService: AuthService, - private notificationsService: NotificationsService, - private router: Router, - private formBuilder: FormBuilder, - private videoChannelService: VideoChannelService - ) { - super() - } - - buildForm () { - this.form = this.formBuilder.group({ - 'display-name': [ '', VIDEO_CHANNEL_DISPLAY_NAME.VALIDATORS ], - description: [ '', VIDEO_CHANNEL_DESCRIPTION.VALIDATORS ], - support: [ '', VIDEO_CHANNEL_SUPPORT.VALIDATORS ] - }) - - this.form.valueChanges.subscribe(data => this.onValueChanged(data)) - } - - ngOnInit () { - this.buildForm() - } - - formValidated () { - this.error = undefined - - const body = this.form.value - const videoChannelCreate: VideoChannelCreate = { - displayName: body['display-name'], - description: body.description || undefined, - support: body.support || undefined - } - - this.videoChannelService.createVideoChannel(videoChannelCreate).subscribe( - () => { - this.authService.refreshUserInformation() - this.notificationsService.success('Success', `Video channel ${videoChannelCreate.displayName} created.`) - this.router.navigate([ '/my-account', 'video-channels' ]) - }, - - err => this.error = err.message - ) - } - - isCreation () { - return true - } - - getFormButtonTitle () { - return 'Create' - } -} diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.html b/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.html deleted file mode 100644 index d5fb6262a..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.html +++ /dev/null @@ -1,42 +0,0 @@ -
Create a video channel
-
Update {{ videoChannel?.displayName }}
- -
{{ error }}
- -
-
- - -
- {{ formErrors['display-name'] }} -
-
- -
- - -
- {{ formErrors.description }} -
-
- -
- - - -
- {{ formErrors.support }} -
-
- - -
diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.scss b/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.scss deleted file mode 100644 index 6fbb8ae8b..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.component.scss +++ /dev/null @@ -1,27 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.form-sub-title { - margin-bottom: 20px; -} - -input[type=text] { - @include peertube-input-text(340px); - - display: block; -} - -textarea { - @include peertube-textarea(500px, 150px); - - display: block; -} - -.peertube-select-container { - @include peertube-select-container(340px); -} - -input[type=submit] { - @include peertube-button; - @include orange-button; -} \ No newline at end of file diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.ts b/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.ts deleted file mode 100644 index e56f46262..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-edit.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { FormReactive } from '@app/shared' - -export abstract class MyAccountVideoChannelEdit extends FormReactive { - abstract isCreation (): boolean - abstract getFormButtonTitle (): string -} diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/my-account/my-account-video-channels/my-account-video-channel-update.component.ts deleted file mode 100644 index c0dc6a939..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channel-update.component.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { Component, OnInit, OnDestroy } from '@angular/core' -import { ActivatedRoute, Router } from '@angular/router' -import { NotificationsService } from 'angular2-notifications' -import 'rxjs/add/observable/from' -import 'rxjs/add/operator/concatAll' -import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' -import { FormBuilder, FormGroup } from '@angular/forms' -import { VideoChannelUpdate } from '../../../../../shared/models/videos' -import { - VIDEO_CHANNEL_DESCRIPTION, - VIDEO_CHANNEL_DISPLAY_NAME, - VIDEO_CHANNEL_SUPPORT -} from '@app/shared/forms/form-validators/video-channel' -import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' -import { Subscription } from 'rxjs/Subscription' -import { VideoChannel } from '@app/shared/video-channel/video-channel.model' -import { AuthService } from '@app/core' - -@Component({ - selector: 'my-account-video-channel-update', - templateUrl: './my-account-video-channel-edit.component.html', - styleUrls: [ './my-account-video-channel-edit.component.scss' ] -}) -export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy { - error: string - - form: FormGroup - formErrors = { - 'display-name': '', - 'description': '', - 'support': '' - } - validationMessages = { - 'display-name': VIDEO_CHANNEL_DISPLAY_NAME.MESSAGES, - 'description': VIDEO_CHANNEL_DESCRIPTION.MESSAGES, - 'support': VIDEO_CHANNEL_SUPPORT.MESSAGES - } - - private videoChannelToUpdate: VideoChannel - private paramsSub: Subscription - - constructor ( - private authService: AuthService, - private notificationsService: NotificationsService, - private router: Router, - private route: ActivatedRoute, - private formBuilder: FormBuilder, - private videoChannelService: VideoChannelService - ) { - super() - } - - buildForm () { - this.form = this.formBuilder.group({ - 'display-name': [ '', VIDEO_CHANNEL_DISPLAY_NAME.VALIDATORS ], - description: [ '', VIDEO_CHANNEL_DESCRIPTION.VALIDATORS ], - support: [ '', VIDEO_CHANNEL_SUPPORT.VALIDATORS ] - }) - - this.form.valueChanges.subscribe(data => this.onValueChanged(data)) - } - - ngOnInit () { - this.buildForm() - - this.paramsSub = this.route.params.subscribe(routeParams => { - const videoChannelId = routeParams['videoChannelId'] - - this.videoChannelService.getVideoChannel(videoChannelId).subscribe( - videoChannelToUpdate => { - this.videoChannelToUpdate = videoChannelToUpdate - - this.form.patchValue({ - 'display-name': videoChannelToUpdate.displayName, - description: videoChannelToUpdate.description, - support: videoChannelToUpdate.support - }) - }, - - err => this.error = err.message - ) - }) - } - - ngOnDestroy () { - if (this.paramsSub) this.paramsSub.unsubscribe() - } - - formValidated () { - this.error = undefined - - const body = this.form.value - const videoChannelUpdate: VideoChannelUpdate = { - displayName: body['display-name'], - description: body.description || undefined, - support: body.support || undefined - } - - this.videoChannelService.updateVideoChannel(this.videoChannelToUpdate.uuid, videoChannelUpdate).subscribe( - () => { - this.authService.refreshUserInformation() - this.notificationsService.success('Success', `Video channel ${videoChannelUpdate.displayName} updated.`) - this.router.navigate([ '/my-account', 'video-channels' ]) - }, - - err => this.error = err.message - ) - } - - isCreation () { - return false - } - - getFormButtonTitle () { - return 'Update' - } -} diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.html b/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.html deleted file mode 100644 index 90c401bc5..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.html +++ /dev/null @@ -1,30 +0,0 @@ -
- - - Create another video channel - -
- -
-
- - Avatar - - -
- -
{{ videoChannel.displayName }}
- - -
- -
{{ videoChannel.followersCount }} subscribers
-
- -
- - - -
-
-
diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.scss b/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.scss deleted file mode 100644 index bcb58eac2..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.scss +++ /dev/null @@ -1,72 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.create-button { - @include create-button; -} - -/deep/ .action-button { - &.action-button-delete { - margin-right: 10px; - } -} - -.video-channel { - display: flex; - min-height: 130px; - padding-bottom: 20px; - margin-bottom: 20px; - border-bottom: 1px solid #C6C6C6; - - img { - @include avatar(80px); - - margin-right: 10px; - } - - .video-channel-info { - flex-grow: 1; - - a.video-channel-names { - @include disable-default-a-behaviour; - - display: flex; - color: #000; - - .video-channel-display-name { - font-weight: $font-semibold; - font-size: 18px; - } - - .video-channel-name { - font-size: 14px; - color: #777272; - } - } - } - - .video-channel-buttons { - min-width: 190px; - } -} - -.video-channels-header { - text-align: right; - margin: 20px 0 50px; -} - -@media screen and (max-width: 800px) { - .video-channel { - flex-direction: column; - height: auto; - text-align: center; - - img { - margin-right: 0; - } - - .video-channel-buttons { - margin-top: 10px; - } - } -} diff --git a/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.ts b/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.ts deleted file mode 100644 index eeaca11df..000000000 --- a/client/src/app/my-account/my-account-video-channels/my-account-video-channels.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Component, OnInit } from '@angular/core' -import { NotificationsService } from 'angular2-notifications' -import 'rxjs/add/observable/from' -import 'rxjs/add/operator/concatAll' -import { AuthService } from '../../core/auth' -import { ConfirmService } from '../../core/confirm' -import { VideoChannel } from '@app/shared/video-channel/video-channel.model' -import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' -import { User } from '@app/shared' - -@Component({ - selector: 'my-account-video-channels', - templateUrl: './my-account-video-channels.component.html', - styleUrls: [ './my-account-video-channels.component.scss' ] -}) -export class MyAccountVideoChannelsComponent implements OnInit { - videoChannels: VideoChannel[] = [] - - private user: User - - constructor ( - private authService: AuthService, - private notificationsService: NotificationsService, - private confirmService: ConfirmService, - private videoChannelService: VideoChannelService - ) {} - - ngOnInit () { - this.user = this.authService.getUser() - - this.loadVideoChannels() - } - - async deleteVideoChannel (videoChannel: VideoChannel) { - const res = await this.confirmService.confirmWithInput( - `Do you really want to delete ${videoChannel.displayName}? It will delete all videos uploaded in this channel too.`, - 'Please type the name of the video channel to confirm', - videoChannel.displayName, - 'Delete' - ) - if (res === false) return - - this.videoChannelService.removeVideoChannel(videoChannel) - .subscribe( - status => { - this.loadVideoChannels() - this.notificationsService.success('Success', `Video channel ${videoChannel.name} deleted.`) - }, - - error => this.notificationsService.error('Error', error.message) - ) - } - - private loadVideoChannels () { - this.authService.userInformationLoaded - .flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account.id)) - .subscribe(res => this.videoChannels = res.data) - } -} -- cgit v1.2.3