mirror of
https://github.com/syncthing/syncthing.git
synced 2026-02-07 12:44:14 -05:00
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { AfterViewInit, Component, OnInit, ViewChild, Input } from '@angular/core';
|
|
import { MatPaginator } from '@angular/material/paginator';
|
|
import { MatSort } from '@angular/material/sort';
|
|
import { MatTable, MatTableDataSource } from '@angular/material/table';
|
|
|
|
import Folder from '../../folder';
|
|
import { SystemConfigService } from '../../services/system-config.service';
|
|
|
|
@Component({
|
|
selector: 'app-folder-list',
|
|
templateUrl: './folder-list.component.html',
|
|
styleUrls: ['./folder-list.component.scss']
|
|
})
|
|
export class FolderListComponent implements AfterViewInit, OnInit {
|
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
|
@ViewChild(MatSort) sort: MatSort;
|
|
@ViewChild(MatTable) table: MatTable<Folder>;
|
|
dataSource: MatTableDataSource<Folder>;
|
|
|
|
applyFilter(event: Event) {
|
|
const filterValue = (event.target as HTMLInputElement).value;
|
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
|
}
|
|
|
|
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
|
displayedColumns = ['id', 'label', 'path', 'state'];
|
|
|
|
constructor(private systemConfigService: SystemConfigService) { };
|
|
|
|
ngOnInit() {
|
|
this.dataSource = new MatTableDataSource();
|
|
this.dataSource.data = [];
|
|
|
|
this.systemConfigService.getFolders().subscribe(
|
|
data => {
|
|
this.dataSource.data = data;
|
|
}
|
|
);
|
|
}
|
|
|
|
ngAfterViewInit() {
|
|
this.dataSource.sort = this.sort;
|
|
this.dataSource.paginator = this.paginator;
|
|
this.table.dataSource = this.dataSource;
|
|
}
|
|
} |