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