X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fserver%2Fserver.service.ts;h=c868ccdcc26abc8e6a746234398fa6bab5339ed4;hb=092092969633bbcf6d4891a083ea497a7d5c3154;hp=52b50cbe8a851346bff4d4407a8486b1ebbf1094;hpb=a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 52b50cbe8..c868ccdcc 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -1,4 +1,4 @@ -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' @@ -6,13 +6,14 @@ import { Observable, of, ReplaySubject } from 'rxjs' 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/' @@ -37,13 +38,23 @@ export class ServerService { 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: { @@ -67,7 +78,8 @@ export class ServerService { } }, user: { - videoQuota: -1 + videoQuota: -1, + videoQuotaDaily: -1 }, import: { videos: { @@ -78,12 +90,17 @@ export class ServerService { enabled: false } } + }, + trending: { + videos: { + intervalDays: 0 + } } } - private videoCategories: Array> = [] - private videoLicences: Array> = [] + private videoCategories: Array> = [] + private videoLicences: Array> = [] private videoLanguages: Array> = [] - private videoPrivacies: Array> = [] + private videoPrivacies: Array> = [] constructor ( private http: HttpClient, @@ -139,20 +156,16 @@ export class ServerService { return this.videoPrivacies } - getAbout () { - return this.http.get(ServerService.BASE_CONFIG_URL + '/about') - } - private loadVideoAttributeEnum ( attributeName: 'categories' | 'licences' | 'languages' | 'privacies', - hashToPopulate: VideoConstant[], + hashToPopulate: VideoConstant[], notifier: ReplaySubject, 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 }))) }) ) @@ -162,7 +175,7 @@ export class ServerService { const label = data[ dataKey ] hashToPopulate.push({ - id: dataKey, + id: attributeName === 'languages' ? dataKey : parseInt(dataKey, 10), label: peertubeTranslate(label, translations) }) }) @@ -178,13 +191,13 @@ export class ServerService { // 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) {