aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-08-13 15:07:23 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 11:07:56 +0100
commitafff310e50f2fa8419bb4242470cbde46ab54463 (patch)
tree34efda2daf8f7cdfd89ef6616a79e2222082f93a /client/src/app/+my-account
parentf619de0e435f7ac3abad2ec772397486358b56e7 (diff)
downloadPeerTube-afff310e50f2fa8419bb4242470cbde46ab54463.tar.gz
PeerTube-afff310e50f2fa8419bb4242470cbde46ab54463.tar.zst
PeerTube-afff310e50f2fa8419bb4242470cbde46ab54463.zip
allow private syndication feeds via a user feedToken
Diffstat (limited to 'client/src/app/+my-account')
-rw-r--r--client/src/app/+my-account/my-account-abuses/my-account-abuses-list.component.ts1
-rw-r--r--client/src/app/+my-account/my-account-applications/my-account-applications.component.html35
-rw-r--r--client/src/app/+my-account/my-account-applications/my-account-applications.component.scss28
-rw-r--r--client/src/app/+my-account/my-account-applications/my-account-applications.component.ts57
-rw-r--r--client/src/app/+my-account/my-account-routing.module.ts10
-rw-r--r--client/src/app/+my-account/my-account.component.ts5
-rw-r--r--client/src/app/+my-account/my-account.module.ts2
7 files changed, 137 insertions, 1 deletions
diff --git a/client/src/app/+my-account/my-account-abuses/my-account-abuses-list.component.ts b/client/src/app/+my-account/my-account-abuses/my-account-abuses-list.component.ts
index e5dd723ff..9316fc0dd 100644
--- a/client/src/app/+my-account/my-account-abuses/my-account-abuses-list.component.ts
+++ b/client/src/app/+my-account/my-account-abuses/my-account-abuses-list.component.ts
@@ -1,4 +1,3 @@
1
2import { Component } from '@angular/core' 1import { Component } from '@angular/core'
3 2
4@Component({ 3@Component({
diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.html b/client/src/app/+my-account/my-account-applications/my-account-applications.component.html
new file mode 100644
index 000000000..62e2cb59b
--- /dev/null
+++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.html
@@ -0,0 +1,35 @@
1<h1>
2 <my-global-icon iconName="codesandbox" aria-hidden="true"></my-global-icon>
3 <ng-container i18n>Applications</ng-container>
4</h1>
5
6<div class="form-row"> <!-- built-in token grid -->
7 <div class="form-group col-12 col-lg-4 col-xl-3">
8 <h2 i18n class="applications-title">SUBSCRIPTION FEED</h2>
9 <div i18n class="applications-description">
10 Used to retrieve the list of videos of the creators
11 you subscribed to from outside PeerTube
12 </div>
13 </div>
14
15 <div class="form-group form-group-right col-12 col-lg-8 col-xl-9">
16
17 <div class="form-group">
18 <label i18n for="feed-url">Feed URL</label>
19 <my-input-readonly-copy [value]="feedUrl"></my-input-readonly-copy>
20 </div>
21
22 <div class="form-group">
23 <label i18n for="feed-token">Feed Token</label>
24 <my-input-readonly-copy [value]="feedToken"></my-input-readonly-copy>
25 </div>
26
27 </div>
28</div>
29
30<div class="form-row mt-4"> <!-- submit placement block -->
31 <div class="col-md-7 col-xl-5"></div>
32 <div class="col-md-5 col-xl-5">
33 <input (click)="renewToken()" type="submit" i18n-value value="Renew token">
34 </div>
35</div>
diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.scss b/client/src/app/+my-account/my-account-applications/my-account-applications.component.scss
new file mode 100644
index 000000000..704132c03
--- /dev/null
+++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.scss
@@ -0,0 +1,28 @@
1@import '_variables';
2@import '_mixins';
3
4label {
5 font-weight: $font-regular;
6 font-size: 100%;
7}
8
9.applications-title {
10 @include settings-big-title;
11}
12
13.form-group {
14 max-width: 500px;
15}
16
17input[type=submit] {
18 @include peertube-button;
19 @include orange-button;
20
21 display: flex;
22 margin-left: auto;
23
24 & + .form-error {
25 display: inline;
26 margin-left: 5px;
27 }
28}
diff --git a/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts
new file mode 100644
index 000000000..c3f09dfe3
--- /dev/null
+++ b/client/src/app/+my-account/my-account-applications/my-account-applications.component.ts
@@ -0,0 +1,57 @@
1
2import { Component, OnInit } from '@angular/core'
3import { AuthService, Notifier, ConfirmService } from '@app/core'
4import { VideoService } from '@app/shared/shared-main'
5import { FeedFormat } from '@shared/models'
6import { Subject, merge } from 'rxjs'
7import { debounceTime } from 'rxjs/operators'
8
9@Component({
10 selector: 'my-account-applications',
11 templateUrl: './my-account-applications.component.html',
12 styleUrls: [ './my-account-applications.component.scss' ]
13})
14export class MyAccountApplicationsComponent implements OnInit {
15 feedUrl: string
16 feedToken: string
17
18 private baseURL = window.location.protocol + '//' + window.location.host
19 private tokenStream = new Subject()
20
21 constructor (
22 private authService: AuthService,
23 private videoService: VideoService,
24 private notifier: Notifier,
25 private confirmService: ConfirmService
26 ) {}
27
28 ngOnInit () {
29 this.feedUrl = this.baseURL
30
31 merge(
32 this.tokenStream,
33 this.authService.userInformationLoaded
34 ).pipe(debounceTime(400))
35 .subscribe(
36 _ => {
37 const user = this.authService.getUser()
38 this.videoService.getVideoSubscriptionFeedUrls(user.account.id)
39 .then(feeds => this.feedUrl = this.baseURL + feeds.find(f => f.format === FeedFormat.RSS).url)
40 .then(_ => this.authService.getScopedTokens().then(tokens => this.feedToken = tokens.feedToken))
41 },
42
43 err => {
44 this.notifier.error(err.message)
45 }
46 )
47 }
48
49 async renewToken () {
50 const res = await this.confirmService.confirm('Renewing the token will disallow previously configured clients from retrieving the feed until they use the new token. Proceed?', 'Renew token')
51 if (res === false) return
52
53 await this.authService.renewScopedTokens()
54 this.notifier.success('Token renewed. Update your client configuration accordingly.')
55 this.tokenStream.next()
56 }
57}
diff --git a/client/src/app/+my-account/my-account-routing.module.ts b/client/src/app/+my-account/my-account-routing.module.ts
index 81380ec6e..226a4a7be 100644
--- a/client/src/app/+my-account/my-account-routing.module.ts
+++ b/client/src/app/+my-account/my-account-routing.module.ts
@@ -8,6 +8,7 @@ import { MyAccountServerBlocklistComponent } from './my-account-blocklist/my-acc
8import { MyAccountNotificationsComponent } from './my-account-notifications/my-account-notifications.component' 8import { MyAccountNotificationsComponent } from './my-account-notifications/my-account-notifications.component'
9import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component' 9import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component'
10import { MyAccountComponent } from './my-account.component' 10import { MyAccountComponent } from './my-account.component'
11import { MyAccountApplicationsComponent } from './my-account-applications/my-account-applications.component'
11 12
12const myAccountRoutes: Routes = [ 13const myAccountRoutes: Routes = [
13 { 14 {
@@ -117,6 +118,15 @@ const myAccountRoutes: Routes = [
117 title: $localize`My abuse reports` 118 title: $localize`My abuse reports`
118 } 119 }
119 } 120 }
121 },
122 {
123 path: 'applications',
124 component: MyAccountApplicationsComponent,
125 data: {
126 meta: {
127 title: 'Applications'
128 }
129 }
120 } 130 }
121 ] 131 ]
122 } 132 }
diff --git a/client/src/app/+my-account/my-account.component.ts b/client/src/app/+my-account/my-account.component.ts
index d6e9d1c15..12966aebb 100644
--- a/client/src/app/+my-account/my-account.component.ts
+++ b/client/src/app/+my-account/my-account.component.ts
@@ -41,6 +41,11 @@ export class MyAccountComponent implements OnInit {
41 label: $localize`Abuse reports`, 41 label: $localize`Abuse reports`,
42 routerLink: '/my-account/abuses', 42 routerLink: '/my-account/abuses',
43 iconName: 'flag' 43 iconName: 'flag'
44 },
45 {
46 label: $localize`Applications`,
47 routerLink: '/my-account/applications',
48 iconName: 'codesandbox'
44 } 49 }
45 ] 50 ]
46 } 51 }
diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts
index 9e3fbcf65..70bf58aae 100644
--- a/client/src/app/+my-account/my-account.module.ts
+++ b/client/src/app/+my-account/my-account.module.ts
@@ -21,6 +21,7 @@ import { MyAccountNotificationPreferencesComponent } from './my-account-settings
21import { MyAccountProfileComponent } from './my-account-settings/my-account-profile/my-account-profile.component' 21import { MyAccountProfileComponent } from './my-account-settings/my-account-profile/my-account-profile.component'
22import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component' 22import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component'
23import { MyAccountComponent } from './my-account.component' 23import { MyAccountComponent } from './my-account.component'
24import { VideoChangeOwnershipComponent } from './my-account-applications/my-account-applications.component'
24 25
25@NgModule({ 26@NgModule({
26 imports: [ 27 imports: [
@@ -51,6 +52,7 @@ import { MyAccountComponent } from './my-account.component'
51 MyAccountAbusesListComponent, 52 MyAccountAbusesListComponent,
52 MyAccountServerBlocklistComponent, 53 MyAccountServerBlocklistComponent,
53 MyAccountNotificationsComponent, 54 MyAccountNotificationsComponent,
55 MyAccountNotificationPreferencesComponent,
54 MyAccountNotificationPreferencesComponent 56 MyAccountNotificationPreferencesComponent
55 ], 57 ],
56 58