From 675e8b8c14dafa82e3e771bfe3fd616e19475766 Mon Sep 17 00:00:00 2001 From: "IBM602-PC0F1E3C\\Arundathi" Date: Mon, 16 Jul 2018 14:30:26 +0530 Subject: Removed duplicate code. The same variable values are set on file upload failure either due to wrong format or due to wrong content of the file being uploaded in uplaod() and uplaodedFileResult() methods of test component. Moved this duplicate code to a single method called setValuesOnFileUploadFailure() and called this method where required. Issue-ID: APPC-1082 Change-Id: If92d375e3cfa44479c2d7f54915a1b6461bdda89 Signed-off-by: Arundathi --- src/app/test/test.component.ts | 50 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts index 3797c8c..7560e7b 100644 --- a/src/app/test/test.component.ts +++ b/src/app/test/test.component.ts @@ -215,21 +215,7 @@ export class TestComponent implements OnInit { } else { this.nService.error('Error', 'Incorrect spreadsheet uploaded'); - this.flag = 1; - this.oldListName1 = ''; - this.vmJson = {}; - this.vnfcJson = {}; - this.subPayload = {}; - this.vmPayload = []; - this.payload = {}; - this.action = ''; - this.actionIdentifiers = {}; - this.apiRequest = ''; - this.apiResponse = ''; - this.enableCounterDiv = false; - this.enableAbort = false; - this.enableTestButton = false; - this.enableDownload = false; + this.setValuesOnFileUploadFailure(); } } @@ -282,21 +268,7 @@ export class TestComponent implements OnInit { this.nService.success('Success', 'SpreadSheet uploaded successfully'); } else { - this.flag = 1; - this.oldListName1 = ''; - this.vmJson = {}; - this.vnfcJson = {}; - this.subPayload = {}; - this.vmPayload = []; - this.payload = {}; - this.action = ''; - this.actionIdentifiers = {}; - this.apiRequest = ''; - this.apiResponse = ''; - this.enableCounterDiv = false; - this.enableAbort = false; - this.enableTestButton = false; - this.enableDownload = false; + this.setValuesOnFileUploadFailure(); this.nService.error("Error", "Please check the contents of the file uploaded") } } @@ -520,4 +492,22 @@ export class TestComponent implements OnInit { } + setValuesOnFileUploadFailure() { + this.flag = 1; + this.oldListName1 = ''; + this.vmJson = {}; + this.vnfcJson = {}; + this.subPayload = {}; + this.vmPayload = []; + this.payload = {}; + this.action = ''; + this.actionIdentifiers = {}; + this.apiRequest = ''; + this.apiResponse = ''; + this.enableCounterDiv = false; + this.enableAbort = false; + this.enableTestButton = false; + this.enableDownload = false; + } + } -- cgit 1.2.3-korg