aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/search/search.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/search/search.component.ts')
-rw-r--r--client/src/app/shared/search/search.component.ts48
1 files changed, 24 insertions, 24 deletions
diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts
index 48413b4f2..ecce20666 100644
--- a/client/src/app/shared/search/search.component.ts
+++ b/client/src/app/shared/search/search.component.ts
@@ -1,9 +1,9 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router'; 2import { Router } from '@angular/router'
3 3
4import { Search } from './search.model'; 4import { Search } from './search.model'
5import { SearchField } from './search-field.type'; 5import { SearchField } from './search-field.type'
6import { SearchService } from './search.service'; 6import { SearchService } from './search.service'
7 7
8@Component({ 8@Component({
9 selector: 'my-search', 9 selector: 'my-search',
@@ -18,53 +18,53 @@ export class SearchComponent implements OnInit {
18 host: 'Pod Host', 18 host: 'Pod Host',
19 magnetUri: 'Magnet URI', 19 magnetUri: 'Magnet URI',
20 tags: 'Tags' 20 tags: 'Tags'
21 }; 21 }
22 searchCriterias: Search = { 22 searchCriterias: Search = {
23 field: 'name', 23 field: 'name',
24 value: '' 24 value: ''
25 }; 25 }
26 26
27 constructor(private searchService: SearchService, private router: Router) {} 27 constructor (private searchService: SearchService, private router: Router) {}
28 28
29 ngOnInit() { 29 ngOnInit () {
30 // Subscribe if the search changed 30 // Subscribe if the search changed
31 // Usually changed by videos list component 31 // Usually changed by videos list component
32 this.searchService.updateSearch.subscribe( 32 this.searchService.updateSearch.subscribe(
33 newSearchCriterias => { 33 newSearchCriterias => {
34 // Put a field by default 34 // Put a field by default
35 if (!newSearchCriterias.field) { 35 if (!newSearchCriterias.field) {
36 newSearchCriterias.field = 'name'; 36 newSearchCriterias.field = 'name'
37 } 37 }
38 38
39 this.searchCriterias = newSearchCriterias; 39 this.searchCriterias = newSearchCriterias
40 } 40 }
41 ); 41 )
42 } 42 }
43 43
44 get choiceKeys() { 44 get choiceKeys () {
45 return Object.keys(this.fieldChoices); 45 return Object.keys(this.fieldChoices)
46 } 46 }
47 47
48 choose($event: MouseEvent, choice: SearchField) { 48 choose ($event: MouseEvent, choice: SearchField) {
49 $event.preventDefault(); 49 $event.preventDefault()
50 $event.stopPropagation(); 50 $event.stopPropagation()
51 51
52 this.searchCriterias.field = choice; 52 this.searchCriterias.field = choice
53 53
54 if (this.searchCriterias.value) { 54 if (this.searchCriterias.value) {
55 this.doSearch(); 55 this.doSearch()
56 } 56 }
57 } 57 }
58 58
59 doSearch() { 59 doSearch () {
60 if (this.router.url.indexOf('/videos/list') === -1) { 60 if (this.router.url.indexOf('/videos/list') === -1) {
61 this.router.navigate([ '/videos/list' ]); 61 this.router.navigate([ '/videos/list' ])
62 } 62 }
63 63
64 this.searchService.searchUpdated.next(this.searchCriterias); 64 this.searchService.searchUpdated.next(this.searchCriterias)
65 } 65 }
66 66
67 getStringChoice(choiceKey: SearchField) { 67 getStringChoice (choiceKey: SearchField) {
68 return this.fieldChoices[choiceKey]; 68 return this.fieldChoices[choiceKey]
69 } 69 }
70} 70}