Merge "Remove redundancy file and do relative modification"
[yardstick.git] / gui / app / scripts / controllers / content.controller.js
1 'use strict';
2
3 angular.module('yardStickGui2App')
4     .controller('ContentController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', '$location', '$localStorage',
5         function ($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, $localStorage) {
6
7
8
9
10             init();
11             $scope.showEnvironment = false;
12             $scope.counldGoDetail = false;
13             $scope.activeStatus = 0;
14             $scope.ifshowEnvChild = false;
15
16             $scope.$watch(function () {
17                 return location.hash
18             }, function (newvalue, oldvalue) {
19                 if (location.hash.indexOf('project') > -1) {
20                     $scope.projectShow = true;
21                     $scope.taskShow = false;
22                     $scope.reportShow = false;
23                 } else if (location.hash.indexOf('task') > -1) {
24                     $scope.taskShow = true;
25                     $scope.projectShow = true;
26                 } else if (location.hash.indexOf('report') > -1) {
27                     $scope.reportShow = true;
28                     $scope.taskShow = true;
29                     $scope.projectShow = true;
30                 } else if (location.hash.indexOf('envDetail') > -1 || location.hash.indexOf('envimageDetail') > -1 ||
31                     location.hash.indexOf('envpodupload') > -1 || location.hash.indexOf('envcontainer') > -1) {
32                     $scope.ifshowEnvChild = true;
33                     $scope.activeStatus=0;
34                 }else{
35                     $scope.ifshowEnvChild=false;
36                     $scope.activeStatus=-1;
37                 }
38
39             })
40
41
42             function init() {
43
44
45                 $scope.showEnvironments = showEnvironments;
46                 $scope.showSteps = $location.path().indexOf('project');
47                 $scope.test = test;
48                 $scope.gotoUploadPage = gotoUploadPage;
49                 $scope.gotoOpenrcPage = gotoOpenrcPage;
50                 $scope.gotoPodPage = gotoPodPage;
51                 $scope.gotoContainerPage = gotoContainerPage;
52                 $scope.gotoTestcase = gotoTestcase;
53                 $scope.gotoEnviron = gotoEnviron;
54                 $scope.gotoSuite = gotoSuite;
55                 $scope.gotoProject = gotoProject;
56                 $scope.gotoTask = gotoTask;
57                 $scope.gotoReport = gotoReport;
58                 $scope.stepsStatus = $localStorage.stepsStatus;
59                 $scope.goBack = goBack;
60
61
62             }
63
64
65
66             function showEnvironments() {
67                 $scope.showEnvironment = true;
68             }
69
70             function test() {
71                 alert('test');
72             }
73
74             function gotoOpenrcPage() {
75                 $scope.path = $location.path();
76                 $scope.uuid = $scope.path.split('/').pop();
77                 $state.go('app.environmentDetail', { uuid: $scope.uuid })
78             }
79
80             function gotoUploadPage() {
81                 $scope.path = $location.path();
82                 $scope.uuid = $scope.path.split('/').pop();
83                 $state.go('app.uploadImage', { uuid: $scope.uuid });
84             }
85
86             function gotoPodPage() {
87                 $scope.path = $location.path();
88                 $scope.uuid = $scope.path.split('/').pop();
89                 $state.go('app.podUpload', { uuid: $scope.uuid });
90             }
91
92             function gotoContainerPage() {
93                 $scope.path = $location.path();
94                 $scope.uuid = $scope.path.split('/').pop();
95                 $state.go('app.container', { uuid: $scope.uuid });
96             }
97
98             function gotoTestcase() {
99                 $state.go('app.testcase');
100             }
101
102             function gotoEnviron() {
103                 if ($location.path().indexOf('env') > -1 || $location.path().indexOf('environment') > -1) {
104                     $scope.counldGoDetail = true;
105                 }
106                 $state.go('app.environment');
107             }
108
109             function gotoSuite() {
110                 $state.go('app.testsuite');
111             }
112
113             function gotoProject() {
114                 $state.go('app.projectList');
115             }
116
117             function gotoTask() {
118                 $state.go('app.tasklist');
119             }
120
121             function gotoReport() {
122                 $state.go('app.report');
123             }
124
125             function goBack() {
126                 if ($location.path().indexOf('main/environment')) {
127                     return;
128                 } else if ($location.path().indexOf('main/envDetail/') || $location.path().indexOf('main/imageDetail/') ||
129                     $location.path().indexOf('main/podupload/') || $location.path().indexOf('main/container/')) {
130                     $state.go('app.environment');
131                     return;
132                 } else {
133                     window.history.back();
134                 }
135
136             }
137
138
139
140
141
142
143         }
144     ]);