X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fserver%2Fserver.service.ts;h=cf9c411a4fe7ead08f3544256f67d4e0cccc8247;hb=88a7f93f8e5666f44121a2e3cf9d33d74c472aa7;hp=10acf6e72d4a4723488a1586779745768c047588;hpb=f8802489bbc2c0363b5668e47de7c35f573342e1;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 10acf6e72..cf9c411a4 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -1,7 +1,7 @@ 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 { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' import { Observable, of, ReplaySubject } from 'rxjs' import { getCompleteLocale, ServerConfig } from '../../../../../shared' import { environment } from '../../../environments/environment' @@ -9,17 +9,21 @@ 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' +import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model' +import { cloneDeep } from 'lodash-es' @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_VIDEO_PLAYLIST_URL = environment.apiUrl + '/api/v1/video-playlists/' private static BASE_LOCALE_URL = environment.apiUrl + '/client/locales/' private static CONFIG_LOCAL_STORAGE_KEY = 'server-config' configLoaded = new ReplaySubject(1) videoPrivaciesLoaded = new ReplaySubject(1) + videoPlaylistPrivaciesLoaded = new ReplaySubject(1) videoCategoriesLoaded = new ReplaySubject(1) videoLicencesLoaded = new ReplaySubject(1) videoLanguagesLoaded = new ReplaySubject(1) @@ -38,6 +42,13 @@ export class ServerService { css: '' } }, + plugin: { + registered: [] + }, + theme: { + registered: [], + default: 'default' + }, email: { enabled: false }, @@ -54,6 +65,9 @@ export class ServerService { enabledResolutions: [], hls: { enabled: false + }, + webtorrent: { + enabled: true } }, avatar: { @@ -95,12 +109,23 @@ export class ServerService { videos: { intervalDays: 0 } + }, + autoBlacklist: { + videos: { + ofUsers: { + enabled: false + } + } + }, + tracker: { + enabled: true } } private videoCategories: Array> = [] private videoLicences: Array> = [] private videoLanguages: Array> = [] private videoPrivacies: Array> = [] + private videoPlaylistPrivacies: Array> = [] constructor ( private http: HttpClient, @@ -121,42 +146,56 @@ export class ServerService { } loadVideoCategories () { - return this.loadVideoAttributeEnum('categories', this.videoCategories, this.videoCategoriesLoaded, true) + return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'categories', this.videoCategories, this.videoCategoriesLoaded, true) } loadVideoLicences () { - return this.loadVideoAttributeEnum('licences', this.videoLicences, this.videoLicencesLoaded) + return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'licences', this.videoLicences, this.videoLicencesLoaded) } loadVideoLanguages () { - return this.loadVideoAttributeEnum('languages', this.videoLanguages, this.videoLanguagesLoaded, true) + return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'languages', this.videoLanguages, this.videoLanguagesLoaded, true) } loadVideoPrivacies () { - return this.loadVideoAttributeEnum('privacies', this.videoPrivacies, this.videoPrivaciesLoaded) + return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'privacies', this.videoPrivacies, this.videoPrivaciesLoaded) + } + + loadVideoPlaylistPrivacies () { + return this.loadAttributeEnum( + ServerService.BASE_VIDEO_PLAYLIST_URL, + 'privacies', + this.videoPlaylistPrivacies, + this.videoPlaylistPrivaciesLoaded + ) } getConfig () { - return this.config + return cloneDeep(this.config) } getVideoCategories () { - return this.videoCategories + return cloneDeep(this.videoCategories) } getVideoLicences () { - return this.videoLicences + return cloneDeep(this.videoLicences) } getVideoLanguages () { - return this.videoLanguages + return cloneDeep(this.videoLanguages) } getVideoPrivacies () { - return this.videoPrivacies + return cloneDeep(this.videoPrivacies) + } + + getVideoPlaylistPrivacies () { + return cloneDeep(this.videoPlaylistPrivacies) } - private loadVideoAttributeEnum ( + private loadAttributeEnum ( + baseUrl: string, attributeName: 'categories' | 'licences' | 'languages' | 'privacies', hashToPopulate: VideoConstant[], notifier: ReplaySubject, @@ -165,7 +204,7 @@ export class ServerService { this.localeObservable .pipe( switchMap(translations => { - return this.http.get<{ [id: string]: string }>(ServerService.BASE_VIDEO_URL + attributeName) + return this.http.get<{ [id: string]: string }>(baseUrl + attributeName) .pipe(map(data => ({ data, translations }))) }) )