From 8600eb5f3c631cceb3dbab06b069ce6bd8417043 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 28 Apr 2018 16:31:14 +0200 Subject: [PATCH] clean new war file extension check --- .../src/app/services/logs/campaign.service.ts | 1 - .../war-submit/war-submit.component.html | 2 +- .../war-submit/war-submit.component.ts | 17 +++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/static/src/app/services/logs/campaign.service.ts b/static/src/app/services/logs/campaign.service.ts index d4cc7ef..2fbda1f 100644 --- a/static/src/app/services/logs/campaign.service.ts +++ b/static/src/app/services/logs/campaign.service.ts @@ -25,7 +25,6 @@ export class CampaignService { return this.http.post(this.config.apiCampaignPath, campaign) .map(res => res.json()); } - } deleteCampaign(id: string) { diff --git a/static/src/app/statistic/war-submit/war-submit.component.html b/static/src/app/statistic/war-submit/war-submit.component.html index 1b37492..4cebf76 100644 --- a/static/src/app/statistic/war-submit/war-submit.component.html +++ b/static/src/app/statistic/war-submit/war-submit.component.html @@ -29,7 +29,7 @@ - + Logfile muss im Format RPT, LOG oder TXT vorliegen diff --git a/static/src/app/statistic/war-submit/war-submit.component.ts b/static/src/app/statistic/war-submit/war-submit.component.ts index 74b3525..5e78590 100644 --- a/static/src/app/statistic/war-submit/war-submit.component.ts +++ b/static/src/app/statistic/war-submit/war-submit.component.ts @@ -18,7 +18,9 @@ export class WarSubmitComponent { fileList: FileList; - showImageError = false; + readonly validExtensions = ['.rpt', '.log', '.txt']; + + showFileError = false; showErrorLabel = false; @@ -35,14 +37,13 @@ export class WarSubmitComponent { } fileChange(event) { - if (!event.target.files[0].name.endsWith('.rpt') - && !event.target.files[0].name.endsWith('.log') - && !event.target.files[0].name.endsWith('.txt')) { - this.showImageError = true; - this.fileList = undefined; - } else { - this.showImageError = false; + if (this.validExtensions.filter(ext => event.target.files[0] && + event.target.files[0].name.endsWith(ext)).length == 1) { + this.showFileError = false; this.fileList = event.target.files; + } else { + this.showFileError = true; + this.fileList = undefined; } }