diff options
author | zhangab <zhanganbing@chinamobile.com> | 2018-05-25 19:15:03 +0800 |
---|---|---|
committer | zhangab <zhanganbing@chinamobile.com> | 2018-05-25 19:15:16 +0800 |
commit | 704c19c2fef0beb4b0d19081fcb72b4d945eb257 (patch) | |
tree | 58a652c8452a66303738d729d97a2e70f04fa95b | |
parent | c1860a6f7cd410f25dfc596720eb70a109090b5f (diff) |
fix scaling progress display bug
Change-Id: I60edb3c467ed46bb9e948837f537e06fed8b1aec
Issue-ID: USECASEUI-119
Signed-off-by: zhangab <zhanganbing@chinamobile.com>
6 files changed, 315 insertions, 36 deletions
diff --git a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js index 4e8f46ef..e15032de 100644 --- a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js +++ b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js @@ -99,6 +99,19 @@ }) }, + getupdateServiceTemplate:function(serviceInstanceId,processFun){ + return $http({ + url: url+'/xxxxxxx/'+ serviceInstanceId, + method: 'GET', + data: null, + headers: uuiHeaders + }).then(function(response){ + var template = response.data; + + processFun(template); + }) + }, + getTemplateParameters: function (template, processFun) { console.log(url+'/service-templates/' + template.id+'?toscaModelPath='+ template.toscaModelURL); return $http({ @@ -113,6 +126,23 @@ }); }, + getComparedTemplateParameters: function (serviceInstanceId,template, processFun) { + var requestBody = { + "model-invariant-id-target": template.invariantUUID, + "model-version-id-target": template.id + } + return $http({ + url: url+'/xxxxxxxxx/' + serviceInstanceId, + method: 'POST', + data: JSON.stringify(requestBody), + headers: uuiHeaders + }).then(function(response){ + var inputRsp = response.data; + console.log(inputRsp); + processFun(inputRsp); + }); + }, + getAllVimInfo: function (processFun) { return $http({ url: url+'/locations/', @@ -222,7 +252,7 @@ } }; - // console.log(requestBody); + console.log(requestBody); // console.log(JSON.stringify(requestBody)); // return false; return $http({ @@ -240,6 +270,94 @@ }); }, + updateService: function (customer, serviceType,serviceInstanceId, service, template, successFun, failedFun) { + var reqPara = []; + var newreqParas = {}; + service.segments.forEach(function (segment) { + var reqParas = {}; + var vfLocations = []; + segment.parameters.forEach(function (parameter) { + if(parameter.type === 'vf_location') { + // name is uuid for vf_location + var loc = { + vnfProfileId: parameter.name, + locationConstraints : { + vimId: parameter.value.value + } + }; + vfLocations.push(loc); + } else if(parameter.type === 'sdn_controller') { + if(parameter.value === undefined || parameter.value === null) { + reqParas[parameter.name] = ''; + } else { + reqParas[parameter.name] = parameter.value.value; + } + } else { + reqParas[parameter.name] = parameter.value; + } + }); + + var para = { + resourceName: segment.nodeTemplateName, + resourceInvariantUuid: segment.invariantUUID,//resourceDefId + resourceUuid: segment.uuid, + resourceCustomizationUuid: segment.customizationUuid, + parameters: { //nsParameters + locationConstraints: vfLocations, + // additionalParamForNs: reqParas, + resources:[], + requestInputs:reqParas + } + }; + reqPara.push(para); + }); + + var templateName = template.name; + if( template.version !== undefined && template.version !== null && template.version !== '' ) { + templateName = templateName + ":" + template.version; + } + + service.parameters.forEach(function(item){ + newreqParas[item.name] = item.value; + }) + + var requestBody = { + service: { + name: service.serviceName, + description: service.serviceDescription, + serviceInvariantUuid: template.invariantUUID, //serviceDefId + serviceUuid: template.uuid, // uuid ?? templateId + globalSubscriberId: customer.id, + serviceType: serviceType.value, + parameters: { + // globalSubscriberId: customer.id, + // subscriberName: customer.name, + // serviceType: serviceType.value, + // templateName: templateName, + locationConstraints:[], + resources: reqPara, + requestInputs:newreqParas + } + } + }; + + console.log(requestBody); + // console.log(JSON.stringify(requestBody)); + return false; + return $http({ + url: url+ '/services/updateService/' + serviceInstanceId, + method: 'POST', + data: JSON.stringify(requestBody), + headers: uuiHeaders + }).then(function(response){ + console.log('update response...'); + console.log(response.data); + // var serviceId = response.data.service.serviceId; + var operationId = response.data.service.operationId; + successFun(operationId); + }); + }, + getScaleServiceDialog:function(customer,serviceType,serviceInstanceId,successFun){ return $http({ url:url+'/getServiceInstanceById?customerId=' + customer + '&serviceType=' + serviceType + '&serviceId=' + serviceInstanceId, @@ -251,10 +369,9 @@ scaleService: function (requestBody, successFun, failedFun) { - // console.log('request body: '); - // console.log(JSON.stringify(requestBody)); + console.log(requestBody); + console.log(JSON.stringify(requestBody)); - return $http({ url: url+'/services/scaleServices/'+requestBody.service.globalSubscriberId, method: 'POST', @@ -262,10 +379,8 @@ headers: uuiHeaders }).then(function(response){ // console.log('create response...'); - // console.log(response.data); - - var serviceId = response.data.service.serviceId; - var operationId = response.data.service.operationId; + console.log(response); + var operationId = response.data.operationId; successFun( operationId); }); }, diff --git a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js index bc41ecef..a4b52941 100644 --- a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js +++ b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js @@ -176,25 +176,69 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' }; ctrl.deleteService = function (serviceInstance) { - var successFun = function (serviceId, operationId) { - var successFun = function (result) { - ctrl.alerts.push({ - type: 'success', - msg: result - }); - ServiceTemplateService.getServiceInstances(ctrl.customer.id, ctrl.serviceType.value, function (instances) { - ctrl.serviceInstances = instances; - }); - } - var failFun = function (reason) { - ctrl.alerts.push({ - type: 'danger', - msg: reason - }); + console.log(serviceInstance); + var deleteServiceName = serviceInstance.serviceInstanceName; + var modalInstance = $uibModal.open({ + ariaLabelledBy: 'modal-title', + ariaDescribedBy: 'modal-body', + template:(function(deleteServiceName){ + var strtemplate = + '<div class="modal-header" style="background-color:#eee;">'+ + '<h4 class="modal-title" id="myModalLabel">'+ + '<span>Delete Request</span>'+ + '</h4>'+ + '</div>'+ + '<div class="modal-body">'+ + '<h3 style="margin-top:10px;"> Are you sure you want to delete <span style="color:red">'+ deleteServiceName + '</span>? </h3>'+ + '</div>'+ + '<div class="modal-footer">'+ + '<button type="button" style="width:80px;" class="btn btn-primary" ng-click="ctrl.ok()" id="startToCreateService">'+ + '<span id="nfv-virtualApplication-iui-text-cancelBtn">YES</span>'+ + '</button>'+ + '<button type="button" style="width:80px;" class="btn btn-warning" ng-click="ctrl.cancel()">'+ + '<span id="nfv-virtualApplication-iui-text-previousBtn">NO</span>'+ + '</button>'+ + '</div>'; + return strtemplate; + })(deleteServiceName), + + controller: function($uibModalInstance){ + this.ok = function(){ + $uibModalInstance.close('delete implement'); + }; + this.cancel = function(){ + $uibModalInstance.dismiss('delete cancel'); + } + } , + controllerAs: 'ctrl', + }); + modalInstance.result.then( + function(res){ + console.log(res); + var successFun = function (serviceId, operationId) { + var successFun = function (result) { + ctrl.alerts.push({ + type: 'success', + msg: result + }); + ServiceTemplateService.getServiceInstances(ctrl.customer.id, ctrl.serviceType.value, function (instances) { + ctrl.serviceInstances = instances; + }); + } + var failFun = function (reason) { + ctrl.alerts.push({ + type: 'danger', + msg: reason + }); + } + openServiceProgressDialog(serviceId, operationId, 'Delete Service', successFun, failFun); + } + ServiceTemplateService.deleteService(serviceInstance.serviceInstanceId, ctrl.customer, ctrl.serviceType, successFun); + }, + function(reason){ + console.log(reason); } - openServiceProgressDialog(serviceId, operationId, 'Delete Service', successFun, failFun); - } - ServiceTemplateService.deleteService(serviceInstance.serviceInstanceId, ctrl.customer, ctrl.serviceType, successFun); + ) }; ctrl.upDateService = function (serviceInstance) { @@ -235,7 +279,7 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' msg: reason }); } - openServiceProgressDialog(result.serviceId, result.operationId, 'Scale Service', successFun, failFun); + openServiceProgressDialog(result.serviceId, result.operationId, 'upDate Service', successFun, failFun); }, function (reason) { console.log('receive cancel button clicked!'); @@ -435,7 +479,7 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' ctrl.locations = []; ctrl.serviceTemplateChanged = function (template) { - console.log('serviceTemplateChanged invoked... ' + template); + console.log(template); if (template === undefined || template === null) { ctrl.service = undefined; ctrl.realTemplate = undefined; @@ -498,6 +542,7 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' ctrl.scalingDirections = ["SCALE_IN","SCALE_OUT"]; ctrl.ok = function () { + let resources = []; ctrl.nsData.forEach(function(item){ resources.push({ @@ -525,11 +570,12 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' }; var successFun = function ( operationId) { $uibModalInstance.close({ + serviceId:serviceInstance.serviceInstanceId, operationId: operationId }); } ServiceTemplateService.scaleService(requestBody, successFun, errorMessage); - + }; // cancel click ctrl.cancel = function () { @@ -539,6 +585,124 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' } ]) + .controller('updateServiceCtrl', ['$scope', '$uibModal', '$uibModalInstance', 'ServiceTemplateService', 'customer', 'serviceType','serviceInstance', + function ($scope, $uibModal, $uibModalInstance, ServiceTemplateService, customer, serviceType,serviceInstance) { + var ctrl = this; + console.log(serviceInstance) + var serviceInstanceId = serviceInstance.serviceInstanceId; + ServiceTemplateService.getupdateServiceTemplate(serviceInstanceId,function(template){ + console.log(template); + ServiceTemplateService.getAllServiceTemplates(function (res) { + console.log(res) + var slectTemplates = []; + res.forEach(function(item){ + if(item.id === template.model-version-id && itme.invariantUUID !== template.model-invariant-id){ + slectTemplates.push(item); + } + }) + ctrl.templates = slectTemplates; + }); + }) + + + ctrl.changeInput = function (serviceTemplate) { + var paras = serviceTemplate.inputs.map(function (input) { + return { + name: input.name, + type: input.type, + description: input.description, + defaultValue: input.defaultValue, + isRequired: input.isRequired, + readonly: "" + }; + }); + + var segmentsPara = serviceTemplate.nestedTemplates.map(function (nestedTemplate) { + var nestedParas = nestedTemplate.inputs.map(function (input) { + return { + name: input.name, + type: input.type, + description: input.description, + defaultValue: input.defaultValue, + isRequired: input.isRequired, + readonly: "" + }; + }); + return { + nodeTemplateName: nestedTemplate.name, + customizationUuid:nestedTemplate.customizationUuid, + invariantUUID: nestedTemplate.invariantUUID, + uuid: nestedTemplate.uuid, + type: nestedTemplate.type, + parameters: nestedParas + }; + }); + + var service = { + serviceName: ctrl.service.serviceName, + serviceDescription: ctrl.service.serviceDescription, + parameters: paras, + segments: segmentsPara + }; + ctrl.service = service; + console.log(service); + }; + ctrl.service = { + serviceName: '', + serviceDescription: '', + parameters: [], + segments: [] + }; + ctrl.sdnControllers = []; + ctrl.locations = []; + + ctrl.serviceTemplateChanged = function (template) { + console.log('serviceTemplateChanged invoked... ' + template); + if (template === undefined || template === null) { + ctrl.service = undefined; + ctrl.realTemplate = undefined; + } else { + ServiceTemplateService.getComparedTemplateParameters(serviceInstanceId,template, function (templateRsp) { + ctrl.realTemplate = templateRsp; + ctrl.changeInput(ctrl.realTemplate); + }); + } + }; + + ctrl.ok = function () { + console.log('ok button clicked!'); + console.log('service: '); + console.log(customer); + console.log(serviceType); + console.log(ctrl.service); + console.log(ctrl.realTemplate); + + + var errorMessage = function () { + + }; + var successFun = function (operationId) { + $uibModalInstance.close({ + serviceId: serviceInstanceId, + operationId: operationId + }); + } + ServiceTemplateService.updateService(customer, serviceType,serviceInstanceId, ctrl.service, ctrl.realTemplate, successFun, errorMessage); + }; + // cancel click + ctrl.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; + + ServiceTemplateService.getAllVimInfo(function (vims) { + ctrl.locations = vims; + }); + + ServiceTemplateService.getAllSdnControllers(function (sdnControllers) { + ctrl.sdnControllers = sdnControllers; + }); + } + ]) .controller('packageOnboardCtrl', ['$scope', '$uibModalInstance', 'ServiceTemplateService', 'onboardPackage', function ($scope, $uibModalInstance, ServiceTemplateService, onboardPackage) { var ctrl = this; @@ -597,7 +761,7 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', ' var timer = $interval(function () { ServiceTemplateService.queryServiceProgress(serviceId, operationId, progressFun); - }, 1000); + }, 5000); timerPromise.then(function () { $interval.cancel(timer); diff --git a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/update-service-dialog.html b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/update-service-dialog.html index 810fe81f..a8a92d45 100644 --- a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/update-service-dialog.html +++ b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/update-service-dialog.html @@ -17,7 +17,7 @@ --> <div class="modal-header" style="margin-bottom: 15px;"> <h4 class="modal-title" id="myModalLabel"> - <span>Create</span> + <span>upDate</span> </h4> </div> diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js index d064f311..c98336e0 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/alarm-chartController.js @@ -159,7 +159,7 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', var options = { tooltip: { trigger: 'axis', - formatter: (params) => { + formatter: function(params) { var res = '<p>' + params[0].name + '</p>' + '<div>'; // console.log(params); for (var i = 0; i < params.length; i++) { @@ -189,7 +189,7 @@ app.controller('alarmchartCtrl', ['$scope', '$http', '$routeParams', '$window', boundaryGap: false, data: data.dateList, axisLabel:{ - formatter:(value)=>{ + formatter:function(value){ if($scope.showModeId == 'day'){ return value.slice(5,10) }else if($scope.showModeId == 'hour'){ diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/left-menuController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/left-menuController.js index 93608a69..135ed768 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/left-menuController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/left-menuController.js @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -var currentTab = 'app/uui/fusion/scripts/view-models/performance.html'; +var currentTab = 'app/uui/fusion/scripts/view-models/lifecyclemanagement.html'; app.controller('cmCtrl', ['$scope', function ($scope) { $scope.routeData = [{ diff --git a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js index 6d9c36a7..21363ff0 100644 --- a/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js +++ b/usecaseui-monitor/src/main/webapp/app/uui/fusion/scripts/controller/performance-chartController.js @@ -211,7 +211,7 @@ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , var options = { tooltip: { trigger: 'axis', - formatter: (params) => { + formatter: function(params){ var res = '<p>' + params[0].name + '</p>' + '<div>'; // console.log(params); for (var i = 0; i < params.length; i++) { @@ -241,7 +241,7 @@ app.controller('pertabCtrl', ['$scope', '$http', '$routeParams', '$window' , boundaryGap: true, data: data.dateList, axisLabel:{ - formatter:(value)=>{ + formatter:function(value){ if($scope.showModeId == 'day'){ return value.slice(5,10) }else if($scope.showModeId == 'hour'){ |