diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-24 15:10:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-24 15:13:19 +0200 |
commit | 0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb (patch) | |
tree | 79b5befbc6a04c007e5919805f1514d065b30e11 /client/src/app/+account | |
parent | b4d1af3dd8cdab2d58927e671d62194ca383cd75 (diff) | |
download | PeerTube-0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb.tar.gz PeerTube-0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb.tar.zst PeerTube-0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb.zip |
Add account view
Diffstat (limited to 'client/src/app/+account')
11 files changed, 305 insertions, 0 deletions
diff --git a/client/src/app/+account/account-about/account-about.component.html b/client/src/app/+account/account-about/account-about.component.html new file mode 100644 index 000000000..003a8045e --- /dev/null +++ b/client/src/app/+account/account-about/account-about.component.html | |||
@@ -0,0 +1,12 @@ | |||
1 | <div *ngIf="account" class="row"> | ||
2 | <div class="description col-md-6 col-sm-12"> | ||
3 | <div class="small-title">Description</div> | ||
4 | <div class="content">{{ getAccountDescription() }}</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">Joined {{ account.createdAt | date }}</div> | ||
11 | </div> | ||
12 | </div> \ No newline at end of file | ||
diff --git a/client/src/app/+account/account-about/account-about.component.scss b/client/src/app/+account/account-about/account-about.component.scss new file mode 100644 index 000000000..b1be7d4ed --- /dev/null +++ b/client/src/app/+account/account-about/account-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/+account/account-about/account-about.component.ts b/client/src/app/+account/account-about/account-about.component.ts new file mode 100644 index 000000000..0772b844e --- /dev/null +++ b/client/src/app/+account/account-about/account-about.component.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | ||
3 | import { Location } from '@angular/common' | ||
4 | import { getParameterByName, 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 { Account } from '@app/shared/account/account.model' | ||
13 | import { AccountService } from '@app/shared/account/account.service' | ||
14 | |||
15 | @Component({ | ||
16 | selector: 'my-account-about', | ||
17 | templateUrl: './account-about.component.html', | ||
18 | styleUrls: [ './account-about.component.scss' ] | ||
19 | }) | ||
20 | export class AccountAboutComponent implements OnInit { | ||
21 | private account: Account | ||
22 | |||
23 | constructor ( | ||
24 | protected route: ActivatedRoute, | ||
25 | private accountService: AccountService | ||
26 | ) { } | ||
27 | |||
28 | ngOnInit () { | ||
29 | // Parent get the account for us | ||
30 | this.accountService.accountLoaded | ||
31 | .subscribe(account => this.account = account) | ||
32 | } | ||
33 | |||
34 | getAccountDescription () { | ||
35 | if (this.account.description) return this.account.description | ||
36 | |||
37 | return 'No description' | ||
38 | } | ||
39 | } | ||
diff --git a/client/src/app/+account/account-routing.module.ts b/client/src/app/+account/account-routing.module.ts new file mode 100644 index 000000000..534102121 --- /dev/null +++ b/client/src/app/+account/account-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 { AccountComponent } from './account.component' | ||
5 | import { AccountVideosComponent } from './account-videos/account-videos.component' | ||
6 | import { AccountAboutComponent } from '@app/+account/account-about/account-about.component' | ||
7 | |||
8 | const accountRoutes: Routes = [ | ||
9 | { | ||
10 | path: ':accountId', | ||
11 | component: AccountComponent, | ||
12 | canActivateChild: [ MetaGuard ], | ||
13 | children: [ | ||
14 | { | ||
15 | path: '', | ||
16 | redirectTo: 'videos', | ||
17 | pathMatch: 'full' | ||
18 | }, | ||
19 | { | ||
20 | path: 'videos', | ||
21 | component: AccountVideosComponent, | ||
22 | data: { | ||
23 | meta: { | ||
24 | title: 'Account videos' | ||
25 | } | ||
26 | } | ||
27 | }, | ||
28 | { | ||
29 | path: 'about', | ||
30 | component: AccountAboutComponent, | ||
31 | data: { | ||
32 | meta: { | ||
33 | title: 'About account' | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | ] | ||
38 | } | ||
39 | ] | ||
40 | |||
41 | @NgModule({ | ||
42 | imports: [ RouterModule.forChild(accountRoutes) ], | ||
43 | exports: [ RouterModule ] | ||
44 | }) | ||
45 | export class AccountRoutingModule {} | ||
diff --git a/client/src/app/+account/account-videos/account-videos.component.scss b/client/src/app/+account/account-videos/account-videos.component.scss new file mode 100644 index 000000000..2ba85c031 --- /dev/null +++ b/client/src/app/+account/account-videos/account-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/+account/account-videos/account-videos.component.ts b/client/src/app/+account/account-videos/account-videos.component.ts new file mode 100644 index 000000000..6c0f0bb52 --- /dev/null +++ b/client/src/app/+account/account-videos/account-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 { Account } from '@app/shared/account/account.model' | ||
13 | import { AccountService } from '@app/shared/account/account.service' | ||
14 | |||
15 | @Component({ | ||
16 | selector: 'my-account-videos', | ||
17 | templateUrl: '../../shared/video/abstract-video-list.html', | ||
18 | styleUrls: [ | ||
19 | '../../shared/video/abstract-video-list.scss', | ||
20 | './account-videos.component.scss' | ||
21 | ] | ||
22 | }) | ||
23 | export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
24 | titlePage = 'Published videos' | ||
25 | marginContent = false // Disable margin | ||
26 | currentRoute = '/account/videos' | ||
27 | loadOnInit = false | ||
28 | |||
29 | private account: Account | ||
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 accountService: AccountService, | ||
39 | private videoService: VideoService | ||
40 | ) { | ||
41 | super() | ||
42 | } | ||
43 | |||
44 | ngOnInit () { | ||
45 | super.ngOnInit() | ||
46 | |||
47 | // Parent get the account for us | ||
48 | this.accountService.accountLoaded | ||
49 | .subscribe(account => { | ||
50 | this.account = account | ||
51 | this.currentRoute = '/account/' + this.account.id + '/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.getAccountVideos(this.account, newPagination, this.sort) | ||
66 | } | ||
67 | |||
68 | generateSyndicationList () { | ||
69 | this.syndicationItems = this.videoService.getAccountFeedUrls(this.account.id) | ||
70 | } | ||
71 | } | ||
diff --git a/client/src/app/+account/account.component.html b/client/src/app/+account/account.component.html new file mode 100644 index 000000000..f875b37a4 --- /dev/null +++ b/client/src/app/+account/account.component.html | |||
@@ -0,0 +1,23 @@ | |||
1 | <div *ngIf="account" class="row"> | ||
2 | <div class="sub-menu"> | ||
3 | |||
4 | <div class="account"> | ||
5 | <img [src]="getAvatarUrl()" alt="Avatar" /> | ||
6 | |||
7 | <div class="account-info"> | ||
8 | <div class="account-display-name">{{ account.displayName }}</div> | ||
9 | <div class="account-followers">{{ account.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/+account/account.component.scss b/client/src/app/+account/account.component.scss new file mode 100644 index 000000000..c7b8f038f --- /dev/null +++ b/client/src/app/+account/account.component.scss | |||
@@ -0,0 +1,46 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .sub-menu { | ||
5 | height: 160px; | ||
6 | display: flex; | ||
7 | flex-direction: column; | ||
8 | align-items: start; | ||
9 | |||
10 | .account { | ||
11 | display: flex; | ||
12 | margin-top: 20px; | ||
13 | margin-bottom: 20px; | ||
14 | |||
15 | img { | ||
16 | @include avatar(80px); | ||
17 | |||
18 | margin-right: 20px; | ||
19 | } | ||
20 | |||
21 | .account-info { | ||
22 | display: flex; | ||
23 | flex-direction: column; | ||
24 | justify-content: center; | ||
25 | |||
26 | .account-display-name { | ||
27 | font-size: 23px; | ||
28 | font-weight: $font-bold; | ||
29 | } | ||
30 | |||
31 | .account-followers { | ||
32 | font-size: 15px; | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | |||
37 | .links { | ||
38 | margin-top: 0; | ||
39 | margin-bottom: 10px; | ||
40 | |||
41 | a { | ||
42 | margin-top: 0; | ||
43 | margin-bottom: 0; | ||
44 | } | ||
45 | } | ||
46 | } \ No newline at end of file | ||
diff --git a/client/src/app/+account/account.component.ts b/client/src/app/+account/account.component.ts new file mode 100644 index 000000000..1c3e528a7 --- /dev/null +++ b/client/src/app/+account/account.component.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { ActivatedRoute } from '@angular/router' | ||
3 | import { AccountService } from '@app/shared/account/account.service' | ||
4 | import { Account } from '@app/shared/account/account.model' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-account', | ||
8 | templateUrl: './account.component.html', | ||
9 | styleUrls: [ './account.component.scss' ] | ||
10 | }) | ||
11 | export class AccountComponent implements OnInit { | ||
12 | private account: Account | ||
13 | |||
14 | constructor ( | ||
15 | private route: ActivatedRoute, | ||
16 | private accountService: AccountService | ||
17 | ) {} | ||
18 | |||
19 | ngOnInit () { | ||
20 | const accountId = parseInt(this.route.snapshot.params['accountId'], 10) | ||
21 | |||
22 | this.accountService.getAccount(accountId) | ||
23 | .subscribe(account => this.account = account) | ||
24 | } | ||
25 | |||
26 | getAvatarUrl () { | ||
27 | return Account.GET_ACCOUNT_AVATAR_URL(this.account) | ||
28 | } | ||
29 | } | ||
diff --git a/client/src/app/+account/account.module.ts b/client/src/app/+account/account.module.ts new file mode 100644 index 000000000..2fe67f3c5 --- /dev/null +++ b/client/src/app/+account/account.module.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | import { SharedModule } from '../shared' | ||
3 | import { AccountRoutingModule } from './account-routing.module' | ||
4 | import { AccountComponent } from './account.component' | ||
5 | import { AccountVideosComponent } from './account-videos/account-videos.component' | ||
6 | import { AccountAboutComponent } from './account-about/account-about.component' | ||
7 | |||
8 | @NgModule({ | ||
9 | imports: [ | ||
10 | AccountRoutingModule, | ||
11 | SharedModule | ||
12 | ], | ||
13 | |||
14 | declarations: [ | ||
15 | AccountComponent, | ||
16 | AccountVideosComponent, | ||
17 | AccountAboutComponent | ||
18 | ], | ||
19 | |||
20 | exports: [ | ||
21 | AccountComponent | ||
22 | ], | ||
23 | |||
24 | providers: [] | ||
25 | }) | ||
26 | export class AccountModule { } | ||
diff --git a/client/src/app/+account/index.ts b/client/src/app/+account/index.ts new file mode 100644 index 000000000..dc56ffdbd --- /dev/null +++ b/client/src/app/+account/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './account-routing.module' | ||
2 | export * from './account.component' | ||
3 | export * from './account.module' | ||