From 0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 24 Apr 2018 15:10:54 +0200 Subject: Add account view --- .../account-about/account-about.component.html | 12 ++++ .../account-about/account-about.component.scss | 8 +++ .../account-about/account-about.component.ts | 39 ++++++++++++ client/src/app/+account/account-routing.module.ts | 45 ++++++++++++++ .../account-videos/account-videos.component.scss | 3 + .../account-videos/account-videos.component.ts | 71 ++++++++++++++++++++++ client/src/app/+account/account.component.html | 23 +++++++ client/src/app/+account/account.component.scss | 46 ++++++++++++++ client/src/app/+account/account.component.ts | 29 +++++++++ client/src/app/+account/account.module.ts | 26 ++++++++ client/src/app/+account/index.ts | 3 + 11 files changed, 305 insertions(+) create mode 100644 client/src/app/+account/account-about/account-about.component.html create mode 100644 client/src/app/+account/account-about/account-about.component.scss create mode 100644 client/src/app/+account/account-about/account-about.component.ts create mode 100644 client/src/app/+account/account-routing.module.ts create mode 100644 client/src/app/+account/account-videos/account-videos.component.scss create mode 100644 client/src/app/+account/account-videos/account-videos.component.ts create mode 100644 client/src/app/+account/account.component.html create mode 100644 client/src/app/+account/account.component.scss create mode 100644 client/src/app/+account/account.component.ts create mode 100644 client/src/app/+account/account.module.ts create mode 100644 client/src/app/+account/index.ts (limited to 'client/src/app/+account') 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 @@ +
+
+
Description
+
{{ getAccountDescription() }}
+
+ +
+
Stats
+ +
Joined {{ account.createdAt | date }}
+
+
\ 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 @@ +@import '_variables'; +@import '_mixins'; + +.small-title { + @include in-content-small-title; + + margin-bottom: 20px; +} 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 @@ +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 { + private 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/+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 @@ +import { NgModule } from '@angular/core' +import { RouterModule, Routes } from '@angular/router' +import { MetaGuard } from '@ngx-meta/core' +import { AccountComponent } from './account.component' +import { AccountVideosComponent } from './account-videos/account-videos.component' +import { AccountAboutComponent } from '@app/+account/account-about/account-about.component' + +const accountRoutes: Routes = [ + { + path: ':accountId', + component: AccountComponent, + canActivateChild: [ MetaGuard ], + children: [ + { + path: '', + redirectTo: 'videos', + pathMatch: 'full' + }, + { + path: 'videos', + component: AccountVideosComponent, + data: { + meta: { + title: 'Account videos' + } + } + }, + { + path: 'about', + component: AccountAboutComponent, + data: { + meta: { + title: 'About account' + } + } + } + ] + } +] + +@NgModule({ + imports: [ RouterModule.forChild(accountRoutes) ], + exports: [ RouterModule ] +}) +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 @@ +.title-page-single { + margin-top: 0; +} \ 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 @@ +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/+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 @@ +
+ + +
+ +
+
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 @@ +@import '_variables'; +@import '_mixins'; + +.sub-menu { + height: 160px; + display: flex; + flex-direction: column; + align-items: start; + + .account { + display: flex; + margin-top: 20px; + margin-bottom: 20px; + + img { + @include avatar(80px); + + margin-right: 20px; + } + + .account-info { + display: flex; + flex-direction: column; + justify-content: center; + + .account-display-name { + font-size: 23px; + font-weight: $font-bold; + } + + .account-followers { + font-size: 15px; + } + } + } + + .links { + margin-top: 0; + margin-bottom: 10px; + + a { + margin-top: 0; + margin-bottom: 0; + } + } +} \ 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 @@ +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({ + selector: 'my-account', + templateUrl: './account.component.html', + styleUrls: [ './account.component.scss' ] +}) +export class AccountComponent implements OnInit { + private 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) + } + + getAvatarUrl () { + return Account.GET_ACCOUNT_AVATAR_URL(this.account) + } +} 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 @@ +import { NgModule } from '@angular/core' +import { SharedModule } from '../shared' +import { AccountRoutingModule } from './account-routing.module' +import { AccountComponent } from './account.component' +import { AccountVideosComponent } from './account-videos/account-videos.component' +import { AccountAboutComponent } from './account-about/account-about.component' + +@NgModule({ + imports: [ + AccountRoutingModule, + SharedModule + ], + + declarations: [ + AccountComponent, + AccountVideosComponent, + AccountAboutComponent + ], + + exports: [ + AccountComponent + ], + + providers: [] +}) +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 @@ +export * from './account-routing.module' +export * from './account.component' +export * from './account.module' -- cgit v1.2.3