aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-library/my-history/my-history.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-12 15:28:54 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-13 12:02:21 +0100
commit17119e4a546522468878cf115558b17949ab50d0 (patch)
tree3f130cfd7fdccf5aeeac9beee941750590239047 /client/src/app/+my-library/my-history/my-history.component.ts
parentb4bc269e5517849b5b89052f0c1a2c01b6f65089 (diff)
downloadPeerTube-17119e4a546522468878cf115558b17949ab50d0.tar.gz
PeerTube-17119e4a546522468878cf115558b17949ab50d0.tar.zst
PeerTube-17119e4a546522468878cf115558b17949ab50d0.zip
Reorganize left menu and account menu
Add my-settings and my-library in left menu Move administration below my-library Split account menu: my-setting and my library
Diffstat (limited to 'client/src/app/+my-library/my-history/my-history.component.ts')
-rw-r--r--client/src/app/+my-library/my-history/my-history.component.ts102
1 files changed, 102 insertions, 0 deletions
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
new file mode 100644
index 000000000..e11f05c47
--- /dev/null
+++ b/client/src/app/+my-library/my-history/my-history.component.ts
@@ -0,0 +1,102 @@
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import {
4 AuthService,
5 ComponentPagination,
6 ConfirmService,
7 LocalStorageService,
8 Notifier,
9 ScreenService,
10 ServerService,
11 UserService
12} from '@app/core'
13import { immutableAssign } from '@app/helpers'
14import { UserHistoryService } from '@app/shared/shared-main'
15import { AbstractVideoList } from '@app/shared/shared-video-miniature'
16
17@Component({
18 templateUrl: './my-history.component.html',
19 styleUrls: [ './my-history.component.scss' ]
20})
21export class MyHistoryComponent extends AbstractVideoList implements OnInit, OnDestroy {
22 titlePage: string
23 pagination: ComponentPagination = {
24 currentPage: 1,
25 itemsPerPage: 5,
26 totalItems: null
27 }
28 videosHistoryEnabled: boolean
29
30 constructor (
31 protected router: Router,
32 protected serverService: ServerService,
33 protected route: ActivatedRoute,
34 protected authService: AuthService,
35 protected userService: UserService,
36 protected notifier: Notifier,
37 protected screenService: ScreenService,
38 protected storageService: LocalStorageService,
39 private confirmService: ConfirmService,
40 private userHistoryService: UserHistoryService
41 ) {
42 super()
43
44 this.titlePage = $localize`My videos history`
45 }
46
47 ngOnInit () {
48 super.ngOnInit()
49
50 this.videosHistoryEnabled = this.authService.getUser().videosHistoryEnabled
51 }
52
53 ngOnDestroy () {
54 super.ngOnDestroy()
55 }
56
57 getVideosObservable (page: number) {
58 const newPagination = immutableAssign(this.pagination, { currentPage: page })
59
60 return this.userHistoryService.getUserVideosHistory(newPagination)
61 }
62
63 generateSyndicationList () {
64 throw new Error('Method not implemented.')
65 }
66
67 onVideosHistoryChange () {
68 this.userService.updateMyProfile({ videosHistoryEnabled: this.videosHistoryEnabled })
69 .subscribe(
70 () => {
71 const message = this.videosHistoryEnabled === true ?
72 $localize`Videos history is enabled` :
73 $localize`Videos history is disabled`
74
75 this.notifier.success(message)
76
77 this.authService.refreshUserInformation()
78 },
79
80 err => this.notifier.error(err.message)
81 )
82 }
83
84 async deleteHistory () {
85 const title = $localize`Delete videos history`
86 const message = $localize`Are you sure you want to delete all your videos history?`
87
88 const res = await this.confirmService.confirm(message, title)
89 if (res !== true) return
90
91 this.userHistoryService.deleteUserVideosHistory()
92 .subscribe(
93 () => {
94 this.notifier.success($localize`Videos history deleted`)
95
96 this.reloadVideos()
97 },
98
99 err => this.notifier.error(err.message)
100 )
101 }
102}