diff --git a/src/main/resources/static/js/controllers/vimInstanceController.js b/src/main/resources/static/js/controllers/vimInstanceController.js index 3b6591724..6b40524d3 100644 --- a/src/main/resources/static/js/controllers/vimInstanceController.js +++ b/src/main/resources/static/js/controllers/vimInstanceController.js @@ -34,11 +34,11 @@ angular.module('app').controller('vimInstanceCtrl', function ($scope, $routePara $scope.setFormInput = function () { formInput = true; fileInput = false; - + }; $scope.setFileInput = function () { formInput = false; - fileInput = true; + fileInput = true; }; $scope.changeText = function (text) { @@ -84,14 +84,14 @@ angular.module('app').controller('vimInstanceCtrl', function ($scope, $routePara $scope.hoverOut = function () { this.hoverEdit = false; }; -function checkKey() { - if (angular.isUndefined($scope.newvim.keyPair)) { - return; - } - if ($scope.newvim.keyPair === '') { - delete $scope.newvim.keyPair; + function checkKey() { + if (angular.isUndefined($scope.newvim.keyPair)) { + return; + } + if ($scope.newvim.keyPair === '') { + delete $scope.newvim.keyPair; + } } -} $scope.setFile = function (element) { $scope.$apply(function ($scope) { @@ -137,7 +137,7 @@ function checkKey() { loadVIM(); }) .error(function (data, status) { - showError(data, status); + showError(data, status); }); } else if ($scope.textTopologyJson !== '') { @@ -159,9 +159,9 @@ function checkKey() { } $('#modalDC').on('hidden.bs.modal', function () { - $(this).find("input,textarea,select").val('').end(); + $(this).find("input,textarea,select").val('').end(); - }); + }); $scope.textTopologyJson = ''; $scope.file = ''; }; @@ -262,8 +262,30 @@ function checkKey() { $scope.vimInstanceJSON = JSON.stringify(response, undefined, 4); }).error(function (data, status) { + showError(data, status); + }); + else { + http.get(url) + .success(function (response) { + $scope.vimInstances = response; + }) + .error(function (data, status) { showError(data, status); }); + } + } + + $scope.loadVIM = function() { + if (!angular.isUndefined($routeParams.vimInstanceId)) + http.get(url + $routeParams.vimInstanceId) + .success(function (response, status) { + console.log(response); + $scope.vimInstance = response; + $scope.vimInstanceJSON = JSON.stringify(response, undefined, 4); + + }).error(function (data, status) { + showError(data, status); + }); else { http.get(url) .success(function (response) { @@ -274,7 +296,24 @@ function checkKey() { }); } } + var promise = $interval($scope.loadVIM, 10000); + $scope.$on('$destroy',function(){ + if(promise) + $interval.cancel(promise); + }); + $scope.ActiveVIM = function(status) { + if(status === 'ACTIVE') { + return true; + } + return false; + }; + $scope.PendingVIM = function(status) { + if(status != 'ACTIVE') { + return true; + } + return false; + }; function loadInstalled() { http.get(bareUrl + "/api/v1/plugins").success(function (response) { @@ -298,15 +337,15 @@ function checkKey() { function showError(data, status) { if (status === 500) { $scope.alerts.push({ - type: 'danger', - msg: 'An error occured and could not be handled properly, please, report to us and we will fix it as soon as possible' - }); + type: 'danger', + msg: 'An error occured and could not be handled properly, please, report to us and we will fix it as soon as possible' + }); } else { - console.log('Status: ' + status + ' Data: ' + JSON.stringify(data)); - $scope.alerts.push({ - type: 'danger', - msg: data.message + " Code: " + status - }); + console.log('Status: ' + status + ' Data: ' + JSON.stringify(data)); + $scope.alerts.push({ + type: 'danger', + msg: data.message + " Code: " + status + }); } $('.modal').modal('hide'); diff --git a/src/main/resources/static/pages/nsdescriptors/nsdescriptors.html b/src/main/resources/static/pages/nsdescriptors/nsdescriptors.html index b77c6f242..1f96644f6 100644 --- a/src/main/resources/static/pages/nsdescriptors/nsdescriptors.html +++ b/src/main/resources/static/pages/nsdescriptors/nsdescriptors.html @@ -1340,6 +1340,7 @@