aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/+my-account-video-channels
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 10:40:04 +0200
committerChocobozzz <me@florianbigard.com>2020-08-14 10:28:30 +0200
commit66357162f8e1227495f09bd4f68446aad7071c6d (patch)
tree7d4429506deb512b2fe1d0267f38a28cda20af55 /client/src/app/+my-account/+my-account-video-channels
parent8c360747995e17eb5520e22fc3d7bd4c3d26eeee (diff)
downloadPeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.gz
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.tar.zst
PeerTube-66357162f8e1227495f09bd4f68446aad7071c6d.zip
Migrate to $localize
* Remove i18n polyfill to translate things in components * Reduce bundle sizes * Improve runtime perf * Reduce a lot the time to make a full client build * Reduce client build complexity * We don't need a service to translate things anymore (so we will be able to translate title pages etc) Unfortunately we may loose some translations in the migration process. I'll put a message on weblate to notify translators
Diffstat (limited to 'client/src/app/+my-account/+my-account-video-channels')
-rw-r--r--client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts14
-rw-r--r--client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts10
-rw-r--r--client/src/app/+my-account/+my-account-video-channels/my-account-video-channels.component.ts48
3 files changed, 29 insertions, 43 deletions
diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
index 039c389e4..5c438c3bf 100644
--- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
+++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
@@ -3,7 +3,6 @@ import { Router } from '@angular/router'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' 4import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
5import { VideoChannelService } from '@app/shared/shared-main' 5import { VideoChannelService } from '@app/shared/shared-main'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { VideoChannelCreate } from '@shared/models' 6import { VideoChannelCreate } from '@shared/models'
8import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 7import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
9 8
@@ -21,9 +20,8 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
21 private videoChannelValidatorsService: VideoChannelValidatorsService, 20 private videoChannelValidatorsService: VideoChannelValidatorsService,
22 private notifier: Notifier, 21 private notifier: Notifier,
23 private router: Router, 22 private router: Router,
24 private videoChannelService: VideoChannelService, 23 private videoChannelService: VideoChannelService
25 private i18n: I18n 24 ) {
26 ) {
27 super() 25 super()
28 } 26 }
29 27
@@ -55,15 +53,13 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
55 () => { 53 () => {
56 this.authService.refreshUserInformation() 54 this.authService.refreshUserInformation()
57 55
58 this.notifier.success( 56 this.notifier.success($localize`Video channel ${videoChannelCreate.displayName} created.`)
59 this.i18n('Video channel {{videoChannelName}} created.', { videoChannelName: videoChannelCreate.displayName })
60 )
61 this.router.navigate([ '/my-account', 'video-channels' ]) 57 this.router.navigate([ '/my-account', 'video-channels' ])
62 }, 58 },
63 59
64 err => { 60 err => {
65 if (err.status === 409) { 61 if (err.status === 409) {
66 this.error = this.i18n('This name already exists on this instance.') 62 this.error = $localize`This name already exists on this instance.`
67 return 63 return
68 } 64 }
69 65
@@ -77,6 +73,6 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
77 } 73 }
78 74
79 getFormButtonTitle () { 75 getFormButtonTitle () {
80 return this.i18n('Create') 76 return $localize`Create`
81 } 77 }
82} 78}
diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
index 489c437ea..485521dcc 100644
--- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
+++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
@@ -4,7 +4,6 @@ import { ActivatedRoute, Router } from '@angular/router'
4import { AuthService, Notifier, ServerService } from '@app/core' 4import { AuthService, Notifier, ServerService } from '@app/core'
5import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' 5import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
6import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' 6import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { ServerConfig, VideoChannelUpdate } from '@shared/models' 7import { ServerConfig, VideoChannelUpdate } from '@shared/models'
9import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 8import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
10 9
@@ -29,7 +28,6 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
29 private router: Router, 28 private router: Router,
30 private route: ActivatedRoute, 29 private route: ActivatedRoute,
31 private videoChannelService: VideoChannelService, 30 private videoChannelService: VideoChannelService,
32 private i18n: I18n,
33 private serverService: ServerService 31 private serverService: ServerService
34 ) { 32 ) {
35 super() 33 super()
@@ -87,9 +85,7 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
87 () => { 85 () => {
88 this.authService.refreshUserInformation() 86 this.authService.refreshUserInformation()
89 87
90 this.notifier.success( 88 this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`)
91 this.i18n('Video channel {{videoChannelName}} updated.', { videoChannelName: videoChannelUpdate.displayName })
92 )
93 89
94 this.router.navigate([ '/my-account', 'video-channels' ]) 90 this.router.navigate([ '/my-account', 'video-channels' ])
95 }, 91 },
@@ -102,7 +98,7 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
102 this.videoChannelService.changeVideoChannelAvatar(this.videoChannelToUpdate.name, formData) 98 this.videoChannelService.changeVideoChannelAvatar(this.videoChannelToUpdate.name, formData)
103 .subscribe( 99 .subscribe(
104 data => { 100 data => {
105 this.notifier.success(this.i18n('Avatar changed.')) 101 this.notifier.success($localize`Avatar changed.`)
106 102
107 this.videoChannelToUpdate.updateAvatar(data.avatar) 103 this.videoChannelToUpdate.updateAvatar(data.avatar)
108 }, 104 },
@@ -124,7 +120,7 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
124 } 120 }
125 121
126 getFormButtonTitle () { 122 getFormButtonTitle () {
127 return this.i18n('Update') 123 return $localize`Update`
128 } 124 }
129 125
130 isBulkUpdateVideosDisplayed () { 126 isBulkUpdateVideosDisplayed () {
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 ad9368794..2aff09cd9 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
@@ -1,11 +1,10 @@
1import { ChartData } from 'chart.js' 1import { ChartData } from 'chart.js'
2import { max, maxBy, min, minBy } from 'lodash-es' 2import { max, maxBy, min, minBy } from 'lodash-es'
3import { flatMap, debounceTime } from 'rxjs/operators' 3import { Subject } from 'rxjs'
4import { debounceTime, mergeMap } from 'rxjs/operators'
4import { Component, OnInit } from '@angular/core' 5import { Component, OnInit } from '@angular/core'
5import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core' 6import { AuthService, ConfirmService, Notifier, ScreenService, User } from '@app/core'
6import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' 7import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { Subject } from 'rxjs'
9 8
10@Component({ 9@Component({
11 selector: 'my-account-video-channels', 10 selector: 'my-account-video-channels',
@@ -30,9 +29,8 @@ export class MyAccountVideoChannelsComponent implements OnInit {
30 private notifier: Notifier, 29 private notifier: Notifier,
31 private confirmService: ConfirmService, 30 private confirmService: ConfirmService,
32 private videoChannelService: VideoChannelService, 31 private videoChannelService: VideoChannelService,
33 private screenService: ScreenService, 32 private screenService: ScreenService
34 private i18n: I18n 33 ) {}
35 ) {}
36 34
37 ngOnInit () { 35 ngOnInit () {
38 this.user = this.authService.getUser() 36 this.user = this.authService.getUser()
@@ -110,17 +108,13 @@ export class MyAccountVideoChannelsComponent implements OnInit {
110 108
111 async deleteVideoChannel (videoChannel: VideoChannel) { 109 async deleteVideoChannel (videoChannel: VideoChannel) {
112 const res = await this.confirmService.confirmWithInput( 110 const res = await this.confirmService.confirmWithInput(
113 this.i18n( 111 $localize`Do you really want to delete ${videoChannel.displayName}?
114 // tslint:disable 112It will delete ${videoChannel.videosCount} videos uploaded in this channel, and you will not be able to create another
115 'Do you really want to delete {{channelDisplayName}}? It will delete {{videosCount}} videos uploaded in this channel, and you will not be able to create another channel with the same name ({{channelName}})!', 113channel with the same name (${videoChannel.name})!`,
116 { channelDisplayName: videoChannel.displayName, videosCount: videoChannel.videosCount, channelName: videoChannel.name } 114
117 ), 115 $localize`Please type the display name of the video channel (${videoChannel.displayName}) to confirm`,
118 this.i18n( 116
119 'Please type the display name of the video channel ({{displayName}}) to confirm', 117 $localize`Delete`
120 { displayName: videoChannel.displayName }
121 ),
122 videoChannel.displayName,
123 this.i18n('Delete')
124 ) 118 )
125 if (res === false) return 119 if (res === false) return
126 120
@@ -128,9 +122,7 @@ export class MyAccountVideoChannelsComponent implements OnInit {
128 .subscribe( 122 .subscribe(
129 () => { 123 () => {
130 this.loadVideoChannels() 124 this.loadVideoChannels()
131 this.notifier.success( 125 this.notifier.success($localize`Video channel ${videoChannel.displayName} deleted.`)
132 this.i18n('Video channel {{videoChannelName}} deleted.', { videoChannelName: videoChannel.displayName })
133 )
134 }, 126 },
135 127
136 error => this.notifier.error(error.message) 128 error => this.notifier.error(error.message)
@@ -139,7 +131,7 @@ export class MyAccountVideoChannelsComponent implements OnInit {
139 131
140 private loadVideoChannels () { 132 private loadVideoChannels () {
141 this.authService.userInformationLoaded 133 this.authService.userInformationLoaded
142 .pipe(flatMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true, this.channelsSearch))) 134 .pipe(mergeMap(() => this.videoChannelService.listAccountVideoChannels(this.user.account, null, true, this.channelsSearch)))
143 .subscribe(res => { 135 .subscribe(res => {
144 this.videoChannels = res.data 136 this.videoChannels = res.data
145 this.totalItems = res.total 137 this.totalItems = res.total
@@ -149,10 +141,10 @@ export class MyAccountVideoChannelsComponent implements OnInit {
149 labels: v.viewsPerDay.map(day => day.date.toLocaleDateString()), 141 labels: v.viewsPerDay.map(day => day.date.toLocaleDateString()),
150 datasets: [ 142 datasets: [
151 { 143 {
152 label: this.i18n('Views for the day'), 144 label: $localize`Views for the day`,
153 data: v.viewsPerDay.map(day => day.views), 145 data: v.viewsPerDay.map(day => day.views),
154 fill: false, 146 fill: false,
155 borderColor: "#c6c6c6" 147 borderColor: '#c6c6c6'
156 } 148 }
157 ] 149 ]
158 } as ChartData)) 150 } as ChartData))
@@ -160,13 +152,15 @@ export class MyAccountVideoChannelsComponent implements OnInit {
160 // chart options that depend on chart data: 152 // chart options that depend on chart data:
161 // we don't want to skew values and have min at 0, so we define what the floor/ceiling is here 153 // we don't want to skew values and have min at 0, so we define what the floor/ceiling is here
162 this.videoChannelsMinimumDailyViews = min( 154 this.videoChannelsMinimumDailyViews = min(
163 this.videoChannels.map(v => minBy( // compute local minimum daily views for each channel, by their "views" attribute 155 // compute local minimum daily views for each channel, by their "views" attribute
156 this.videoChannels.map(v => minBy(
164 v.viewsPerDay, 157 v.viewsPerDay,
165 day => day.views 158 day => day.views
166 ).views) // the object returned is a ViewPerDate, so we still need to get the views attribute 159 ).views) // the object returned is a ViewPerDate, so we still need to get the views attribute
167 ) 160 )
168 this.videoChannelsMaximumDailyViews = max( 161 this.videoChannelsMaximumDailyViews = max(
169 this.videoChannels.map(v => maxBy( // compute local maximum daily views for each channel, by their "views" attribute 162 // compute local maximum daily views for each channel, by their "views" attribute
163 this.videoChannels.map(v => maxBy(
170 v.viewsPerDay, 164 v.viewsPerDay,
171 day => day.views 165 day => day.views
172 ).views) // the object returned is a ViewPerDate, so we still need to get the views attribute 166 ).views) // the object returned is a ViewPerDate, so we still need to get the views attribute