aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/app/search.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/app/search.component.ts')
-rw-r--r--client/angular/app/search.component.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/client/angular/app/search.component.ts b/client/angular/app/search.component.ts
new file mode 100644
index 000000000..3e8db70c0
--- /dev/null
+++ b/client/angular/app/search.component.ts
@@ -0,0 +1,48 @@
1import { Component, EventEmitter, Output } from '@angular/core';
2import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from '@angular/router-deprecated';
3import { HTTP_PROVIDERS } from '@angular/http';
4
5import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
6
7import { Search, SearchField } from './search';
8
9@Component({
10 selector: 'my-search',
11 templateUrl: 'app/angular/app/search.component.html',
12 directives: [ DROPDOWN_DIRECTIVES ]
13})
14
15export class SearchComponent {
16 @Output() search: EventEmitter<Search> = new EventEmitter<Search>();
17
18 searchCriterias: Search = {
19 field: "name",
20 value: ""
21 }
22 fieldChoices = {
23 name: "Name",
24 author: "Author",
25 podUrl: "Pod Url",
26 magnetUri: "Magnet Uri"
27 }
28
29 get choiceKeys() {
30 return Object.keys(this.fieldChoices);
31 }
32
33 getStringChoice(choiceKey: SearchField): string {
34 return this.fieldChoices[choiceKey];
35 }
36
37 choose($event:MouseEvent, choice: SearchField){
38 $event.preventDefault();
39 $event.stopPropagation();
40
41 this.searchCriterias.field = choice;
42 }
43
44 doSearch(): void {
45 this.search.emit(this.searchCriterias);
46 }
47
48}