aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-18 09:31:09 +0100
committerChocobozzz <me@florianbigard.com>2018-12-18 11:35:51 +0100
commit80bfd33c0bf910e2cfdd3270b14ba9eddd90e2e8 (patch)
tree80cd14e2f503db64ebec5fcfbb94ce5db25f46c9 /client/src/app/shared
parent8b9a525a180cc9f3a98c334cc052dcfc8f36dcd4 (diff)
downloadPeerTube-80bfd33c0bf910e2cfdd3270b14ba9eddd90e2e8.tar.gz
PeerTube-80bfd33c0bf910e2cfdd3270b14ba9eddd90e2e8.tar.zst
PeerTube-80bfd33c0bf910e2cfdd3270b14ba9eddd90e2e8.zip
Add history page on client
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/menu/top-menu-dropdown.component.html5
-rw-r--r--client/src/app/shared/menu/top-menu-dropdown.component.scss4
-rw-r--r--client/src/app/shared/menu/top-menu-dropdown.component.ts14
-rw-r--r--client/src/app/shared/shared.module.ts2
-rw-r--r--client/src/app/shared/users/user-history.service.ts45
5 files changed, 66 insertions, 4 deletions
diff --git a/client/src/app/shared/menu/top-menu-dropdown.component.html b/client/src/app/shared/menu/top-menu-dropdown.component.html
index 2d6d1c4bf..d3c896019 100644
--- a/client/src/app/shared/menu/top-menu-dropdown.component.html
+++ b/client/src/app/shared/menu/top-menu-dropdown.component.html
@@ -4,7 +4,10 @@
4 <a *ngIf="menuEntry.routerLink" [routerLink]="menuEntry.routerLink" routerLinkActive="active" class="title-page">{{ menuEntry.label }}</a> 4 <a *ngIf="menuEntry.routerLink" [routerLink]="menuEntry.routerLink" routerLinkActive="active" class="title-page">{{ menuEntry.label }}</a>
5 5
6 <div *ngIf="!menuEntry.routerLink" ngbDropdown class="parent-entry" #dropdown="ngbDropdown" (mouseleave)="closeDropdownIfHovered(dropdown)"> 6 <div *ngIf="!menuEntry.routerLink" ngbDropdown class="parent-entry" #dropdown="ngbDropdown" (mouseleave)="closeDropdownIfHovered(dropdown)">
7 <span (mouseenter)="openDropdownOnHover(dropdown)" role="button" class="title-page" [ngClass]="{ active: !!suffixLabels[menuEntry.label] }" ngbDropdownToggle> 7 <span
8 (mouseenter)="openDropdownOnHover(dropdown)" [ngClass]="{ active: !!suffixLabels[menuEntry.label] }" ngbDropdownAnchor
9 (click)="dropdownAnchorClicked(dropdown)" role="button" class="title-page"
10 >
8 <ng-container i18n>{{ menuEntry.label }}</ng-container> 11 <ng-container i18n>{{ menuEntry.label }}</ng-container>
9 <ng-container *ngIf="!!suffixLabels[menuEntry.label]"> - {{ suffixLabels[menuEntry.label] }}</ng-container> 12 <ng-container *ngIf="!!suffixLabels[menuEntry.label]"> - {{ suffixLabels[menuEntry.label] }}</ng-container>
10 </span> 13 </span>
diff --git a/client/src/app/shared/menu/top-menu-dropdown.component.scss b/client/src/app/shared/menu/top-menu-dropdown.component.scss
index f3ef8f814..77159532f 100644
--- a/client/src/app/shared/menu/top-menu-dropdown.component.scss
+++ b/client/src/app/shared/menu/top-menu-dropdown.component.scss
@@ -12,3 +12,7 @@
12 position: relative; 12 position: relative;
13 top: 2px; 13 top: 2px;
14} 14}
15
16/deep/ .dropdown-menu {
17 margin-top: 0 !important;
18}
diff --git a/client/src/app/shared/menu/top-menu-dropdown.component.ts b/client/src/app/shared/menu/top-menu-dropdown.component.ts
index 272b721b2..e859c30dd 100644
--- a/client/src/app/shared/menu/top-menu-dropdown.component.ts
+++ b/client/src/app/shared/menu/top-menu-dropdown.component.ts
@@ -1,9 +1,8 @@
1import { Component, Input, OnDestroy, OnInit } from '@angular/core' 1import { Component, Input, OnDestroy, OnInit } from '@angular/core'
2import { filter, take } from 'rxjs/operators' 2import { filter, take } from 'rxjs/operators'
3import { NavigationStart, Router } from '@angular/router' 3import { NavigationEnd, Router } from '@angular/router'
4import { Subscription } from 'rxjs' 4import { Subscription } from 'rxjs'
5import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' 5import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
6import { drop } from 'lodash-es'
7 6
8export type TopMenuDropdownParam = { 7export type TopMenuDropdownParam = {
9 label: string 8 label: string
@@ -34,7 +33,7 @@ export class TopMenuDropdownComponent implements OnInit, OnDestroy {
34 this.updateChildLabels(window.location.pathname) 33 this.updateChildLabels(window.location.pathname)
35 34
36 this.routeSub = this.router.events 35 this.routeSub = this.router.events
37 .pipe(filter(event => event instanceof NavigationStart)) 36 .pipe(filter(event => event instanceof NavigationEnd))
38 .subscribe(() => this.updateChildLabels(window.location.pathname)) 37 .subscribe(() => this.updateChildLabels(window.location.pathname))
39 } 38 }
40 39
@@ -52,6 +51,15 @@ export class TopMenuDropdownComponent implements OnInit, OnDestroy {
52 .subscribe(e => this.openedOnHover = false) 51 .subscribe(e => this.openedOnHover = false)
53 } 52 }
54 53
54 dropdownAnchorClicked (dropdown: NgbDropdown) {
55 if (this.openedOnHover) {
56 this.openedOnHover = false
57 return
58 }
59
60 return dropdown.toggle()
61 }
62
55 closeDropdownIfHovered (dropdown: NgbDropdown) { 63 closeDropdownIfHovered (dropdown: NgbDropdown) {
56 if (this.openedOnHover === false) return 64 if (this.openedOnHover === false) return
57 65
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 9810e9485..4a5d664db 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -62,6 +62,7 @@ import { UserBanModalComponent } from '@app/shared/moderation'
62import { UserModerationDropdownComponent } from '@app/shared/moderation/user-moderation-dropdown.component' 62import { UserModerationDropdownComponent } from '@app/shared/moderation/user-moderation-dropdown.component'
63import { BlocklistService } from '@app/shared/blocklist' 63import { BlocklistService } from '@app/shared/blocklist'
64import { TopMenuDropdownComponent } from '@app/shared/menu/top-menu-dropdown.component' 64import { TopMenuDropdownComponent } from '@app/shared/menu/top-menu-dropdown.component'
65import { UserHistoryService } from '@app/shared/users/user-history.service'
65 66
66@NgModule({ 67@NgModule({
67 imports: [ 68 imports: [
@@ -181,6 +182,7 @@ import { TopMenuDropdownComponent } from '@app/shared/menu/top-menu-dropdown.com
181 VideoChangeOwnershipValidatorsService, 182 VideoChangeOwnershipValidatorsService,
182 VideoAcceptOwnershipValidatorsService, 183 VideoAcceptOwnershipValidatorsService,
183 BlocklistService, 184 BlocklistService,
185 UserHistoryService,
184 186
185 I18nPrimengCalendarService, 187 I18nPrimengCalendarService,
186 ScreenService, 188 ScreenService,
diff --git a/client/src/app/shared/users/user-history.service.ts b/client/src/app/shared/users/user-history.service.ts
new file mode 100644
index 000000000..9ed25bfc7
--- /dev/null
+++ b/client/src/app/shared/users/user-history.service.ts
@@ -0,0 +1,45 @@
1import { HttpClient, HttpParams } from '@angular/common/http'
2import { Injectable } from '@angular/core'
3import { environment } from '../../../environments/environment'
4import { RestExtractor } from '../rest/rest-extractor.service'
5import { RestService } from '../rest/rest.service'
6import { Video } from '../video/video.model'
7import { catchError, map, switchMap } from 'rxjs/operators'
8import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
9import { VideoService } from '@app/shared/video/video.service'
10import { ResultList } from '../../../../../shared'
11
12@Injectable()
13export class UserHistoryService {
14 static BASE_USER_VIDEOS_HISTORY_URL = environment.apiUrl + '/api/v1/users/me/history/videos'
15
16 constructor (
17 private authHttp: HttpClient,
18 private restExtractor: RestExtractor,
19 private restService: RestService,
20 private videoService: VideoService
21 ) {}
22
23 getUserVideosHistory (historyPagination: ComponentPagination) {
24 const pagination = this.restService.componentPaginationToRestPagination(historyPagination)
25
26 let params = new HttpParams()
27 params = this.restService.addRestGetParams(params, pagination)
28
29 return this.authHttp
30 .get<ResultList<Video>>(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL, { params })
31 .pipe(
32 switchMap(res => this.videoService.extractVideos(res)),
33 catchError(err => this.restExtractor.handleError(err))
34 )
35 }
36
37 deleteUserVideosHistory () {
38 return this.authHttp
39 .post(UserHistoryService.BASE_USER_VIDEOS_HISTORY_URL + '/remove', {})
40 .pipe(
41 map(() => this.restExtractor.extractDataBool()),
42 catchError(err => this.restExtractor.handleError(err))
43 )
44 }
45}