file delete
This commit is contained in:
@@ -36,15 +36,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</th>
|
</th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<td mat-cell *matCellDef="let element">
|
||||||
<button
|
|
||||||
mat-icon-button
|
|
||||||
(click)="onClickDownload(element.ID, element.Name)"
|
|
||||||
matTooltip="Datei herunterladen"
|
|
||||||
matTooltipPosition="left"
|
|
||||||
*ngIf="fileEditId !== element.ID"
|
|
||||||
>
|
|
||||||
<fa-icon [icon]="faDownload"></fa-icon>
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(click)="onClickEdit(element.ID)"
|
(click)="onClickEdit(element.ID)"
|
||||||
@@ -54,6 +45,15 @@
|
|||||||
>
|
>
|
||||||
<fa-icon [icon]="faEdit"></fa-icon>
|
<fa-icon [icon]="faEdit"></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
mat-icon-button
|
||||||
|
(click)="onClickDownload(element.ID, element.Name)"
|
||||||
|
matTooltip="Datei herunterladen"
|
||||||
|
matTooltipPosition="left"
|
||||||
|
*ngIf="fileEditId !== element.ID"
|
||||||
|
>
|
||||||
|
<fa-icon [icon]="faDownload"></fa-icon>
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
matTooltip="Zurück zur Tabelle"
|
matTooltip="Zurück zur Tabelle"
|
||||||
@@ -63,6 +63,15 @@
|
|||||||
>
|
>
|
||||||
<fa-icon [icon]="faArrow"></fa-icon>
|
<fa-icon [icon]="faArrow"></fa-icon>
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
mat-icon-button
|
||||||
|
matTooltip="Anhang löschen"
|
||||||
|
matTooltipPosition="left"
|
||||||
|
(click)="onClickDelete(element.ID)"
|
||||||
|
*ngIf="fileEditId === element.ID"
|
||||||
|
>
|
||||||
|
<fa-icon [icon]="faTrash"></fa-icon>
|
||||||
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
||||||
import { Song } from 'src/app/models/song.model';
|
import { Song } from 'src/app/models/song.model';
|
||||||
import { SongsService } from 'src/app/data/songs.service';
|
import { SongsService } from 'src/app/data/songs.service';
|
||||||
import { DownloadService } from 'src/app/data/download.service';
|
import { DownloadService } from 'src/app/data/download.service';
|
||||||
import { faFileUpload, faDownload, faEdit, faLongArrowAltLeft } from '@fortawesome/free-solid-svg-icons';
|
import {
|
||||||
|
faFileUpload,
|
||||||
|
faDownload,
|
||||||
|
faEdit,
|
||||||
|
faLongArrowAltLeft,
|
||||||
|
faTrash
|
||||||
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FileuploadFactory } from 'src/app/services/fileupload.factory';
|
import { FileuploadFactory } from 'src/app/services/fileupload.factory';
|
||||||
import { FileUploader } from 'ng2-file-upload';
|
import { FileUploader } from 'ng2-file-upload';
|
||||||
|
|
||||||
@@ -15,6 +22,7 @@ export class SongFilesComponent {
|
|||||||
public song: Song;
|
public song: Song;
|
||||||
public selectedSongId = 0;
|
public selectedSongId = 0;
|
||||||
public faFileUpload = faFileUpload;
|
public faFileUpload = faFileUpload;
|
||||||
|
public faTrash = faTrash;
|
||||||
public faArrow = faLongArrowAltLeft;
|
public faArrow = faLongArrowAltLeft;
|
||||||
public faDownload = faDownload;
|
public faDownload = faDownload;
|
||||||
public faEdit = faEdit;
|
public faEdit = faEdit;
|
||||||
@@ -27,7 +35,7 @@ export class SongFilesComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private downloadService: DownloadService,
|
private downloadService: DownloadService,
|
||||||
private fileuploadFactory: FileuploadFactory,
|
private fileuploadFactory: FileuploadFactory,
|
||||||
songService: SongsService,
|
private songService: SongsService,
|
||||||
change: ChangeDetectorRef
|
change: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
songService.selectedSong.subscribe(_ => {
|
songService.selectedSong.subscribe(_ => {
|
||||||
@@ -35,7 +43,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).subscribe();
|
this.newFileUploader.onCompleteItem = () =>
|
||||||
|
songService.selectSong(_.ID).subscribe();
|
||||||
this.newFileUploader.onProgressItem = () => change.markForCheck;
|
this.newFileUploader.onProgressItem = () => change.markForCheck;
|
||||||
} else {
|
} else {
|
||||||
this.selectedSongId = 0;
|
this.selectedSongId = 0;
|
||||||
@@ -49,11 +58,17 @@ export class SongFilesComponent {
|
|||||||
public onClickDownload(fileId: number, filename): void {
|
public onClickDownload(fileId: number, filename): void {
|
||||||
this.downloadService.get(this.selectedSongId, fileId, filename);
|
this.downloadService.get(this.selectedSongId, fileId, filename);
|
||||||
}
|
}
|
||||||
public onFileOverNew(hover: boolean) {
|
public onFileOverNew(hover: boolean): void {
|
||||||
this.fileOverNew = hover;
|
this.fileOverNew = hover;
|
||||||
}
|
}
|
||||||
public onClickEdit(fileId: number) {
|
public onClickEdit(fileId: number): void {
|
||||||
this.fileEditId = fileId;
|
this.fileEditId = fileId;
|
||||||
}
|
}
|
||||||
|
public onClickDelete(fileId: number): void {
|
||||||
|
const songId = this.song.ID;
|
||||||
|
this.songService
|
||||||
|
.deleteFile$(songId, fileId)
|
||||||
|
.pipe(switchMap(() => this.songService.selectSong(songId)))
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,4 +106,19 @@ export class SongsService extends OdataService {
|
|||||||
const get = this.httpClient.get(url);
|
const get = this.httpClient.get(url);
|
||||||
return get;
|
return get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public deleteFile$(
|
||||||
|
songId: number,
|
||||||
|
fileId: number
|
||||||
|
): Observable<any> {
|
||||||
|
const url =
|
||||||
|
base +
|
||||||
|
'/api/songs/' +
|
||||||
|
songId +
|
||||||
|
'/files/' +
|
||||||
|
fileId +
|
||||||
|
'/delete';
|
||||||
|
const get = this.httpClient.get(url);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user