diff options
Diffstat (limited to 'client/src/app/core/server/server.service.ts')
-rw-r--r-- | client/src/app/core/server/server.service.ts | 45 |
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 @@ | |||
1 | import { Observable, of, Subject } from 'rxjs' | ||
1 | import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators' | 2 | import { first, map, share, shareReplay, switchMap, tap } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 3 | import { HttpClient } from '@angular/common/http' |
3 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
4 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' | ||
5 | import { Observable, of, Subject } from 'rxjs' | ||
6 | import { getCompleteLocale, ServerConfig } from '../../../../../shared' | ||
7 | import { environment } from '../../../environments/environment' | ||
8 | import { VideoConstant } from '../../../../../shared/models/videos' | ||
9 | import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n' | ||
10 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' | 5 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' |
6 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' | ||
11 | import { sortBy } from '@app/shared/misc/utils' | 7 | import { sortBy } from '@app/shared/misc/utils' |
8 | import { SearchTargetType } from '@shared/models/search/search-target-query.model' | ||
12 | import { ServerStats } from '@shared/models/server' | 9 | import { ServerStats } from '@shared/models/server' |
10 | import { getCompleteLocale, ServerConfig } from '../../../../../shared' | ||
11 | import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n' | ||
12 | import { VideoConstant } from '../../../../../shared/models/videos' | ||
13 | import { environment } from '../../../environments/environment' | ||
13 | 14 | ||
14 | @Injectable() | 15 | @Injectable() |
15 | export class ServerService { | 16 | export 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', |