3 angular.module('yardStickGui2App')
4 .controller('ImageController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', '$location', '$interval',
5 function($scope, $state, $stateParams, mainFactory, Upload, toaster, $location, $interval) {
9 $scope.showloading = false;
10 $scope.ifshowStatus = 0;
15 $scope.uuid = $stateParams.uuid;
16 $scope.uploadImage = uploadImage;
21 function getItemIdDetail() {
22 mainFactory.ItemDetail().get({
23 'envId': $stateParams.uuid
24 }).$promise.then(function(response) {
25 if (response.status == 1) {
26 $scope.baseElementInfo = response.result.environment;
33 body: response.error_msg,
47 function getImageListSimple() {
49 mainFactory.ImageList().get({}).$promise.then(function(response) {
50 if (response.status == 1) {
51 $scope.imageListData = response.result.images;
52 // $scope.imageStatus = response.result.status;
57 title: 'get data failed',
65 title: 'get data failed',
73 function getImageList() {
74 if ($scope.intervalImgae != undefined) {
75 $interval.cancel($scope.intervalImgae);
77 mainFactory.ImageList().get({}).$promise.then(function(response) {
78 if (response.status == 1) {
79 $scope.imageListData = response.result.images;
80 $scope.imageStatus = response.result.status;
82 if ($scope.imageStatus == 0) {
83 $scope.intervalImgae = $interval(function() {
86 } else if ($scope.intervalImgae != undefined) {
87 $interval.cancel($scope.intervalImgae);
93 title: 'get data failed',
101 title: 'get data failed',
102 body: 'please retry',
108 function uploadImage() {
109 $scope.imageStatus = 0;
110 $interval.cancel($scope.intervalImgae);
111 $scope.ifshowStatus = 1;
112 $scope.showloading = true;
113 mainFactory.uploadImage().post({
114 'action': 'load_image',
116 'environment_id': $scope.uuid
119 }).$promise.then(function(response) {
120 $scope.showloading = false;
121 if (response.status == 1) {
124 title: 'create success',
125 body: 'you can go next step',
128 setTimeout(function() {
136 body: 'something wrong',
145 body: 'something wrong',
151 $scope.goBack = function goBack() {
152 $state.go('app2.projectList');
155 $scope.goNext = function goNext() {
156 $scope.path = $location.path();
157 $scope.uuid = $scope.path.split('/').pop();
158 $state.go('app.podUpload', { uuid: $scope.uuid });