UtilityService: Removed hard coded values 91/57991/1
authorArundathi Patil <arundpil@in.ibm.com>
Mon, 30 Jul 2018 09:46:54 +0000 (15:16 +0530)
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>
Mon, 30 Jul 2018 09:47:03 +0000 (15:17 +0530)
Moved the hard coded values from utility service file to app-contants
file as variables.

Issue-ID: APPC-1054
Change-Id: Iac62da47deeeb66402f413e90ee0ab50130ca185
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
src/app/shared/services/utilityService/utility.service.ts
src/constants/app-constants.ts

index f22f2ab..a683f33 100644 (file)
@@ -26,19 +26,20 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
 import {Injectable} from '@angular/core';
 import {NotificationsService} from 'angular2-notifications';
 import { saveAs } from 'file-saver';
+import { appConstants } from '../../../../constants/app-constants';
 
 @Injectable()
 export class UtilityService {
-    public putAction = 'uploadArtifact';
-    public getAction = 'getArtifact';
-    private retrievalSuccessMessage = 'Retrieved artifact successfully';
-    private retrievalFailureMessage = 'There is no artifact saved in APPC for the selected action';
-    private saveSuccessMessage = 'Successfully uploaded the ';
-    private saveFailureMessage = 'Error in saving the ';
-    public connectionErrorMessage = 'Error in connecting to the APPC Server';
+    public putAction = appConstants.messages.artifactUploadAction;
+    public getAction = appConstants.messages.artifactgetAction;
+    private retrievalSuccessMessage = appConstants.messages.retrievalSuccessMessage;
+    private retrievalFailureMessage = appConstants.messages.retrievalFailureMessage;
+    private saveSuccessMessage = appConstants.messages.saveSuccessMessage;
+    private saveFailureMessage = appConstants.messages.saveFailureMessage;
+    public connectionErrorMessage = appConstants.errors.connectionError;
     
-    private successMessage = 'Retrieved artifact successfully';
-    private failureMessage = 'There is no artifact saved in APPC for the selected action!';
+    private successMessage = appConstants.messages.artifactRetrivalsuccessMessage;
+    private failureMessage = appConstants.messages.artifactRetrivalfailureMessage;
 
     constructor(private notificationService: NotificationsService) {
     }
@@ -56,12 +57,12 @@ export class UtilityService {
 
     public checkResult(result: any) {
 
-        if (result.output.status.code == '401') {
-            this.notificationService.info('Information', this.failureMessage);
+        if (result.output.status.code == appConstants.errorCode["401"]) {
+            this.notificationService.info(appConstants.notifications.titles.information, this.failureMessage);
             return false;
         }
-        else if (result.output.status.code == '400') {
-            this.notificationService.success('Success', this.successMessage);
+        else if (result.output.status.code == appConstants.errorCode["400"]) {
+            this.notificationService.success(appConstants.notifications.titles.success, this.successMessage);
             return true;
         }
 
@@ -69,24 +70,24 @@ export class UtilityService {
 
     public processApiSubscribe(result: any, action, artifactType) {
 
-        if (result.output.status.code == '401' && action == this.getAction) {
-            this.notificationService.info('Information', this.retrievalFailureMessage);
+        if (result.output.status.code == appConstants.errorCode["401"] && action == this.getAction) {
+            this.notificationService.info(appConstants.notifications.titles.information, this.retrievalFailureMessage);
         }
-        else if (result.output.status.code == '400' && action == this.getAction) {
-            this.notificationService.success('Success', this.retrievalSuccessMessage);
+        else if (result.output.status.code == appConstants.errorCode["400"] && action == this.getAction) {
+            this.notificationService.success(appConstants.notifications.titles.success, this.retrievalSuccessMessage);
         }
-        if (result.output.status.code == '401' && action == this.putAction) {
-            this.notificationService.warn('Error', this.saveFailureMessage + artifactType);
+        if (result.output.status.code == appConstants.errorCode["401"] && action == this.putAction) {
+            this.notificationService.warn(appConstants.notifications.titles.error, this.saveFailureMessage + artifactType);
         }
-        else if (result.output.status.code == '400' && action == this.putAction) {
-            this.notificationService.success('Success', this.saveSuccessMessage + artifactType);
+        else if (result.output.status.code == appConstants.errorCode["400"] && action == this.putAction) {
+            this.notificationService.success(appConstants.notifications.titles.success, this.saveSuccessMessage + artifactType);
         }
 
     }
 
     public processApiError()
     {
-        this.notificationService.error('Error', this.connectionErrorMessage);
+        this.notificationService.error(appConstants.notifications.titles.error, this.connectionErrorMessage);
     }
 
 
index 0f44f0f..0c45ebb 100644 (file)
@@ -167,5 +167,26 @@ export const appConstants = {
         pauseOnHover: true,
         clickToClose: true,
         maxLength: 200
+    },
+    "messages" : {
+        "retrievalSuccessMessage" : 'Retrieved artifact successfully',
+        "retrievalFailureMessage" : 'There is no artifact saved in APPC for the selected action',
+        "saveSuccessMessage" : 'Successfully uploaded the ',
+        "saveFailureMessage" : 'Error in saving the ',
+        "artifactRetrivalsuccessMessage" : 'Retrieved artifact successfully',
+        "artifactRetrivalfailureMessage" : 'There is no artifact saved in APPC for the selected action!',
+        "artifactUploadAction" : 'uploadArtifact',
+        "artifactgetAction" : 'getArtifact'
+    },
+    "errorCode" : {
+        "401" : '401',
+        "400" : '400'
+    },
+    "notifications" : {
+        "titles" : {
+            "information" : 'Information',
+            "success" : 'Success',
+            "error" : 'Error'
+        }
     }
 };
\ No newline at end of file