]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/plugins/plugin.service.ts
Merge remote-tracking branch 'weblate/develop' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / core / plugins / plugin.service.ts
index c2dcf9fefd26d62e77ed6abd241e0d5945c1527b..6a1a46e73c875dfa625aefd9a2f153dd8a3677a7 100644 (file)
@@ -19,6 +19,7 @@ import {
   PluginTranslation,
   PluginType,
   PublicServerSetting,
+  RegisterClientSettingsScript,
   ServerConfigPlugin
 } from '@shared/models'
 import { environment } from '../../../environments/environment'
@@ -33,6 +34,7 @@ export class PluginService implements ClientHook {
 
   pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
     common: new ReplaySubject<boolean>(1),
+    'admin-plugin': new ReplaySubject<boolean>(1),
     search: new ReplaySubject<boolean>(1),
     'video-watch': new ReplaySubject<boolean>(1),
     signup: new ReplaySubject<boolean>(1),
@@ -58,6 +60,7 @@ export class PluginService implements ClientHook {
   private formFields: FormFields = {
     video: []
   }
+  private settingsScripts: { [ npmName: string ]: RegisterClientSettingsScript } = {}
 
   constructor (
     private authService: AuthService,
@@ -200,6 +203,10 @@ export class PluginService implements ClientHook {
     return this.formFields.video.filter(f => f.videoFormOptions.type === type)
   }
 
+  getRegisteredSettingsScript (npmName: string) {
+    return this.settingsScripts[npmName]
+  }
+
   translateBy (npmName: string, toTranslate: string) {
     const helpers = this.helpers[npmName]
     if (!helpers) {
@@ -220,6 +227,7 @@ export class PluginService implements ClientHook {
       return loadPlugin({
         hooks: this.hooks,
         formFields: this.formFields,
+        onSettingsScripts: options => this.settingsScripts[npmName] = options,
         pluginInfo,
         peertubeHelpersFactory: () => helpers
       })
@@ -263,6 +271,13 @@ export class PluginService implements ClientHook {
         return this.authService.isLoggedIn()
       },
 
+      getAuthHeader: () => {
+        if (!this.authService.isLoggedIn()) return undefined
+
+        const value = this.authService.getRequestHeaderValue()
+        return { 'Authorization': value }
+      },
+
       notifier: {
         info: (text: string, title?: string, timeout?: number) => this.notifier.info(text, title, timeout),
         error: (text: string, title?: string, timeout?: number) => this.notifier.error(text, title, timeout),