diff options
Diffstat (limited to 'client/src/app/+search')
-rw-r--r-- | client/src/app/+search/search-filters.component.ts | 9 | ||||
-rw-r--r-- | client/src/app/+search/search.component.ts | 20 |
2 files changed, 19 insertions, 10 deletions
diff --git a/client/src/app/+search/search-filters.component.ts b/client/src/app/+search/search-filters.component.ts index 59aba22ff..f5f0c87ed 100644 --- a/client/src/app/+search/search-filters.component.ts +++ b/client/src/app/+search/search-filters.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' | 1 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' |
2 | import { ServerService } from '@app/core' | 2 | import { ServerService } from '@app/core' |
3 | import { AdvancedSearch } from '@app/shared/shared-search' | 3 | import { AdvancedSearch } from '@app/shared/shared-search' |
4 | import { ServerConfig, VideoConstant } from '@shared/models' | 4 | import { HTMLServerConfig, VideoConstant } from '@shared/models' |
5 | 5 | ||
6 | type FormOption = { id: string, label: string } | 6 | type FormOption = { id: string, label: string } |
7 | 7 | ||
@@ -30,7 +30,7 @@ export class SearchFiltersComponent implements OnInit { | |||
30 | originallyPublishedStartYear: string | 30 | originallyPublishedStartYear: string |
31 | originallyPublishedEndYear: string | 31 | originallyPublishedEndYear: string |
32 | 32 | ||
33 | private serverConfig: ServerConfig | 33 | private serverConfig: HTMLServerConfig |
34 | 34 | ||
35 | constructor ( | 35 | constructor ( |
36 | private serverService: ServerService | 36 | private serverService: ServerService |
@@ -97,9 +97,8 @@ export class SearchFiltersComponent implements OnInit { | |||
97 | } | 97 | } |
98 | 98 | ||
99 | ngOnInit () { | 99 | ngOnInit () { |
100 | this.serverConfig = this.serverService.getTmpConfig() | 100 | this.serverConfig = this.serverService.getHTMLConfig() |
101 | this.serverService.getConfig() | 101 | |
102 | .subscribe(config => this.serverConfig = config) | ||
103 | 102 | ||
104 | this.serverService.getVideoCategories().subscribe(categories => this.videoCategories = categories) | 103 | this.serverService.getVideoCategories().subscribe(categories => this.videoCategories = categories) |
105 | this.serverService.getVideoLicences().subscribe(licences => this.videoLicences = licences) | 104 | this.serverService.getVideoLicences().subscribe(licences => this.videoLicences = licences) |
diff --git a/client/src/app/+search/search.component.ts b/client/src/app/+search/search.component.ts index 4381659e1..a31096bb2 100644 --- a/client/src/app/+search/search.component.ts +++ b/client/src/app/+search/search.component.ts | |||
@@ -6,7 +6,7 @@ import { immutableAssign } from '@app/helpers' | |||
6 | import { Video, VideoChannel } from '@app/shared/shared-main' | 6 | import { Video, VideoChannel } from '@app/shared/shared-main' |
7 | import { AdvancedSearch, SearchService } from '@app/shared/shared-search' | 7 | import { AdvancedSearch, SearchService } from '@app/shared/shared-search' |
8 | import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature' | 8 | import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature' |
9 | import { SearchTargetType, ServerConfig } from '@shared/models' | 9 | import { HTMLServerConfig, SearchTargetType } from '@shared/models' |
10 | 10 | ||
11 | @Component({ | 11 | @Component({ |
12 | selector: 'my-search', | 12 | selector: 'my-search', |
@@ -37,7 +37,6 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | errorMessage: string | 39 | errorMessage: string |
40 | serverConfig: ServerConfig | ||
41 | 40 | ||
42 | userMiniature: User | 41 | userMiniature: User |
43 | 42 | ||
@@ -49,6 +48,8 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
49 | 48 | ||
50 | private lastSearchTarget: SearchTargetType | 49 | private lastSearchTarget: SearchTargetType |
51 | 50 | ||
51 | private serverConfig: HTMLServerConfig | ||
52 | |||
52 | constructor ( | 53 | constructor ( |
53 | private route: ActivatedRoute, | 54 | private route: ActivatedRoute, |
54 | private router: Router, | 55 | private router: Router, |
@@ -62,8 +63,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
62 | ) { } | 63 | ) { } |
63 | 64 | ||
64 | ngOnInit () { | 65 | ngOnInit () { |
65 | this.serverService.getConfig() | 66 | this.serverConfig = this.serverService.getHTMLConfig() |
66 | .subscribe(config => this.serverConfig = config) | ||
67 | 67 | ||
68 | this.subActivatedRoute = this.route.queryParams.subscribe( | 68 | this.subActivatedRoute = this.route.queryParams.subscribe( |
69 | async queryParams => { | 69 | async queryParams => { |
@@ -81,7 +81,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
81 | 81 | ||
82 | this.advancedSearch = new AdvancedSearch(queryParams) | 82 | this.advancedSearch = new AdvancedSearch(queryParams) |
83 | if (!this.advancedSearch.searchTarget) { | 83 | if (!this.advancedSearch.searchTarget) { |
84 | this.advancedSearch.searchTarget = await this.serverService.getDefaultSearchTarget() | 84 | this.advancedSearch.searchTarget = this.getDefaultSearchTarget() |
85 | } | 85 | } |
86 | 86 | ||
87 | // Don't hide filters if we have some of them AND the user just came on the webpage | 87 | // Don't hide filters if we have some of them AND the user just came on the webpage |
@@ -286,4 +286,14 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
286 | 'filter:api.search.video-channels.list.result' | 286 | 'filter:api.search.video-channels.list.result' |
287 | ) | 287 | ) |
288 | } | 288 | } |
289 | |||
290 | private getDefaultSearchTarget(): SearchTargetType { | ||
291 | const searchIndexConfig = this.serverConfig.search.searchIndex | ||
292 | |||
293 | if (searchIndexConfig.enabled && (searchIndexConfig.isDefaultSearch || searchIndexConfig.disableLocalSearch)) { | ||
294 | return 'search-index' | ||
295 | } | ||
296 | |||
297 | return 'local' | ||
298 | } | ||
289 | } | 299 | } |