diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
commit | a6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch) | |
tree | 03204a408d56311692c3528bedcf95d2455e94f2 /client/src/app/shared/search | |
parent | 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff) | |
parent | c4403b29ad4db097af528a7f04eea07e0ed320d0 (diff) | |
download | PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip |
Merge branch 'master' into webseed-merged
Diffstat (limited to 'client/src/app/shared/search')
-rw-r--r-- | client/src/app/shared/search/search.component.ts | 16 | ||||
-rw-r--r-- | client/src/app/shared/search/search.service.ts | 3 |
2 files changed, 11 insertions, 8 deletions
diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts index e864fbc17..b6237469b 100644 --- a/client/src/app/shared/search/search.component.ts +++ b/client/src/app/shared/search/search.component.ts | |||
@@ -1,15 +1,13 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | import { Router } from '@angular/router'; | |
3 | import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; | ||
4 | 3 | ||
5 | import { Search } from './search.model'; | 4 | import { Search } from './search.model'; |
6 | import { SearchField } from './search-field.type'; | 5 | import { SearchField } from './search-field.type'; |
7 | import { SearchService } from './search.service'; | 6 | import { SearchService } from './search.service'; |
8 | 7 | ||
9 | @Component({ | 8 | @Component({ |
10 | selector: 'my-search', | 9 | selector: 'my-search', |
11 | template: require('./search.component.html'), | 10 | templateUrl: './search.component.html' |
12 | directives: [ DROPDOWN_DIRECTIVES ] | ||
13 | }) | 11 | }) |
14 | 12 | ||
15 | export class SearchComponent implements OnInit { | 13 | export class SearchComponent implements OnInit { |
@@ -25,10 +23,10 @@ export class SearchComponent implements OnInit { | |||
25 | value: '' | 23 | value: '' |
26 | }; | 24 | }; |
27 | 25 | ||
28 | constructor(private searchService: SearchService) {} | 26 | constructor(private searchService: SearchService, private router: Router) {} |
29 | 27 | ||
30 | ngOnInit() { | 28 | ngOnInit() { |
31 | // Subscribe is the search changed | 29 | // Subscribe if the search changed |
32 | // Usually changed by videos list component | 30 | // Usually changed by videos list component |
33 | this.searchService.updateSearch.subscribe( | 31 | this.searchService.updateSearch.subscribe( |
34 | newSearchCriterias => { | 32 | newSearchCriterias => { |
@@ -58,6 +56,10 @@ export class SearchComponent implements OnInit { | |||
58 | } | 56 | } |
59 | 57 | ||
60 | doSearch() { | 58 | doSearch() { |
59 | if (this.router.url.indexOf('/videos/list') === -1) { | ||
60 | this.router.navigate([ '/videos/list' ]); | ||
61 | } | ||
62 | |||
61 | this.searchService.searchUpdated.next(this.searchCriterias); | 63 | this.searchService.searchUpdated.next(this.searchCriterias); |
62 | } | 64 | } |
63 | 65 | ||
diff --git a/client/src/app/shared/search/search.service.ts b/client/src/app/shared/search/search.service.ts index c7993db3d..717a7fa50 100644 --- a/client/src/app/shared/search/search.service.ts +++ b/client/src/app/shared/search/search.service.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core'; |
2 | import { Subject } from 'rxjs/Subject'; | 2 | import { Subject } from 'rxjs/Subject'; |
3 | import { ReplaySubject } from 'rxjs/ReplaySubject'; | ||
3 | 4 | ||
4 | import { Search } from './search.model'; | 5 | import { Search } from './search.model'; |
5 | 6 | ||
@@ -12,6 +13,6 @@ export class SearchService { | |||
12 | 13 | ||
13 | constructor() { | 14 | constructor() { |
14 | this.updateSearch = new Subject<Search>(); | 15 | this.updateSearch = new Subject<Search>(); |
15 | this.searchUpdated = new Subject<Search>(); | 16 | this.searchUpdated = new ReplaySubject<Search>(1); |
16 | } | 17 | } |
17 | } | 18 | } |