summaryrefslogtreecommitdiffstats
path: root/reporting/pages/app/scripts/controllers/gating.controller.js
blob: 52b381daa6163a915200f60e518ae5977079886e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict';

angular.module('opnfvApp')
    .controller('GatingController', ['$scope', '$state', '$stateParams', 'TableFactory', function($scope, $state, $stateParams, TableFactory) {

        init();

        function init() {
            $scope.goTest = goTest;
            $scope.goLogin = goLogin;

            $scope.scenarios = {};

            $scope.scenarioList = _toSelectList(['all']);
            $scope.versionList = _toSelectList(['master', 'fraser', 'gambia']);
            $scope.installerList = _toSelectList(['all', 'apex', 'compass', 'daisy', 'fuel', 'joid']);
            $scope.iterationList = _toSelectList([10, 20, 30]);

            $scope.selectScenario = 'all';
            $scope.selectVersion = 'master';
            $scope.selectInstaller = 'all';
            $scope.selectIteration = 10;

            $scope.ScenarioConfig = {
                create: true,
                valueField: 'title',
                labelField: 'title',
                delimiter: '|',
                maxItems: 1,
                placeholder: 'Scenario',
                onChange: function(value) {
                    $scope.selectScenario = value;
                }
            }

            $scope.VersionConfig = {
                create: true,
                valueField: 'title',
                labelField: 'title',
                delimiter: '|',
                maxItems: 1,
                placeholder: 'Version',
                onChange: function(value) {
                    $scope.selectVersion = value;
                    getScenarioResult();
                }
            }

            $scope.InstallerConfig = {
                create: true,
                valueField: 'title',
                labelField: 'title',
                delimiter: '|',
                maxItems: 1,
                placeholder: 'Installer',
                onChange: function(value) {
                    $scope.selectInstaller = value;
                    getScenarioResult();
                }
            }

            $scope.IterationConfig = {
                create: true,
                valueField: 'title',
                labelField: 'title',
                delimiter: '|',
                maxItems: 1,
                placeholder: 'Iteration',
                onChange: function(value) {
                    $scope.selectIteration = value;
                    getScenarioResult();
                }
            }
            getScenarioResult();
        }

        function getScenarioResult(){
            _getScenarioResult($scope.selectVersion, $scope.selectInstaller, $scope.selectIteration);
        }

        function _getScenarioResult(version, installer, iteration){
            var data = {
                'version': version,
                'iteration': iteration
            }

            if(installer != 'all'){
                data['installer'] = installer;
            }

            TableFactory.getScenarioResult().get(data).$promise.then(function(resp){
                $scope.scenarios = resp;
                _concat($scope.scenarioList, _toSelectList(Object.keys(resp)));
            }, function(err){
            });
        }

        function _concat(aList, bList){
            angular.forEach(bList, function(ele){
                aList.push(ele);
            });
        }

        function _toSelectList(arr){
            var tempList = [];
            angular.forEach(arr, function(ele){
                tempList.push({'title': ele});
            });
            return tempList;
        }

        function goTest() {
            $state.go("select.selectTestCase");
        }

        function goLogin() {
            $state.go("login");
        }
    }]);