From 830b4faff15fb9c81d88e8e69fcdf94aad32bef8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Mar 2019 15:36:44 +0100 Subject: Add/update/delete/list my playlists --- client/src/app/core/server/server.service.ts | 30 ++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'client/src/app/core/server/server.service.ts') diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 10acf6e72..acaca8a01 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -9,17 +9,20 @@ 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' @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) @@ -101,6 +104,7 @@ export class ServerService { private videoLicences: Array> = [] private videoLanguages: Array> = [] private videoPrivacies: Array> = [] + private videoPlaylistPrivacies: Array> = [] constructor ( private http: HttpClient, @@ -121,19 +125,28 @@ 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 () { @@ -156,7 +169,12 @@ export class ServerService { return this.videoPrivacies } - private loadVideoAttributeEnum ( + getVideoPlaylistPrivacies () { + return this.videoPlaylistPrivacies + } + + private loadAttributeEnum ( + baseUrl: string, attributeName: 'categories' | 'licences' | 'languages' | 'privacies', hashToPopulate: VideoConstant[], notifier: ReplaySubject, @@ -165,7 +183,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 }))) }) ) -- cgit v1.2.3