diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-25 16:56:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-25 16:56:13 +0200 |
commit | 170726f523ff48f89da45473fc53ca54784f43dd (patch) | |
tree | f9f783ebdfc934c6831396c2bf33f658d6640583 /client/src/app/+video-channels | |
parent | cc918ac3f45e32f031cce7b6e0473e5c2c34b8ae (diff) | |
download | PeerTube-170726f523ff48f89da45473fc53ca54784f43dd.tar.gz PeerTube-170726f523ff48f89da45473fc53ca54784f43dd.tar.zst PeerTube-170726f523ff48f89da45473fc53ca54784f43dd.zip |
Implement video channel views
Diffstat (limited to 'client/src/app/+video-channels')
11 files changed, 253 insertions, 0 deletions
diff --git a/client/src/app/+video-channels/index.ts b/client/src/app/+video-channels/index.ts new file mode 100644 index 000000000..6683d1b12 --- /dev/null +++ b/client/src/app/+video-channels/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './video-channels-routing.module' | ||
2 | export * from './video-channels.component' | ||
3 | export * from './video-channels.module' | ||
diff --git a/client/src/app/+video-channels/video-channel-about/video-channel-about.component.html b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.html new file mode 100644 index 000000000..65ad6f541 --- /dev/null +++ b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.html | |||
@@ -0,0 +1,12 @@ | |||
1 | <div *ngIf="videoChannel" class="row"> | ||
2 | <div class="description col-md-6 col-sm-12"> | ||
3 | <div class="small-title">Description</div> | ||
4 | <div class="content">{{ getVideoChannelDescription() }}</div> | ||
5 | </div> | ||
6 | |||
7 | <div class="stats col-md-6 col-sm-12"> | ||
8 | <div class="small-title">Stats</div> | ||
9 | |||
10 | <div class="content">Created {{ videoChannel.createdAt | date }}</div> | ||
11 | </div> | ||
12 | </div> \ No newline at end of file | ||
diff --git a/client/src/app/+video-channels/video-channel-about/video-channel-about.component.scss b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.scss new file mode 100644 index 000000000..b1be7d4ed --- /dev/null +++ b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.scss | |||
@@ -0,0 +1,8 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .small-title { | ||
5 | @include in-content-small-title; | ||
6 | |||
7 | margin-bottom: 20px; | ||
8 | } | ||
diff --git a/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts new file mode 100644 index 000000000..5d435708e --- /dev/null +++ b/client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute } from '@angular/router' | ||
3 | import 'rxjs/add/observable/from' | ||
4 | import 'rxjs/add/operator/concatAll' | ||
5 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | ||
6 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-video-channel-about', | ||
10 | templateUrl: './video-channel-about.component.html', | ||
11 | styleUrls: [ './video-channel-about.component.scss' ] | ||
12 | }) | ||
13 | export class VideoChannelAboutComponent implements OnInit { | ||
14 | videoChannel: VideoChannel | ||
15 | |||
16 | constructor ( | ||
17 | protected route: ActivatedRoute, | ||
18 | private videoChannelService: VideoChannelService | ||
19 | ) { } | ||
20 | |||
21 | ngOnInit () { | ||
22 | // Parent get the video channel for us | ||
23 | this.videoChannelService.videoChannelLoaded | ||
24 | .subscribe(videoChannel => this.videoChannel = videoChannel) | ||
25 | } | ||
26 | |||
27 | getVideoChannelDescription () { | ||
28 | if (this.videoChannel.description) return this.videoChannel.description | ||
29 | |||
30 | return 'No description' | ||
31 | } | ||
32 | } | ||
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.scss b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.scss new file mode 100644 index 000000000..2ba85c031 --- /dev/null +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.scss | |||
@@ -0,0 +1,3 @@ | |||
1 | .title-page-single { | ||
2 | margin-top: 0; | ||
3 | } \ No newline at end of file | ||
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts new file mode 100644 index 000000000..3cda630d3 --- /dev/null +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts | |||
@@ -0,0 +1,71 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { Location } from '@angular/common' | ||
4 | import { immutableAssign } from '@app/shared/misc/utils' | ||
5 | import { NotificationsService } from 'angular2-notifications' | ||
6 | import 'rxjs/add/observable/from' | ||
7 | import 'rxjs/add/operator/concatAll' | ||
8 | import { AuthService } from '../../core/auth' | ||
9 | import { ConfirmService } from '../../core/confirm' | ||
10 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | ||
11 | import { VideoService } from '../../shared/video/video.service' | ||
12 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | ||
13 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
14 | |||
15 | @Component({ | ||
16 | selector: 'my-video-channel-videos', | ||
17 | templateUrl: '../../shared/video/abstract-video-list.html', | ||
18 | styleUrls: [ | ||
19 | '../../shared/video/abstract-video-list.scss', | ||
20 | './video-channel-videos.component.scss' | ||
21 | ] | ||
22 | }) | ||
23 | export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
24 | titlePage = 'Published videos' | ||
25 | marginContent = false // Disable margin | ||
26 | currentRoute = '/video-channel/videos' | ||
27 | loadOnInit = false | ||
28 | |||
29 | private videoChannel: VideoChannel | ||
30 | |||
31 | constructor ( | ||
32 | protected router: Router, | ||
33 | protected route: ActivatedRoute, | ||
34 | protected authService: AuthService, | ||
35 | protected notificationsService: NotificationsService, | ||
36 | protected confirmService: ConfirmService, | ||
37 | protected location: Location, | ||
38 | private videoChannelService: VideoChannelService, | ||
39 | private videoService: VideoService | ||
40 | ) { | ||
41 | super() | ||
42 | } | ||
43 | |||
44 | ngOnInit () { | ||
45 | super.ngOnInit() | ||
46 | |||
47 | // Parent get the video channel for us | ||
48 | this.videoChannelService.videoChannelLoaded | ||
49 | .subscribe(videoChannel => { | ||
50 | this.videoChannel = videoChannel | ||
51 | this.currentRoute = '/video-channel/' + this.videoChannel.uuid + '/videos' | ||
52 | |||
53 | this.loadMoreVideos(this.pagination.currentPage) | ||
54 | this.generateSyndicationList() | ||
55 | }) | ||
56 | } | ||
57 | |||
58 | ngOnDestroy () { | ||
59 | super.ngOnDestroy() | ||
60 | } | ||
61 | |||
62 | getVideosObservable (page: number) { | ||
63 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | ||
64 | |||
65 | return this.videoService.getVideoChannelVideos(this.videoChannel, newPagination, this.sort) | ||
66 | } | ||
67 | |||
68 | generateSyndicationList () { | ||
69 | this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id) | ||
70 | } | ||
71 | } | ||
diff --git a/client/src/app/+video-channels/video-channels-routing.module.ts b/client/src/app/+video-channels/video-channels-routing.module.ts new file mode 100644 index 000000000..935578d2a --- /dev/null +++ b/client/src/app/+video-channels/video-channels-routing.module.ts | |||
@@ -0,0 +1,45 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | import { RouterModule, Routes } from '@angular/router' | ||
3 | import { MetaGuard } from '@ngx-meta/core' | ||
4 | import { VideoChannelsComponent } from './video-channels.component' | ||
5 | import { VideoChannelVideosComponent } from './video-channel-videos/video-channel-videos.component' | ||
6 | import { VideoChannelAboutComponent } from './video-channel-about/video-channel-about.component' | ||
7 | |||
8 | const videoChannelsRoutes: Routes = [ | ||
9 | { | ||
10 | path: ':videoChannelId', | ||
11 | component: VideoChannelsComponent, | ||
12 | canActivateChild: [ MetaGuard ], | ||
13 | children: [ | ||
14 | { | ||
15 | path: '', | ||
16 | redirectTo: 'videos', | ||
17 | pathMatch: 'full' | ||
18 | }, | ||
19 | { | ||
20 | path: 'videos', | ||
21 | component: VideoChannelVideosComponent, | ||
22 | data: { | ||
23 | meta: { | ||
24 | title: 'Video channel videos' | ||
25 | } | ||
26 | } | ||
27 | }, | ||
28 | { | ||
29 | path: 'about', | ||
30 | component: VideoChannelAboutComponent, | ||
31 | data: { | ||
32 | meta: { | ||
33 | title: 'About video channel' | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | ] | ||
38 | } | ||
39 | ] | ||
40 | |||
41 | @NgModule({ | ||
42 | imports: [ RouterModule.forChild(videoChannelsRoutes) ], | ||
43 | exports: [ RouterModule ] | ||
44 | }) | ||
45 | export class VideoChannelsRoutingModule {} | ||
diff --git a/client/src/app/+video-channels/video-channels.component.html b/client/src/app/+video-channels/video-channels.component.html new file mode 100644 index 000000000..098e1eed4 --- /dev/null +++ b/client/src/app/+video-channels/video-channels.component.html | |||
@@ -0,0 +1,23 @@ | |||
1 | <div *ngIf="videoChannel" class="row"> | ||
2 | <div class="sub-menu"> | ||
3 | |||
4 | <div class="actor"> | ||
5 | <img [src]="videoChannel.avatarUrl" alt="Avatar" /> | ||
6 | |||
7 | <div class="actor-info"> | ||
8 | <div class="actor-display-name">{{ videoChannel.displayName }}</div> | ||
9 | <div class="actor-followers">{{ videoChannel.followersCount }} subscribers</div> | ||
10 | </div> | ||
11 | </div> | ||
12 | |||
13 | <div class="links"> | ||
14 | <a routerLink="videos" routerLinkActive="active" class="title-page">Videos</a> | ||
15 | |||
16 | <a routerLink="about" routerLinkActive="active" class="title-page">About</a> | ||
17 | </div> | ||
18 | </div> | ||
19 | |||
20 | <div class="margin-content"> | ||
21 | <router-outlet></router-outlet> | ||
22 | </div> | ||
23 | </div> | ||
diff --git a/client/src/app/+video-channels/video-channels.component.scss b/client/src/app/+video-channels/video-channels.component.scss new file mode 100644 index 000000000..909b65bc7 --- /dev/null +++ b/client/src/app/+video-channels/video-channels.component.scss | |||
@@ -0,0 +1,6 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .sub-menu { | ||
5 | @include sub-menu-with-actor; | ||
6 | } \ No newline at end of file | ||
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts new file mode 100644 index 000000000..5eca64fb5 --- /dev/null +++ b/client/src/app/+video-channels/video-channels.component.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute } from '@angular/router' | ||
3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
4 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | ||
5 | |||
6 | @Component({ | ||
7 | templateUrl: './video-channels.component.html', | ||
8 | styleUrls: [ './video-channels.component.scss' ] | ||
9 | }) | ||
10 | export class VideoChannelsComponent implements OnInit { | ||
11 | videoChannel: VideoChannel | ||
12 | |||
13 | constructor ( | ||
14 | private route: ActivatedRoute, | ||
15 | private videoChannelService: VideoChannelService | ||
16 | ) {} | ||
17 | |||
18 | ngOnInit () { | ||
19 | const videoChannelId = this.route.snapshot.params['videoChannelId'] | ||
20 | |||
21 | this.videoChannelService.getVideoChannel(videoChannelId) | ||
22 | .subscribe(videoChannel => this.videoChannel = videoChannel) | ||
23 | } | ||
24 | } | ||
diff --git a/client/src/app/+video-channels/video-channels.module.ts b/client/src/app/+video-channels/video-channels.module.ts new file mode 100644 index 000000000..a09ea6f11 --- /dev/null +++ b/client/src/app/+video-channels/video-channels.module.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | import { SharedModule } from '../shared' | ||
3 | import { VideoChannelsRoutingModule } from './video-channels-routing.module' | ||
4 | import { VideoChannelsComponent } from './video-channels.component' | ||
5 | import { VideoChannelVideosComponent } from './video-channel-videos/video-channel-videos.component' | ||
6 | import { VideoChannelAboutComponent } from './video-channel-about/video-channel-about.component' | ||
7 | |||
8 | @NgModule({ | ||
9 | imports: [ | ||
10 | VideoChannelsRoutingModule, | ||
11 | SharedModule | ||
12 | ], | ||
13 | |||
14 | declarations: [ | ||
15 | VideoChannelsComponent, | ||
16 | VideoChannelVideosComponent, | ||
17 | VideoChannelAboutComponent | ||
18 | ], | ||
19 | |||
20 | exports: [ | ||
21 | VideoChannelsComponent | ||
22 | ], | ||
23 | |||
24 | providers: [] | ||
25 | }) | ||
26 | export class VideoChannelsModule { } | ||