ActivityPub-federated video streaming platform using P2P directly in your web browser
Add video channel account list
Chocobozzzd3e91a5f72ac
diff --git a/client/src/app/+account/account-routing.module.ts b/client/src/app/+account/account-routing.module.tsindex 5341021219..f72d8373fe 100644--- a/client/src/app/+account/account-routing.module.ts+++ b/client/src/app/+account/account-routing.module.ts@@ -3,7 +3,8 @@ 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'+import { AccountAboutComponent } from './account-about/account-about.component'+import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component'const accountRoutes: Routes = [{@@ -25,6 +26,15 @@ const accountRoutes: Routes = [}}},+ {+ path: 'video-channels',+ component: AccountVideoChannelsComponent,+ data: {+ meta: {+ title: 'Account video channels'+ }+ }+ },{path: 'about',component: AccountAboutComponent,diff --git a/client/src/app/+account/account-video-channels/account-video-channels.component.html b/client/src/app/+account/account-video-channels/account-video-channels.component.htmlnew file mode 100644index 0000000000..d20b40c600--- /dev/null+++ b/client/src/app/+account/account-video-channels/account-video-channels.component.html@@ -0,0 +1,11 @@+<div *ngIf="account" class="row">+ <a+ *ngFor="let videoChannel of videoChannels" [routerLink]="[ '/video-channels', videoChannel.uuid ]"+ class="video-channel" title="See this video channel"+ >+ <img [src]="videoChannel.avatarUrl" alt="Avatar" />++ <div class="video-channel-display-name">{{ videoChannel.displayName }}</div>+ <div class="video-channel-followers">{{ videoChannel.followersCount }} subscribers</div>+ </a>+</div>\ No newline at end of filediff --git a/client/src/app/+account/account-video-channels/account-video-channels.component.scss b/client/src/app/+account/account-video-channels/account-video-channels.component.scssnew file mode 100644index 0000000000..c9c7fa8ebe--- /dev/null+++ b/client/src/app/+account/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 filediff --git a/client/src/app/+account/account-video-channels/account-video-channels.component.ts b/client/src/app/+account/account-video-channels/account-video-channels.component.tsnew file mode 100644index 0000000000..8915eb6229--- /dev/null+++ b/client/src/app/+account/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.getVideoChannels(account.id))+ .map(res => res.data)+ .subscribe(videoChannels => this.videoChannels = videoChannels)+ }+}diff --git a/client/src/app/+account/account.component.html b/client/src/app/+account/account.component.htmlindex f875b37a42..d0e99edda0 100644--- a/client/src/app/+account/account.component.html+++ b/client/src/app/+account/account.component.html@@ -2,7 +2,7 @@<div class="sub-menu"><div class="account">- <img [src]="getAvatarUrl()" alt="Avatar" />+ <img [src]="account.avatarUrl" alt="Avatar" /><div class="account-info"><div class="account-display-name">{{ account.displayName }}</div>@@ -13,6 +13,8 @@<div class="links"><a routerLink="videos" routerLinkActive="active" class="title-page">Videos</a>+ <a routerLink="video-channels" routerLinkActive="active" class="title-page">Video channels</a>+<a routerLink="about" routerLinkActive="active" class="title-page">About</a></div></div>diff --git a/client/src/app/+account/account.component.ts b/client/src/app/+account/account.component.tsindex ae5354ed9b..d936ce2fe0 100644--- a/client/src/app/+account/account.component.ts+++ b/client/src/app/+account/account.component.ts@@ -22,8 +22,4 @@ export class AccountComponent implements OnInit {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.tsindex 2fe67f3c59..82ef06e76d 100644--- a/client/src/app/+account/account.module.ts+++ b/client/src/app/+account/account.module.ts@@ -4,6 +4,7 @@ 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'+import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component'@NgModule({imports: [@@ -14,6 +15,7 @@ import { AccountAboutComponent } from './account-about/account-about.component'declarations: [AccountComponent,AccountVideosComponent,+ AccountVideoChannelsComponent,AccountAboutComponent],diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.htmlindex 832cd9e78f..e4cd40628c 100644--- a/client/src/app/menu/menu.component.html+++ b/client/src/app/menu/menu.component.html@@ -1,7 +1,7 @@<menu><div *ngIf="isLoggedIn" class="logged-in-block"><a routerLink="/account/settings">- <img [src]="getUserAvatarUrl()" alt="Avatar" />+ <img [src]="user.accountAvatarUrl" alt="Avatar" /></a><div class="logged-in-info">diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.tsindex 1f66e37542..4c35bb3a51 100644--- a/client/src/app/menu/menu.component.ts+++ b/client/src/app/menu/menu.component.ts@@ -51,10 +51,6 @@ export class MenuComponent implements OnInit {)}- getUserAvatarUrl () {- return this.user.getAvatarUrl()- }-isRegistrationAllowed () {return this.serverService.getConfig().signup.allowed}diff --git a/client/src/app/my-account/my-account-settings/my-account-settings.component.html b/client/src/app/my-account/my-account-settings/my-account-settings.component.htmlindex 7ae27dc751..e11d93c01d 100644--- a/client/src/app/my-account/my-account-settings/my-account-settings.component.html+++ b/client/src/app/my-account/my-account-settings/my-account-settings.component.html@@ -1,5 +1,5 @@<div class="user">- <img [src]="getAvatarUrl()" alt="Avatar" />+ <img [src]="user.accountAvatarUrl" alt="Avatar" /><div class="user-info"><div class="user-info-username">{{ user.username }}</div>diff --git a/client/src/app/my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/my-account/my-account-settings/my-account-settings.component.tsindex 91420cc6fd..06d1138e72 100644--- a/client/src/app/my-account/my-account-settings/my-account-settings.component.ts+++ b/client/src/app/my-account/my-account-settings/my-account-settings.component.ts@@ -42,10 +42,6 @@ export class MyAccountSettingsComponent implements OnInit {.subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)}- getAvatarUrl () {- return this.user.getAvatarUrl()- }-changeAvatar () {const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ]diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.tsindex 10a70ac31a..6a3c6451c4 100644--- a/client/src/app/shared/account/account.model.ts+++ b/client/src/app/shared/account/account.model.ts@@ -1,50 +1,14 @@import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'-import { Avatar } from '../../../../../shared/models/avatars/avatar.model'-import { getAbsoluteAPIUrl } from '../misc/utils'+import { Actor } from '../actor/actor.model'-export class Account implements ServerAccount {- id: number- uuid: string- url: string- name: string+export class Account extends Actor implements ServerAccount {displayName: stringdescription: string- host: string- followingCount: number- followersCount: number- createdAt: Date- updatedAt: Date- avatar: Avatar-- static GET_ACCOUNT_AVATAR_URL (account: Account) {- const absoluteAPIUrl = getAbsoluteAPIUrl()-- if (account && account.avatar) return absoluteAPIUrl + account.avatar.path-- return window.location.origin + '/client/assets/images/default-avatar.png'- }-- static CREATE_BY_STRING (accountName: string, host: string) {- const absoluteAPIUrl = getAbsoluteAPIUrl()- const thisHost = new URL(absoluteAPIUrl).host-- if (host.trim() === thisHost) return accountName-- return accountName + '@' + host- }constructor (hash: ServerAccount) {- this.id = hash.id- this.uuid = hash.uuid- this.url = hash.url- this.name = hash.name+ super(hash)+this.displayName = hash.displayNamethis.description = hash.description- this.host = hash.host- this.followingCount = hash.followingCount- this.followersCount = hash.followersCount- this.createdAt = new Date(hash.createdAt.toString())- this.updatedAt = new Date(hash.updatedAt.toString())- this.avatar = hash.avatar}}diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.tsnew file mode 100644index 0000000000..56ff780b78--- /dev/null+++ b/client/src/app/shared/actor/actor.model.ts@@ -0,0 +1,50 @@+import { Actor as ActorServer } from '../../../../../shared/models/actors/actor.model'+import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'+import { Avatar } from '../../../../../shared/models/avatars/avatar.model'++export abstract class Actor implements ActorServer {+ id: number+ uuid: string+ url: string+ name: string+ host: string+ followingCount: number+ followersCount: number+ createdAt: Date+ updatedAt: Date+ avatar: Avatar++ avatarUrl: string++ static GET_ACTOR_AVATAR_URL (actor: { avatar: Avatar }) {+ const absoluteAPIUrl = getAbsoluteAPIUrl()++ if (actor && actor.avatar) return absoluteAPIUrl + actor.avatar.path++ return window.location.origin + '/client/assets/images/default-avatar.png'+ }++ static CREATE_BY_STRING (accountName: string, host: string) {+ const absoluteAPIUrl = getAbsoluteAPIUrl()+ const thisHost = new URL(absoluteAPIUrl).host++ if (host.trim() === thisHost) return accountName++ return accountName + '@' + host+ }++ protected constructor (hash: ActorServer) {+ this.id = hash.id+ this.uuid = hash.uuid+ this.url = hash.url+ this.name = hash.name+ this.host = hash.host+ this.followingCount = hash.followingCount+ this.followersCount = hash.followersCount+ this.createdAt = new Date(hash.createdAt.toString())+ this.updatedAt = new Date(hash.updatedAt.toString())+ this.avatar = hash.avatar++ this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)+ }+}diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.tsindex 2178eebc81..20019e47ae 100644--- a/client/src/app/shared/shared.module.ts+++ b/client/src/app/shared/shared.module.ts@@ -32,6 +32,7 @@ import { VideoFeedComponent } from './video/video-feed.component'import { VideoThumbnailComponent } from './video/video-thumbnail.component'import { VideoService } from './video/video.service'import { AccountService } from '@app/shared/account/account.service'+import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'@NgModule({imports: [@@ -106,7 +107,8 @@ import { AccountService } from '@app/shared/account/account.service'UserService,VideoService,AccountService,- MarkdownService+ MarkdownService,+ VideoChannelService]})export class SharedModule { }diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.tsindex 2bdc48a1dc..d4551de894 100644--- a/client/src/app/shared/users/user.model.ts+++ b/client/src/app/shared/users/user.model.ts@@ -1,6 +1,6 @@-import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'-import { Account } from '../account/account.model'+import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'+import { Actor } from '@app/shared/actor/actor.model'export type UserConstructorHash = {id: number,@@ -25,6 +25,7 @@ export class User implements UserServerModel {account: AccountvideoChannels: VideoChannel[]createdAt: Date+ accountAvatarUrl: stringconstructor (hash: UserConstructorHash) {this.id = hash.id@@ -52,19 +53,23 @@ export class User implements UserServerModel {if (hash.createdAt !== undefined) {this.createdAt = hash.createdAt}++ this.updateComputedAttributes()}hasRight (right: UserRight) {return hasUserRight(this.role, right)}- getAvatarUrl () {- return Account.GET_ACCOUNT_AVATAR_URL(this.account)- }-patch (obj: UserServerModel) {for (const key of Object.keys(obj)) {this[key] = obj[key]}++ this.updateComputedAttributes()+ }++ private updateComputedAttributes () {+ this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)}}diff --git a/client/src/app/shared/video-channel/video-channel.model.ts b/client/src/app/shared/video-channel/video-channel.model.tsnew file mode 100644index 0000000000..01381ac304--- /dev/null+++ b/client/src/app/shared/video-channel/video-channel.model.ts@@ -0,0 +1,23 @@+import { VideoChannel as ServerVideoChannel } from '../../../../../shared/models/videos/video-channel.model'+import { Actor } from '../actor/actor.model'++export class VideoChannel extends Actor implements ServerVideoChannel {+ displayName: string+ description: string+ support: string+ isLocal: boolean+ ownerAccount?: {+ id: number+ uuid: string+ }++ constructor (hash: ServerVideoChannel) {+ super(hash)++ this.displayName = hash.displayName+ this.description = hash.description+ this.support = hash.support+ this.isLocal = hash.isLocal+ this.ownerAccount = hash.ownerAccount+ }+}diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.tsnew file mode 100644index 0000000000..1f9088c38b--- /dev/null+++ b/client/src/app/shared/video-channel/video-channel.service.ts@@ -0,0 +1,36 @@+import { Injectable } from '@angular/core'+import 'rxjs/add/operator/catch'+import 'rxjs/add/operator/map'+import { Observable } from 'rxjs/Observable'+import { RestExtractor } from '../rest/rest-extractor.service'+import { RestService } from '../rest/rest.service'+import { HttpClient } from '@angular/common/http'+import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos'+import { AccountService } from '../account/account.service'+import { ResultList } from '../../../../../shared'+import { VideoChannel } from './video-channel.model'++@Injectable()+export class VideoChannelService {+ constructor (+ private authHttp: HttpClient,+ private restExtractor: RestExtractor,+ private restService: RestService+ ) {}++ getVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {+ return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')+ .map(res => this.extractVideoChannels(res))+ .catch((res) => this.restExtractor.handleError(res))+ }++ private extractVideoChannels (result: ResultList<VideoChannelServer>) {+ const videoChannels: VideoChannel[] = []++ for (const videoChannelJSON of result.data) {+ videoChannels.push(new VideoChannel(videoChannelJSON))+ }++ return { data: videoChannels, total: result.total }+ }+}diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.tsindex 2e85f40eff..f56eecaebe 100644--- a/client/src/app/shared/video/video.model.ts+++ b/client/src/app/shared/video/video.model.ts@@ -1,13 +1,14 @@-import { Account } from '@app/shared/account/account.model'import { User } from '../'import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared'import { Avatar } from '../../../../../shared/models/avatars/avatar.model'import { VideoConstant } from '../../../../../shared/models/videos/video.model'import { getAbsoluteAPIUrl } from '../misc/utils'import { ServerConfig } from '../../../../../shared/models'+import { Actor } from '@app/shared/actor/actor.model'export class Video implements VideoServerModel {by: string+ accountAvatarUrl: stringcreatedAt: DateupdatedAt: DatepublishedAt: Date@@ -85,7 +86,8 @@ export class Video implements VideoServerModel {this.nsfw = hash.nsfwthis.account = hash.account- this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host)+ this.by = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)+ this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)}isVideoNSFWForUser (user: User, serverConfig: ServerConfig) {diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.htmlindex e393daa79f..54d7286db5 100644--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html@@ -1,6 +1,6 @@<form novalidate [formGroup]="form" (ngSubmit)="formValidated()"><div class="avatar-and-textarea">- <img [src]="getUserAvatarUrl()" alt="Avatar" />+ <img [src]="user.accountAvatarUrl" alt="Avatar" /><div class="form-group"><textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }"diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.tsindex 731652fda4..d1ca1968be 100644--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts@@ -100,10 +100,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {return this.form.value['text']}- getUserAvatarUrl () {- return this.user.getAvatarUrl()- }-private addCommentReply (commentCreate: VideoCommentCreate) {return this.videoCommentService.addCommentReply(this.video.id, this.parentComment.id, commentCreate)diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.htmlindex 8a649e88fe..06808ef808 100644--- a/client/src/app/videos/+video-watch/comment/video-comment.component.html+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html@@ -1,5 +1,5 @@<div class="root-comment">- <img [src]="getAvatarUrl(comment.account)" alt="Avatar" />+ <img [src]="comment.accountAvatarUrl" alt="Avatar" /><div class="comment"><div *ngIf="highlightedComment === true" class="highlighted-comment">Highlighted comment</div>diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.tsindex 26fc9d0b8c..e90008de9b 100644--- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts@@ -1,11 +1,9 @@import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'import { LinkifierService } from '@app/videos/+video-watch/comment/linkifier.service'import * as sanitizeHtml from 'sanitize-html'-import { Account as AccountInterface } from '../../../../../../shared/models/actors'import { UserRight } from '../../../../../../shared/models/users'import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'import { AuthService } from '../../../core/auth'-import { Account } from '../../../shared/account/account.model'import { Video } from '../../../shared/video/video.model'import { VideoComment } from './video-comment.model'@@ -80,10 +78,6 @@ export class VideoCommentComponent implements OnInit, OnChanges {this.resetReply.emit()}- getAvatarUrl (account: AccountInterface) {- return Account.GET_ACCOUNT_AVATAR_URL(account)- }-isRemovableByUser () {return this.isUserLoggedIn() &&(diff --git a/client/src/app/videos/+video-watch/comment/video-comment.model.ts b/client/src/app/videos/+video-watch/comment/video-comment.model.tsindex 8fa02aee18..fe591811ee 100644--- a/client/src/app/videos/+video-watch/comment/video-comment.model.ts+++ b/client/src/app/videos/+video-watch/comment/video-comment.model.ts@@ -1,6 +1,6 @@-import { Account } from '@app/shared/account/account.model'import { Account as AccountInterface } from '../../../../../../shared/models/actors'import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model'+import { Actor } from '@app/shared/actor/actor.model'export class VideoComment implements VideoCommentServerModel {id: number@@ -14,6 +14,7 @@ export class VideoComment implements VideoCommentServerModel {account: AccountInterfacetotalReplies: numberby: string+ accountAvatarUrlconstructor (hash: VideoCommentServerModel) {this.id = hash.id@@ -27,6 +28,7 @@ export class VideoComment implements VideoCommentServerModel {this.account = hash.accountthis.totalReplies = hash.totalReplies- this.by = Account.CREATE_BY_STRING(this.account.name, this.account.host)+ this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)+ this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)}}diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.htmlindex 036d75d3ca..5d3361561b 100644--- a/client/src/app/videos/+video-watch/video-watch.component.html+++ b/client/src/app/videos/+video-watch/video-watch.component.html@@ -24,7 +24,7 @@<div class="video-info-by"><a [routerLink]="[ '/account', video.account.id ]" title="Go the account page"><span>By {{ video.by }}</span>- <img [src]="getAvatarPath()" alt="Account avatar" />+ <img [src]="video.accountAvatarUrl" alt="Account avatar" /></a></div></div>diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.tsindex 4b0c495832..615b969e51 100644--- a/client/src/app/videos/+video-watch/video-watch.component.ts+++ b/client/src/app/videos/+video-watch/video-watch.component.ts@@ -228,10 +228,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {return this.video.isBlackistableBy(this.user)}- getAvatarPath () {- return Account.GET_ACCOUNT_AVATAR_URL(this.video.account)- }-getVideoPoster () {if (!this.video) return ''