-import { map, share, switchMap, tap } from 'rxjs/operators'
+import { map, shareReplay, switchMap, tap } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Inject, Injectable, LOCALE_ID } from '@angular/core'
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
import { getCompleteLocale, ServerConfig } from '../../../../../shared'
import { About } from '../../../../../shared/models/server/about.model'
import { environment } from '../../../environments/environment'
-import { VideoConstant } from '../../../../../shared/models/videos'
-import { isDefaultLocale } from '../../../../../shared/models/i18n'
-import { getDevLocale, isOnDevLocale, peertubeTranslate } from '@app/shared/i18n/i18n-utils'
+import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
+import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
+import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
import { sortBy } from '@app/shared/misc/utils'
@Injectable()
export class ServerService {
+ private static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server/'
private static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config/'
private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/'
private static BASE_LOCALE_URL = environment.apiUrl + '/client/locales/'
css: ''
}
},
+ email: {
+ enabled: false
+ },
+ contactForm: {
+ enabled: false
+ },
serverVersion: 'Unknown',
signup: {
allowed: false,
- allowedForCurrentIP: false
+ allowedForCurrentIP: false,
+ requiresEmailVerification: false
},
transcoding: {
- enabledResolutions: []
+ enabledResolutions: [],
+ hls: {
+ enabled: false
+ }
},
avatar: {
file: {
}
},
user: {
- videoQuota: -1
+ videoQuota: -1,
+ videoQuotaDaily: -1
},
import: {
videos: {
enabled: false
}
}
+ },
+ trending: {
+ videos: {
+ intervalDays: 0
+ }
}
}
- private videoCategories: Array<VideoConstant<string>> = []
- private videoLicences: Array<VideoConstant<string>> = []
+ private videoCategories: Array<VideoConstant<number>> = []
+ private videoLicences: Array<VideoConstant<number>> = []
private videoLanguages: Array<VideoConstant<string>> = []
- private videoPrivacies: Array<VideoConstant<string>> = []
+ private videoPrivacies: Array<VideoConstant<VideoPrivacy>> = []
constructor (
private http: HttpClient,
return this.videoPrivacies
}
- getAbout () {
- return this.http.get<About>(ServerService.BASE_CONFIG_URL + '/about')
- }
-
private loadVideoAttributeEnum (
attributeName: 'categories' | 'licences' | 'languages' | 'privacies',
- hashToPopulate: VideoConstant<string>[],
+ hashToPopulate: VideoConstant<string | number>[],
notifier: ReplaySubject<boolean>,
sort = false
) {
this.localeObservable
.pipe(
switchMap(translations => {
- return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
+ return this.http.get<{ [id: string]: string }>(ServerService.BASE_VIDEO_URL + attributeName)
.pipe(map(data => ({ data, translations })))
})
)
const label = data[ dataKey ]
hashToPopulate.push({
- id: dataKey,
+ id: attributeName === 'languages' ? dataKey : parseInt(dataKey, 10),
label: peertubeTranslate(label, translations)
})
})
// Default locale, nothing to translate
if (isDefaultLocale(completeLocale)) {
- this.localeObservable = of({}).pipe(share())
+ this.localeObservable = of({}).pipe(shareReplay())
return
}
this.localeObservable = this.http
.get(ServerService.BASE_LOCALE_URL + completeLocale + '/server.json')
- .pipe(share())
+ .pipe(shareReplay())
}
private saveConfigLocally (config: ServerConfig) {