diff options
Diffstat (limited to 'gui/app/scripts/controllers')
-rw-r--r-- | gui/app/scripts/controllers/container.controller.js | 2 | ||||
-rw-r--r-- | gui/app/scripts/controllers/content.controller.js | 30 | ||||
-rw-r--r-- | gui/app/scripts/controllers/detail.controller.js | 5 | ||||
-rw-r--r-- | gui/app/scripts/controllers/image.controller.js | 303 | ||||
-rw-r--r-- | gui/app/scripts/controllers/main.js | 177 | ||||
-rw-r--r-- | gui/app/scripts/controllers/pod.controller.js | 2 | ||||
-rw-r--r-- | gui/app/scripts/controllers/project.controller.js | 2 | ||||
-rw-r--r-- | gui/app/scripts/controllers/projectDetail.controller.js | 8 | ||||
-rw-r--r-- | gui/app/scripts/controllers/testcase.controller.js | 4 | ||||
-rw-r--r-- | gui/app/scripts/controllers/testsuit.controller.js | 6 |
10 files changed, 309 insertions, 230 deletions
diff --git a/gui/app/scripts/controllers/container.controller.js b/gui/app/scripts/controllers/container.controller.js index 6c2ccd8ff..3ad200a91 100644 --- a/gui/app/scripts/controllers/container.controller.js +++ b/gui/app/scripts/controllers/container.controller.js @@ -128,7 +128,7 @@ angular.module('yardStickGui2App') $scope.selectContainer = name; } $scope.goBack = function goBack() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } $scope.openDeleteEnv = function openDeleteEnv(id, name) { diff --git a/gui/app/scripts/controllers/content.controller.js b/gui/app/scripts/controllers/content.controller.js index d2bc19eea..0288fa540 100644 --- a/gui/app/scripts/controllers/content.controller.js +++ b/gui/app/scripts/controllers/content.controller.js @@ -2,7 +2,7 @@ angular.module('yardStickGui2App') .controller('ContentController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', '$location', '$localStorage', - function($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, $localStorage) { + function ($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, $localStorage) { @@ -11,10 +11,11 @@ angular.module('yardStickGui2App') $scope.showEnvironment = false; $scope.counldGoDetail = false; $scope.activeStatus = 0; + $scope.ifshowEnvChild = false; - $scope.$watch(function() { + $scope.$watch(function () { return location.hash - }, function(newvalue, oldvalue) { + }, function (newvalue, oldvalue) { if (location.hash.indexOf('project') > -1) { $scope.projectShow = true; $scope.taskShow = false; @@ -26,6 +27,13 @@ angular.module('yardStickGui2App') $scope.reportShow = true; $scope.taskShow = true; $scope.projectShow = true; + } else if (location.hash.indexOf('envDetail') > -1 || location.hash.indexOf('envimageDetail') > -1 || + location.hash.indexOf('envpodupload') > -1 || location.hash.indexOf('envcontainer') > -1) { + $scope.ifshowEnvChild = true; + $scope.activeStatus=0; + }else{ + $scope.ifshowEnvChild=false; + $scope.activeStatus=-1; } }) @@ -88,30 +96,30 @@ angular.module('yardStickGui2App') } function gotoTestcase() { - $state.go('app2.testcase'); + $state.go('app.testcase'); } function gotoEnviron() { if ($location.path().indexOf('env') > -1 || $location.path().indexOf('environment') > -1) { $scope.counldGoDetail = true; } - $state.go('app2.environment'); + $state.go('app.environment'); } function gotoSuite() { - $state.go('app2.testsuite'); + $state.go('app.testsuite'); } function gotoProject() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } function gotoTask() { - $state.go('app2.tasklist'); + $state.go('app.tasklist'); } function gotoReport() { - $state.go('app2.report'); + $state.go('app.report'); } function goBack() { @@ -119,7 +127,7 @@ angular.module('yardStickGui2App') return; } else if ($location.path().indexOf('main/envDetail/') || $location.path().indexOf('main/imageDetail/') || $location.path().indexOf('main/podupload/') || $location.path().indexOf('main/container/')) { - $state.go('app2.environment'); + $state.go('app.environment'); return; } else { window.history.back(); @@ -133,4 +141,4 @@ angular.module('yardStickGui2App') } - ]);
\ No newline at end of file + ]); diff --git a/gui/app/scripts/controllers/detail.controller.js b/gui/app/scripts/controllers/detail.controller.js index 3e2eaa100..bfdb525f7 100644 --- a/gui/app/scripts/controllers/detail.controller.js +++ b/gui/app/scripts/controllers/detail.controller.js @@ -108,6 +108,7 @@ angular.module('yardStickGui2App') //buildtoEnvInfo function buildToEnvInfo(object) { + $scope.envInfo=[]; var tempKeyArray = Object.keys(object); for (var i = 0; i < tempKeyArray.length; i++) { @@ -118,7 +119,11 @@ angular.module('yardStickGui2App') value: tempValue }; $scope.envInfo.push(temp); + } + + console.log($scope.envInfo); + console.log($scope.openrcInfo); } function uploadFiles($file, $invalidFiles) { diff --git a/gui/app/scripts/controllers/image.controller.js b/gui/app/scripts/controllers/image.controller.js index 53acff405..d7a7edfa9 100644 --- a/gui/app/scripts/controllers/image.controller.js +++ b/gui/app/scripts/controllers/image.controller.js @@ -1,155 +1,240 @@ 'use strict'; angular.module('yardStickGui2App') - .controller('ImageController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', '$location', '$interval', - function($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, $interval) { + .controller('ImageController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', '$location', '$interval', 'ngDialog', + function($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, $interval, ngDialog) { init(); - $scope.showloading = false; - $scope.ifshowStatus = 0; function init() { + $scope.showloading = false; + $scope.ifshowStatus = 0; + + $scope.yardstickImage = [ + { + 'name': 'yardstick-image', + 'description': '', + 'size': 'N/A', + 'status': 'N/A', + 'time': 'N/A' + }, + { + 'name': 'Ubuntu-16.04', + 'description': '', + 'size': 'N/A', + 'status': 'N/A', + 'time': 'N/A' + }, + { + 'name': 'cirros-0.3.5', + 'description': '', + 'size': 'N/A', + 'status': 'N/A', + 'time': 'N/A' + } + ]; + $scope.customImage = []; $scope.uuid = $stateParams.uuid; - $scope.uploadImage = uploadImage; - getItemIdDetail(); - getImageListSimple(); + $scope.showloading = false; + $scope.url = null; + $scope.environmentInfo = null; + + getYardstickImageList(); + getCustomImageList(function(image, image_id){}); } - function getItemIdDetail() { + function getYardstickImageList(){ + mainFactory.ImageList().get({}).$promise.then(function(response){ + if(response.status == 1){ + angular.forEach($scope.yardstickImage, function(ele, index){ + if(typeof(response.result.images[ele.name]) != 'undefined'){ + $scope.yardstickImage[index] = response.result.images[ele.name]; + } + }); + }else{ + mainFactory.errorHandler1(response); + } + }, function(response){ + mainFactory.errorHandler2(response); + }); + } + + function getCustomImageList(func){ mainFactory.ItemDetail().get({ 'envId': $stateParams.uuid }).$promise.then(function(response) { - if (response.status == 1) { - $scope.baseElementInfo = response.result.environment; - - - } else { - toaster.pop({ - type: 'error', - title: 'fail', - body: response.error_msg, - timeout: 3000 + if(response.status == 1){ + $scope.environmentInfo = response.result.environment; + $scope.customImage = []; + angular.forEach(response.result.environment.image_id, function(ele){ + mainFactory.getImage().get({'imageId': ele}).$promise.then(function(responseData){ + if(responseData.status == 1){ + $scope.customImage.push(responseData.result.image); + func(responseData.result.image, ele); + }else{ + mainFactory.errorHandler1(responseData); + } + }, function(errorData){ + mainFactory.errorHandler2(errorData); + }); }); + }else{ + mainFactory.errorHandler1(response); } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'fail', - body: 'unknow error', - timeout: 3000 - }); - }) + }, function(response){ + mainFactory.errorHandler2(response); + }); } - function getImageListSimple() { - - mainFactory.ImageList().get({}).$promise.then(function(response) { - if (response.status == 1) { - $scope.imageListData = response.result.images; - // $scope.imageStatus = response.result.status; - - } else { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 - }); - } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 + $scope.loadYardstickImage = function(image_name){ + + var updateImageTask = $interval(updateYardstickImage, 10000); + + function updateYardstickImage(){ + mainFactory.ImageList().get({}).$promise.then(function(responseData){ + if(responseData.status == 1){ + if(typeof(responseData.result.images[image_name]) != 'undefined' && responseData.result.images[image_name].status == 'ACTIVE'){ + angular.forEach($scope.yardstickImage, function(ele, index){ + if(ele.name == image_name){ + $scope.yardstickImage[index] = responseData.result.images[ele.name]; + } + }); + $interval.cancel(updateImageTask); + } + }else{ + mainFactory.errorHandler1(responseData); + } + },function(errorData){ + mainFactory.errorHandler2(errorData); }); - }) - } + } + mainFactory.uploadImage().post({'action': 'load_image', 'args': {'name': image_name}}).$promise.then(function(response){ + },function(response){ + mainFactory.errorHandler2(response); + }); + } - function getImageList() { - if ($scope.intervalImgae != undefined) { - $interval.cancel($scope.intervalImgae); - } - mainFactory.ImageList().get({}).$promise.then(function(response) { - if (response.status == 1) { - $scope.imageListData = response.result.images; - $scope.imageStatus = response.result.status; - - if ($scope.imageStatus == 0) { - $scope.intervalImgae = $interval(function() { - getImageList(); - }, 5000); - } else if ($scope.intervalImgae != undefined) { - $interval.cancel($scope.intervalImgae); + $scope.deleteYardstickImage = function(image_name){ + + var updateImageTask = $interval(updateYardstickImage, 10000); + + function updateYardstickImage(){ + mainFactory.ImageList().get({}).$promise.then(function(response){ + if(response.status == 1){ + if(typeof(response.result.images[image_name]) == 'undefined'){ + angular.forEach($scope.yardstickImage, function(ele, index){ + if(ele.name == image_name){ + $scope.yardstickImage[index].size = 'N/A'; + $scope.yardstickImage[index].status = 'N/A'; + $scope.yardstickImage[index].time = 'N/A'; + } + }); + $interval.cancel(updateImageTask); + } + }else{ + mainFactory.errorHandler1(response); } + },function(response){ + mainFactory.errorHandler2(response); + }); + } - } else { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 + mainFactory.uploadImage().post({'action': 'delete_image', 'args': {'name': image_name}}).$promise.then(function(response){ + },function(response){ + mainFactory.errorHandler2(response); + }); + } + + $scope.uploadCustomImageByUrl = function(url){ + mainFactory.uploadImageByUrl().post({ + 'action': 'upload_image_by_url', + 'args': { + 'environment_id': $stateParams.uuid, + 'url': url + } + }).$promise.then(function(response){ + if(response.status == 1){ + var updateImageTask = $interval(getCustomImageList, 30000, 10, true, function(image, image_id){ + if(image_id == response.result.uuid && image.status == 'ACTIVE'){ + $interval.cancel(updateImageTask); + } }); + ngDialog.close(); + }else{ + mainFactory.errorHandler1(response); } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 - }); - }) + }, function(response){ + mainFactory.errorHandler2(response); + }); } - function uploadImage() { - $scope.imageStatus = 0; - $interval.cancel($scope.intervalImgae); - $scope.ifshowStatus = 1; + $scope.uploadCustomImage = function($file, $invalidFiles) { $scope.showloading = true; - mainFactory.uploadImage().post({ - 'action': 'load_image', - 'args': { - 'environment_id': $scope.uuid - } - }).$promise.then(function(response) { + $scope.displayImageFile = $file; + Upload.upload({ + url: Base_URL + '/api/v2/yardstick/images', + data: { file: $file, 'environment_id': $scope.uuid, 'action': 'upload_image' } + }).then(function(response) { + $scope.showloading = false; - if (response.status == 1) { + if (response.data.status == 1) { + toaster.pop({ type: 'success', - title: 'create success', + title: 'upload success', body: 'you can go next step', timeout: 3000 }); - setTimeout(function() { - getImageList(); - }, 10000); - } else { - toaster.pop({ - type: 'error', - title: 'failed', - body: 'something wrong', - timeout: 3000 + var updateImageTask = $interval(getCustomImageList, 10000, 10, true, function(image, image_id){ + if(image_id == response.data.result.uuid && image.status == 'ACTIVE'){ + $interval.cancel(updateImageTask); + } }); + }else{ + mainFactory.errorHandler1(response); + } + }, function(response) { + $scope.uploadfile = null; + mainFactory.errorHandler2(response); + }) + } + + $scope.deleteCustomImage = function(image_id){ + mainFactory.deleteImage().delete({'imageId': image_id}).$promise.then(function(response){ + if(response.status == 1){ + $interval(getCustomImageList, 10000, 5, true, function(image, image_id){ + }); + }else{ + mainFactory.errorHandler2(response); } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'failed', - body: 'something wrong', - timeout: 3000 - }); + }, function(response){ + mainFactory.errorHandler2(response); + }); + } + + $scope.openImageDialog = function(){ + $scope.url = null; + ngDialog.open({ + preCloseCallback: function(value) { + }, + template: 'views/modal/imageDialog.html', + scope: $scope, + className: 'ngdialog-theme-default', + width: 950, + showClose: true, + closeByDocument: false }) } $scope.goBack = function goBack() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } $scope.goNext = function goNext() { @@ -158,9 +243,5 @@ angular.module('yardStickGui2App') $state.go('app.podUpload', { uuid: $scope.uuid }); } - - - - } ]); diff --git a/gui/app/scripts/controllers/main.js b/gui/app/scripts/controllers/main.js index e3e880e62..ceec83fa9 100644 --- a/gui/app/scripts/controllers/main.js +++ b/gui/app/scripts/controllers/main.js @@ -15,14 +15,10 @@ angular.module('yardStickGui2App') $scope.showImage = null; $scope.showContainer = null; $scope.showNextOpenRc = null; - $scope.showNextPod = null; + $scope.showNextPod = 1; $scope.displayContainerInfo = []; $scope.containerList = [{ value: 'create_influxdb', name: "InfluxDB" }, { value: 'create_grafana', name: "Grafana" }] - $scope.items = [ - 'The first choice!', - 'And another choice for you.', - 'but wait! A third!' - ]; + $scope.$on('$destroy', function() { $interval.cancel($scope.intervalImgae) }); @@ -55,7 +51,6 @@ angular.module('yardStickGui2App') $scope.chooseResult = chooseResult; getEnvironmentList(); - // getImageList(); } @@ -89,7 +84,7 @@ angular.module('yardStickGui2App') } $scope.goToImage = function goToImage() { - getImageListSimple(); + getImageList(); $scope.showImage = 1; } $scope.goToPod = function goToPod() { @@ -294,7 +289,7 @@ angular.module('yardStickGui2App') $scope.showImage = null; $scope.showContainer = null; $scope.showNextOpenRc = null; - $scope.showNextPod = null; + $scope.showNextPod = 1; $scope.displayContainerInfo = []; $scope.displayPodFile = null; @@ -312,7 +307,6 @@ angular.module('yardStickGui2App') ngDialog.open({ preCloseCallback: function(value) { getEnvironmentList(); - // getImageList(); }, template: 'views/modal/environmentDialog.html', scope: $scope, @@ -381,7 +375,7 @@ angular.module('yardStickGui2App') $scope.goBack = function goBack() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } $scope.displayContainerInfo = []; @@ -483,106 +477,97 @@ angular.module('yardStickGui2App') }) } - $scope.uploadImage = function uploadImage() { - $scope.imageStatus = 0; - $scope.showImageStatus = 1; - $scope.showloading = true; - mainFactory.uploadImage().post({ - 'action': 'load_image', - 'args': { - 'environment_id': $scope.uuid + $scope.yardstickImage = { + 'yardstick-image': { + 'name': 'yardstick-image', + 'description': '', + 'status': 'N/A' + }, + 'Ubuntu-16.04': { + 'name': 'Ubuntu-16.04', + 'description': '', + 'status': 'N/A' + }, + 'cirros-0.3.5': { + 'name': 'cirros-0.3.5', + 'description': '', + 'status': 'N/A' + } + }; - } - }).$promise.then(function(response) { - $scope.showloading = false; - if (response.status == 1) { - toaster.pop({ - type: 'success', - title: 'create success', - body: 'you can go next step', - timeout: 3000 - }); - setTimeout(function() { - getImageList(); - }, 10000); - $scope.showNextPod = 1; + $scope.selectImageList = []; - } else { - toaster.pop({ - type: 'error', - title: 'failed', - body: 'something wrong', - timeout: 3000 - }); + $scope.selectImage = function(name){ + $scope.selectImageList.push(name); + } - } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'failed', - body: 'something wrong', - timeout: 3000 - }); - }) + $scope.unselectImage = function(name){ + var index = $scope.selectImageList.indexOf(name); + $scope.selectImageList.splice(index, 1); } - function getImageList() { - if ($scope.intervalImgae != undefined) { - $interval.cancel($scope.intervalImgae); - } - mainFactory.ImageList().get({}).$promise.then(function(response) { - if (response.status == 1) { - $scope.imageListData = response.result.images; - $scope.imageStatus = response.result.status; + $scope.uploadImage = function() { + $scope.imageStatus = 0; + $scope.showImageStatus = 1; + $scope.showloading = true; - if ($scope.imageStatus == 0) { - $scope.intervalImgae = $interval(function() { - getImageList(); - }, 5000); - } else if ($scope.intervalImgae != undefined) { - $interval.cancel($scope.intervalImgae); + var updateImageTask = $interval(function(){ + mainFactory.ImageList().get({}).$promise.then(function(response){ + if(response.status == 1){ + var isOk = true; + angular.forEach($scope.selectImageList, function(ele){ + if(typeof(response.result.images[ele]) != 'undefined' && response.result.images[ele].status == 'ACTIVE'){ + $scope.yardstickImage[ele] = response.result.images[ele]; + }else{ + isOk = false; + } + }); + if(isOk){ + $interval.cancel(updateImageTask); + $scope.imageStatus = 1; + } + }else{ + mainFactory.errorHandler1(response); } - - } else { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 - }); - } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 + }, function(response){ + mainFactory.errorHandler2(response); }); - }) + }, 10000); + + angular.forEach($scope.selectImageList, function(ele){ + mainFactory.uploadImage().post({ + 'action': 'load_image', + 'args': { + 'name': ele + } + }).$promise.then(function(response) { + if(response.status == 1){ + $scope.showloading = false; + $scope.showNextPod = 1; + }else{ + mainFactory.errorHandler1(response); + } + }, function(response) { + mainFactory.errorHandler2(response); + }) + }); } - function getImageListSimple() { + function getImageList() { mainFactory.ImageList().get({}).$promise.then(function(response) { if (response.status == 1) { - $scope.imageListData = response.result.images; - $scope.imageStatus = response.result.status; - - } else { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 + angular.forEach($scope.yardstickImage, function(value, key){ + if(typeof(response.result.images[key]) != 'undefined'){ + $scope.yardstickImage[key] = response.result.images[key]; + } }); + $scope.imageStatus = response.result.status; + }else{ + mainFactory.errorHandler1(response); } - }, function(error) { - toaster.pop({ - type: 'error', - title: 'get data failed', - body: 'please retry', - timeout: 3000 - }); + }, function(response) { + mainFactory.errorHandler2(response); }) } diff --git a/gui/app/scripts/controllers/pod.controller.js b/gui/app/scripts/controllers/pod.controller.js index 3ef236854..56dfee148 100644 --- a/gui/app/scripts/controllers/pod.controller.js +++ b/gui/app/scripts/controllers/pod.controller.js @@ -113,7 +113,7 @@ angular.module('yardStickGui2App') } $scope.goBack = function goBack() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } diff --git a/gui/app/scripts/controllers/project.controller.js b/gui/app/scripts/controllers/project.controller.js index 0a7b8b932..197474567 100644 --- a/gui/app/scripts/controllers/project.controller.js +++ b/gui/app/scripts/controllers/project.controller.js @@ -91,7 +91,7 @@ angular.module('yardStickGui2App') } function gotoDetail(id) { - $state.go('app2.projectdetail', { projectId: id }) + $state.go('app.projectdetail', { projectId: id }) } diff --git a/gui/app/scripts/controllers/projectDetail.controller.js b/gui/app/scripts/controllers/projectDetail.controller.js index a616f3ee7..e8468045d 100644 --- a/gui/app/scripts/controllers/projectDetail.controller.js +++ b/gui/app/scripts/controllers/projectDetail.controller.js @@ -606,16 +606,16 @@ angular.module('yardStickGui2App') function gotoDetail(id) { - $state.go('app2.tasklist', { taskId: id }); + $state.go('app.tasklist', { taskId: id }); } function gotoReport(id) { - $state.go('app2.report', { taskId: id }); + $state.go('app.report', { taskId: id }); } function gotoModify(id) { - $state.go('app2.taskModify', { taskId: id }); + $state.go('app.taskModify', { taskId: id }); } function goBack() { @@ -672,7 +672,7 @@ angular.module('yardStickGui2App') } $scope.gotoLog = function gotoLog(task_id) { - $state.go('app2.taskLog', { taskId: task_id }); + $state.go('app.taskLog', { taskId: task_id }); } } ]); diff --git a/gui/app/scripts/controllers/testcase.controller.js b/gui/app/scripts/controllers/testcase.controller.js index 616ceb4a8..c93fd8cb0 100644 --- a/gui/app/scripts/controllers/testcase.controller.js +++ b/gui/app/scripts/controllers/testcase.controller.js @@ -41,7 +41,7 @@ angular.module('yardStickGui2App') } function gotoDetail(name) { - $state.go('app2.testcasedetail', { name: name }); + $state.go('app.testcasedetail', { name: name }); } @@ -93,7 +93,7 @@ angular.module('yardStickGui2App') } $scope.goBack = function goBack() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } $scope.openDeleteEnv = function openDeleteEnv(id, name) { diff --git a/gui/app/scripts/controllers/testsuit.controller.js b/gui/app/scripts/controllers/testsuit.controller.js index abc9095c7..a15daa776 100644 --- a/gui/app/scripts/controllers/testsuit.controller.js +++ b/gui/app/scripts/controllers/testsuit.controller.js @@ -41,16 +41,16 @@ angular.module('yardStickGui2App') function gotoDetail(name) { var temp = name.split('.')[0]; - $state.go('app2.suitedetail', { name: temp }) + $state.go('app.suitedetail', { name: temp }) } function gotoCreateSuite() { - $state.go('app2.suitcreate'); + $state.go('app.suitcreate'); } $scope.goBack = function goBack() { - $state.go('app2.projectList'); + $state.go('app.projectList'); } |