///
///
///
///
///
///
///
///
module Configs{
export var GfsController = controller('GfsController', ["$scope", "$templateCache", "$location", "$routeParams", "$http", "$timeout", 'ConfigsModel', 'ngDialog',
($scope, $templateCache:ng.ITemplateCacheService, $location, $routeParams, $http, $timeout, ConfigsModel, ngDialog) =>{
$scope.model = ConfigsModel;
$scope.volumes = ConfigsModel.cluster;
shareInit($scope, $location, $routeParams);
$scope.createGfs = () => {
ngDialog.open({
template: 'newDialog.html',
controller:'Configs.VolumeController',
width: 1005,
scope: $scope,
closeByDocument : false,
data: {
name: '',
path: '',
status: true,
brick: [{
ip: ["0", "0", "0", "0"],
path: '',
status: false,
editable: true
}],
editable: true
},
className: 'ngdialog-theme-default'
});
}
$scope.editRow = (volume) => {
var fVolume = formatVolume(volume);
ngDialog.open({
template: 'newDialog.html',
width: 1005,
data: fVolume,
scope: $scope,
className: 'ngdialog-theme-default',
controller: 'Configs.VolumeController',
closeByDocument : false
});
}
$scope.showDeleteVolume = {
show: false,
item: null,
open: (entity) => {
var showDeleteVolume = $scope.showDeleteVolume;
showDeleteVolume.show = true;
showDeleteVolume.item = entity;
},
onOk: () => {
var showDeleteVolume = $scope.showDeleteVolume;
$timeout(() =>{
console.log(showDeleteVolume.item);
var spinner;
$.ajax({
type: "POST",
url: "/java/console/api/volume/delete",
timeout: 8000,
dataType: 'json',
//async: false,
data: JSON.stringify(showDeleteVolume.item),
contentType: "application/json; charset=utf-8",
beforeSend: () => {
Configs.create_mask(); //创建遮罩层
Kubernetes.create_locadEffect("正在更新云盘信息,请稍等!"); //创建数据加载效果层
var target = document.getElementById('loading')
spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
},
complete: (XMLHttpRequest, textStatus) => {
if(XMLHttpRequest.status == 200){
Kubernetes.createSuccessInfo("success", "更新成功!");
setTimeout("Kubernetes.removeMask()", 1500);
//$scope.model.updateVolumeData();
}else{
Kubernetes.createSuccessInfo("error", "更新失败!");
setTimeout("Kubernetes.removeMask()", 1500);
}
},
success: (data) => {
if(data){
ConfigsModel.cluster = data;
Configs.formatVolumes(ConfigsModel.cluster);
$scope.$apply(() =>{
$scope.volumes = ConfigsModel.cluster;
});
}
}
});
/*$http({
url: "/java/console/api/volume/delete",
method: 'POST',
data: showDeleteVolume.item
}).success(function(data,header,config,status){
/*
更新volume信息
*/
/*$scope.model.updateVolumeData();
}).error(function(data,header,config,status){
Configs.customAlert("提示", "删除Volume失败!", '',null, 0, "error");
});*/
}, 100);
},
onCancel: () =>{
var showDeleteVolume = $scope.showDeleteVolume;
showDeleteVolume.show = false;
showDeleteVolume.item = null;
}
}
$scope.$on('update', (event, data) => {
angular.forEach(data["brick"], (brick) =>{
var ip = [];
if(brick["ip"] instanceof Object){
for(var key in brick["ip"])
ip.push(brick["ip"][key]);
brick["ip"] = ip.join("\.");
}
});
var spinner;
$.ajax({
type: "POST",
url: "/java/console/api/volume/update",
timeout: 15000,
dataType: 'json',
//async: false,
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
beforeSend: () => {
Configs.create_mask(); //创建遮罩层
Kubernetes.create_locadEffect("正在更新云盘信息,请稍等!"); //创建数据加载效果层
var target = document.getElementById('loading')
spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
},
complete: (XMLHttpRequest, textStatus) => {
if(XMLHttpRequest.status == 200){
Kubernetes.createSuccessInfo("success", "更新成功!");
setTimeout("Kubernetes.removeMask()", 1500);
//$scope.model.updateVolumeData();
}else{
Kubernetes.createSuccessInfo("error", "更新失败!");
setTimeout("Kubernetes.removeMask()", 1500);
}
},
success: (data) => {
if(data){
ConfigsModel.cluster = data;
Configs.formatVolumes(ConfigsModel.cluster);
$scope.$apply(() =>{
$scope.volumes = ConfigsModel.cluster;
});
}
}
});
/*$http({
url: "/java/console/api/volume/update",
method: 'POST',
data: data
}).success(function(data,header,config,status){
$scope.model.updateVolumeData();
}).error(function(data,header,config,status){
});*/
});
}]);
}