diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-06 15:36:44 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 830b4faff15fb9c81d88e8e69fcdf94aad32bef8 (patch) | |
tree | 53de6c9e30ce88734b4bdda62016e0498fe78491 /client/src/app/core | |
parent | d4c9f45b31eda0b7a391ddc83eb290ca5cba311f (diff) | |
download | PeerTube-830b4faff15fb9c81d88e8e69fcdf94aad32bef8.tar.gz PeerTube-830b4faff15fb9c81d88e8e69fcdf94aad32bef8.tar.zst PeerTube-830b4faff15fb9c81d88e8e69fcdf94aad32bef8.zip |
Add/update/delete/list my playlists
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/server/server.service.ts | 30 |
1 files changed, 24 insertions, 6 deletions
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 | |||
9 | import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n' | 9 | import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n' |
10 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' | 10 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' |
11 | import { sortBy } from '@app/shared/misc/utils' | 11 | import { sortBy } from '@app/shared/misc/utils' |
12 | import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model' | ||
12 | 13 | ||
13 | @Injectable() | 14 | @Injectable() |
14 | export class ServerService { | 15 | export class ServerService { |
15 | private static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server/' | 16 | private static BASE_SERVER_URL = environment.apiUrl + '/api/v1/server/' |
16 | private static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config/' | 17 | private static BASE_CONFIG_URL = environment.apiUrl + '/api/v1/config/' |
17 | private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' | 18 | private static BASE_VIDEO_URL = environment.apiUrl + '/api/v1/videos/' |
19 | private static BASE_VIDEO_PLAYLIST_URL = environment.apiUrl + '/api/v1/video-playlists/' | ||
18 | private static BASE_LOCALE_URL = environment.apiUrl + '/client/locales/' | 20 | private static BASE_LOCALE_URL = environment.apiUrl + '/client/locales/' |
19 | private static CONFIG_LOCAL_STORAGE_KEY = 'server-config' | 21 | private static CONFIG_LOCAL_STORAGE_KEY = 'server-config' |
20 | 22 | ||
21 | configLoaded = new ReplaySubject<boolean>(1) | 23 | configLoaded = new ReplaySubject<boolean>(1) |
22 | videoPrivaciesLoaded = new ReplaySubject<boolean>(1) | 24 | videoPrivaciesLoaded = new ReplaySubject<boolean>(1) |
25 | videoPlaylistPrivaciesLoaded = new ReplaySubject<boolean>(1) | ||
23 | videoCategoriesLoaded = new ReplaySubject<boolean>(1) | 26 | videoCategoriesLoaded = new ReplaySubject<boolean>(1) |
24 | videoLicencesLoaded = new ReplaySubject<boolean>(1) | 27 | videoLicencesLoaded = new ReplaySubject<boolean>(1) |
25 | videoLanguagesLoaded = new ReplaySubject<boolean>(1) | 28 | videoLanguagesLoaded = new ReplaySubject<boolean>(1) |
@@ -101,6 +104,7 @@ export class ServerService { | |||
101 | private videoLicences: Array<VideoConstant<number>> = [] | 104 | private videoLicences: Array<VideoConstant<number>> = [] |
102 | private videoLanguages: Array<VideoConstant<string>> = [] | 105 | private videoLanguages: Array<VideoConstant<string>> = [] |
103 | private videoPrivacies: Array<VideoConstant<VideoPrivacy>> = [] | 106 | private videoPrivacies: Array<VideoConstant<VideoPrivacy>> = [] |
107 | private videoPlaylistPrivacies: Array<VideoConstant<VideoPlaylistPrivacy>> = [] | ||
104 | 108 | ||
105 | constructor ( | 109 | constructor ( |
106 | private http: HttpClient, | 110 | private http: HttpClient, |
@@ -121,19 +125,28 @@ export class ServerService { | |||
121 | } | 125 | } |
122 | 126 | ||
123 | loadVideoCategories () { | 127 | loadVideoCategories () { |
124 | return this.loadVideoAttributeEnum('categories', this.videoCategories, this.videoCategoriesLoaded, true) | 128 | return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'categories', this.videoCategories, this.videoCategoriesLoaded, true) |
125 | } | 129 | } |
126 | 130 | ||
127 | loadVideoLicences () { | 131 | loadVideoLicences () { |
128 | return this.loadVideoAttributeEnum('licences', this.videoLicences, this.videoLicencesLoaded) | 132 | return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'licences', this.videoLicences, this.videoLicencesLoaded) |
129 | } | 133 | } |
130 | 134 | ||
131 | loadVideoLanguages () { | 135 | loadVideoLanguages () { |
132 | return this.loadVideoAttributeEnum('languages', this.videoLanguages, this.videoLanguagesLoaded, true) | 136 | return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'languages', this.videoLanguages, this.videoLanguagesLoaded, true) |
133 | } | 137 | } |
134 | 138 | ||
135 | loadVideoPrivacies () { | 139 | loadVideoPrivacies () { |
136 | return this.loadVideoAttributeEnum('privacies', this.videoPrivacies, this.videoPrivaciesLoaded) | 140 | return this.loadAttributeEnum(ServerService.BASE_VIDEO_URL, 'privacies', this.videoPrivacies, this.videoPrivaciesLoaded) |
141 | } | ||
142 | |||
143 | loadVideoPlaylistPrivacies () { | ||
144 | return this.loadAttributeEnum( | ||
145 | ServerService.BASE_VIDEO_PLAYLIST_URL, | ||
146 | 'privacies', | ||
147 | this.videoPlaylistPrivacies, | ||
148 | this.videoPlaylistPrivaciesLoaded | ||
149 | ) | ||
137 | } | 150 | } |
138 | 151 | ||
139 | getConfig () { | 152 | getConfig () { |
@@ -156,7 +169,12 @@ export class ServerService { | |||
156 | return this.videoPrivacies | 169 | return this.videoPrivacies |
157 | } | 170 | } |
158 | 171 | ||
159 | private loadVideoAttributeEnum ( | 172 | getVideoPlaylistPrivacies () { |
173 | return this.videoPlaylistPrivacies | ||
174 | } | ||
175 | |||
176 | private loadAttributeEnum ( | ||
177 | baseUrl: string, | ||
160 | attributeName: 'categories' | 'licences' | 'languages' | 'privacies', | 178 | attributeName: 'categories' | 'licences' | 'languages' | 'privacies', |
161 | hashToPopulate: VideoConstant<string | number>[], | 179 | hashToPopulate: VideoConstant<string | number>[], |
162 | notifier: ReplaySubject<boolean>, | 180 | notifier: ReplaySubject<boolean>, |
@@ -165,7 +183,7 @@ export class ServerService { | |||
165 | this.localeObservable | 183 | this.localeObservable |
166 | .pipe( | 184 | .pipe( |
167 | switchMap(translations => { | 185 | switchMap(translations => { |
168 | return this.http.get<{ [id: string]: string }>(ServerService.BASE_VIDEO_URL + attributeName) | 186 | return this.http.get<{ [id: string]: string }>(baseUrl + attributeName) |
169 | .pipe(map(data => ({ data, translations }))) | 187 | .pipe(map(data => ({ data, translations }))) |
170 | }) | 188 | }) |
171 | ) | 189 | ) |