3 angular.module('yardStickGui2App')
4 .controller('TestcaseController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', 'ngDialog', '$loading',
5 function($scope, $state, $stateParams, mainFactory, Upload, toaster, ngDialog, $loading) {
9 $scope.loadingOPENrc = false;
13 $scope.testcaselist = [];
15 $scope.gotoDetail = gotoDetail;
16 $scope.uploadFiles = uploadFiles;
21 function getTestcaseList() {
22 $loading.start('key');
23 mainFactory.getTestcaselist().get({
25 }).$promise.then(function(response) {
26 $loading.finish('key');
27 if (response.status == 1) {
28 $scope.testcaselist = response.result;
33 $loading.finish('key');
43 function gotoDetail(name) {
44 $state.go('app2.testcasedetail', { name: name });
48 function uploadFiles($file, $invalidFiles) {
49 $scope.loadingOPENrc = true;
51 $scope.displayOpenrcFile = $file;
52 timeConstruct($scope.displayOpenrcFile.lastModified);
54 url: Base_URL + '/api/v2/yardstick/testcases',
55 data: { file: $file, 'action': 'upload_case' }
56 }).then(function(response) {
58 $scope.loadingOPENrc = false;
59 if (response.data.status == 1) {
62 title: 'upload success',
63 body: 'you can go next step',
74 $scope.uploadfile = null;
84 function timeConstruct(array) {
85 var date = new Date(1398250549490);
86 var Y = date.getFullYear() + '-';
87 var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
88 var D = date.getDate() + ' ';
89 var h = date.getHours() + ':';
90 var m = date.getMinutes() + ':';
91 var s = date.getSeconds();
92 $scope.filelastModified = Y + M + D + h + m + s;
95 $scope.goBack = function goBack() {
96 $state.go('app2.projectList');
99 $scope.openDeleteEnv = function openDeleteEnv(id, name) {
100 $scope.deleteName = name;
101 $scope.deleteId = id;
103 template: 'views/modal/deleteConfirm.html',
105 className: 'ngdialog-theme-default',
108 closeByDocument: false
113 $scope.deleteTestCase = function deleteTestCase() {
114 mainFactory.deleteTestCase().delete({ 'caseName': $scope.deleteId }).$promise.then(function(response) {
115 if (response.status == 1) {
118 title: 'delete Test Case success',
119 body: 'you can go next step',
128 body: response.result,
137 body: 'unknow error',