You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/plugins/system/ts/sqlManagement.ts

277 lines
8.1 KiB

/// <reference path="../../includes.ts"/>
/// <reference path="systemPlugin.ts"/>
/// <reference path="systemHelpers.ts"/>
/// <reference path="systemServices.ts"/>
/// <reference path="../../configs/ts/configsUtils.ts"/>
/// <reference path="../../configs/ts/customAlert.ts"/>
/// <reference path="../../kubernetes/ts/kubernetesHelpers.ts"/>
module System{
export var SystemSQLManagement = controller('SystemSQLManagement', ['$scope', '$location', '$http', '$element', '$templateCache', 'NgTableParams', 'ngDialog', 'SystemModel', ($scope, $location, $http, $element, $templateCache, NgTableParams, ngDialog, SystemModel) => {
shareInit($scope);
$scope.cities = classifyCity(SystemModel.regionalismInfo);
$scope.status = [{id: 0, label: "有缺失"}, {id: 1, label: "正常"}, {id: 2, label:"待归档"}, {id: 3, label: "待审核"}];
SystemModel.updateSqlInfo();
8 years ago
$scope.model = SystemModel.sqlInfo;
$scope.checkboxes = {
checked: false,
items: {}
};
8 years ago
$scope.optionsFilter= {
x: "all",
y: "all",
z: "all"
}
$scope.tableParams = new NgTableParams({count: 25}, {
counts: [25, 50, 100],
dataset: $scope.model
});
$scope.citySelect = (x) => {
8 years ago
$scope.optionsFilter.x = x;
$scope.optionsFilter.y = $scope.y = "all";
if(x != "all"){
$scope.countries = classifyCountry(SystemModel.regionalismInfo, x); //获取当前市下所有区县
}else{
$scope.countries = [];
}
}
8 years ago
$scope.countrySelect = (y) => {
$scope.optionsFilter.y = y;
}
$scope.statusSelect = (z) => {
8 years ago
$scope.optionsFilter.z = z;
}
8 years ago
$scope.$watch(() =>{
return $scope.optionsFilter;
}, (value) =>{
shareUpdate($scope.model, value);
}, true);
$scope.quickCheck = () => {
updateSqlStatus("/java/console/api/filePackage/totalVerifySqlFile");
}
8 years ago
$scope.quickFile = () => {
updateSqlStatus("/java/console/api/filePackage/totalOnholeSqlFile");
}
$scope.help = () => {
ngDialog.open({
template: 'statusHelp.html',
width: 600,
height: 370,
closeByDocument: false,
className: 'ngdialog-theme-default'
});
}
// watch for check all checkbox
$scope.$watch(function() {
return $scope.checkboxes.checked;
}, function(value) {
angular.forEach($scope.model, function(item) {
$scope.checkboxes.items[item.id] = value;
});
});
8 years ago
// watch for data checkboxes
$scope.$watch(function() {
return $scope.checkboxes.items;
}, function(values) {
$scope.checkable = false;
for(var index in values){
if(values[index] == true){
$scope.checkable = true;
break;
}
}
var checked = 0, unchecked = 0,
total = $scope.model.length;
angular.forEach($scope.model, function(item) {
checked += ($scope.checkboxes.items[item.id]) || 0;
unchecked += Number((!$scope.checkboxes.items[item.id])) || 0;
});
if ((unchecked == 0) || (checked == 0)) {
$scope.checkboxes.checked = (checked == total);
}
angular.element($element[0].getElementsByClassName("select-all")).prop("indeterminate", (checked != 0 && unchecked != 0));
}, true);
//查看
8 years ago
$scope.viewSql = (selected, type) => {
ngDialog.open({
template: 'sqlView.html',
controller:'Configs.SqlViewController',
width: 1000,
height: 600,
scope: $scope,
closeByDocument : false,
data: {type: type, item: selected },
className: 'ngdialog-theme-default'
});
}
//上传
8 years ago
$scope.addSql = (selected, type) => {
ngDialog.open({
template: 'sqlAdd.html',
controller:'Configs.SqlAddController',
width: 600,
height: 600,
scope: $scope,
closeByDocument : false,
data: {type: type, item: selected },
className: 'ngdialog-theme-default'
});
}
8 years ago
//审核
8 years ago
$scope.verifySql = (selected, type) => {
ngDialog.open({
template: 'sqlVerification.html',
controller:'Configs.sqlVerificationController',
width: 1000,
height: 600,
scope: $scope,
closeByDocument : false,
data: {type: type, item: selected },
className: 'ngdialog-theme-default'
});
8 years ago
}
8 years ago
//替换
8 years ago
$scope.moveSql = (selected, type) => {
ngDialog.open({
template: 'sqlMove.html',
controller:'Configs.sqlMoveController',
width: 600,
height: 600,
scope: $scope,
closeByDocument : false,
data: {type: type, item: selected },
className: 'ngdialog-theme-default'
});
}
8 years ago
$scope.$on('onOk', (event, data) => {
Configs.create_mask(); //创建遮罩层
Kubernetes.create_locadEffect("正在更新文件,请稍等!"); //创建数据加载效果层
var target = document.getElementById('loading')
var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
$http({
url: "/java/console/api/filePackage/handleSqlFile",
method: "POST",
params: {type: data.type, opt: data.opt},
data: JSON.stringify({
item: data.item,
content: data.content
})
}).success((data,header,config,status) => {
$("#load").remove();
Kubernetes.removeMask();
$scope.model = SystemModel.sqlInfo = data.data;
shareUpdate($scope.model, $scope.optionsFilter);
}).error((data,header,config,status) => {
$("#load").remove();
Kubernetes.removeMask();
});
});
8 years ago
$scope.$on("replace", (event, data) => {
$http({
url: "/java/console/api/filePackage/handleSqlFile",
method: "POST",
params: {type: data.type, opt: data.opt},
data: JSON.stringify({
item: data.item,
content: data.content
})
}).success((data,header,config,status) => {
8 years ago
$scope.model = SystemModel.sqlInfo = data.data;
shareUpdate($scope.model, $scope.optionsFilter);
8 years ago
}).error((data,header,config,status) => {
Configs.customAlert("提示", "脚本替换或归档失败!", '',null, 0, "error");
});
});
8 years ago
function shareUpdate (data, value){
var filter = data, result = [];
if(value.x != "all"){
angular.forEach(filter, (item) => {
if(item.cityName == value.x)
result.push(item);
});
filter = result;
result = [];
}
8 years ago
if(value.y != "all"){
angular.forEach(filter, (item) => {
if(item.districtName == value.y)
result.push(item);
});
8 years ago
filter = result;
result = [];
}
8 years ago
if(value.z != "all"){
angular.forEach(filter, (item) =>{
if($scope.status[item.sysStatus].label == value.z)
result.push(item);
});
filter = result;
result = [];
}
$scope.tableParams.settings({
dataset: filter
});
8 years ago
$scope.checkboxes = {
checked: false,
items: {}
};
}
8 years ago
function updateSqlStatus(url: string) {
var items = [];
if($scope.model && $scope.model.length > 0){
angular.forEach($scope.model, (item) => {
if($scope.checkboxes.items[item.id])
items.push(item);
});
}
if(items.length <= 0)
return;
Configs.create_mask(); //创建遮罩层
Kubernetes.create_locadEffect("正在更新文件,请稍等!"); //创建数据加载效果层
8 years ago
$http({
url: url,
method: 'POST',
data: JSON.stringify(items)
}).success(function(data,header,config,status){
$scope.model = SystemModel.sqlInfo = data.data;
shareUpdate($scope.model, $scope.optionsFilter);
$("#load").remove();
Kubernetes.removeMask();
//响应成功
}).error(function(data,header,config,status){
//处理响应失败
$("#load").remove();
Kubernetes.removeMask();
Configs.customAlert("提示", "一键审核或归档失败!", '',null, 0, "error");
});
}
}])
}