aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-history
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+my-account/my-account-history')
-rw-r--r--client/src/app/+my-account/my-account-history/my-account-history.component.html14
-rw-r--r--client/src/app/+my-account/my-account-history/my-account-history.component.scss31
-rw-r--r--client/src/app/+my-account/my-account-history/my-account-history.component.ts41
3 files changed, 85 insertions, 1 deletions
diff --git a/client/src/app/+my-account/my-account-history/my-account-history.component.html b/client/src/app/+my-account/my-account-history/my-account-history.component.html
index 653b33f89..d42af37d4 100644
--- a/client/src/app/+my-account/my-account-history/my-account-history.component.html
+++ b/client/src/app/+my-account/my-account-history/my-account-history.component.html
@@ -1,4 +1,16 @@
1<div i18n *ngIf="pagination.totalItems === 0">You don't have history yet.</div> 1<div class="top-buttons">
2 <div class="history-switch">
3 <p-inputSwitch [(ngModel)]="videosHistoryEnabled" (ngModelChange)="onVideosHistoryChange()"></p-inputSwitch>
4 <label i18n>History enabled</label>
5 </div>
6
7 <div class="delete-history">
8 <button (click)="deleteHistory()" i18n>Delete history</button>
9 </div>
10</div>
11
12
13<div class="no-history" i18n *ngIf="pagination.totalItems === 0">You don't have videos history yet.</div>
2 14
3<div myInfiniteScroller (nearOfBottom)="onNearOfBottom()" class="videos" #videosElement> 15<div myInfiniteScroller (nearOfBottom)="onNearOfBottom()" class="videos" #videosElement>
4 <div *ngFor="let videos of videoPages;" class="videos-page"> 16 <div *ngFor="let videos of videoPages;" class="videos-page">
diff --git a/client/src/app/+my-account/my-account-history/my-account-history.component.scss b/client/src/app/+my-account/my-account-history/my-account-history.component.scss
index 115bb0e5c..82150cbe3 100644
--- a/client/src/app/+my-account/my-account-history/my-account-history.component.scss
+++ b/client/src/app/+my-account/my-account-history/my-account-history.component.scss
@@ -1,6 +1,37 @@
1@import '_variables'; 1@import '_variables';
2@import '_mixins'; 2@import '_mixins';
3 3
4.no-history {
5 display: flex;
6 justify-content: center;
7 margin-top: 50px;
8 font-weight: $font-semibold;
9 font-size: 16px;
10}
11
12.top-buttons {
13 margin-bottom: 20px;
14 display: flex;
15
16 .history-switch {
17 display: flex;
18 flex-grow: 1;
19
20 label {
21 margin: 0 0 0 5px;
22 }
23 }
24
25 .delete-history {
26 font-size: 15px;
27
28 button {
29 @include peertube-button;
30 @include grey-button;
31 }
32 }
33}
34
4.video { 35.video {
5 @include row-blocks; 36 @include row-blocks;
6 37
diff --git a/client/src/app/+my-account/my-account-history/my-account-history.component.ts b/client/src/app/+my-account/my-account-history/my-account-history.component.ts
index 508552167..6ec4fefe8 100644
--- a/client/src/app/+my-account/my-account-history/my-account-history.component.ts
+++ b/client/src/app/+my-account/my-account-history/my-account-history.component.ts
@@ -11,6 +11,7 @@ import { VideoService } from '../../shared/video/video.service'
11import { I18n } from '@ngx-translate/i18n-polyfill' 11import { I18n } from '@ngx-translate/i18n-polyfill'
12import { ScreenService } from '@app/shared/misc/screen.service' 12import { ScreenService } from '@app/shared/misc/screen.service'
13import { UserHistoryService } from '@app/shared/users/user-history.service' 13import { UserHistoryService } from '@app/shared/users/user-history.service'
14import { UserService } from '@app/shared'
14 15
15@Component({ 16@Component({
16 selector: 'my-account-history', 17 selector: 'my-account-history',
@@ -25,6 +26,7 @@ export class MyAccountHistoryComponent extends AbstractVideoList implements OnIn
25 itemsPerPage: 5, 26 itemsPerPage: 5,
26 totalItems: null 27 totalItems: null
27 } 28 }
29 videosHistoryEnabled: boolean
28 30
29 protected baseVideoWidth = -1 31 protected baseVideoWidth = -1
30 protected baseVideoHeight = 155 32 protected baseVideoHeight = 155
@@ -33,6 +35,7 @@ export class MyAccountHistoryComponent extends AbstractVideoList implements OnIn
33 protected router: Router, 35 protected router: Router,
34 protected route: ActivatedRoute, 36 protected route: ActivatedRoute,
35 protected authService: AuthService, 37 protected authService: AuthService,
38 protected userService: UserService,
36 protected notificationsService: NotificationsService, 39 protected notificationsService: NotificationsService,
37 protected location: Location, 40 protected location: Location,
38 protected screenService: ScreenService, 41 protected screenService: ScreenService,
@@ -48,6 +51,8 @@ export class MyAccountHistoryComponent extends AbstractVideoList implements OnIn
48 51
49 ngOnInit () { 52 ngOnInit () {
50 super.ngOnInit() 53 super.ngOnInit()
54
55 this.videosHistoryEnabled = this.authService.getUser().videosHistoryEnabled
51 } 56 }
52 57
53 ngOnDestroy () { 58 ngOnDestroy () {
@@ -63,4 +68,40 @@ export class MyAccountHistoryComponent extends AbstractVideoList implements OnIn
63 generateSyndicationList () { 68 generateSyndicationList () {
64 throw new Error('Method not implemented.') 69 throw new Error('Method not implemented.')
65 } 70 }
71
72 onVideosHistoryChange () {
73 this.userService.updateMyProfile({ videosHistoryEnabled: this.videosHistoryEnabled })
74 .subscribe(
75 () => {
76 const message = this.videosHistoryEnabled === true ?
77 this.i18n('Videos history is enabled') :
78 this.i18n('Videos history is disabled')
79
80 this.notificationsService.success(this.i18n('Success'), message)
81
82 this.authService.refreshUserInformation()
83 },
84
85 err => this.notificationsService.error(this.i18n('Error'), err.message)
86 )
87 }
88
89 async deleteHistory () {
90 const title = this.i18n('Delete videos history')
91 const message = this.i18n('Are you sure you want to delete all your videos history?')
92
93 const res = await this.confirmService.confirm(message, title)
94 if (res !== true) return
95
96 this.userHistoryService.deleteUserVideosHistory()
97 .subscribe(
98 () => {
99 this.notificationsService.success(this.i18n('Success'), this.i18n('Videos history deleted'))
100
101 this.reloadVideos()
102 },
103
104 err => this.notificationsService.error(this.i18n('Error'), err.message)
105 )
106 }
66} 107}