X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=vid-app-common%2Fsrc%2Fmain%2Fwebapp%2Fapp%2Fvid%2Fscripts%2Fcontroller%2FServiceModelController.js;h=b29680f9dd502b3dc246acd5983b5a909c85e4d2;hb=cbf73dae518c62d5ebd077816e457d5e8db15a85;hp=b52b463bc8b54d1967de41fab11353b63165a4e7;hpb=683c41801c25daafd5c5edf10555898c038bce58;p=vid.git diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js index b52b463bc..b29680f9d 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * VID * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,47 +22,77 @@ (function () { 'use strict'; - appDS2.controller("ServiceModelController", function ($scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService, - PropertyService, UtilityService) { + appDS2.controller("ServiceModelController",function ($uibModal, $scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService, + PropertyService, UtilityService, AsdcService, $timeout, featureFlags) { $scope.popup = {}; - + var defaultViewPerPage = 10; // var baseEndpoint = "vid"; var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS; if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) { pathQuery = COMPONENT.SERVICES_PATH; } - + window.addEventListener("message", receiveMessage, false); + + function receiveMessage(event){ + if(event.data == 'navigateTo') { + $location.path('/models/services').search({}); + $scope.$apply(); + $scope.rememberFilter = true; + } + if(event.data == 'navigateToInstantiationStatus') { + $location.path('/instantiationStatus').search({}); + $scope.$apply(); + } + } + $scope.getServiceModels = function() { $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC; $http.get(pathQuery) - .then(function successCallback(response) { + .then(function (response) { $scope.services = []; if (response.data && angular.isArray(response.data.services)) { wholeData = response.data.services; - $scope.services = $scope.filterDataWithHigherVersion(wholeData); - $scope.viewPerPage=10; - $scope.totalPage=$scope.services.length/$scope.viewPerPage; - $scope.sortBy=COMPONENT.NAME; - $scope.scrollViewPerPage=2; - $scope.currentPage=1; - $scope.searchCategory; - $scope.currentPageNum=1; - $scope.isSpinnerVisible = false; - $scope.isProgressVisible = false; + $scope.services = $scope.filterDataWithHigherVersion(wholeData); + $scope.viewPerPage = defaultViewPerPage; + $scope.totalPage=$scope.services.length/$scope.viewPerPage; + $scope.sortBy=COMPONENT.NAME; + $scope.scrollViewPerPage=2; + $scope.currentPage=1; + $scope.currentPageNum=1; + $scope.isSpinnerVisible = false; + $scope.isProgressVisible = false; + var searchKey = sessionStorage.getItem("searchKey"); + if (searchKey != 'undefined' && searchKey!=null && ($scope.rememberFilter)) { + var searchKey = JSON.parse(sessionStorage.getItem("searchKey")); + $scope.searchString = searchKey.searchString || ''; + $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage; + $scope.totalPage = $scope.services.length / $scope.viewPerPage; + $timeout(function () { + // the table controller handles the current page once + // data is loaded, therefore we're delying the paging + // override + $scope.currentPage = $scope.currentPageNum = searchKey.currentPage ? parseInt(searchKey.currentPage) : 1; + }, 0); + $scope.rememberFilter = false; + } } else { $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC; $scope.error = true; $scope.isSpinnerVisible = false; } $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary'; - }, function errorCallback(response) { + }, function (response) { console.log("Error: " + response); }); }; + $scope.isShowOrchestrationType = function() { + return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ORCHESTRATION_TYPE); + }; + var wholeData=[]; $scope.filterDataWithHigherVersion = function(serviceData){ @@ -96,28 +127,49 @@ var polls = PropertyService.retrieveMsoMaxPolls(); PropertyService.setMsoMaxPolls(polls); - - //PropertyService.setMsoBaseUrl("testmso"); - PropertyService.setServerResponseTimeoutMsec(30000); - } + }; $scope.prevPage = function() { $scope.currentPage--; - } + }; $scope.nextPage = function() { $scope.currentPage++; - } + }; + + $scope.showReportWindow = function() { + + const modalWindow = $uibModal.open({ + templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html', + controller: 'reportModalController', + controllerAs: 'vm', + resolve: { + errorMsg: function () { + return $scope.status; + } + } + }); + + }; + + $scope.isShowErrorReport = function() { + return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS); + }; $scope.createType = COMPONENT.A_LA_CARTE; $scope.deployService = function(service) { - + var searchKey = { + searchString: $scope.searchString, + viewPerPage: $scope.viewPerPage, + currentPage: $scope.currentPage + }; + sessionStorage.setItem("searchKey",JSON.stringify(searchKey)); console.log("Instantiating SDC service " + service.uuid); - + $http.get(COMPONENT.SERVICES_PATH + service.uuid) - .then(function successCallback(getServiceResponse) { - + .then(function (getServiceResponse) { + var serviceModel = getServiceResponse.data; //VID-233 bug fix when models doesn't exists @@ -154,44 +206,48 @@ "description": serviceModel.service.description, "category":serviceModel.service.category }); - DataService.setALaCarte (true); + + var shouldTakeTheAsyncInstantiationFlow = AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel); + DataService.setShouldIncludeInAsyncInstantiationFlow(shouldTakeTheAsyncInstantiationFlow); + + DataService.setALaCarte (true); + DataService.setPnf(!angular.equals(serviceModel.pnfs, {})); $scope.createType = COMPONENT.A_LA_CARTE; var broadcastType = COMPONENT.CREATE_COMPONENT; - - if (UtilityService.arrayContains (VIDCONFIGURATION.MACRO_SERVICES, serviceModel.service.invariantUuid )) { - DataService.setALaCarte (false); - $scope.createType = COMPONENT.MACRO; - var convertedAsdcModel = UtilityService.convertModel(serviceModel); - - //console.log ("display inputs "); - //console.log (JSON.stringify ( convertedAsdcModel.completeDisplayInputs)); - - DataService.setModelInfo(COMPONENT.SERVICE, { - "modelInvariantId": serviceModel.service.invariantUuid, - "modelVersion": serviceModel.service.version, - "modelNameVersionId": serviceModel.service.uuid, - "modelName": serviceModel.service.name, - "description": serviceModel.service.description, - "category":serviceModel.service.category, - "serviceEcompNaming": serviceModel.service.serviceEcompNaming, - "inputs": serviceModel.service.inputs, - "serviceType": serviceModel.service.serviceType, - "serviceRole": serviceModel.service.serviceRole, - "displayInputs": convertedAsdcModel.completeDisplayInputs - }); - }; - + if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) { + DataService.setALaCarte(false); + if(!shouldTakeTheAsyncInstantiationFlow){ + $scope.createType = COMPONENT.MACRO; + var convertedAsdcModel = UtilityService.convertModel(serviceModel); + + DataService.setModelInfo(COMPONENT.SERVICE, { + "modelInvariantId": serviceModel.service.invariantUuid, + "modelVersion": serviceModel.service.version, + "modelNameVersionId": serviceModel.service.uuid, + "modelName": serviceModel.service.name, + "description": serviceModel.service.description, + "category": serviceModel.service.category, + "serviceEcompNaming": serviceModel.service.serviceEcompNaming, + "inputs": serviceModel.service.inputs, + "serviceType": serviceModel.service.serviceType, + "serviceRole": serviceModel.service.serviceRole, + "displayInputs": convertedAsdcModel.completeDisplayInputs + }); + } + } + $scope.$broadcast(broadcastType, { componentId : COMPONENT.SERVICE, + modelNameVersionId: serviceModel.service.uuid, callbackFunction : function(response) { if (response.isSuccessful) { vidService.setModel(serviceModel); - + var subscriberId = FIELD.STATUS.NOT_FOUND; var serviceType = FIELD.STATUS.NOT_FOUND; - + var serviceInstanceId = response.instanceId; - + for (var i = 0; i < response.control.length; i++) { if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) { subscriberId = response.control[i].value; @@ -199,15 +255,14 @@ serviceType = response.control[i].value; } } - - + + $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId); - + } } }); - - }, function errorCallback(response) { + }, function (response) { console.log("Error: " + response); }); }; @@ -231,7 +286,7 @@ callbackFunction : function(response) { } }); - } + }; $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) { $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI; @@ -243,7 +298,7 @@ }).then(function(response){ if (response.data.status < 200 || response.data.status > 202) { - $scope.showError(FIELD.ERROR.MSO) + $scope.showError(FIELD.ERROR.MSO); return; }