summaryrefslogtreecommitdiffstats
path: root/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js
diff options
context:
space:
mode:
Diffstat (limited to 'usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js')
-rw-r--r--usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js195
1 files changed, 182 insertions, 13 deletions
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 b09cfb07..0b2d431d 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
@@ -13,38 +13,207 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-app.controller('lcmCtrl', ['$scope','$uibModal', '$log', '$http', '$timeout', '$interval', 'uiGridConstants', 'uiGridGroupingConstants',
- function ($scope,$uibModal, $log, $http, $timeout, $interval) {
- $scope.openCreateServiceDialog = function () {
- console.log('start to open dialog....');
+app.controller('lcmCtrl', ['$scope', '$state', '$uibModal', '$log', '$http', '$timeout', '$interval', 'ServiceTemplateService',
+ function ($scope, $state, $uibModal, $log, $http, $timeout, $interval, ServiceTemplateService) {
+ var ctrl = this;
+ ctrl.openCreateServiceDialog = function () {
var modalInstance = $uibModal.open({
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
templateUrl : 'app/uui/fusion/scripts/view-models/create-service-dialog.html',
- controller : 'createServiceCtrl'
+ controller : 'createServiceCtrl',
+ controllerAs : 'ctrl',
+ resolve: {
+ customer: function () {
+ return ctrl.customer;
+ },
+ serviceType: function () {
+ return ctrl.serviceType;
+ }
+ }
+ });
+ modalInstance.result.then(
+ function(result) {
+ console.log('receive ok button clicked!');
+ console.log(result);
+ },
+ function(reason) {
+ console.log('receive cancel button clicked!');
+ console.log(reason);
+ $log.info('Modal dismissed at: ' + new Date());
+ }
+ );
+ };
+
+ ctrl.init = function () {
+ ctrl.canCreateService = "true";
+ ServiceTemplateService.getAllCustomers(function (customers) {
+ ctrl.customers = customers;
+ });
+ ServiceTemplateService.getPackages(function (packages) {
+ ctrl.packages = packages;
+ });
+ };
+
+ ctrl.customerChanged = function () {
+ if(ctrl.customer === undefined || ctrl.customer === null) {
+ ctrl.serviceTypes = [];
+ } else {
+ ServiceTemplateService.getAllServiceTypes(ctrl.customer.id, function (serviceTypes) {
+ ctrl.serviceTypes = serviceTypes;
+ });
+ }
+ ctrl.serviceType = undefined;
+ ctrl.canCreateService = "true";
+ };
+
+ ctrl.serviceTypeChanged = function () {
+ if(ctrl.serviceType === undefined || ctrl.serviceType === null || ctrl.customer === undefined || ctrl.customer === null) {
+ ctrl.canCreateService = "true";
+ return;
+ }
+ ctrl.canCreateService = "false";
+ ServiceTemplateService.getServiceInstances(ctrl.customer.id, ctrl.serviceType.type, function (instances) {
+ ctrl.serviceInstances = instances;
+ });
+ };
+
+ ctrl.packageOnboard = function (onboardPackage) {
+ var modalInstance = $uibModal.open({
+ ariaLabelledBy: 'modal-title',
+ ariaDescribedBy: 'modal-body',
+ templateUrl : 'app/uui/fusion/scripts/view-models/vnf-ns-onboard-dialog.html',
+ controller : 'packageOnboardCtrl',
+ controllerAs : 'ctrl',
+ resolve: {
+ onboardPackage: function () {
+ return onboardPackage;
+ }
+ }
});
modalInstance.result.then(
- function() {
+ function(result) {
console.log('receive ok button clicked!');
+ console.log(result);
},
- function() {
+ function(reason) {
console.log('receive cancel button clicked!');
- $log.info('Modal dismissed at: ' + new Date())
+ console.log(reason);
+ $log.info('Modal dismissed at: ' + new Date());
}
);
};
}
]
)
-.controller('createServiceCtrl',['ServiceTemplateService',
- function($scope, $uibModalInstance, ServiceTemplateService) {
+.controller('createServiceCtrl',['$scope', '$state', '$uibModalInstance', 'ServiceTemplateService', 'customer', 'serviceType',
+ function($scope, $state, $uibModalInstance, ServiceTemplateService, customer, serviceType) {
+ var ctrl = this;
+
+ ctrl.templates = ServiceTemplateService.getAllServiceTemplates();
- $scope.ok = function() {
+ ctrl.changeInput = function (serviceTemplate) {
+ var paras = serviceTemplate.inputs.map(function (input) {
+ return {
+ name: input.name,
+ 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,
+ description: input.description,
+ defaultValue: input.defaultValue,
+ isRequired: input.isRequired,
+ readonly: ""
+ };
+ });
+ return {
+ nodeTemplateName: nestedTemplate.name,
+ location: {
+ name: nestedTemplate.name + " location",// ???
+ },
+ parameters: nestedParas
+ };
+ });
+
+ var service = {
+ serviceName: ctrl.service.serviceName,
+ serviceDescription: ctrl.service.serviceDescription,
+ location: {
+ name: "local host" // ???
+ },
+ parameters: paras,
+ segments: segmentsPara
+ };
+ ctrl.service = service;
+ };
+
+ ctrl.serviceTemplateChanged = function (template) {
+ console.log('serviceTemplateChanged invoked... ' + template);
+ if(template === undefined || template === null) {
+ ctrl.service = undefined;
+ ctrl.realTemplate = undefined;
+ } else {
+ ServiceTemplateService.getTemplateParameters(template, function (templateRsp) {
+ ctrl.realTemplate = templateRsp;
+ ctrl.changeInput(ctrl.realTemplate);
+ });
+ }
+ };
+
+ ctrl.ok = function() {
console.log('ok button clicked!');
+ console.log('service: ');
+ console.log(ctrl.service);
+ console.log(customer);
+ console.log(serviceType);
+ console.log(ctrl.realTemplate);
+ ServiceTemplateService.createService(customer, serviceType, ctrl.service, ctrl.realTemplate);
+ var result = 'success.';
+ $uibModalInstance.close(result);
};
+
+ console.log($uibModalInstance);
// cancel click
- $scope.cancel = function() {
+ ctrl.cancel = function() {
$uibModalInstance.dismiss('cancel');
- }
+ };
+
+ ServiceTemplateService.getAllVimInfo(function (vims) {
+ ctrl.locations = vims;
+ });
+ }]
+).controller('packageOnboardCtrl',['$scope', '$state', '$uibModalInstance', 'ServiceTemplateService','onboardPackage',
+ function($scope, $state, $uibModalInstance, ServiceTemplateService, onboardPackage) {
+ var ctrl = this;
+
+ ServiceTemplateService.getAllVimInfo(function (vims) {
+ ctrl.packageLocations = vims;
+ });
+
+ ctrl.ok = function() {
+ var proVims = [];
+ ctrl.packageLocations.forEach(function (location) {
+ if(location.productenv) {
+ proVims.push(location.name);
+ }
+ });
+ ServiceTemplateService.packageOnboard(onboardPackage, {
+ testenv: ctrl.testenv,
+ productenv: proVims
+ });
+ $uibModalInstance.close('successfully');
+ };
+ // cancel click
+ ctrl.cancel = function() {
+ $uibModalInstance.dismiss('cancel');
+ };
+
}]
);