diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-06 11:39:22 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-06 11:43:01 +0200 |
commit | a6dbbf03865a955caaedc3b12f3de3e386fe850f (patch) | |
tree | 8beae7a5868c4bc9a89667852686cc3d312b2253 /client/src/app/+about | |
parent | 776ca9b1cc21daf96b48ecc9cc70a50ee3bfaf68 (diff) | |
download | PeerTube-a6dbbf03865a955caaedc3b12f3de3e386fe850f.tar.gz PeerTube-a6dbbf03865a955caaedc3b12f3de3e386fe850f.tar.zst PeerTube-a6dbbf03865a955caaedc3b12f3de3e386fe850f.zip |
Add list of instance follows in about page
Diffstat (limited to 'client/src/app/+about')
6 files changed, 154 insertions, 1 deletions
diff --git a/client/src/app/+about/about-follows/about-follows.component.html b/client/src/app/+about/about-follows/about-follows.component.html new file mode 100644 index 000000000..18689bbf7 --- /dev/null +++ b/client/src/app/+about/about-follows/about-follows.component.html | |||
@@ -0,0 +1,22 @@ | |||
1 | <div class="row" myInfiniteScroller [autoInit]="true" (nearOfBottom)="onNearOfBottom()"> | ||
2 | <div class="col-xl-6 col-md-12"> | ||
3 | <div i18n class="subtitle">Followers</div> | ||
4 | |||
5 | <div i18n class="no-results" *ngIf="followersPagination.totalItems === 0">This instance does not have followers.</div> | ||
6 | |||
7 | <a *ngFor="let follower of followers" [href]="buildLink(follower)" target="_blank" rel="noopener noreferrer"> | ||
8 | {{ follower }} | ||
9 | </a> | ||
10 | </div> | ||
11 | |||
12 | <div class="col-xl-6 col-md-12"> | ||
13 | <div i18n class="subtitle">Followings</div> | ||
14 | |||
15 | <div i18n class="no-results" *ngIf="followingsPagination.totalItems === 0">This instance does not have followings.</div> | ||
16 | |||
17 | <a *ngFor="let following of followings" [href]="buildLink(following)" target="_blank" rel="noopener noreferrer"> | ||
18 | {{ following }} | ||
19 | </a> | ||
20 | </div> | ||
21 | |||
22 | </div> | ||
diff --git a/client/src/app/+about/about-follows/about-follows.component.scss b/client/src/app/+about/about-follows/about-follows.component.scss new file mode 100644 index 000000000..e0d597a96 --- /dev/null +++ b/client/src/app/+about/about-follows/about-follows.component.scss | |||
@@ -0,0 +1,14 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .subtitle { | ||
5 | font-size: 18px; | ||
6 | font-weight: $font-semibold; | ||
7 | margin-bottom: 20px; | ||
8 | } | ||
9 | |||
10 | a { | ||
11 | display: block; | ||
12 | width: fit-content; | ||
13 | margin-top: 3px; | ||
14 | } | ||
diff --git a/client/src/app/+about/about-follows/about-follows.component.ts b/client/src/app/+about/about-follows/about-follows.component.ts new file mode 100644 index 000000000..f0e1375d6 --- /dev/null +++ b/client/src/app/+about/about-follows/about-follows.component.ts | |||
@@ -0,0 +1,103 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { FollowService } from '@app/shared/instance/follow.service' | ||
3 | import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model' | ||
4 | import { Notifier } from '@app/core' | ||
5 | import { RestService } from '@app/shared' | ||
6 | import { SortMeta } from 'primeng/api' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-about-follows', | ||
10 | templateUrl: './about-follows.component.html', | ||
11 | styleUrls: [ './about-follows.component.scss' ] | ||
12 | }) | ||
13 | |||
14 | export class AboutFollowsComponent implements OnInit { | ||
15 | followers: string[] = [] | ||
16 | followings: string[] = [] | ||
17 | |||
18 | followersPagination: ComponentPagination = { | ||
19 | currentPage: 1, | ||
20 | itemsPerPage: 40, | ||
21 | totalItems: null | ||
22 | } | ||
23 | |||
24 | followingsPagination: ComponentPagination = { | ||
25 | currentPage: 1, | ||
26 | itemsPerPage: 40, | ||
27 | totalItems: null | ||
28 | } | ||
29 | |||
30 | sort: SortMeta = { | ||
31 | field: 'createdAt', | ||
32 | order: -1 | ||
33 | } | ||
34 | |||
35 | constructor ( | ||
36 | private restService: RestService, | ||
37 | private notifier: Notifier, | ||
38 | private followService: FollowService | ||
39 | ) { } | ||
40 | |||
41 | ngOnInit () { | ||
42 | this.loadMoreFollowers() | ||
43 | |||
44 | this.loadMoreFollowings() | ||
45 | } | ||
46 | |||
47 | onNearOfBottom () { | ||
48 | this.onNearOfFollowersBottom() | ||
49 | |||
50 | this.onNearOfFollowingsBottom() | ||
51 | } | ||
52 | |||
53 | onNearOfFollowersBottom () { | ||
54 | if (!hasMoreItems(this.followersPagination)) return | ||
55 | |||
56 | this.followersPagination.currentPage += 1 | ||
57 | this.loadMoreFollowers() | ||
58 | } | ||
59 | |||
60 | onNearOfFollowingsBottom () { | ||
61 | if (!hasMoreItems(this.followingsPagination)) return | ||
62 | |||
63 | this.followingsPagination.currentPage += 1 | ||
64 | this.loadMoreFollowings() | ||
65 | } | ||
66 | |||
67 | buildLink (host: string) { | ||
68 | return window.location.protocol + '//' + host | ||
69 | } | ||
70 | |||
71 | private loadMoreFollowers () { | ||
72 | const pagination = this.restService.componentPaginationToRestPagination(this.followersPagination) | ||
73 | |||
74 | this.followService.getFollowers(pagination, this.sort) | ||
75 | .subscribe( | ||
76 | resultList => { | ||
77 | const newFollowers = resultList.data.map(r => r.follower.host) | ||
78 | this.followers = this.followers.concat(newFollowers) | ||
79 | |||
80 | this.followersPagination.totalItems = resultList.total | ||
81 | }, | ||
82 | |||
83 | err => this.notifier.error(err.message) | ||
84 | ) | ||
85 | } | ||
86 | |||
87 | private loadMoreFollowings () { | ||
88 | const pagination = this.restService.componentPaginationToRestPagination(this.followingsPagination) | ||
89 | |||
90 | this.followService.getFollowing(pagination, this.sort) | ||
91 | .subscribe( | ||
92 | resultList => { | ||
93 | const newFollowings = resultList.data.map(r => r.following.host) | ||
94 | this.followings = this.followings.concat(newFollowings) | ||
95 | |||
96 | this.followingsPagination.totalItems = resultList.total | ||
97 | }, | ||
98 | |||
99 | err => this.notifier.error(err.message) | ||
100 | ) | ||
101 | } | ||
102 | |||
103 | } | ||
diff --git a/client/src/app/+about/about-routing.module.ts b/client/src/app/+about/about-routing.module.ts index c83c62c7f..33e5070cb 100644 --- a/client/src/app/+about/about-routing.module.ts +++ b/client/src/app/+about/about-routing.module.ts | |||
@@ -4,6 +4,7 @@ import { MetaGuard } from '@ngx-meta/core' | |||
4 | import { AboutComponent } from './about.component' | 4 | import { AboutComponent } from './about.component' |
5 | import { AboutInstanceComponent } from '@app/+about/about-instance/about-instance.component' | 5 | import { AboutInstanceComponent } from '@app/+about/about-instance/about-instance.component' |
6 | import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component' | 6 | import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component' |
7 | import { AboutFollowsComponent } from '@app/+about/about-follows/about-follows.component' | ||
7 | 8 | ||
8 | const aboutRoutes: Routes = [ | 9 | const aboutRoutes: Routes = [ |
9 | { | 10 | { |
@@ -33,6 +34,15 @@ const aboutRoutes: Routes = [ | |||
33 | title: 'About PeerTube' | 34 | title: 'About PeerTube' |
34 | } | 35 | } |
35 | } | 36 | } |
37 | }, | ||
38 | { | ||
39 | path: 'follows', | ||
40 | component: AboutFollowsComponent, | ||
41 | data: { | ||
42 | meta: { | ||
43 | title: 'About follows' | ||
44 | } | ||
45 | } | ||
36 | } | 46 | } |
37 | ] | 47 | ] |
38 | } | 48 | } |
diff --git a/client/src/app/+about/about.component.html b/client/src/app/+about/about.component.html index 8c50835c1..0c4a5156d 100644 --- a/client/src/app/+about/about.component.html +++ b/client/src/app/+about/about.component.html | |||
@@ -5,10 +5,12 @@ | |||
5 | <a i18n routerLink="instance" routerLinkActive="active" class="title-page">Instance</a> | 5 | <a i18n routerLink="instance" routerLinkActive="active" class="title-page">Instance</a> |
6 | 6 | ||
7 | <a i18n routerLink="peertube" routerLinkActive="active" class="title-page">PeerTube</a> | 7 | <a i18n routerLink="peertube" routerLinkActive="active" class="title-page">PeerTube</a> |
8 | |||
9 | <a i18n routerLink="follows" routerLinkActive="active" class="title-page">Follows</a> | ||
8 | </div> | 10 | </div> |
9 | </div> | 11 | </div> |
10 | 12 | ||
11 | <div class="margin-content"> | 13 | <div class="margin-content"> |
12 | <router-outlet></router-outlet> | 14 | <router-outlet></router-outlet> |
13 | </div> | 15 | </div> |
14 | </div> \ No newline at end of file | 16 | </div> |
diff --git a/client/src/app/+about/about.module.ts b/client/src/app/+about/about.module.ts index 9c6b29740..49a7a52f8 100644 --- a/client/src/app/+about/about.module.ts +++ b/client/src/app/+about/about.module.ts | |||
@@ -6,6 +6,7 @@ import { SharedModule } from '../shared' | |||
6 | import { AboutInstanceComponent } from '@app/+about/about-instance/about-instance.component' | 6 | import { AboutInstanceComponent } from '@app/+about/about-instance/about-instance.component' |
7 | import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component' | 7 | import { AboutPeertubeComponent } from '@app/+about/about-peertube/about-peertube.component' |
8 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' | 8 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
9 | import { AboutFollowsComponent } from '@app/+about/about-follows/about-follows.component' | ||
9 | 10 | ||
10 | @NgModule({ | 11 | @NgModule({ |
11 | imports: [ | 12 | imports: [ |
@@ -17,6 +18,7 @@ import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-a | |||
17 | AboutComponent, | 18 | AboutComponent, |
18 | AboutInstanceComponent, | 19 | AboutInstanceComponent, |
19 | AboutPeertubeComponent, | 20 | AboutPeertubeComponent, |
21 | AboutFollowsComponent, | ||
20 | ContactAdminModalComponent | 22 | ContactAdminModalComponent |
21 | ], | 23 | ], |
22 | 24 | ||