diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-25 09:57:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-25 10:41:07 +0200 |
commit | ad9e39fb815d85e5e718c40540fa75471474fa17 (patch) | |
tree | 960accb16bca0fac7694b3f3d5d038534b66c224 /client/src | |
parent | 06be7ed0b27b371465c5d1b7f92b4adfb0b866ea (diff) | |
download | PeerTube-ad9e39fb815d85e5e718c40540fa75471474fa17.tar.gz PeerTube-ad9e39fb815d85e5e718c40540fa75471474fa17.tar.zst PeerTube-ad9e39fb815d85e5e718c40540fa75471474fa17.zip |
Only use account name in routes
Diffstat (limited to 'client/src')
12 files changed, 34 insertions, 16 deletions
diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index 0852c4bb7..a6e6dd656 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts | |||
@@ -26,7 +26,7 @@ export class AccountVideoChannelsComponent implements OnInit { | |||
26 | this.accountService.accountLoaded | 26 | this.accountService.accountLoaded |
27 | .pipe( | 27 | .pipe( |
28 | tap(account => this.account = account), | 28 | tap(account => this.account = account), |
29 | flatMap(account => this.videoChannelService.listAccountVideoChannels(account.id)), | 29 | flatMap(account => this.videoChannelService.listAccountVideoChannels(account)), |
30 | map(res => res.data) | 30 | map(res => res.data) |
31 | ) | 31 | ) |
32 | .subscribe(videoChannels => this.videoChannels = videoChannels) | 32 | .subscribe(videoChannels => this.videoChannels = videoChannels) |
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts index 7abf48826..20c8798d1 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channels.component.ts | |||
@@ -52,7 +52,7 @@ export class MyAccountVideoChannelsComponent implements OnInit { | |||
52 | 52 | ||
53 | private loadVideoChannels () { | 53 | private loadVideoChannels () { |
54 | this.authService.userInformationLoaded | 54 | this.authService.userInformationLoaded |
55 | .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account.id))) | 55 | .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account))) |
56 | .subscribe(res => this.videoChannels = res.data) | 56 | .subscribe(res => this.videoChannels = res.data) |
57 | } | 57 | } |
58 | } | 58 | } |
diff --git a/client/src/app/+video-channels/video-channels.component.html b/client/src/app/+video-channels/video-channels.component.html index da0d76acf..6b25d16ab 100644 --- a/client/src/app/+video-channels/video-channels.component.html +++ b/client/src/app/+video-channels/video-channels.component.html | |||
@@ -10,7 +10,7 @@ | |||
10 | </div> | 10 | </div> |
11 | <div class="actor-followers">{{ videoChannel.followersCount }} subscribers</div> | 11 | <div class="actor-followers">{{ videoChannel.followersCount }} subscribers</div> |
12 | 12 | ||
13 | <a [routerLink]="[ '/accounts', videoChannel.ownerAccount.id ]" title="Go the owner account page" class="actor-owner"> | 13 | <a [routerLink]="[ '/accounts', videoChannel.ownerBy ]" title="Go the owner account page" class="actor-owner"> |
14 | <span>Created by {{ videoChannel.ownerBy }}</span> | 14 | <span>Created by {{ videoChannel.ownerBy }}</span> |
15 | <img [src]="videoChannel.ownerAvatarUrl" alt="Owner account avatar" /> | 15 | <img [src]="videoChannel.ownerAvatarUrl" alt="Owner account avatar" /> |
16 | </a> | 16 | </a> |
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html index 6a2a495a2..1a95477b7 100644 --- a/client/src/app/menu/menu.component.html +++ b/client/src/app/menu/menu.component.html | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | <ul *dropdownMenu class="dropdown-menu"> | 15 | <ul *dropdownMenu class="dropdown-menu"> |
16 | <li> | 16 | <li> |
17 | <a i18n [routerLink]="[ '/accounts', user.account?.id ]" class="dropdown-item" title="My public profile"> | 17 | <a i18n [routerLink]="[ '/accounts', user.account?.nameWithHost ]" class="dropdown-item" title="My public profile"> |
18 | My public profile | 18 | My public profile |
19 | </a> | 19 | </a> |
20 | 20 | ||
diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts index 6a3c6451c..5058e372f 100644 --- a/client/src/app/shared/account/account.model.ts +++ b/client/src/app/shared/account/account.model.ts | |||
@@ -4,11 +4,13 @@ import { Actor } from '../actor/actor.model' | |||
4 | export class Account extends Actor implements ServerAccount { | 4 | export class Account extends Actor implements ServerAccount { |
5 | displayName: string | 5 | displayName: string |
6 | description: string | 6 | description: string |
7 | nameWithHost: string | ||
7 | 8 | ||
8 | constructor (hash: ServerAccount) { | 9 | constructor (hash: ServerAccount) { |
9 | super(hash) | 10 | super(hash) |
10 | 11 | ||
11 | this.displayName = hash.displayName | 12 | this.displayName = hash.displayName |
12 | this.description = hash.description | 13 | this.description = hash.description |
14 | this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host) | ||
13 | } | 15 | } |
14 | } | 16 | } |
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index d4551de89..b4be2270f 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -1,6 +1,14 @@ | |||
1 | import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' | 1 | import { |
2 | Account as AccountServerModel, | ||
3 | hasUserRight, | ||
4 | User as UserServerModel, | ||
5 | UserRight, | ||
6 | UserRole, | ||
7 | VideoChannel | ||
8 | } from '../../../../../shared' | ||
2 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | 9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' |
3 | import { Actor } from '@app/shared/actor/actor.model' | 10 | import { Actor } from '@app/shared/actor/actor.model' |
11 | import { Account } from '@app/shared/account/account.model' | ||
4 | 12 | ||
5 | export type UserConstructorHash = { | 13 | export type UserConstructorHash = { |
6 | id: number, | 14 | id: number, |
@@ -11,7 +19,7 @@ export type UserConstructorHash = { | |||
11 | nsfwPolicy?: NSFWPolicyType, | 19 | nsfwPolicy?: NSFWPolicyType, |
12 | autoPlayVideo?: boolean, | 20 | autoPlayVideo?: boolean, |
13 | createdAt?: Date, | 21 | createdAt?: Date, |
14 | account?: Account, | 22 | account?: AccountServerModel, |
15 | videoChannels?: VideoChannel[] | 23 | videoChannels?: VideoChannel[] |
16 | } | 24 | } |
17 | export class User implements UserServerModel { | 25 | export class User implements UserServerModel { |
@@ -32,7 +40,10 @@ export class User implements UserServerModel { | |||
32 | this.username = hash.username | 40 | this.username = hash.username |
33 | this.email = hash.email | 41 | this.email = hash.email |
34 | this.role = hash.role | 42 | this.role = hash.role |
35 | this.account = hash.account | 43 | |
44 | if (hash.account !== undefined) { | ||
45 | this.account = new Account(hash.account) | ||
46 | } | ||
36 | 47 | ||
37 | if (hash.videoChannels !== undefined) { | 48 | if (hash.videoChannels !== undefined) { |
38 | this.videoChannels = hash.videoChannels | 49 | this.videoChannels = hash.videoChannels |
@@ -66,6 +77,10 @@ export class User implements UserServerModel { | |||
66 | this[key] = obj[key] | 77 | this[key] = obj[key] |
67 | } | 78 | } |
68 | 79 | ||
80 | if (obj.account !== undefined) { | ||
81 | this.account = new Account(obj.account) | ||
82 | } | ||
83 | |||
69 | this.updateComputedAttributes() | 84 | this.updateComputedAttributes() |
70 | } | 85 | } |
71 | 86 | ||
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts index e1e3bf697..55e4c2a31 100644 --- a/client/src/app/shared/video-channel/video-channel.service.ts +++ b/client/src/app/shared/video-channel/video-channel.service.ts | |||
@@ -8,6 +8,7 @@ import { AccountService } from '../account/account.service' | |||
8 | import { ResultList } from '../../../../../shared' | 8 | import { ResultList } from '../../../../../shared' |
9 | import { VideoChannel } from './video-channel.model' | 9 | import { VideoChannel } from './video-channel.model' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { Account } from '@app/shared/account/account.model' | ||
11 | 12 | ||
12 | @Injectable() | 13 | @Injectable() |
13 | export class VideoChannelService { | 14 | export class VideoChannelService { |
@@ -29,8 +30,8 @@ export class VideoChannelService { | |||
29 | ) | 30 | ) |
30 | } | 31 | } |
31 | 32 | ||
32 | listAccountVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> { | 33 | listAccountVideoChannels (account: Account): Observable<ResultList<VideoChannel>> { |
33 | return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels') | 34 | return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/video-channels') |
34 | .pipe( | 35 | .pipe( |
35 | map(res => this.extractVideoChannels(res)), | 36 | map(res => this.extractVideoChannels(res)), |
36 | catchError((res) => this.restExtractor.handleError(res)) | 37 | catchError((res) => this.restExtractor.handleError(res)) |
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts index 5397aa37f..5fc55fca6 100644 --- a/client/src/app/shared/video/video-details.model.ts +++ b/client/src/app/shared/video/video-details.model.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared' | 1 | import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared' |
2 | import { Account } from '../../../../../shared/models/actors' | ||
3 | import { AuthUser } from '../../core' | 2 | import { AuthUser } from '../../core' |
4 | import { Video } from '../../shared/video/video.model' | 3 | import { Video } from '../../shared/video/video.model' |
4 | import { Account } from '@app/shared/account/account.model' | ||
5 | 5 | ||
6 | export class VideoDetails extends Video implements VideoDetailsServerModel { | 6 | export class VideoDetails extends Video implements VideoDetailsServerModel { |
7 | descriptionPath: string | 7 | descriptionPath: string |
@@ -21,7 +21,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { | |||
21 | this.descriptionPath = hash.descriptionPath | 21 | this.descriptionPath = hash.descriptionPath |
22 | this.files = hash.files | 22 | this.files = hash.files |
23 | this.channel = hash.channel | 23 | this.channel = hash.channel |
24 | this.account = hash.account | 24 | this.account = new Account(hash.account) |
25 | this.tags = hash.tags | 25 | this.tags = hash.tags |
26 | this.support = hash.support | 26 | this.support = hash.support |
27 | this.commentsEnabled = hash.commentsEnabled | 27 | this.commentsEnabled = hash.commentsEnabled |
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index 1725e9f5c..09ce0ef7f 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html | |||
@@ -6,10 +6,10 @@ | |||
6 | class="video-miniature-name" | 6 | class="video-miniature-name" |
7 | [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }" | 7 | [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }" |
8 | > | 8 | > |
9 | {{ video.name }} | 9 | {{ video.name }} |
10 | </a> | 10 | </a> |
11 | 11 | ||
12 | <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> | 12 | <span class="video-miniature-created-at-views">{{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> |
13 | <a class="video-miniature-account" [routerLink]="[ '/accounts', video.account.id ]">{{ video.by }}</a> | 13 | <a class="video-miniature-account" [routerLink]="[ '/accounts', video.by ]">{{ video.by }}</a> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 5b8e2467a..d1e32faeb 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -120,7 +120,7 @@ export class VideoService { | |||
120 | params = this.restService.addRestGetParams(params, pagination, sort) | 120 | params = this.restService.addRestGetParams(params, pagination, sort) |
121 | 121 | ||
122 | return this.authHttp | 122 | return this.authHttp |
123 | .get(AccountService.BASE_ACCOUNT_URL + account.id + '/videos', { params }) | 123 | .get(AccountService.BASE_ACCOUNT_URL + account.nameWithHost + '/videos', { params }) |
124 | .pipe( | 124 | .pipe( |
125 | map(this.extractVideos), | 125 | map(this.extractVideos), |
126 | catchError(res => this.restExtractor.handleError(res)) | 126 | catchError(res => this.restExtractor.handleError(res)) |
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index 00c2ed3f1..339da1bf4 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts | |||
@@ -63,7 +63,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
63 | }), | 63 | }), |
64 | switchMap(video => { | 64 | switchMap(video => { |
65 | return this.videoChannelService | 65 | return this.videoChannelService |
66 | .listAccountVideoChannels(video.account.id) | 66 | .listAccountVideoChannels(video.account) |
67 | .pipe( | 67 | .pipe( |
68 | map(result => result.data), | 68 | map(result => result.data), |
69 | map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName }))), | 69 | map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName }))), |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index 212bfdd8c..583a97562 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html | |||
@@ -25,7 +25,7 @@ | |||
25 | </div> | 25 | </div> |
26 | 26 | ||
27 | <div class="video-info-by"> | 27 | <div class="video-info-by"> |
28 | <a [routerLink]="[ '/accounts', video.account.id ]" title="Go the account page"> | 28 | <a [routerLink]="[ '/accounts', video.by ]" title="Go the account page"> |
29 | <span>By {{ video.by }}</span> | 29 | <span>By {{ video.by }}</span> |
30 | <img [src]="video.accountAvatarUrl" alt="Account avatar" /> | 30 | <img [src]="video.accountAvatarUrl" alt="Account avatar" /> |
31 | </a> | 31 | </a> |