]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / plugins / plugin-search / plugin-search.component.ts
index 935e113620dea24b101a92cc5b18579bd6cfb418..dc59e759b5adf323ab264d2e7074718d6e24d551 100644 (file)
@@ -1,5 +1,5 @@
 import { Component, OnInit } from '@angular/core'
-import { Notifier } from '@app/core'
+import { Notifier, ServerService } from '@app/core'
 import { ConfirmService } from '../../../core'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { PluginType } from '@shared/models/plugins/plugin.type'
@@ -25,7 +25,8 @@ export class PluginSearchComponent implements OnInit {
 
   pagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 10
+    itemsPerPage: 10,
+    totalItems: null
   }
   sort = '-popularity'
 
@@ -34,10 +35,14 @@ export class PluginSearchComponent implements OnInit {
 
   plugins: PeerTubePluginIndex[] = []
   installing: { [name: string]: boolean } = {}
+  pluginInstalled = false
+
+  onDataSubject = new Subject<any[]>()
 
   private searchSubject = new Subject<string>()
 
   constructor (
+    private server: ServerService,
     private i18n: I18n,
     private pluginService: PluginApiService,
     private notifier: Notifier,
@@ -65,8 +70,10 @@ export class PluginSearchComponent implements OnInit {
     this.reloadPlugins()
   }
 
-  onSearchChange (search: string) {
-    this.searchSubject.next(search)
+  onSearchChange (event: Event) {
+    const target = event.target as HTMLInputElement
+
+    this.searchSubject.next(target.value)
   }
 
   reloadPlugins () {
@@ -88,9 +95,16 @@ export class PluginSearchComponent implements OnInit {
 
             this.plugins = this.plugins.concat(res.data)
             this.pagination.totalItems = res.total
+
+            this.onDataSubject.next(res.data)
           },
 
-          err => this.notifier.error(err.message)
+          err => {
+            console.error(err)
+
+            const message = this.i18n('The plugin index is not available. Please retry later.')
+            this.notifier.error(message)
+          }
         )
   }
 
@@ -121,6 +135,7 @@ export class PluginSearchComponent implements OnInit {
         .subscribe(
           () => {
             this.installing[plugin.npmName] = false
+            this.pluginInstalled = true
 
             this.notifier.success(this.i18n('{{pluginName}} installed.', { pluginName: plugin.name }))