From 170726f523ff48f89da45473fc53ca54784f43dd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Apr 2018 16:56:13 +0200 Subject: Implement video channel views --- .../account-about/account-about.component.html | 12 ++++ .../account-about/account-about.component.scss | 8 +++ .../account-about/account-about.component.ts | 39 ++++++++++++ .../account-video-channels.component.html | 11 ++++ .../account-video-channels.component.scss | 30 +++++++++ .../account-video-channels.component.ts | 33 ++++++++++ .../account-videos/account-videos.component.scss | 3 + .../account-videos/account-videos.component.ts | 71 ++++++++++++++++++++++ .../src/app/+accounts/accounts-routing.module.ts | 55 +++++++++++++++++ client/src/app/+accounts/accounts.component.html | 25 ++++++++ client/src/app/+accounts/accounts.component.scss | 6 ++ client/src/app/+accounts/accounts.component.ts | 24 ++++++++ client/src/app/+accounts/accounts.module.ts | 28 +++++++++ client/src/app/+accounts/index.ts | 3 + 14 files changed, 348 insertions(+) create mode 100644 client/src/app/+accounts/account-about/account-about.component.html create mode 100644 client/src/app/+accounts/account-about/account-about.component.scss create mode 100644 client/src/app/+accounts/account-about/account-about.component.ts create mode 100644 client/src/app/+accounts/account-video-channels/account-video-channels.component.html create mode 100644 client/src/app/+accounts/account-video-channels/account-video-channels.component.scss create mode 100644 client/src/app/+accounts/account-video-channels/account-video-channels.component.ts create mode 100644 client/src/app/+accounts/account-videos/account-videos.component.scss create mode 100644 client/src/app/+accounts/account-videos/account-videos.component.ts create mode 100644 client/src/app/+accounts/accounts-routing.module.ts create mode 100644 client/src/app/+accounts/accounts.component.html create mode 100644 client/src/app/+accounts/accounts.component.scss create mode 100644 client/src/app/+accounts/accounts.component.ts create mode 100644 client/src/app/+accounts/accounts.module.ts create mode 100644 client/src/app/+accounts/index.ts (limited to 'client/src/app/+accounts') diff --git a/client/src/app/+accounts/account-about/account-about.component.html b/client/src/app/+accounts/account-about/account-about.component.html new file mode 100644 index 000000000..003a8045e --- /dev/null +++ b/client/src/app/+accounts/account-about/account-about.component.html @@ -0,0 +1,12 @@ +
+
+
Description
+
{{ getAccountDescription() }}
+
+ +
+
Stats
+ +
Joined {{ account.createdAt | date }}
+
+
\ No newline at end of file diff --git a/client/src/app/+accounts/account-about/account-about.component.scss b/client/src/app/+accounts/account-about/account-about.component.scss new file mode 100644 index 000000000..b1be7d4ed --- /dev/null +++ b/client/src/app/+accounts/account-about/account-about.component.scss @@ -0,0 +1,8 @@ +@import '_variables'; +@import '_mixins'; + +.small-title { + @include in-content-small-title; + + margin-bottom: 20px; +} diff --git a/client/src/app/+accounts/account-about/account-about.component.ts b/client/src/app/+accounts/account-about/account-about.component.ts new file mode 100644 index 000000000..8746875cb --- /dev/null +++ b/client/src/app/+accounts/account-about/account-about.component.ts @@ -0,0 +1,39 @@ +import { Component, OnDestroy, OnInit } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' +import { Location } from '@angular/common' +import { getParameterByName, immutableAssign } from '@app/shared/misc/utils' +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 { AbstractVideoList } from '../../shared/video/abstract-video-list' +import { VideoService } from '../../shared/video/video.service' +import { Account } from '@app/shared/account/account.model' +import { AccountService } from '@app/shared/account/account.service' + +@Component({ + selector: 'my-account-about', + templateUrl: './account-about.component.html', + styleUrls: [ './account-about.component.scss' ] +}) +export class AccountAboutComponent implements OnInit { + account: Account + + constructor ( + protected route: ActivatedRoute, + private accountService: AccountService + ) { } + + ngOnInit () { + // Parent get the account for us + this.accountService.accountLoaded + .subscribe(account => this.account = account) + } + + getAccountDescription () { + if (this.account.description) return this.account.description + + return 'No description' + } +} diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html new file mode 100644 index 000000000..d20b40c60 --- /dev/null +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html @@ -0,0 +1,11 @@ +
+ + Avatar + +
{{ videoChannel.displayName }}
+
{{ videoChannel.followersCount }} subscribers
+
+
\ No newline at end of file diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss b/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss new file mode 100644 index 000000000..c9c7fa8eb --- /dev/null +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss @@ -0,0 +1,30 @@ +@import '_variables'; +@import '_mixins'; + +.row { + text-align: center; +} + +a.video-channel { + @include disable-default-a-behaviour; + + display: inline-block; + text-align: center; + color: #000; + margin: 10px 30px; + + img { + @include avatar(80px); + + margin-bottom: 10px; + } + + .video-channel-display-name { + font-size: 20px; + font-weight: $font-bold; + } + + .video-channel-followers { + font-size: 15px; + } +} \ No newline at end of file diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts new file mode 100644 index 000000000..4c5782f9d --- /dev/null +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts @@ -0,0 +1,33 @@ +import { Component, OnInit } from '@angular/core' +import { ActivatedRoute } from '@angular/router' +import 'rxjs/add/observable/from' +import 'rxjs/add/operator/concatAll' +import { Account } from '@app/shared/account/account.model' +import { AccountService } from '@app/shared/account/account.service' +import { VideoChannel } from '../../../../../shared/models/videos' +import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' + +@Component({ + selector: 'my-account-video-channels', + templateUrl: './account-video-channels.component.html', + styleUrls: [ './account-video-channels.component.scss' ] +}) +export class AccountVideoChannelsComponent implements OnInit { + account: Account + videoChannels: VideoChannel[] = [] + + constructor ( + protected route: ActivatedRoute, + private accountService: AccountService, + private videoChannelService: VideoChannelService + ) { } + + ngOnInit () { + // Parent get the account for us + this.accountService.accountLoaded + .do(account => this.account = account) + .flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)) + .map(res => res.data) + .subscribe(videoChannels => this.videoChannels = videoChannels) + } +} diff --git a/client/src/app/+accounts/account-videos/account-videos.component.scss b/client/src/app/+accounts/account-videos/account-videos.component.scss new file mode 100644 index 000000000..2ba85c031 --- /dev/null +++ b/client/src/app/+accounts/account-videos/account-videos.component.scss @@ -0,0 +1,3 @@ +.title-page-single { + margin-top: 0; +} \ No newline at end of file diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts new file mode 100644 index 000000000..6c0f0bb52 --- /dev/null +++ b/client/src/app/+accounts/account-videos/account-videos.component.ts @@ -0,0 +1,71 @@ +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 'rxjs/add/observable/from' +import 'rxjs/add/operator/concatAll' +import { AuthService } from '../../core/auth' +import { ConfirmService } from '../../core/confirm' +import { AbstractVideoList } from '../../shared/video/abstract-video-list' +import { VideoService } from '../../shared/video/video.service' +import { Account } from '@app/shared/account/account.model' +import { AccountService } from '@app/shared/account/account.service' + +@Component({ + selector: 'my-account-videos', + templateUrl: '../../shared/video/abstract-video-list.html', + styleUrls: [ + '../../shared/video/abstract-video-list.scss', + './account-videos.component.scss' + ] +}) +export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { + titlePage = 'Published videos' + marginContent = false // Disable margin + currentRoute = '/account/videos' + loadOnInit = false + + private account: Account + + constructor ( + protected router: Router, + protected route: ActivatedRoute, + protected authService: AuthService, + protected notificationsService: NotificationsService, + protected confirmService: ConfirmService, + protected location: Location, + private accountService: AccountService, + private videoService: VideoService + ) { + super() + } + + ngOnInit () { + super.ngOnInit() + + // Parent get the account for us + this.accountService.accountLoaded + .subscribe(account => { + this.account = account + this.currentRoute = '/account/' + this.account.id + '/videos' + + this.loadMoreVideos(this.pagination.currentPage) + this.generateSyndicationList() + }) + } + + ngOnDestroy () { + super.ngOnDestroy() + } + + getVideosObservable (page: number) { + const newPagination = immutableAssign(this.pagination, { currentPage: page }) + + return this.videoService.getAccountVideos(this.account, newPagination, this.sort) + } + + generateSyndicationList () { + this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id) + } +} diff --git a/client/src/app/+accounts/accounts-routing.module.ts b/client/src/app/+accounts/accounts-routing.module.ts new file mode 100644 index 000000000..ffe606b43 --- /dev/null +++ b/client/src/app/+accounts/accounts-routing.module.ts @@ -0,0 +1,55 @@ +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { MetaGuard } from '@ngx-meta/core' +import { AccountsComponent } from './accounts.component' +import { AccountVideosComponent } from './account-videos/account-videos.component' +import { AccountAboutComponent } from './account-about/account-about.component' +import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component' + +const accountsRoutes: Routes = [ + { + path: ':accountId', + component: AccountsComponent, + canActivateChild: [ MetaGuard ], + children: [ + { + path: '', + redirectTo: 'videos', + pathMatch: 'full' + }, + { + path: 'videos', + component: AccountVideosComponent, + data: { + meta: { + title: 'Account videos' + } + } + }, + { + path: 'video-channels', + component: AccountVideoChannelsComponent, + data: { + meta: { + title: 'Account video channels' + } + } + }, + { + path: 'about', + component: AccountAboutComponent, + data: { + meta: { + title: 'About account' + } + } + } + ] + } +] + +@NgModule({ + imports: [ RouterModule.forChild(accountsRoutes) ], + exports: [ RouterModule ] +}) +export class AccountsRoutingModule {} diff --git a/client/src/app/+accounts/accounts.component.html b/client/src/app/+accounts/accounts.component.html new file mode 100644 index 000000000..549676e5a --- /dev/null +++ b/client/src/app/+accounts/accounts.component.html @@ -0,0 +1,25 @@ +
+ + +
+ +
+
diff --git a/client/src/app/+accounts/accounts.component.scss b/client/src/app/+accounts/accounts.component.scss new file mode 100644 index 000000000..909b65bc7 --- /dev/null +++ b/client/src/app/+accounts/accounts.component.scss @@ -0,0 +1,6 @@ +@import '_variables'; +@import '_mixins'; + +.sub-menu { + @include sub-menu-with-actor; +} \ No newline at end of file diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts new file mode 100644 index 000000000..1298803c3 --- /dev/null +++ b/client/src/app/+accounts/accounts.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core' +import { ActivatedRoute } from '@angular/router' +import { AccountService } from '@app/shared/account/account.service' +import { Account } from '@app/shared/account/account.model' + +@Component({ + templateUrl: './accounts.component.html', + styleUrls: [ './accounts.component.scss' ] +}) +export class AccountsComponent implements OnInit { + account: Account + + constructor ( + private route: ActivatedRoute, + private accountService: AccountService + ) {} + + ngOnInit () { + const accountId = parseInt(this.route.snapshot.params['accountId'], 10) + + this.accountService.getAccount(accountId) + .subscribe(account => this.account = account) + } +} diff --git a/client/src/app/+accounts/accounts.module.ts b/client/src/app/+accounts/accounts.module.ts new file mode 100644 index 000000000..8e679822a --- /dev/null +++ b/client/src/app/+accounts/accounts.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core' +import { SharedModule } from '../shared' +import { AccountsRoutingModule } from './accounts-routing.module' +import { AccountsComponent } from './accounts.component' +import { AccountVideosComponent } from './account-videos/account-videos.component' +import { AccountAboutComponent } from './account-about/account-about.component' +import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component' + +@NgModule({ + imports: [ + AccountsRoutingModule, + SharedModule + ], + + declarations: [ + AccountsComponent, + AccountVideosComponent, + AccountVideoChannelsComponent, + AccountAboutComponent + ], + + exports: [ + AccountsComponent + ], + + providers: [] +}) +export class AccountsModule { } diff --git a/client/src/app/+accounts/index.ts b/client/src/app/+accounts/index.ts new file mode 100644 index 000000000..4dfb6f586 --- /dev/null +++ b/client/src/app/+accounts/index.ts @@ -0,0 +1,3 @@ +export * from './accounts-routing.module' +export * from './accounts.component' +export * from './accounts.module' -- cgit v1.2.3