diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-18 11:32:37 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-12-18 11:35:51 +0100 |
commit | 276d96529529621d5f70473990095495f2743c29 (patch) | |
tree | 9fc62fc44dce05302215b10da13789ce89c9ee04 /client/src/app/+my-account/my-account-history/my-account-history.component.ts | |
parent | 80bfd33c0bf910e2cfdd3270b14ba9eddd90e2e8 (diff) | |
download | PeerTube-276d96529529621d5f70473990095495f2743c29.tar.gz PeerTube-276d96529529621d5f70473990095495f2743c29.tar.zst PeerTube-276d96529529621d5f70473990095495f2743c29.zip |
Add ability to disable and clear history
Diffstat (limited to 'client/src/app/+my-account/my-account-history/my-account-history.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account-history/my-account-history.component.ts | 41 |
1 files changed, 41 insertions, 0 deletions
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' | |||
11 | import { I18n } from '@ngx-translate/i18n-polyfill' | 11 | import { I18n } from '@ngx-translate/i18n-polyfill' |
12 | import { ScreenService } from '@app/shared/misc/screen.service' | 12 | import { ScreenService } from '@app/shared/misc/screen.service' |
13 | import { UserHistoryService } from '@app/shared/users/user-history.service' | 13 | import { UserHistoryService } from '@app/shared/users/user-history.service' |
14 | import { 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 | } |