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 | |
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')
4 files changed, 88 insertions, 2 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' | |||
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 | } |
diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index c05406438..80d9f0cf7 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { TableModule } from 'primeng/table' | 1 | import { TableModule } from 'primeng/table' |
2 | import { NgModule } from '@angular/core' | 2 | import { NgModule } from '@angular/core' |
3 | import { AutoCompleteModule } from 'primeng/autocomplete' | 3 | import { AutoCompleteModule } from 'primeng/autocomplete' |
4 | import { InputSwitchModule } from 'primeng/inputswitch' | ||
4 | import { SharedModule } from '../shared' | 5 | import { SharedModule } from '../shared' |
5 | import { MyAccountRoutingModule } from './my-account-routing.module' | 6 | import { MyAccountRoutingModule } from './my-account-routing.module' |
6 | import { MyAccountChangePasswordComponent } from './my-account-settings/my-account-change-password/my-account-change-password.component' | 7 | import { MyAccountChangePasswordComponent } from './my-account-settings/my-account-change-password/my-account-change-password.component' |
@@ -29,7 +30,8 @@ import { MyAccountHistoryComponent } from '@app/+my-account/my-account-history/m | |||
29 | MyAccountRoutingModule, | 30 | MyAccountRoutingModule, |
30 | AutoCompleteModule, | 31 | AutoCompleteModule, |
31 | SharedModule, | 32 | SharedModule, |
32 | TableModule | 33 | TableModule, |
34 | InputSwitchModule | ||
33 | ], | 35 | ], |
34 | 36 | ||
35 | declarations: [ | 37 | declarations: [ |