3 angular.module('yardStickGui2App')
4 .controller('PodController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', '$location', 'ngDialog',
5 function($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, ngDialog) {
9 $scope.showloading = false;
10 $scope.loadingOPENrc = false;
15 $scope.uuid = $stateParams.uuid;
16 $scope.uploadFiles = uploadFiles;
21 function getItemIdDetail() {
22 mainFactory.ItemDetail().get({
24 }).$promise.then(function(response) {
25 if (response.status == 1) {
26 $scope.name = response.result.environment.name;
27 $scope.podId = response.result.environment.pod_id;
28 if ($scope.podId != null) {
29 getPodDetail($scope.podId);
31 $scope.podData = null;
45 function getPodDetail(id) {
46 mainFactory.getPodDetail().get({
48 }).$promise.then(function(response) {
49 if (response.status == 1) {
50 $scope.podData = response.result;
65 function uploadFiles($file, $invalidFiles) {
66 $scope.loadingOPENrc = true;
68 $scope.displayOpenrcFile = $file;
69 timeConstruct($scope.displayOpenrcFile.lastModified);
71 url: Base_URL + '/api/v2/yardstick/pods',
72 data: { file: $file, 'environment_id': $scope.uuid, 'action': 'upload_pod_file' }
73 }).then(function(response) {
75 $scope.loadingOPENrc = false;
76 if (response.data.status == 1) {
79 title: 'upload success',
80 body: 'you can go next step',
84 $scope.podData = response.data.result;
94 $scope.uploadfile = null;
104 function timeConstruct(array) {
105 var date = new Date(1398250549490);
106 var Y = date.getFullYear() + '-';
107 var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
108 var D = date.getDate() + ' ';
109 var h = date.getHours() + ':';
110 var m = date.getMinutes() + ':';
111 var s = date.getSeconds();
112 $scope.filelastModified = Y + M + D + h + m + s;
115 $scope.goBack = function goBack() {
116 $state.go('app2.projectList');
120 $scope.goNext = function goNext() {
121 $scope.path = $location.path();
122 $scope.uuid = $scope.path.split('/').pop();
123 $state.go('app.container', { uuid: $scope.uuid });
126 $scope.openDeleteEnv = function openDeleteEnv(id, name) {
127 $scope.deleteName = name;
128 $scope.deleteId = id;
130 template: 'views/modal/deleteConfirm.html',
132 className: 'ngdialog-theme-default',
135 closeByDocument: false
140 $scope.deletePod = function deletePod() {
141 mainFactory.deletePod().delete({ 'podId': $scope.podId }).$promise.then(function(response) {
142 if (response.status == 1) {
145 title: 'delete pod success',
146 body: 'you can go next step',
150 $scope.uuid = $stateParams.uuid;
151 $scope.uploadFiles = uploadFiles;
152 $scope.displayOpenrcFile = null;
158 body: response.result,
167 body: 'unknow error',