diff options
author | Chocobozzz <me@florianbigard.com> | 2022-01-18 11:23:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-01-18 11:23:41 +0100 |
commit | 7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180 (patch) | |
tree | 016cb0d966fe9fea8a6381eb246e966f5c4eae57 /client/src/app | |
parent | 3b83faccfffc13adaef0b63c211b1ce4944e8b3b (diff) | |
download | PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.tar.gz PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.tar.zst PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.zip |
Add ability to delete history element
Diffstat (limited to 'client/src/app')
4 files changed, 34 insertions, 6 deletions
diff --git a/client/src/app/+my-library/my-history/my-history.component.html b/client/src/app/+my-library/my-history/my-history.component.html index 8e564cf93..14bf01804 100644 --- a/client/src/app/+my-library/my-history/my-history.component.html +++ b/client/src/app/+my-library/my-history/my-history.component.html | |||
@@ -13,9 +13,9 @@ | |||
13 | <label i18n>Track watch history</label> | 13 | <label i18n>Track watch history</label> |
14 | </div> | 14 | </div> |
15 | 15 | ||
16 | <button class="delete-history" (click)="deleteHistory()" i18n> | 16 | <button class="delete-history" (click)="clearAllHistory()" i18n> |
17 | <my-global-icon iconName="delete" aria-hidden="true"></my-global-icon> | 17 | <my-global-icon iconName="delete" aria-hidden="true"></my-global-icon> |
18 | Delete history | 18 | Clear all history |
19 | </button> | 19 | </button> |
20 | </div> | 20 | </div> |
21 | 21 | ||
@@ -30,4 +30,10 @@ | |||
30 | [enableSelection]="false" | 30 | [enableSelection]="false" |
31 | [disabled]="disabled" | 31 | [disabled]="disabled" |
32 | #videosSelection | 32 | #videosSelection |
33 | ></my-videos-selection> | 33 | > |
34 | <ng-template ptTemplate="rowButtons" let-video> | ||
35 | <div class="action-button"> | ||
36 | <my-delete-button i18n-label label="Delete from history" (click)="deleteHistoryElement(video)"></my-delete-button> | ||
37 | </div> | ||
38 | </ng-template> | ||
39 | </my-videos-selection> | ||
diff --git a/client/src/app/+my-library/my-history/my-history.component.scss b/client/src/app/+my-library/my-history/my-history.component.scss index cb8507569..3257b2215 100644 --- a/client/src/app/+my-library/my-history/my-history.component.scss +++ b/client/src/app/+my-library/my-history/my-history.component.scss | |||
@@ -53,6 +53,11 @@ | |||
53 | @include row-blocks($column-responsive: false); | 53 | @include row-blocks($column-responsive: false); |
54 | } | 54 | } |
55 | 55 | ||
56 | .action-button { | ||
57 | display: flex; | ||
58 | align-self: flex-end; | ||
59 | } | ||
60 | |||
56 | @media screen and (max-width: $small-view) { | 61 | @media screen and (max-width: $small-view) { |
57 | .top-buttons { | 62 | .top-buttons { |
58 | grid-template-columns: auto 1fr auto; | 63 | grid-template-columns: auto 1fr auto; |
diff --git a/client/src/app/+my-library/my-history/my-history.component.ts b/client/src/app/+my-library/my-history/my-history.component.ts index 95cfaee41..34efe5558 100644 --- a/client/src/app/+my-library/my-history/my-history.component.ts +++ b/client/src/app/+my-library/my-history/my-history.component.ts | |||
@@ -123,14 +123,25 @@ export class MyHistoryComponent implements OnInit, DisableForReuseHook { | |||
123 | }) | 123 | }) |
124 | } | 124 | } |
125 | 125 | ||
126 | async deleteHistory () { | 126 | deleteHistoryElement (video: Video) { |
127 | this.userHistoryService.deleteUserVideoHistoryElement(video) | ||
128 | .subscribe({ | ||
129 | next: () => { | ||
130 | this.videos = this.videos.filter(v => v.id !== video.id) | ||
131 | }, | ||
132 | |||
133 | error: err => this.notifier.error(err.message) | ||
134 | }) | ||
135 | } | ||
136 | |||
137 | async clearAllHistory () { | ||
127 | const title = $localize`Delete videos history` | 138 | const title = $localize`Delete videos history` |
128 | const message = $localize`Are you sure you want to delete all your videos history?` | 139 | const message = $localize`Are you sure you want to delete all your videos history?` |
129 | 140 | ||
130 | const res = await this.confirmService.confirm(message, title) | 141 | const res = await this.confirmService.confirm(message, title) |
131 | if (res !== true) return | 142 | if (res !== true) return |
132 | 143 | ||
133 | this.userHistoryService.deleteUserVideosHistory() | 144 | this.userHistoryService.clearAllUserVideosHistory() |
134 | .subscribe({ | 145 | .subscribe({ |
135 | next: () => { | 146 | next: () => { |
136 | this.notifier.success($localize`Videos history deleted`) | 147 | this.notifier.success($localize`Videos history deleted`) |
diff --git a/client/src/app/shared/shared-main/users/user-history.service.ts b/client/src/app/shared/shared-main/users/user-history.service.ts index a4841897d..e28bcdca9 100644 --- a/client/src/app/shared/shared-main/users/user-history.service.ts +++ b/client/src/app/shared/shared-main/users/user-history.service.ts | |||
@@ -34,7 +34,13 @@ export class UserHistoryService { | |||
34 | ) | 34 | ) |
35 | } | 35 | } |
36 | 36 | ||
37 | deleteUserVideosHistory () { | 37 | deleteUserVideoHistoryElement (video: Video) { |
38 | return this.authHttp | ||
39 | .delete(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL + '/' + video.id) | ||
40 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
41 | } | ||
42 | |||
43 | clearAllUserVideosHistory () { | ||
38 | return this.authHttp | 44 | return this.authHttp |
39 | .post(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL + '/remove', {}) | 45 | .post(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL + '/remove', {}) |
40 | .pipe( | 46 | .pipe( |