Merge "Add common openstack opertation scenarios: network"
[yardstick.git] / gui / app / scripts / controllers / testsuit.controller.js
1 'use strict';
2
3 angular.module('yardStickGui2App')
4     .controller('SuiteListController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', 'ngDialog', '$loading',
5         function($scope, $state, $stateParams, mainFactory, Upload, toaster, ngDialog, $loading) {
6
7
8             init();
9
10
11             function init() {
12                 $scope.testsuitlist = [];
13                 getsuiteList();
14                 $scope.gotoDetail = gotoDetail;
15                 $scope.gotoCreateSuite = gotoCreateSuite;
16
17
18             }
19
20             function getsuiteList() {
21                 $loading.start('key');
22                 mainFactory.suiteList().get({
23
24                 }).$promise.then(function(response) {
25                     $loading.finish('key');
26                     if (response.status == 1) {
27                         $scope.testsuitlist = response.result.testsuites;
28
29                     }
30                 }, function(error) {
31                     $loading.finish('key');
32                     toaster.pop({
33                         type: 'error',
34                         title: 'fail',
35                         body: 'unknow error',
36                         timeout: 3000
37                     });
38                 })
39             }
40
41             function gotoDetail(name) {
42                 var temp = name.split('.')[0];
43
44                 $state.go('app.suitedetail', { name: temp })
45
46             }
47
48             function gotoCreateSuite() {
49                 $state.go('app.suitcreate');
50             }
51
52             $scope.goBack = function goBack() {
53                 $state.go('app.projectList');
54             }
55
56
57             $scope.openDeleteEnv = function openDeleteEnv(id, name) {
58                 $scope.deleteName = name;
59                 $scope.deleteId = id.split('.')[0];
60                 ngDialog.open({
61                     template: 'views/modal/deleteConfirm.html',
62                     scope: $scope,
63                     className: 'ngdialog-theme-default',
64                     width: 500,
65                     showClose: true,
66                     closeByDocument: false
67                 })
68
69             }
70
71             $scope.deleteSuite = function deleteSuite() {
72                 mainFactory.deleteTestSuite().delete({ 'suite_name': $scope.deleteId }).$promise.then(function(response) {
73                     if (response.status == 1) {
74                         toaster.pop({
75                             type: 'success',
76                             title: 'delete Test Suite success',
77                             body: 'you can go next step',
78                             timeout: 3000
79                         });
80                         ngDialog.close();
81                         getTestcaseList();
82                     } else {
83                         toaster.pop({
84                             type: 'error',
85                             title: 'Wrong',
86                             body: response.result,
87                             timeout: 3000
88                         });
89                     }
90
91                 }, function(error) {
92                     toaster.pop({
93                         type: 'error',
94                         title: 'fail',
95                         body: 'unknow error',
96                         timeout: 3000
97                     });
98                 })
99             }
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118         }
119     ]);