def8e72931171e5924409d1510df36e74cbab4dd
[releng.git] / utils / test / reporting / pages / app / scripts / controllers / testvisual.controller.js
1 'use strict';
2
3 /**
4  * @ngdoc function
5  * @name opnfvdashBoardAngularApp.controller:testVisualController
6  * @description
7  * # TableController
8  * Controller of the opnfvdashBoardAngularApp
9  */
10 angular.module('opnfvApp')
11     .controller('testVisualController', ['$scope', '$state', '$stateParams', 'TableFactory', 'ngDialog', '$http', '$loading',
12         function($scope, $state, $stateParams, TableFactory, ngDialog, $http, $loading) {
13             $scope.dovet = "50,168,177,443";
14             $scope.functest = "194,173,356,442";
15             $scope.yardstick = "377,183,521,412";
16             $scope.vsperf = "542,185,640,414";
17             $scope.stor = "658,187,750,410";
18             $scope.qtip = "769,190,852,416";
19             $scope.bootleneck = "870,192,983,419";
20             $scope.noPopArea1 = "26,8,1190,180";
21             $scope.noPopArea2 = "1018,193,1190,590";
22             $scope.noPopArea3 = "37,455,1003,584";
23
24             init();
25             $scope.showSelectValue = 0;
26             $scope.scenarioList = ["os_nosdn_kvm_noha", "os_nosdn_kvm_no", "os_nosdn_kvm_"];
27
28             function init() {
29                 $scope.myTrigger = myTrigger;
30                 $scope.openTestDetail = openTestDetail;
31                 $scope.pop = pop;
32                 $scope.getDetail = getDetail;
33                 getUrl();
34
35
36
37             }
38
39             function myTrigger(name) {
40                 $loading.start('Key');
41                 $scope.tableData = null;
42                 $scope.modalName = name;
43
44                 var url = PROJECT_URL + '/projects/' + name + '/cases';
45
46                 var config = {
47                     headers: {
48                         'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
49                     }
50                 }
51                 $http.get(url, config).then(function(response) {
52                     if (response.status == 200) {
53                         $scope.tableData = response.data;
54
55                         $scope.tableData = constructObjectArray($scope.tableData);
56                         console.log($scope.tableData);
57                         $loading.finish('Key');
58
59
60
61                     }
62                 })
63             }
64
65             //construct key value for tableData
66             function constructObjectArray(array) {
67                 var templateArray = [];
68                 for (var i = 0; i < array.length; i++) {
69                     var key = Object.keys(array[i])[0];
70                     var value = array[i][key];
71                     var temp = {
72                         'key': key,
73                         'value': value
74                     };
75                     templateArray.push(temp);
76
77                 }
78
79                 return templateArray;
80             }
81
82             function getDetail(casename) {
83                 TableFactory.getProjectTestCaseDetail().get({
84                     'project': $scope.modalName,
85                     'testcase': casename
86                 }).$promise.then(function(response) {
87                     if (response != null) {
88                         $scope.name_modal = response.name;
89                         $scope.description_modal = response.description;
90                         openTestDetail();
91                     }
92                 })
93
94             }
95
96
97             function openTestDetail() {
98                 ngDialog.open({
99                     template: 'views/modal/testcasedetail.html',
100                     className: 'ngdialog-theme-default',
101                     scope: $scope,
102                     showClose: false
103                 })
104             }
105
106             function getUrl() {
107                 TableFactory.getProjectUrl().get({
108
109                 }).$promise.then(function(response) {
110                     if (response != null) {
111                         $scope.functesturl = response.functest;
112                         $scope.yardstickurl = response.yardstick;
113                         $scope.vsperfurl = response.vsperf;
114                         $scope.storperfurl = response.storperf;
115                         $scope.qtipurl = response.qtip;
116                         $scope.bottlenecksurl = response.bottlenecks;
117                         $scope.doveturl = null;
118                     }
119                 })
120             }
121
122
123
124
125
126
127
128
129
130
131         }
132     ]);