]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-sort.component.ts
c950fa8aa0d8714b6c4d94dd6e02cdc6de8db2b4
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-sort.component.ts
1 import { Component, EventEmitter, Input, Output } from '@angular/core';
2
3 import { SortField } from '../shared';
4
5 @Component({
6 selector: 'my-video-sort',
7 templateUrl: './video-sort.component.html'
8 })
9
10 export class VideoSortComponent {
11 @Output() sort = new EventEmitter<any>();
12
13 @Input() currentSort: SortField;
14
15 sortChoices = {
16 'name': 'Name - Asc',
17 '-name': 'Name - Desc',
18 'duration': 'Duration - Asc',
19 '-duration': 'Duration - Desc',
20 'createdAt': 'Created Date - Asc',
21 '-createdAt': 'Created Date - Desc',
22 'views': 'Views - Asc',
23 '-views': 'Views - Desc'
24 };
25
26 get choiceKeys() {
27 return Object.keys(this.sortChoices);
28 }
29
30 getStringChoice(choiceKey: SortField) {
31 return this.sortChoices[choiceKey];
32 }
33
34 onSortChange() {
35 this.sort.emit(this.currentSort);
36 }
37 }