aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+search
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-04 13:31:41 +0200
committerChocobozzz <me@florianbigard.com>2021-06-04 15:45:44 +0200
commit2989628b7913383b39ac34c7db8666a21f8e5037 (patch)
treeac7759177c04e524e7845143fd685aefb49e810e /client/src/app/+search
parent8e08d415f9473b6b72fef698729453e726da16e7 (diff)
downloadPeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.gz
PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.zst
PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.zip
Use HTML config when possible
Diffstat (limited to 'client/src/app/+search')
-rw-r--r--client/src/app/+search/search-filters.component.ts9
-rw-r--r--client/src/app/+search/search.component.ts20
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 @@
1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { AdvancedSearch } from '@app/shared/shared-search' 3import { AdvancedSearch } from '@app/shared/shared-search'
4import { ServerConfig, VideoConstant } from '@shared/models' 4import { HTMLServerConfig, VideoConstant } from '@shared/models'
5 5
6type FormOption = { id: string, label: string } 6type 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'
6import { Video, VideoChannel } from '@app/shared/shared-main' 6import { Video, VideoChannel } from '@app/shared/shared-main'
7import { AdvancedSearch, SearchService } from '@app/shared/shared-search' 7import { AdvancedSearch, SearchService } from '@app/shared/shared-search'
8import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature' 8import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature'
9import { SearchTargetType, ServerConfig } from '@shared/models' 9import { 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}