Merge "Sample ACL VNF"
[yardstick.git] / gui / app / scripts / controllers / report.controller.js
1 'use strict';
2
3 angular.module('yardStickGui2App')
4     .controller('ReportController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', 'ngDialog',
5         function($scope, $state, $stateParams, mainFactory, Upload, toaster, ngDialog) {
6
7
8             init();
9
10
11             function init() {
12                 getDetailTaskForList();
13
14
15
16             }
17             $scope.goBack = function goBack() {
18                 window.history.back();
19             }
20
21             function getDetailTaskForList(id) {
22                 mainFactory.getTaskDetail().get({
23                     'taskId': $stateParams.taskId
24                 }).$promise.then(function(response) {
25                     if (response.status == 1) {
26                         if (response.result.task.status == -1) {
27                             response.result.task['stausWidth'] = '5%';
28                         } else if (response.result.task.status == 0) {
29                             response.result.task['stausWidth'] = '50%';
30                         } else if (response.result.task.status == 1) {
31                             response.result.task['stausWidth'] = '100%';
32                         } else if (response.result.task.status == 2) {
33                             response.result.task['stausWidth'] = 'red';
34                         }
35                         $scope.result = response.result.task;
36                         $scope.testcaseinfo = response.result.task.result.testcases;
37                         var key = Object.keys($scope.testcaseinfo);
38                         $scope.testcaseResult = $scope.testcaseinfo[key];
39
40                         $scope.envIdForTask = response.result.task.environment_id;
41                         getItemIdDetail();
42
43
44                     }
45                 }, function(error) {
46                     toaster.pop({
47                         type: 'error',
48                         title: 'fail',
49                         body: 'unknow error',
50                         timeout: 3000
51                     });
52
53                 })
54             }
55
56             $scope.goToExternal = function goToExternal(id) {
57                 var url = Grafana_URL +':'+$scope.jumpPort+'/dashboard/db'+ '/' + id;
58
59                 window.open(url, '_blank');
60             }
61
62             function getItemIdDetail() {
63                 $scope.displayContainerInfo = [];
64                 mainFactory.ItemDetail().get({
65                     'envId': $scope.envIdForTask
66                 }).$promise.then(function(response) {
67                     if (response.status == 1) {
68                         if (response.result.environment.container_id.grafana != null) {
69                             getConDetail(response.result.environment.container_id.grafana);
70
71                         } else {
72                             $scope.jumpPort = 3000;
73                         }
74
75
76                     }
77                 }, function(error) {
78                     toaster.pop({
79                         type: 'error',
80                         title: 'fail',
81                         body: 'unknow error',
82                         timeout: 3000
83                     });
84                 })
85             }
86
87             function getConDetail(id) {
88                 mainFactory.containerDetail().get({
89                     'containerId': id
90                 }).$promise.then(function(response) {
91                     if (response.status == 1) {
92                         // $scope.podData = response.result;
93                         $scope.jumpPort = response.result.container.port;
94
95                     }
96
97                 }, function(error) {
98                     toaster.pop({
99                         type: 'error',
100                         title: 'fail',
101                         body: 'unknow error',
102                         timeout: 3000
103                     });
104                 })
105
106             }
107
108
109
110
111
112
113
114         }
115     ]);