diff options
Diffstat (limited to 'client/src/app/+my-library/my-subscriptions')
3 files changed, 197 insertions, 0 deletions
diff --git a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html new file mode 100644 index 000000000..6ab3826ba --- /dev/null +++ b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html | |||
@@ -0,0 +1,42 @@ | |||
1 | <h1> | ||
2 | <span> | ||
3 | <my-global-icon iconName="subscriptions" aria-hidden="true"></my-global-icon> | ||
4 | <ng-container i18n>My subscriptions</ng-container> | ||
5 | <span class="badge badge-secondary"> {{ pagination.totalItems }}</span> | ||
6 | </span> | ||
7 | </h1> | ||
8 | |||
9 | <div class="video-subscriptions-header d-flex justify-content-between"> | ||
10 | <div class="has-feedback has-clear"> | ||
11 | <input type="text" placeholder="Search your subscriptions" i18n-placeholder [(ngModel)]="subscriptionsSearch" | ||
12 | (ngModelChange)="onSubscriptionsSearchChanged()" /> | ||
13 | <a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" (click)="resetSearch()"></a> | ||
14 | <span class="sr-only" i18n>Clear filters</span> | ||
15 | </div> | ||
16 | </div> | ||
17 | |||
18 | <div class="no-results" i18n *ngIf="pagination.totalItems === 0">You don't have any subscriptions yet.</div> | ||
19 | |||
20 | <div class="video-channels" myInfiniteScroller [autoInit]="true" (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()"> | ||
21 | <div *ngFor="let videoChannel of videoChannels" class="video-channel"> | ||
22 | <a [routerLink]="[ '/video-channels', videoChannel.nameWithHost ]"> | ||
23 | <img [src]="videoChannel.avatarUrl" alt="Avatar" /> | ||
24 | </a> | ||
25 | |||
26 | <div class="video-channel-info"> | ||
27 | <a [routerLink]="[ '/video-channels', videoChannel.nameWithHost ]" class="video-channel-names" i18n-title title="Channel page"> | ||
28 | <div class="video-channel-display-name">{{ videoChannel.displayName }}</div> | ||
29 | <div class="video-channel-name">{{ videoChannel.nameWithHost }}</div> | ||
30 | </a> | ||
31 | |||
32 | <div i18n class="video-channel-followers">{{ videoChannel.followersCount }} subscribers</div> | ||
33 | |||
34 | <a [routerLink]="[ '/accounts', videoChannel.ownerBy ]" i18n-title title="Owner account page" class="actor-owner"> | ||
35 | <span i18n>Created by {{ videoChannel.ownerBy }}</span> | ||
36 | <img [src]="videoChannel.ownerAvatarUrl" alt="Owner account avatar" /> | ||
37 | </a> | ||
38 | </div> | ||
39 | |||
40 | <my-subscribe-button [videoChannels]="[videoChannel]"></my-subscribe-button> | ||
41 | </div> | ||
42 | </div> | ||
diff --git a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss new file mode 100644 index 000000000..5ead45dd8 --- /dev/null +++ b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss | |||
@@ -0,0 +1,81 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | input[type=text] { | ||
5 | @include peertube-input-text(300px); | ||
6 | } | ||
7 | |||
8 | .video-channel { | ||
9 | @include row-blocks; | ||
10 | |||
11 | img { | ||
12 | @include avatar(80px); | ||
13 | |||
14 | margin-right: 10px; | ||
15 | } | ||
16 | |||
17 | .video-channel-info { | ||
18 | flex-grow: 1; | ||
19 | |||
20 | a.video-channel-names { | ||
21 | @include disable-default-a-behaviour; | ||
22 | |||
23 | width: fit-content; | ||
24 | display: flex; | ||
25 | align-items: baseline; | ||
26 | color: pvar(--mainForegroundColor); | ||
27 | |||
28 | .video-channel-display-name { | ||
29 | font-weight: $font-semibold; | ||
30 | font-size: 18px; | ||
31 | } | ||
32 | |||
33 | .video-channel-name { | ||
34 | font-size: 14px; | ||
35 | color: $grey-actor-name; | ||
36 | margin-left: 5px; | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | .actor-owner { | ||
42 | @include actor-owner; | ||
43 | |||
44 | margin-top: 0; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | .video-subscriptions-header { | ||
49 | margin-bottom: 30px; | ||
50 | } | ||
51 | |||
52 | @media screen and (max-width: $small-view) { | ||
53 | .video-channel { | ||
54 | .video-channel-info { | ||
55 | padding-bottom: 10px; | ||
56 | text-align: center; | ||
57 | |||
58 | .video-channel-names { | ||
59 | flex-direction: column; | ||
60 | align-items: center !important; | ||
61 | margin: auto; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | img { | ||
66 | margin-right: 0; | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | @media screen and (max-width: $mobile-view) { | ||
72 | .video-subscriptions-header { | ||
73 | flex-direction: column; | ||
74 | |||
75 | input[type=text] { | ||
76 | width: 100% !important; | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | |||
diff --git a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts new file mode 100644 index 000000000..3b748eccf --- /dev/null +++ b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts | |||
@@ -0,0 +1,74 @@ | |||
1 | import { Subject } from 'rxjs' | ||
2 | import { debounceTime } from 'rxjs/operators' | ||
3 | import { Component, OnInit } from '@angular/core' | ||
4 | import { ComponentPagination, Notifier } from '@app/core' | ||
5 | import { VideoChannel } from '@app/shared/shared-main' | ||
6 | import { UserSubscriptionService } from '@app/shared/shared-user-subscription' | ||
7 | |||
8 | @Component({ | ||
9 | templateUrl: './my-subscriptions.component.html', | ||
10 | styleUrls: [ './my-subscriptions.component.scss' ] | ||
11 | }) | ||
12 | export class MySubscriptionsComponent implements OnInit { | ||
13 | videoChannels: VideoChannel[] = [] | ||
14 | |||
15 | pagination: ComponentPagination = { | ||
16 | currentPage: 1, | ||
17 | itemsPerPage: 10, | ||
18 | totalItems: null | ||
19 | } | ||
20 | |||
21 | onDataSubject = new Subject<any[]>() | ||
22 | |||
23 | subscriptionsSearch: string | ||
24 | subscriptionsSearchChanged = new Subject<string>() | ||
25 | |||
26 | constructor ( | ||
27 | private userSubscriptionService: UserSubscriptionService, | ||
28 | private notifier: Notifier | ||
29 | ) {} | ||
30 | |||
31 | ngOnInit () { | ||
32 | this.loadSubscriptions() | ||
33 | |||
34 | this.subscriptionsSearchChanged | ||
35 | .pipe(debounceTime(500)) | ||
36 | .subscribe(() => { | ||
37 | this.pagination.currentPage = 1 | ||
38 | this.loadSubscriptions(false) | ||
39 | }) | ||
40 | } | ||
41 | |||
42 | resetSearch () { | ||
43 | this.subscriptionsSearch = '' | ||
44 | this.onSubscriptionsSearchChanged() | ||
45 | } | ||
46 | |||
47 | onSubscriptionsSearchChanged () { | ||
48 | this.subscriptionsSearchChanged.next() | ||
49 | } | ||
50 | |||
51 | onNearOfBottom () { | ||
52 | // Last page | ||
53 | if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return | ||
54 | |||
55 | this.pagination.currentPage += 1 | ||
56 | this.loadSubscriptions() | ||
57 | } | ||
58 | |||
59 | private loadSubscriptions (more = true) { | ||
60 | this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.subscriptionsSearch }) | ||
61 | .subscribe( | ||
62 | res => { | ||
63 | this.videoChannels = more | ||
64 | ? this.videoChannels.concat(res.data) | ||
65 | : res.data | ||
66 | this.pagination.totalItems = res.total | ||
67 | |||
68 | this.onDataSubject.next(res.data) | ||
69 | }, | ||
70 | |||
71 | error => this.notifier.error(error.message) | ||
72 | ) | ||
73 | } | ||
74 | } | ||