aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/server/server.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/server/server.service.ts')
-rw-r--r--client/src/app/core/server/server.service.ts180
1 files changed, 20 insertions, 160 deletions
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index 6918957f4..251963858 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -4,7 +4,7 @@ import { HttpClient } from '@angular/common/http'
4import { Inject, Injectable, LOCALE_ID } from '@angular/core' 4import { Inject, Injectable, LOCALE_ID } from '@angular/core'
5import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' 5import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers'
6import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' 6import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n'
7import { SearchTargetType, ServerConfig, ServerStats, VideoConstant } from '@shared/models' 7import { HTMLServerConfig, SearchTargetType, ServerConfig, ServerStats, VideoConstant } from '@shared/models'
8import { environment } from '../../../environments/environment' 8import { environment } from '../../../environments/environment'
9 9
10@Injectable() 10@Injectable()
@@ -28,163 +28,26 @@ export class ServerService {
28 private configReset = false 28 private configReset = false
29 29
30 private configLoaded = false 30 private configLoaded = false
31 private config: ServerConfig = { 31 private config: ServerConfig
32 instance: { 32 private htmlConfig: HTMLServerConfig
33 name: 'PeerTube',
34 shortDescription: 'PeerTube, a federated (ActivityPub) video streaming platform ' +
35 'using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.',
36 isNSFW: false,
37 defaultNSFWPolicy: 'do_not_list' as 'do_not_list',
38 defaultClientRoute: '',
39 customizations: {
40 javascript: '',
41 css: ''
42 }
43 },
44 plugin: {
45 registered: [],
46 registeredExternalAuths: [],
47 registeredIdAndPassAuths: []
48 },
49 theme: {
50 registered: [],
51 default: 'default'
52 },
53 email: {
54 enabled: false
55 },
56 contactForm: {
57 enabled: false
58 },
59 serverVersion: 'Unknown',
60 signup: {
61 allowed: false,
62 allowedForCurrentIP: false,
63 requiresEmailVerification: false,
64 minimumAge: 16
65 },
66 transcoding: {
67 profile: 'default',
68 availableProfiles: [ 'default' ],
69 enabledResolutions: [],
70 hls: {
71 enabled: false
72 },
73 webtorrent: {
74 enabled: true
75 }
76 },
77 live: {
78 enabled: false,
79 allowReplay: true,
80 maxDuration: null,
81 maxInstanceLives: -1,
82 maxUserLives: -1,
83 transcoding: {
84 enabled: false,
85 profile: 'default',
86 availableProfiles: [ 'default' ],
87 enabledResolutions: []
88 },
89 rtmp: {
90 port: 1935
91 }
92 },
93 avatar: {
94 file: {
95 size: { max: 0 },
96 extensions: []
97 }
98 },
99 banner: {
100 file: {
101 size: { max: 0 },
102 extensions: []
103 }
104 },
105 video: {
106 image: {
107 size: { max: 0 },
108 extensions: []
109 },
110 file: {
111 extensions: []
112 }
113 },
114 videoCaption: {
115 file: {
116 size: { max: 0 },
117 extensions: []
118 }
119 },
120 user: {
121 videoQuota: -1,
122 videoQuotaDaily: -1
123 },
124 import: {
125 videos: {
126 http: {
127 enabled: false
128 },
129 torrent: {
130 enabled: false
131 }
132 }
133 },
134 trending: {
135 videos: {
136 intervalDays: 0,
137 algorithms: {
138 enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ],
139 default: 'most-viewed'
140 }
141 }
142 },
143 autoBlacklist: {
144 videos: {
145 ofUsers: {
146 enabled: false
147 }
148 }
149 },
150 tracker: {
151 enabled: true
152 },
153 followings: {
154 instance: {
155 autoFollowIndex: {
156 indexUrl: 'https://instances.joinpeertube.org'
157 }
158 }
159 },
160 broadcastMessage: {
161 enabled: false,
162 message: '',
163 level: 'info',
164 dismissable: false
165 },
166 search: {
167 remoteUri: {
168 users: true,
169 anonymous: false
170 },
171 searchIndex: {
172 enabled: false,
173 url: '',
174 disableLocalSearch: false,
175 isDefaultSearch: false
176 }
177 },
178 homepage: {
179 enabled: false
180 }
181 }
182 33
183 constructor ( 34 constructor (
184 private http: HttpClient, 35 private http: HttpClient,
185 @Inject(LOCALE_ID) private localeId: string 36 @Inject(LOCALE_ID) private localeId: string
186 ) { 37 ) {
187 this.loadConfigLocally() 38 }
39
40 loadConfig () {
41 try {
42 return this.loadConfigLocally()
43 } catch (err) {
44 // Expected in dev mode since we can't inject the config in the HTML
45 if (environment.production !== false) {
46 console.error('Cannot load config locally. Fallback to API.')
47 }
48
49 return this.getConfig()
50 }
188 } 51 }
189 52
190 getServerVersionAndCommit () { 53 getServerVersionAndCommit () {
@@ -343,13 +206,10 @@ export class ServerService {
343 206
344 private loadConfigLocally () { 207 private loadConfigLocally () {
345 const configString = window['PeerTubeServerConfig'] 208 const configString = window['PeerTubeServerConfig']
346 if (!configString) return 209 if (!configString) {
347 210 throw new Error('Could not find PeerTubeServerConfig in HTML')
348 try {
349 const parsed = JSON.parse(configString)
350 Object.assign(this.config, parsed)
351 } catch (err) {
352 console.error('Cannot parse config saved in from index.html.', err)
353 } 211 }
212
213 this.config = JSON.parse(configString)
354 } 214 }
355} 215}