mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-15 12:55:14 +00:00
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Http } from '@angular/http';
|
|
import { FileManagerService } from '../file-manager.service';
|
|
import { DataSource } from '@angular/cdk';
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
@Component({
|
|
selector : 'fuse-file-list',
|
|
templateUrl: './file-list.component.html',
|
|
styleUrls : ['./file-list.component.scss']
|
|
})
|
|
export class FileListComponent implements OnInit
|
|
{
|
|
files: any;
|
|
dataSource: FilesDataSource | null;
|
|
displayedColumns = ['icon', 'name', 'type', 'owner', 'size', 'modified', 'detail-button'];
|
|
selected: any;
|
|
|
|
constructor(private fileManagerService: FileManagerService)
|
|
{
|
|
this.fileManagerService.onFilesChanged.subscribe(files => {
|
|
this.files = files;
|
|
});
|
|
this.fileManagerService.onFileSelected.subscribe(selected => {
|
|
this.selected = selected;
|
|
});
|
|
}
|
|
|
|
ngOnInit()
|
|
{
|
|
this.dataSource = new FilesDataSource(this.fileManagerService);
|
|
}
|
|
|
|
onSelect(selected)
|
|
{
|
|
this.fileManagerService.onFileSelected.next(selected);
|
|
}
|
|
}
|
|
|
|
export class FilesDataSource extends DataSource<any>
|
|
{
|
|
constructor(private fileManagerService: FileManagerService)
|
|
{
|
|
super();
|
|
}
|
|
|
|
/** Connect function called by the table to retrieve one stream containing the data to render. */
|
|
connect(): Observable<any[]>
|
|
{
|
|
return this.fileManagerService.onFilesChanged;
|
|
}
|
|
|
|
disconnect()
|
|
{
|
|
}
|
|
}
|