]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/rest/rest-table.ts
Fix rowsPerPage change, add filter clear button, update video-abuse-list search query...
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / rest / rest-table.ts
index 891fb7b2b3cc179d00a1f7465ce1bb7bfbdd6d90..d4e6cf5f2c877b78701895429f2f06098860f3d1 100644 (file)
@@ -13,6 +13,7 @@ export abstract class RestTable {
   search: string
   rowsPerPageOptions = [ 10, 20, 50, 100 ]
   rowsPerPage = this.rowsPerPageOptions[0]
+  expandedRows = {}
 
   private searchStream: Subject<string>
 
@@ -73,6 +74,29 @@ export abstract class RestTable {
     this.searchStream.next(target.value)
   }
 
+  onPage (event: { first: number, rows: number }) {
+    if (this.rowsPerPage !== event.rows) {
+      this.rowsPerPage = event.rows
+      this.pagination = {
+        start: event.first,
+        count: this.rowsPerPage
+      }
+      this.loadData()
+    }
+    this.expandedRows = {}
+  }
+
+  setTableFilter (filter: string) {
+    // FIXME: cannot use ViewChild, so create a component for the filter input
+    const filterInput = document.getElementById('table-filter') as HTMLInputElement
+    if (filterInput) filterInput.value = filter
+  }
+
+  resetSearch () {
+    this.searchStream.next('')
+    this.setTableFilter('')
+  }
+
   protected abstract loadData (): void
 
   private getSortLocalStorageKey () {