]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/search/search.component.ts
Use ng2-file-upload instead of jquery and add tags support to the video
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / search / search.component.ts
1 import { Component, EventEmitter, Output } from '@angular/core';
2
3 import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
4
5 import { Search } from './search.model';
6 import { SearchField } from './search-field.type';
7
8 @Component({
9 selector: 'my-search',
10 template: require('./search.component.html'),
11 directives: [ DROPDOWN_DIRECTIVES ]
12 })
13
14 export class SearchComponent {
15 @Output() search = new EventEmitter<Search>();
16
17 fieldChoices = {
18 name: 'Name',
19 author: 'Author',
20 podUrl: 'Pod Url',
21 magnetUri: 'Magnet Uri',
22 tags: 'Tags'
23 };
24 searchCriterias: Search = {
25 field: 'name',
26 value: ''
27 };
28
29 get choiceKeys() {
30 return Object.keys(this.fieldChoices);
31 }
32
33 choose($event: MouseEvent, choice: SearchField) {
34 $event.preventDefault();
35 $event.stopPropagation();
36
37 this.searchCriterias.field = choice;
38 }
39
40 doSearch() {
41 this.search.emit(this.searchCriterias);
42 }
43
44 getStringChoice(choiceKey: SearchField) {
45 return this.fieldChoices[choiceKey];
46 }
47 }