3 angular.module('yardStickGui2App')
4 .controller('ContainerController', ['$scope', '$state', '$stateParams', 'mainFactory', 'Upload', 'toaster', 'ngDialog',
5 function($scope, $state, $stateParams, mainFactory, Upload, toaster, ngDialog) {
9 $scope.showloading = false;
11 $scope.displayContainerInfo = [];
12 $scope.containerList = [{ value: 'create_influxdb', name: "InfluxDB" }, { value: 'create_grafana', name: "Grafana" }]
17 $scope.uuid = $stateParams.uuid;
18 $scope.createContainer = createContainer;
19 $scope.openChooseContainnerDialog = openChooseContainnerDialog;
26 function getItemIdDetail() {
27 $scope.displayContainerInfo = [];
28 mainFactory.ItemDetail().get({
30 }).$promise.then(function(response) {
31 if (response.status == 1) {
32 $scope.envName = response.result.environment.name;
33 $scope.containerId = response.result.environment.container_id;
34 if ($scope.containerId != null) {
36 var keysArray = Object.keys($scope.containerId);
37 for (var k in $scope.containerId) {
38 getConDetail($scope.containerId[k]);
41 $scope.podData = null;
55 function getConDetail(id) {
56 mainFactory.containerDetail().get({
58 }).$promise.then(function(response) {
59 if (response.status == 1) {
60 // $scope.podData = response.result;
61 response.result.container['id'] = id;
62 $scope.displayContainerInfo.push(response.result.container);
77 function createContainer() {
79 $scope.showloading = true;
80 mainFactory.runAcontainer().post({
81 'action': $scope.selectContainer.value,
83 'environment_id': $scope.uuid,
85 }).$promise.then(function(response) {
86 $scope.showloading = false;
87 if (response.status == 1) {
90 title: 'create container success',
91 body: 'you can go next step',
94 setTimeout(function() {
101 body: response.error_msg,
109 body: 'unknow error',
116 function openChooseContainnerDialog() {
118 template: 'views/modal/chooseContainer.html',
120 className: 'ngdialog-theme-default',
123 closeByDocument: false
127 function chooseResult(name) {
128 $scope.selectContainer = name;
130 $scope.goBack = function goBack() {
131 $state.go('app2.projectList');
134 $scope.openDeleteEnv = function openDeleteEnv(id, name) {
135 $scope.deleteName = name;
136 $scope.deleteId = id;
138 template: 'views/modal/deleteConfirm.html',
140 className: 'ngdialog-theme-default',
143 closeByDocument: false
148 $scope.deleteContainer = function deleteContainer() {
149 mainFactory.deleteContainer().delete({ 'containerId': $scope.deleteId }).$promise.then(function(response) {
150 if (response.status == 1) {
153 title: 'delete container success',
154 body: 'you can go next step',
164 body: response.error_msg,
173 body: 'unknow error',