aboutsummaryrefslogtreecommitdiffstats
path: root/gui/app/scripts/controllers/report.controller.js
blob: 9b6b5958b69a9ba037a868b663e288d3c06b4526 (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
'use strict';

angular.module('yardStickGui2App')
    .controller('ReportController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', 'ngDialog',
        function($scope, $state, $stateParams, mainFactory, Upload, toaster, ngDialog) {


            init();


            function init() {
                getDetailTaskForList();



            }
            $scope.goBack = function goBack() {
                window.history.back();
            }

            function getDetailTaskForList(id) {
                mainFactory.getTaskDetail().get({
                    'taskId': $stateParams.taskId
                }).$promise.then(function(response) {
                    if (response.status == 1) {
                        if (response.result.task.status == -1) {
                            response.result.task['stausWidth'] = '5%';
                        } else if (response.result.task.status == 0) {
                            response.result.task['stausWidth'] = '50%';
                        } else if (response.result.task.status == 1) {
                            response.result.task['stausWidth'] = '100%';
                        } else if (response.result.task.status == 2) {
                            response.result.task['stausWidth'] = 'red';
                        }
                        $scope.result = response.result.task;
                        $scope.testcaseinfo = response.result.task.result.testcases;
                        var key = Object.keys($scope.testcaseinfo);
                        $scope.testcaseResult = $scope.testcaseinfo[key];

                        $scope.envIdForTask = response.result.task.environment_id;
                        getItemIdDetail();


                    }
                }, function(error) {
                    toaster.pop({
                        type: 'error',
                        title: 'fail',
                        body: 'unknow error',
                        timeout: 3000
                    });

                })
            }

            $scope.goToExternal = function goToExternal(id) {
                var url = External_URL + ':' + $scope.jumpPort + '/dashboard/db' + '/' + id;

                window.open(url, '_blank');
            }

            function getItemIdDetail() {
                $scope.displayContainerInfo = [];
                mainFactory.ItemDetail().get({
                    'envId': $scope.envIdForTask
                }).$promise.then(function(response) {
                    if (response.status == 1) {
                        if (response.result.environment.container_id.grafana != null) {
                            getConDetail(response.result.environment.container_id.grafana);

                        } else {
                            $scope.jumpPort = 3000;
                        }


                    }
                }, function(error) {
                    toaster.pop({
                        type: 'error',
                        title: 'fail',
                        body: 'unknow error',
                        timeout: 3000
                    });
                })
            }

            function getConDetail(id) {
                mainFactory.containerDetail().get({
                    'containerId': id
                }).$promise.then(function(response) {
                    if (response.status == 1) {
                        // $scope.podData = response.result;
                        $scope.jumpPort = response.result.container.port;

                    }

                }, function(error) {
                    toaster.pop({
                        type: 'error',
                        title: 'fail',
                        body: 'unknow error',
                        timeout: 3000
                    });
                })

            }







        }
    ]);