adding orchestration type to service models view
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / ServiceModelController.js
index aee4c05..b29680f 100755 (executable)
@@ -2,7 +2,8 @@
  * ============LICENSE_START=======================================================\r
  * VID\r
  * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.\r
+ * Modifications Copyright (C) 2019 IBM.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -21,8 +22,8 @@
 (function () {\r
        'use strict';\r
 \r
-       appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,\r
-                       PropertyService, UtilityService, AsdcService,$timeout) {\r
+       appDS2.controller("ServiceModelController",function ($uibModal, $scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,\r
+                       PropertyService, UtilityService, AsdcService, $timeout, featureFlags) {\r
 \r
                $scope.popup = {};\r
                var defaultViewPerPage = 10;\r
@@ -50,7 +51,7 @@
                        $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC;\r
 \r
                        $http.get(pathQuery)\r
-                       .then(function successCallback(response) {\r
+                       .then(function (response) {\r
                                $scope.services = [];\r
                                if (response.data && angular.isArray(response.data.services)) {\r
                                        wholeData = response.data.services;\r
@@ -63,7 +64,8 @@
                     $scope.currentPageNum=1;\r
                     $scope.isSpinnerVisible = false;\r
                     $scope.isProgressVisible = false;\r
-                    if (sessionStorage.getItem("searchKey")!='undefined' && ($scope.rememberFilter)) {\r
+                                       var searchKey = sessionStorage.getItem("searchKey");\r
+                    if (searchKey != 'undefined' && searchKey!=null && ($scope.rememberFilter)) {\r
                         var searchKey = JSON.parse(sessionStorage.getItem("searchKey"));\r
                         $scope.searchString = searchKey.searchString || '';\r
                         $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage;\r
                                        $scope.isSpinnerVisible = false;\r
                                }\r
                                $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary';\r
-                       }, function errorCallback(response) {\r
+                       }, function (response) {\r
                                console.log("Error: " + response);\r
                        });\r
                };\r
 \r
+               $scope.isShowOrchestrationType = function() {\r
+                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ORCHESTRATION_TYPE);\r
+               };\r
+\r
                var wholeData=[];\r
 \r
                $scope.filterDataWithHigherVersion = function(serviceData){\r
                \r
                var polls = PropertyService.retrieveMsoMaxPolls();\r
                PropertyService.setMsoMaxPolls(polls);\r
-               \r
-               //PropertyService.setMsoBaseUrl("testmso");\r
-               PropertyService.setServerResponseTimeoutMsec(30000);\r
         };\r
                \r
                $scope.prevPage = function() {\r
                        $scope.currentPage++;\r
                };\r
 \r
+               $scope.showReportWindow = function() {\r
+\r
+                       const modalWindow = $uibModal.open({\r
+                               templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',\r
+                               controller: 'reportModalController',\r
+                               controllerAs: 'vm',\r
+                               resolve: {\r
+                                       errorMsg: function () {\r
+                                               return $scope.status;\r
+                                       }\r
+                               }\r
+                       });\r
 \r
+               };\r
+\r
+               $scope.isShowErrorReport = function() {\r
+                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);\r
+               };\r
                \r
                $scope.createType = COMPONENT.A_LA_CARTE;\r
                $scope.deployService = function(service) {\r
                        console.log("Instantiating SDC service " + service.uuid);\r
 \r
                        $http.get(COMPONENT.SERVICES_PATH + service.uuid)\r
-                               .then(function successCallback(getServiceResponse) {\r
+                               .then(function (getServiceResponse) {\r
 \r
                                        var serviceModel = getServiceResponse.data;\r
 \r
                                                "description": serviceModel.service.description,\r
                                                "category":serviceModel.service.category\r
                                        });\r
-                                       DataService.setALaCarte (true);\r
-          DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));\r
+\r
+                    var shouldTakeTheAsyncInstantiationFlow = AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel);\r
+                    DataService.setShouldIncludeInAsyncInstantiationFlow(shouldTakeTheAsyncInstantiationFlow);\r
+\r
+                    DataService.setALaCarte (true);\r
+                    DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));\r
                                        $scope.createType = COMPONENT.A_LA_CARTE;\r
                                        var broadcastType = COMPONENT.CREATE_COMPONENT;\r
                     if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {\r
                         DataService.setALaCarte(false);\r
-                        if(AsdcService.shouldExcludeMacroFromAsyncInstatiationFlow(serviceModel)){\r
-                               DataService.setShouldExcludeMacroFromAsyncInstatiationFlow(true);\r
+                        if(!shouldTakeTheAsyncInstantiationFlow){\r
                             $scope.createType = COMPONENT.MACRO;\r
                             var convertedAsdcModel = UtilityService.convertModel(serviceModel);\r
 \r
                                 "serviceRole": serviceModel.service.serviceRole,\r
                                 "displayInputs": convertedAsdcModel.completeDisplayInputs\r
                             });\r
-\r
                         }\r
                     }\r
 \r
                                                }\r
                                            }\r
                                        });\r
-                               }, function errorCallback(response) {\r
+                               }, function (response) {\r
                                        console.log("Error: " + response);\r
                                });\r
                };\r