Removed duplicate code. 91/56491/2
authorIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>
Mon, 16 Jul 2018 09:00:26 +0000 (14:30 +0530)
committerTakamune Cho <tc012c@att.com>
Mon, 16 Jul 2018 14:40:38 +0000 (14:40 +0000)
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 <arundpil@in.ibm.com>
src/app/test/test.component.ts

index 3797c8c..7560e7b 100644 (file)
@@ -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;
+    }
+
 }