diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2017-01-04 14:25:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-01-04 14:25:42 +0000 |
commit | 10a7c1ea663ce09f0bcda151c82bfca068f8b588 (patch) | |
tree | 3c147afcb063299606bb3ddf87cbb431e9a014c1 /utils/test/reporting/pages/app/scripts | |
parent | 7aeefe4aa6315c2ad5aea8e0e1bf4d33f34c17d9 (diff) | |
parent | 64605f1cc7117854abb203375deee396e0d65cc1 (diff) |
Merge "Create Test Reporting landing page"
Diffstat (limited to 'utils/test/reporting/pages/app/scripts')
7 files changed, 721 insertions, 0 deletions
diff --git a/utils/test/reporting/pages/app/scripts/app.js b/utils/test/reporting/pages/app/scripts/app.js new file mode 100644 index 000000000..6e99ce3d7 --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/app.js @@ -0,0 +1,20 @@ +'use strict'; + +/** + * @ngdoc overview + * @name opnfvApp + * @description + * # opnfvApp + * + * Main module of the application. + */ +angular + .module('opnfvApp', [ + 'ngAnimate', + 'ui.router', + 'oc.lazyLoad', + 'ui.bootstrap', + 'ngResource', + 'selectize' + + ]); diff --git a/utils/test/reporting/pages/app/scripts/config.js b/utils/test/reporting/pages/app/scripts/config.js new file mode 100644 index 000000000..838460a38 --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/config.js @@ -0,0 +1,14 @@ +/** + * @ngdoc overview + * @name opnfvApp + * @description + * # opnfvApp + * + * Main config file of the application. + */ +angular + .module('opnfvApp').config(function () { + + } + + ) diff --git a/utils/test/reporting/pages/app/scripts/config.router.js b/utils/test/reporting/pages/app/scripts/config.router.js new file mode 100644 index 000000000..641ea6a74 --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/config.router.js @@ -0,0 +1,53 @@ +'use strict' +/** + * @ngdoc function + * @name opnfvdashBoardAngularApp.config:config.router.js + * @description config of the ui router and lazy load setting + * config of the opnfvdashBoardAngularApp + */ +angular.module('opnfvApp') + .run([ + '$rootScope', '$state', '$stateParams', + function ($rootScope, $state, $stateParams) { + + $rootScope.$state = $state; + $rootScope.$stateParams = $stateParams; + + } + ] + ).config(['$stateProvider', '$urlRouterProvider', + function ($stateProvider, $urlRouterProvider) { + + $urlRouterProvider.otherwise('/landingpage/table'); + + $stateProvider + .state('landingpage', { + url: "/landingpage", + //controller: 'MainCtrl', + templateUrl: "views/main.html", + data: { pageTitle: '首页', specialClass: 'landing-page' }, + resolve: { + controller: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load([ + + ]) + }] + } + }) + .state('landingpage.table', { + url: "/table", + controller:'TableController', + templateUrl: "views/commons/table.html", + resolve: { + controller: ['$ocLazyLoad', function ($ocLazyLoad) { + return $ocLazyLoad.load([ + // 'scripts/controllers/table.controller.js' + + + ]) + }] + } + }) + + }]) + .run(); diff --git a/utils/test/reporting/pages/app/scripts/controllers/table.controller.js b/utils/test/reporting/pages/app/scripts/controllers/table.controller.js new file mode 100644 index 000000000..8ca1e474c --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/controllers/table.controller.js @@ -0,0 +1,520 @@ +'use strict'; + +/** + * @ngdoc function + * @name opnfvdashBoardAngularApp.controller:TableController + * @description + * # TableController + * Controller of the opnfvdashBoardAngularApp + */ +angular.module('opnfvApp') + .controller('TableController', ['$scope', '$state', '$stateParams', 'TableFactory', function ($scope, $state, $stateParams, TableFactory) { + + $scope.filterlist = []; + $scope.selection = []; + $scope.statusList = ["Success", "Warning", "Danger"]; + $scope.projectList = ["Deployment", "Functest", "Yardstick"]; + $scope.installerList = ["apex", "compass", "fuel", "joid"]; + $scope.versionlist = ["Colorado", "Master"]; + $scope.loopci = ["Daily", "Weekly", "Monthly"]; + $scope.time = ["10 days", "1 Month"]; + $scope.tableDataAll = {}; + $scope.tableInfoAll = {}; + + + + $scope.scenario = + { + "scenarios": { + "os-nosdn-kvm-noha": { + "status": "Success", + "installers": { + "apex": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS", + + + }, + { + "project": "Functest", + "score": "null", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "compass": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "fuel": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "joid": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ] + } + }, + "os-nosdn-ovs-ha": { + "status": "Danger", + "installers": { + "apex": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS", + + + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "compass": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "fuel": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "joid": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ] + } + }, + "os-nosdn-ovs-noha": { + "status": "Warning", + "installers": { + "apex": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS", + + + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "compass": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "fuel": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ], + "joid": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "score": "13/14", + "status": "SUCCESS" + } + ] + } + } + } + }; + + // var headData = Object.keys($scope.scenario.scenarios.os_nosdn_kvm_noha.installers); + // $scope.headData = headData; + //construct json + function constructJson() { + + var colspan; + var InstallerData; + var projectsInfo; + $scope.tableDataAll["scenario"] = []; + + + for (var item in $scope.scenario.scenarios) { + + + + + var headData = Object.keys($scope.scenario.scenarios[item].installers); + var scenarioStatus = $scope.scenario.scenarios[item].status; + + + InstallerData = headData; + var projectData = []; + var datadisplay = []; + var projects = []; + + + for (var j = 0; j < headData.length; j++) { + + projectData.push($scope.scenario.scenarios[item].installers[headData[j]]); + } + for (var j = 0; j < projectData.length; j++) { + + for (var k = 0; k < projectData[j].length; k++) { + projects.push(projectData[j][k].project); + var temArray = []; + temArray.push(projectData[j][k].score); + temArray.push(projectData[j][k].project); + temArray.push(headData[j]); + datadisplay.push(temArray); + + } + + } + + colspan = projects.length / headData.length; + + var tabledata = { + scenarioName: item, Installer: InstallerData, projectData: projectData, projects: projects, + datadisplay: datadisplay, colspan: colspan, status: scenarioStatus + }; + + JSON.stringify(tabledata); + $scope.tableDataAll.scenario.push(tabledata); + + } + + + projectsInfo = $scope.tableDataAll.scenario[0].projects; + + var tempHeadData = []; + + + + for (var i = 0; i < InstallerData.length; i++) { + for (var j = 0; j < colspan; j++) { + tempHeadData.push(InstallerData[i]); + } + } + + console.log(tempHeadData); + + var projectsInfoAll = []; + + for (var i = 0; i < projectsInfo.length; i++) { + var tempA = []; + tempA.push(projectsInfo[i]); + tempA.push(tempHeadData[i]); + projectsInfoAll.push(tempA); + + } + console.log(projectsInfoAll); + + $scope.tableDataAll["colspan"] = colspan; + $scope.tableDataAll["Installer"] = InstallerData; + $scope.tableDataAll["Projects"] = projectsInfoAll; + + console.log($scope.tableDataAll); + + } + + //get json element size + function getSize(jsondata) { + var size = 0; + for (var item in jsondata) { + size++; + } + return size; + } + + init(); + function init() { + $scope.toggleSelection = toggleSelection; + + constructJson(); + + } + + // $scope.test=false; + + var statusListString = $scope.statusList.toString(); + var projectListString = $scope.projectList.toString(); + var installerListString = $scope.installerList.toString(); + + + $scope.colspan=$scope.tableDataAll.colspan; + //filter function + function filterData() { + + + $scope.selectInstallers = []; + $scope.selectProjects = []; + $scope.selectStatus = []; + for (var i = 0; i < $scope.selection.length; i++) { + if (statusListString.indexOf($scope.selection[i]) > -1) { + $scope.selectStatus.push($scope.selection[i]); + } + if (projectListString.indexOf($scope.selection[i]) > -1) { + $scope.selectProjects.push($scope.selection[i]); + } + if (installerListString.indexOf($scope.selection[i]) > -1) { + $scope.selectInstallers.push($scope.selection[i]); + } + } + + $scope.colspan=$scope.selectProjects.length; + //when some selection is empty, we set it full + if($scope.selectInstallers.length==0){ + $scope.selectInstallers=$scope.installerList; + + } + if($scope.selectProjects.length==0){ + $scope.selectProjects=$scope.projectList; + $scope.colspan=$scope.tableDataAll.colspan; + } + if($scope.selectStatus.length==0){ + $scope.selectStatus=$scope.statusList + } + } + + + //find all same element index + function getSameElementIndex(array, element) { + var indices = []; + var idx = array.indexOf(element); + while (idx != -1) { + indices.push(idx); + idx = array.indexOf(element, idx + 1); + } + //return indices; + var result = { element: element, index: indices }; + JSON.stringify(result); + return result; + } + + //delete element in array + function deletElement(array, index) { + array.splice(index, 1); + + } + + + $scope.VersionOption = [ + { title: 'Colorado' }, + { title: 'Master' } + ]; + $scope.VersionConfig = { + create: true, + valueField: 'title', + labelField: 'title', + delimiter: '|', + maxItems: 1, + placeholder: 'Version', + onChange: function (value) { + checkElementArrayValue($scope.selection, $scope.VersionOption); + $scope.selection.push(value); + // console.log($scope.selection); + + } + + } + + $scope.LoopOption = [ + { title: 'Daily' }, + { title: 'Weekly' }, + { title: 'Monthly' } + ]; + $scope.LoopConfig = { + create: true, + valueField: 'title', + labelField: 'title', + delimiter: '|', + maxItems: 1, + placeholder: 'Loop', + onChange: function (value) { + checkElementArrayValue($scope.selection, $scope.LoopOption); + $scope.selection.push(value); + // console.log($scope.selection); + + } + } + + $scope.TimeOption = [ + { title: '10 days' }, + { title: '1 month' } + ]; + $scope.TimeConfig = { + create: true, + valueField: 'title', + labelField: 'title', + delimiter: '|', + maxItems: 1, + placeholder: 'Time', + onChange: function (value) { + checkElementArrayValue($scope.selection, $scope.TimeOption); + $scope.selection.push(value); + // console.log($scope.selection) + + } + } + + //remove element in the array + function removeArrayValue(arr, value) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == value) { + arr.splice(i, 1); + break; + } + } + } + + //check if exist element + function checkElementArrayValue(arrayA, arrayB) { + for (var i = 0; i < arrayB.length; i++) { + if (arrayA.indexOf(arrayB[i].title) > -1) { + removeArrayValue(arrayA, arrayB[i].title); + } + } + } + + function toggleSelection(status) { + var idx = $scope.selection.indexOf(status); + + if (idx > -1) { + $scope.selection.splice(idx, 1); + } + else { + $scope.selection.push(status); + } + console.log($scope.selection); + filterData(); + + } + + }]); diff --git a/utils/test/reporting/pages/app/scripts/data.json b/utils/test/reporting/pages/app/scripts/data.json new file mode 100644 index 000000000..a15fdf37e --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/data.json @@ -0,0 +1,76 @@ + +{"scenarios": { + "os-nosdn-kvm-noha": { + "status": "Success", + "installers": { + "apex": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "socre": "13/14", + "status": "SUCCESS" + } + ], + "compass": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "socre": "13/14", + "status": "SUCCESS" + } + ], + "fuel": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "socre": "13/14", + "status": "SUCCESS" + } + ], + "joid": [ + { + "project": "Deployment", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Functest", + "score": "13/14", + "status": "SUCCESS" + }, + { + "project": "Yardstick", + "socre": "13/14", + "status": "SUCCESS" + } + ] + } + } +}} diff --git a/utils/test/reporting/pages/app/scripts/directives/mydirective.js b/utils/test/reporting/pages/app/scripts/directives/mydirective.js new file mode 100644 index 000000000..1d7177a56 --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/directives/mydirective.js @@ -0,0 +1,18 @@ +'use strict'; + +/** + * @ngdoc directive + * @name opnfvApp.directive:myDirective + * @description + * # myDirective + */ +angular.module('opnfvApp') + .directive('myDirective', function () { + return { + template: '<div></div>', + restrict: 'E', + link: function postLink(scope, element, attrs) { + element.text('this is the myDirective directive'); + } + }; + }); diff --git a/utils/test/reporting/pages/app/scripts/factory/table.factory.js b/utils/test/reporting/pages/app/scripts/factory/table.factory.js new file mode 100644 index 000000000..22443221e --- /dev/null +++ b/utils/test/reporting/pages/app/scripts/factory/table.factory.js @@ -0,0 +1,20 @@ +'use strict'; + +/** + * get data factory + */ +angular.module('opnfvApp') + .factory('TableFactory', function ($resource, $rootScope) { + // var baseUrl = base_Url; + + return { + getFilter: function () { + return $resource(baseUrl + '/', {}, { + 'post': { + method: 'POST', + + } + }); + } + }; + }); |