file upload fix

This commit is contained in:
Benjamin Ifland
2019-03-27 17:12:27 +01:00
parent a109f790e9
commit 06ef90fce4
5 changed files with 26 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ import { MatChipsModule } from '@angular/material/chips';
import { MatRadioModule } from '@angular/material/radio'; import { MatRadioModule } from '@angular/material/radio';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { MatTooltipModule } from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { TableComponent } from './components/songs/table/table.component'; import { TableComponent } from './components/songs/table/table.component';
import { SongsComponent } from './components/songs/songs.component'; import { SongsComponent } from './components/songs/songs.component';
@@ -43,7 +44,6 @@ import { FileUploadModule } from 'ng2-file-upload';
BrowserAnimationsModule, BrowserAnimationsModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
AppRoutingModule,
HttpClientModule, HttpClientModule,
ODataModule, ODataModule,
@@ -55,9 +55,11 @@ import { FileUploadModule } from 'ng2-file-upload';
MatRadioModule, MatRadioModule,
MatSelectModule, MatSelectModule,
MatTooltipModule, MatTooltipModule,
MatProgressBarModule,
FontAwesomeModule, FontAwesomeModule,
FileUploadModule, FileUploadModule,
AppRoutingModule,
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]

View File

@@ -4,22 +4,24 @@
<table mat-table [dataSource]="song.Files" class="mat-elevation-z8"> <table mat-table [dataSource]="song.Files" class="mat-elevation-z8">
<ng-container matColumnDef="name"> <ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> <th mat-header-cell *matHeaderCellDef>
<div
[uploader]="newFileUploader"
(fileOver)="onFileOverNew($event)"
[class.file-over]="fileOverNew"
>
Angehängte Dateien Angehängte Dateien
</div>
</th> </th>
<td mat-cell *matCellDef="let element">{{ element.Name }}</td> <td mat-cell *matCellDef="let element">{{ element.Name }}</td>
</ng-container> </ng-container>
<ng-container matColumnDef="action"> <ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef> <th mat-header-cell *matHeaderCellDef>
<input
type="file"
ng2FileSelect
[uploader]="newFileUploader"
multiple
style="display:none"
#newFileUploaderRef
/>
<button <button
mat-icon-button mat-icon-button
(click)="onClickNew()" (click)="newFileUploaderRef.click()"
matTooltip="neue Datei hochladen" matTooltip="neue Datei hochladen"
matTooltipPosition="left" matTooltipPosition="left"
> >
@@ -38,7 +40,14 @@
</td> </td>
</ng-container> </ng-container>
<tr mat-header-row *matHeaderRowDef="columns"></tr> <tr
mat-header-row
*matHeaderRowDef="columns"
ng2FileDrop
[uploader]="newFileUploader"
(fileOver)="onFileOverNew($event)"
[class.file-over]="fileOverNew"
></tr>
<tr mat-row *matRowDef="let row; columns: columns"></tr> <tr mat-row *matRowDef="let row; columns: columns"></tr>
</table> </table>
</mat-card-content> </mat-card-content>

View File

@@ -32,6 +32,8 @@ export class SongFilesComponent {
this.selectedSongId = _.ID; this.selectedSongId = _.ID;
this.song = _; this.song = _;
this.newFileUploader = this.fileuploadFactory.provideForNewFiles(_.ID); this.newFileUploader = this.fileuploadFactory.provideForNewFiles(_.ID);
this.newFileUploader.onCompleteItem = () => songService.selectSong(_.ID);
this.newFileUploader.onProgressItem = () => change.markForCheck;
} else { } else {
this.selectedSongId = 0; this.selectedSongId = 0;
this.song = null; this.song = null;
@@ -41,7 +43,6 @@ export class SongFilesComponent {
}); });
} }
public onClickNew(): void {}
public onClickDownload(id: number): void {} public onClickDownload(id: number): void {}
public onFileOverNew(hover: boolean) { public onFileOverNew(hover: boolean) {
this.fileOverNew = hover; this.fileOverNew = hover;

View File

@@ -1,5 +1,5 @@
<app-table></app-table> <app-table></app-table>
<app-song [@blend] *ngIf="songsService.state === State.read"></app-song>
<app-song-files [@blend] *ngIf="songsService.state === State.read"></app-song-files>
<app-song-edit [@blend] *ngIf="songsService.state === State.edit"></app-song-edit> <app-song-edit [@blend] *ngIf="songsService.state === State.edit"></app-song-edit>
<app-song-new [@blend] *ngIf="songsService.state === State.new"></app-song-new> <app-song-new [@blend] *ngIf="songsService.state === State.new"></app-song-new>
<app-song [@blend] *ngIf="songsService.state === State.read"></app-song>
<app-song-files [@blend] *ngIf="songsService.state === State.read"></app-song-files>

View File

@@ -10,7 +10,7 @@ html {
} }
.page-container { .page-container {
position: absolute; position: fixed;
top: 20px; top: 20px;
left: 20px; left: 20px;
bottom: 20px; bottom: 20px;