Merge "Add spec cpu2006 test case"
[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
15             $scope.$watch(function() {
16                 return location.hash
17             }, function(newvalue, oldvalue) {
18                 if (location.hash.indexOf('project') > -1) {
19                     $scope.projectShow = true;
20                     $scope.taskShow = false;
21                     $scope.reportShow = false;
22                 } else if (location.hash.indexOf('task') > -1) {
23                     $scope.taskShow = true;
24                     $scope.projectShow = true;
25                 } else if (location.hash.indexOf('report') > -1) {
26                     $scope.reportShow = true;
27                     $scope.taskShow = true;
28                     $scope.projectShow = true;
29                 }
30
31             })
32
33
34             function init() {
35
36
37                 $scope.showEnvironments = showEnvironments;
38                 $scope.showSteps = $location.path().indexOf('project');
39                 $scope.test = test;
40                 $scope.gotoUploadPage = gotoUploadPage;
41                 $scope.gotoOpenrcPage = gotoOpenrcPage;
42                 $scope.gotoPodPage = gotoPodPage;
43                 $scope.gotoContainerPage = gotoContainerPage;
44                 $scope.gotoTestcase = gotoTestcase;
45                 $scope.gotoEnviron = gotoEnviron;
46                 $scope.gotoSuite = gotoSuite;
47                 $scope.gotoProject = gotoProject;
48                 $scope.gotoTask = gotoTask;
49                 $scope.gotoReport = gotoReport;
50                 $scope.stepsStatus = $localStorage.stepsStatus;
51                 $scope.goBack = goBack;
52
53
54             }
55
56
57
58             function showEnvironments() {
59                 $scope.showEnvironment = true;
60             }
61
62             function test() {
63                 alert('test');
64             }
65
66             function gotoOpenrcPage() {
67                 $scope.path = $location.path();
68                 $scope.uuid = $scope.path.split('/').pop();
69                 $state.go('app.environmentDetail', { uuid: $scope.uuid })
70             }
71
72             function gotoUploadPage() {
73                 $scope.path = $location.path();
74                 $scope.uuid = $scope.path.split('/').pop();
75                 $state.go('app.uploadImage', { uuid: $scope.uuid });
76             }
77
78             function gotoPodPage() {
79                 $scope.path = $location.path();
80                 $scope.uuid = $scope.path.split('/').pop();
81                 $state.go('app.podUpload', { uuid: $scope.uuid });
82             }
83
84             function gotoContainerPage() {
85                 $scope.path = $location.path();
86                 $scope.uuid = $scope.path.split('/').pop();
87                 $state.go('app.container', { uuid: $scope.uuid });
88             }
89
90             function gotoTestcase() {
91                 $state.go('app2.testcase');
92             }
93
94             function gotoEnviron() {
95                 if ($location.path().indexOf('env') > -1 || $location.path().indexOf('environment') > -1) {
96                     $scope.counldGoDetail = true;
97                 }
98                 $state.go('app2.environment');
99             }
100
101             function gotoSuite() {
102                 $state.go('app2.testsuite');
103             }
104
105             function gotoProject() {
106                 $state.go('app2.projectList');
107             }
108
109             function gotoTask() {
110                 $state.go('app2.tasklist');
111             }
112
113             function gotoReport() {
114                 $state.go('app2.report');
115             }
116
117             function goBack() {
118                 if ($location.path().indexOf('main/environment')) {
119                     return;
120                 } else if ($location.path().indexOf('main/envDetail/') || $location.path().indexOf('main/imageDetail/') ||
121                     $location.path().indexOf('main/podupload/') || $location.path().indexOf('main/container/')) {
122                     $state.go('app2.environment');
123                     return;
124                 } else {
125                     window.history.back();
126                 }
127
128             }
129
130
131
132
133
134
135         }
136     ]);