clean new war file extension check

pull/34/head
Florian Hartwich 2018-04-28 16:31:14 +02:00
parent b40c664bce
commit 8600eb5f3c
3 changed files with 10 additions and 10 deletions

View File

@ -25,7 +25,6 @@ export class CampaignService {
return this.http.post(this.config.apiCampaignPath, campaign) return this.http.post(this.config.apiCampaignPath, campaign)
.map(res => res.json()); .map(res => res.json());
} }
} }
deleteCampaign(id: string) { deleteCampaign(id: string) {

View File

@ -29,7 +29,7 @@
<label for="log">Logfile</label> <label for="log">Logfile</label>
<input id="log" name="log" class="ui-button form-control" type="file" <input id="log" name="log" class="ui-button form-control" type="file"
(change)="fileChange($event)"> (change)="fileChange($event)">
<span class="label label-bg label-danger center-block" style="font-size:small" *ngIf="showImageError"> <span class="label label-bg label-danger center-block" style="font-size:small" *ngIf="showFileError">
Logfile muss im Format RPT, LOG oder TXT vorliegen Logfile muss im Format RPT, LOG oder TXT vorliegen
</span> </span>
</div> </div>

View File

@ -18,7 +18,9 @@ export class WarSubmitComponent {
fileList: FileList; fileList: FileList;
showImageError = false; readonly validExtensions = ['.rpt', '.log', '.txt'];
showFileError = false;
showErrorLabel = false; showErrorLabel = false;
@ -35,14 +37,13 @@ export class WarSubmitComponent {
} }
fileChange(event) { fileChange(event) {
if (!event.target.files[0].name.endsWith('.rpt') if (this.validExtensions.filter(ext => event.target.files[0] &&
&& !event.target.files[0].name.endsWith('.log') event.target.files[0].name.endsWith(ext)).length == 1) {
&& !event.target.files[0].name.endsWith('.txt')) { this.showFileError = false;
this.showImageError = true;
this.fileList = undefined;
} else {
this.showImageError = false;
this.fileList = event.target.files; this.fileList = event.target.files;
} else {
this.showFileError = true;
this.fileList = undefined;
} }
} }