aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-24 15:10:54 +0200
committerChocobozzz <me@florianbigard.com>2018-04-24 15:13:19 +0200
commit0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb (patch)
tree79b5befbc6a04c007e5919805f1514d065b30e11 /client/src/app/shared
parentb4d1af3dd8cdab2d58927e671d62194ca383cd75 (diff)
downloadPeerTube-0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb.tar.gz
PeerTube-0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb.tar.zst
PeerTube-0626e7af82e02f8a5bd1e74a7d4d8c916d073ceb.zip
Add account view
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/account/account.model.ts15
-rw-r--r--client/src/app/shared/account/account.service.ts31
-rw-r--r--client/src/app/shared/shared.module.ts2
-rw-r--r--client/src/app/shared/video/abstract-video-list.html4
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts1
-rw-r--r--client/src/app/shared/video/video.service.ts18
6 files changed, 69 insertions, 2 deletions
diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts
index 0bdc76478..3d5176bdd 100644
--- a/client/src/app/shared/account/account.model.ts
+++ b/client/src/app/shared/account/account.model.ts
@@ -16,6 +16,21 @@ export class Account implements ServerAccount {
16 updatedAt: Date 16 updatedAt: Date
17 avatar: Avatar 17 avatar: Avatar
18 18
19 constructor (hash: ServerAccount) {
20 this.id = hash.id
21 this.uuid = hash.uuid
22 this.url = hash.url
23 this.name = hash.name
24 this.displayName = hash.displayName
25 this.description = hash.description
26 this.host = hash.host
27 this.followingCount = hash.followingCount
28 this.followersCount = hash.followersCount
29 this.createdAt = new Date(hash.createdAt.toString())
30 this.updatedAt = new Date(hash.updatedAt.toString())
31 this.avatar = hash.avatar
32 }
33
19 static GET_ACCOUNT_AVATAR_URL (account: Account) { 34 static GET_ACCOUNT_AVATAR_URL (account: Account) {
20 const absoluteAPIUrl = getAbsoluteAPIUrl() 35 const absoluteAPIUrl = getAbsoluteAPIUrl()
21 36
diff --git a/client/src/app/shared/account/account.service.ts b/client/src/app/shared/account/account.service.ts
new file mode 100644
index 000000000..8c66ae04a
--- /dev/null
+++ b/client/src/app/shared/account/account.service.ts
@@ -0,0 +1,31 @@
1import { Injectable } from '@angular/core'
2import 'rxjs/add/operator/catch'
3import 'rxjs/add/operator/map'
4import { environment } from '../../../environments/environment'
5import { Observable } from 'rxjs/Observable'
6import { Account } from '@app/shared/account/account.model'
7import { RestExtractor } from '@app/shared/rest/rest-extractor.service'
8import { RestService } from '@app/shared/rest/rest.service'
9import { HttpClient } from '@angular/common/http'
10import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
11import { ReplaySubject } from 'rxjs/ReplaySubject'
12
13@Injectable()
14export class AccountService {
15 static BASE_ACCOUNT_URL = environment.apiUrl + '/api/v1/accounts/'
16
17 accountLoaded = new ReplaySubject<Account>(1)
18
19 constructor (
20 private authHttp: HttpClient,
21 private restExtractor: RestExtractor,
22 private restService: RestService
23 ) {}
24
25 getAccount (id: number): Observable<Account> {
26 return this.authHttp.get<ServerAccount>(AccountService.BASE_ACCOUNT_URL + id)
27 .map(accountHash => new Account(accountHash))
28 .do(account => this.accountLoaded.next(account))
29 .catch((res) => this.restExtractor.handleError(res))
30 }
31}
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 74730e2aa..2178eebc8 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -31,6 +31,7 @@ import { VideoMiniatureComponent } from './video/video-miniature.component'
31import { VideoFeedComponent } from './video/video-feed.component' 31import { VideoFeedComponent } from './video/video-feed.component'
32import { VideoThumbnailComponent } from './video/video-thumbnail.component' 32import { VideoThumbnailComponent } from './video/video-thumbnail.component'
33import { VideoService } from './video/video.service' 33import { VideoService } from './video/video.service'
34import { AccountService } from '@app/shared/account/account.service'
34 35
35@NgModule({ 36@NgModule({
36 imports: [ 37 imports: [
@@ -104,6 +105,7 @@ import { VideoService } from './video/video.service'
104 VideoBlacklistService, 105 VideoBlacklistService,
105 UserService, 106 UserService,
106 VideoService, 107 VideoService,
108 AccountService,
107 MarkdownService 109 MarkdownService
108 ] 110 ]
109}) 111})
diff --git a/client/src/app/shared/video/abstract-video-list.html b/client/src/app/shared/video/abstract-video-list.html
index cb04e07b4..690529dcf 100644
--- a/client/src/app/shared/video/abstract-video-list.html
+++ b/client/src/app/shared/video/abstract-video-list.html
@@ -1,5 +1,5 @@
1<div class="margin-content"> 1<div [ngClass]="{ 'margin-content': marginContent }">
2 <div class="title-page title-page-single"> 2 <div *ngIf="titlePage" class="title-page title-page-single">
3 {{ titlePage }} 3 {{ titlePage }}
4 </div> 4 </div>
5 <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed> 5 <my-video-feed [syndicationItems]="syndicationItems"></my-video-feed>
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index 728c864e9..642a85f65 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -29,6 +29,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
29 syndicationItems = [] 29 syndicationItems = []
30 30
31 loadOnInit = true 31 loadOnInit = true
32 marginContent = true
32 pageHeight: number 33 pageHeight: number
33 videoWidth: number 34 videoWidth: number
34 videoHeight: number 35 videoHeight: number
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index ef8babd55..f82aa7389 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -21,6 +21,8 @@ import { VideoDetails } from './video-details.model'
21import { VideoEdit } from './video-edit.model' 21import { VideoEdit } from './video-edit.model'
22import { Video } from './video.model' 22import { Video } from './video.model'
23import { objectToFormData } from '@app/shared/misc/utils' 23import { objectToFormData } from '@app/shared/misc/utils'
24import { Account } from '@app/shared/account/account.model'
25import { AccountService } from '@app/shared/account/account.service'
24 26
25@Injectable() 27@Injectable()
26export class VideoService { 28export class VideoService {
@@ -97,6 +99,22 @@ export class VideoService {
97 .catch((res) => this.restExtractor.handleError(res)) 99 .catch((res) => this.restExtractor.handleError(res))
98 } 100 }
99 101
102 getAccountVideos (
103 account: Account,
104 videoPagination: ComponentPagination,
105 sort: VideoSortField
106 ): Observable<{ videos: Video[], totalVideos: number}> {
107 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
108
109 let params = new HttpParams()
110 params = this.restService.addRestGetParams(params, pagination, sort)
111
112 return this.authHttp
113 .get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params })
114 .map(this.extractVideos)
115 .catch((res) => this.restExtractor.handleError(res))
116 }
117
100 getVideos ( 118 getVideos (
101 videoPagination: ComponentPagination, 119 videoPagination: ComponentPagination,
102 sort: VideoSortField, 120 sort: VideoSortField,