diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-08-13 15:07:23 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 11:07:56 +0100 |
commit | afff310e50f2fa8419bb4242470cbde46ab54463 (patch) | |
tree | 34efda2daf8f7cdfd89ef6616a79e2222082f93a /client/src/app/+my-account/my-account-applications | |
parent | f619de0e435f7ac3abad2ec772397486358b56e7 (diff) | |
download | PeerTube-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/my-account-applications')
3 files changed, 120 insertions, 0 deletions
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 | |||
4 | label { | ||
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 | |||
17 | input[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 | |||
2 | import { Component, OnInit } from '@angular/core' | ||
3 | import { AuthService, Notifier, ConfirmService } from '@app/core' | ||
4 | import { VideoService } from '@app/shared/shared-main' | ||
5 | import { FeedFormat } from '@shared/models' | ||
6 | import { Subject, merge } from 'rxjs' | ||
7 | import { 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 | }) | ||
14 | export 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 | } | ||