init uploader

This commit is contained in:
Benjamin Ifland
2019-03-27 15:53:02 +01:00
parent 02d395b480
commit a109f790e9
7 changed files with 612 additions and 610 deletions

View File

@@ -3,7 +3,15 @@
<mat-card-content>
<table mat-table [dataSource]="song.Files" class="mat-elevation-z8">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef>Angehängte Dateien</th>
<th mat-header-cell *matHeaderCellDef>
<div
[uploader]="newFileUploader"
(fileOver)="onFileOverNew($event)"
[class.file-over]="fileOverNew"
>
Angehängte Dateien
</div>
</th>
<td mat-cell *matCellDef="let element">{{ element.Name }}</td>
</ng-container>

View File

@@ -9,3 +9,7 @@ button {
color: #000;
}
}
tr.file-over {
background: #f908;
}

View File

@@ -3,6 +3,8 @@ import { Song } from 'src/app/models/song.model';
import { SongsService } from 'src/app/data/songs.service';
import { DownloadService } from 'src/app/data/download.service';
import { faFileUpload, faDownload } from '@fortawesome/free-solid-svg-icons';
import { FileuploadFactory } from 'src/app/services/fileupload.factory';
import { FileUploader } from 'ng2-file-upload';
@Component({
selector: 'app-song-files',
@@ -15,9 +17,13 @@ export class SongFilesComponent {
public faFileUpload = faFileUpload;
public faDownload = faDownload;
public columns = ['name', 'action'];
public newFileUploader: FileUploader;
public fileOverNew = false;
constructor(
private downloadService: DownloadService,
private fileuploadFactory: FileuploadFactory,
songService: SongsService,
change: ChangeDetectorRef
) {
@@ -25,9 +31,11 @@ export class SongFilesComponent {
if (_) {
this.selectedSongId = _.ID;
this.song = _;
this.newFileUploader = this.fileuploadFactory.provideForNewFiles(_.ID);
} else {
this.selectedSongId = 0;
this.song = null;
this.newFileUploader = null;
}
change.markForCheck();
});
@@ -35,4 +43,7 @@ export class SongFilesComponent {
public onClickNew(): void {}
public onClickDownload(id: number): void {}
public onFileOverNew(hover: boolean) {
this.fileOverNew = hover;
}
}