aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/server/server.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-29 16:16:24 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-10 14:02:41 +0200
commit5fb2e2888ce032c638e4b75d07458642f0833e52 (patch)
tree8830d873569316889b8134027e9a43b198cca38f /client/src/app/core/server/server.service.ts
parent62e7be634bc189f942ae51cb4b080079ab503ff0 (diff)
downloadPeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.gz
PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.zst
PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.zip
First implem global search
Diffstat (limited to 'client/src/app/core/server/server.service.ts')
-rw-r--r--client/src/app/core/server/server.service.ts45
1 files changed, 33 insertions, 12 deletions
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index fdfbe4c02..a804efd28 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -1,15 +1,16 @@
1import { Observable, of, Subject } from 'rxjs'
1import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators' 2import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 3import { HttpClient } from '@angular/common/http'
3import { Inject, Injectable, LOCALE_ID } from '@angular/core' 4import { Inject, Injectable, LOCALE_ID } from '@angular/core'
4import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage'
5import { Observable, of, Subject } from 'rxjs'
6import { getCompleteLocale, ServerConfig } from '../../../../../shared'
7import { environment } from '../../../environments/environment'
8import { VideoConstant } from '../../../../../shared/models/videos'
9import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
10import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' 5import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
6import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage'
11import { sortBy } from '@app/shared/misc/utils' 7import { sortBy } from '@app/shared/misc/utils'
8import { SearchTargetType } from '@shared/models/search/search-target-query.model'
12import { ServerStats } from '@shared/models/server' 9import { ServerStats } from '@shared/models/server'
10import { getCompleteLocale, ServerConfig } from '../../../../../shared'
11import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
12import { VideoConstant } from '../../../../../shared/models/videos'
13import { environment } from '../../../environments/environment'
13 14
14@Injectable() 15@Injectable()
15export class ServerService { 16export class ServerService {
@@ -47,12 +48,6 @@ export class ServerService {
47 css: '' 48 css: ''
48 } 49 }
49 }, 50 },
50 search: {
51 remoteUri: {
52 users: true,
53 anonymous: false
54 }
55 },
56 plugin: { 51 plugin: {
57 registered: [], 52 registered: [],
58 registeredExternalAuths: [], 53 registeredExternalAuths: [],
@@ -145,6 +140,18 @@ export class ServerService {
145 message: '', 140 message: '',
146 level: 'info', 141 level: 'info',
147 dismissable: false 142 dismissable: false
143 },
144 search: {
145 remoteUri: {
146 users: true,
147 anonymous: false
148 },
149 searchIndex: {
150 enabled: false,
151 url: '',
152 disableLocalSearch: false,
153 isDefaultSearch: false
154 }
148 } 155 }
149 } 156 }
150 157
@@ -264,6 +271,20 @@ export class ServerService {
264 return this.http.get<ServerStats>(ServerService.BASE_STATS_URL) 271 return this.http.get<ServerStats>(ServerService.BASE_STATS_URL)
265 } 272 }
266 273
274 getDefaultSearchTarget (): Promise<SearchTargetType> {
275 return this.getConfig().pipe(
276 map(config => {
277 const searchIndexConfig = config.search.searchIndex
278
279 if (searchIndexConfig.enabled && (searchIndexConfig.isDefaultSearch || searchIndexConfig.disableLocalSearch)) {
280 return 'search-index'
281 }
282
283 return 'local'
284 })
285 ).toPromise()
286 }
287
267 private loadAttributeEnum <T extends string | number> ( 288 private loadAttributeEnum <T extends string | number> (
268 baseUrl: string, 289 baseUrl: string,
269 attributeName: 'categories' | 'licences' | 'languages' | 'privacies', 290 attributeName: 'categories' | 'licences' | 'languages' | 'privacies',