///
///
///
module Configs{
export var TableEdit = controller('TableEdit', ['$scope', ($scope) => {
$scope.editRow = (entity)=>{
$scope.$emit('editRow', entity);
}
$scope.deleteRowOne ={
show: false,
item: null,
open: (entity) => {
var deleteRowOne = $scope.deleteRowOne;
deleteRowOne.show = true;
deleteRowOne.item = entity;
},
onOk: () => {
var deleteRowOne = $scope.deleteRowOne;
$scope.$emit('deleteRow', deleteRowOne.item);
},
onCancel: () => {
var deleteRowOne = $scope.deleteRowOne;
deleteRowOne.show = false;
deleteRowOne.item = null;
}
}
}]);
export var VolumeController = controller('VolumeController', ['$scope', '$http', ($scope, $http) => {
$scope.status = $scope.ngDialogData.status;
$scope.save = (entity) =>{
changeStatus(entity);
$scope.closeThisDialog();
}
$scope. cancel = () =>{
$scope.closeThisDialog();
}
$scope.deleteBrock = (volume:volume, brock) => {
if(volume.brick.length>1)
deleteBrock(volume, brock);
else
$scope.showMessage = true;
}
$scope.addBrock = (volume) => {
var block = {
ip: "", //存储块的机器ip地址
path: "", //存储块路径
status: false, //存储块的状态
editable:true
};
addBrock(volume, block);
$scope.showMessage = false;
}
$scope.stopVolume = (volume) =>{
volume.status = false;
}
$scope.startVolume = (volume) =>{
volume.status = true;
}
function changeStatus(entity){
angular.forEach(entity.brick, (brick) =>{
var ip = [];
if(brick["ip"] instanceof Object){
for(var key in brick["ip"])
ip.push(brick["ip"][key]);
brick["ip"] = ip.join("\.");
}
});
$http({
url: "/java/console/api/volume/update",
method: 'POST',
data: entity
}).success(function(data,header,config,status){
/*
更新volume信息
*/
}).error(function(data,header,config,status){
});
}
}]);
}