3 angular.module('yardStickGui2App')
4 .controller('TaskController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', 'ngDialog',
5 function($scope, $state, $stateParams, mainFactory, Upload, toaster, ngDialog) {
12 getDetailTaskForList();
16 function getDetailTaskForList() {
17 mainFactory.getTaskDetail().get({
18 'taskId': $stateParams.taskId
19 }).$promise.then(function(response) {
20 if (response.status == 1) {
21 if (response.result.task.status == -1) {
22 response.result.task['stausWidth'] = '5%';
23 } else if (response.result.task.status == 0) {
24 response.result.task['stausWidth'] = '50%';
25 } else if (response.result.task.status == 1) {
26 response.result.task['stausWidth'] = '100%';
27 } else if (response.result.task.status == 2) {
28 response.result.task['stausWidth'] = 'red';
31 $scope.taskDetailData = response.result.task;
32 if ($scope.taskDetailData.environment_id != null) {
33 getItemIdDetail($scope.taskDetailData.environment_id);
48 function getItemIdDetail(id) {
49 mainFactory.ItemDetail().get({
51 }).$promise.then(function(response) {
52 if (response.status == 1) {
53 $scope.displayEnv = response.result.environment;
55 if (response.result.environment.pod_id != null) {
56 getPodDetail(response.result.environment.pod_id);
57 } else if (response.result.environment.image_id != null) {
58 getImageDetail(response.result.environment.image_id);
59 } else if (response.result.environment.openrc_id != null) {
60 getOpenrcDetail(response.result.environment.openrc_id != null);
61 } else if (response.result.environment.container_id.length != 0) {
62 $scope.displayContainerDetail = [];
63 var containerArray = response.result.environment.container_id;
64 for (var i = 0; i < containerArray.length; i++) {
65 getContainerId(containerArray[i]);
73 body: response.error_msg,
88 function getOpenrcDetail(openrcId) {
89 mainFactory.getEnvironmentDetail().get({
91 }).$promise.then(function(response) {
93 $scope.openrcInfo = response.result;
94 // buildToEnvInfo($scope.openrcInfo.openrc)
95 }, function(response) {
102 function getImageDetail(id) {
103 mainFactory.ImageDetail().get({
105 }).$promise.then(function(response) {
106 if (response.status == 1) {
107 $scope.imageDetail = response.result.image;
114 body: 'unknow error',
121 function getPodDetail(id) {
122 mainFactory.podDeatil().get({
124 }).$promise.then(function(response) {
125 if (response.status == 1) {
126 $scope.podDetail = response.result.pod;
132 body: 'unknow error',
138 function getContainerId(containerId) {
139 mainFactory.containerDetail().get({
140 'containerId': containerId
141 }).$promise.then(function(response) {
142 if (response.status == 1) {
143 $scope.container = response.result.container;
144 $scope.displayContainerDetail.push($scope.container);
150 body: response.error_msg,
158 body: 'unknow error',
163 $scope.goBack = function goBack() {
164 window.history.back();