/// /// /// /// /// /// 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.submitted = false; $scope.status = $scope.ngDialogData.status; $scope. cancel = () =>{ $scope.closeThisDialog(); $scope.submitted = false; } $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; } $scope.onSubmit = (entity) => { if($scope.volumeForm.$valid){ $scope.$emit('update', entity); $scope.closeThisDialog(); }else{ $scope.submitted = true; } } }]); export var SystemInfoController = controller('SystemInfoController', ['$scope', ($scope) =>{ }]); export var SqlViewController = controller('SqlViewController', ['$scope', '$http', ($scope, $http) =>{ $scope.content = ""; getSqlContent(); function getSqlContent(){ $http({ url: "/java/console/api/filePackage/readSqlFile", method:'POST', params: {type: $scope.ngDialogData.type}, data: JSON.stringify($scope.ngDialogData.item) }).success(function(data,header,config,status){ $scope.old_content = data.data1; //响应成功 }).error(function(data,header,config,status){ //处理响应失败 $scope.old_content = "获取脚本内容失败" }); } $scope.upLoadSqlFile = () => { if(typeof FileReader == 'undefined'){ throw "浏览器不支持FileReader读取文件"; }else{ Configs.FileInputPlugin((file) =>{ $scope.enable = true; if(typeof typeof FileReader == 'undefined') throw "浏览器不支持FileReader读取文件"; else{ var fr = new FileReader(); fr.onloadend = (e) =>{ $scope.new_content = e.target["result"]; } fr.readAsText(file[0],"UTF-8"); } }); } } $scope.onOk = () => { $scope.enable = false; if(null == $scope.new_content || $scope.new_content == ""){ console.log("上传的内容不能为空"); $scope.closeThisDialog(); }else{ $scope.$emit("onOk",{ url: "/java/console/api/filePackage/handleSqlFile", item: $scope.ngDialogData.item, content: $scope.new_content, opt: "add", type: $scope.ngDialogData.type }); $scope.closeThisDialog(); /*$http({ url: "/java/console/api/filePackage/handleSqlFile", method: "POST", params: {type: $scope.ngDialogData.type}, data: JSON.stringify($scope.ngDialogData.item) }).scuess((data,header,config,status) => { }).error((data,header,config,status) => { });*/ //$scope.closeThisDialog(); } } $scope.cancel = () => { $scope.enable = false; $scope.closeThisDialog(); } }]); export var SqlAddController = controller('SqlAddController', ['$scope', '$http', ($scope, $http) => { $scope.content = null; $scope.sqlFileUpload = () =>{ Configs.FileInputPlugin((file) =>{ $scope.enable = true; if(typeof typeof FileReader == 'undefined') throw "浏览器不支持FileReader读取文件"; else{ var fr = new FileReader(); fr.onloadend = (e) =>{ $scope.content = e.target["result"]; } fr.readAsText(file[0],"UTF-8"); } }); } $scope.onOk = () => { $scope.enable = false; if(null ==$scope.content || $scope.content == ""){ console.log("上传的内容不能为空"); $scope.closeThisDialog(); } else{ $scope.$emit("onOk",{ url: "/java/console/api/filePackage/handleSqlFile", item: $scope.ngDialogData.item, content: $scope.content, opt: "add", type: $scope.ngDialogData.type }); $scope.closeThisDialog(); } $scope.cancel = () => { $scope.enable = false; $scope.closeThisDialog(); } } }]); export var sqlVerificationController = controller('sqlVerificationController', ['$scope', '$http', ($scope, $http) => { getSqlContent(); $scope.replace = () => { $scope.$emit("replace", { url: "/java/console/api/filePackage/handleSqlFile", item: $scope.ngDialogData.item, content: $scope.content, opt: "replace", type: $scope.ngDialogData.type }); $scope.closeThisDialog(); } function getSqlContent(){ $http({ url: "/java/console/api/filePackage/readSqlFile", method:'POST', params: {type: $scope.ngDialogData.type}, data: JSON.stringify($scope.ngDialogData.item) }).success(function(data,header,config,status){ $scope.standard = data.data1; $scope.unnormal = data.data2; //响应成功 }).error(function(data,header,config,status){ //处理响应失败 $scope.unnormal = $scope.standard = "获取脚本内容失败"; }); } }]); export var sqlMoveController = controller("sqlMoveController", ['$scope', '$http', ($scope, $http) => { getSqlContent(); $scope.move = () => { $scope.$emit("replace", { url: "/java/console/api/filePackage/handleSqlFile", item: $scope.ngDialogData.item, content: $scope.content, opt: "replace", type: $scope.ngDialogData.type }); $scope.closeThisDialog(); } function getSqlContent(){ $http({ url: "/java/console/api/filePackage/readSqlFile", method:'POST', params: {type: $scope.ngDialogData.type}, data: JSON.stringify($scope.ngDialogData.item) }).success(function(data,header,config,status){ $scope.content = data.data2; //响应成功 }).error(function(data,header,config,status){ //处理响应失败 $scope.content = "获取脚本内容失败"; }); } }]); export var sysVerUpdateController = controller('sysVerUpdateController', ['$scope', ($scope) => { }]); }