diff --git a/apps/asset/views.py b/apps/asset/views.py
index 9ef34d98..c5dbfaf2 100644
--- a/apps/asset/views.py
+++ b/apps/asset/views.py
@@ -212,7 +212,7 @@ def post(self, request, *args, **kwagrs):
@method_decorator_adaptor(permission_required, "asset.assets_delete_assets","/403/")
def delete(self, request, *args, **kwagrs):
- for ast in QueryDict(request.body).getlist('assetsIds[]'):
+ for ast in QueryDict(request.body).getlist('ids[]'):
try:
assets = Assets.objects.get(id=int(ast))
except Exception as ex:
diff --git a/apps/databases/mysql/consumers.py b/apps/databases/mysql/consumers.py
index 880278df..3cdd2c59 100644
--- a/apps/databases/mysql/consumers.py
+++ b/apps/databases/mysql/consumers.py
@@ -151,9 +151,10 @@ def __check_sql_parse(self, sql, allow_sql):
if len(keywords) > 1:
if keywords[0] + '_' + keywords[1] in grant_sql:
return True
-# print(_first_token, keywords, grant_sql, allow_sql)
+
+# print(sql_type, _first_token , keywords)
- if _first_token in allow_sql: return True
+ if _first_token in allow_sql and sql_type in ["dml", "ddl"]: return True
return "SQL未授权, 联系管理员授权"
diff --git a/static/js/account/center.js b/static/js/account/center.js
index bd69e4f6..8933818b 100644
--- a/static/js/account/center.js
+++ b/static/js/account/center.js
@@ -147,26 +147,24 @@ function RefreshAssetsTable(tableId, urlData){
});
}
-function RefreshChoiceAssets(){
- var btnObj = $(this);
- btnObj.attr('disabled',true);
+function batchManageChoiceAssets(dataList, title, content, type){
var serverId = [];
- var ips = ''
- $.each($('input[type=checkbox]input[name="ckbox"]:checked'),function(){
- ips += '' + $(this).parent().parent().find("td").eq(5).text() + '
'
- serverId.push($(this).val())
- });
+ let ips = ''
+ for (var i=0; i 0){
$.confirm({
- type: 'blue',
- title: '更新资产',
- content: '确认更新这些资产:
' + ips,
+ type: 'red',
+ title: title,
+ content: content + ips,
buttons: {
- '更新': {
+ '确定': {
btnClass: 'btn-blue',
action: function() {
$.ajax({
- type: 'POST',
+ type: type,
url: '/assets/batch/',
dataType:"json",
data:{
@@ -202,14 +200,12 @@ function RefreshChoiceAssets(){
styling: 'bootstrap3',
delay: 18000
});
- }
- btnObj.removeAttr('disabled');
+ }
},
error:function(response){
- btnObj.removeAttr('disabled');
new PNotify({
title: 'Ops Failed!',
- text: '资产修改失败',
+ text: '批量操作失败',
type: 'error',
styling: 'bootstrap3'
});
@@ -223,96 +219,13 @@ function RefreshChoiceAssets(){
}
else{
$.alert({
- title: '批量更新资产',
+ title: '批量操作资产',
content: '请至少选择一个资产!',
type: 'red',
});
- btnObj.removeAttr('disabled');
}
}
-function DeleteChoiceAssets(){
- var btnObj = $(this);
- btnObj.attr('disabled',true);
- var serverId = [];
- var ips = ''
- $.each($('input[type=checkbox]input[name="ckbox"]:checked'),function(){
- ips += '' + $(this).parent().parent().find("td").eq(5).text() + '
'
- serverId.push($(this).val())
- });
- if (serverId.length > 0){
- $.confirm({
- type: 'red',
- title: '删除资产',
- content: '确认删除这些资产:
' + ips,
- buttons: {
- '删除': {
- btnClass: 'btn-blue',
- action: function() {
- $.ajax({
- type: 'DELETE',
- url: '/assets/batch/',
- dataType:"json",
- data:{
- 'assetsIds':serverId,
- },
- success:function(response){
- var sip = '';
- var fip = '';
- var modal = '';
- for (var i = 0; i < response['data']['success'].length; i++){
- sip += response['data']['success'][i] + '
'
- }
- for (var i = 0; i < response['data']['failed'].length; i++){
- fip += response['data']['failed'][i] + '
'
- }
- msg = '成功:'+ '
' + sip + '
' + '失败:'+ '
' + fip;
- if (response['code']==200){
- new PNotify({
- title: 'Success!',
- text: msg,
- type: 'success',
- styling: 'bootstrap3',
- delay: 18000
- });
- }
- else{
- new PNotify({
- title: 'Ops Failed!',
- text: response["msg"],
- type: 'error',
- styling: 'bootstrap3',
- delay: 18000
- });
- }
- btnObj.removeAttr('disabled');
- },
- error:function(response){
- btnObj.removeAttr('disabled');
- new PNotify({
- title: 'Ops Failed!',
- text: '资产修改失败',
- type: 'error',
- styling: 'bootstrap3'
- });
- }
- });
- }
- },
- '取消': function() {},
- }
- });
- }
- else{
- $.alert({
- title: '批量删除资产',
- content: '请至少选择一个资产!',
- type: 'red',
- });
- btnObj.removeAttr('disabled');
- }
-};
-
$(document).ready(function() {
if($("#assetsListTable").length){
@@ -398,8 +311,17 @@ $(document).ready(function() {
{
text: '',
className: "btn-sm",
- action: function ( e, dt, node, config ) {
- DeleteChoiceAssets()
+ action: function ( e, dt, node, config ) {
+ let dataList = dt.rows('.selected').data()
+ if (dataList.length==0){
+ $.alert({
+ title: '操作失败',
+ content: '批量删除资产失败,请先选择资产',
+ type: 'red',
+ });
+ }else{
+ batchManageChoiceAssets(dataList, '批量删除', '批量删除资产:' ,'DELETE')
+ }
}
},
{
@@ -407,7 +329,6 @@ $(document).ready(function() {
className: "btn-sm",
action: function ( e, dt, node, config ) {
let dataList = dt.rows('.selected').data()
- var vips = ''
if (dataList.length==0){
$.alert({
title: '操作失败',
@@ -415,7 +336,7 @@ $(document).ready(function() {
type: 'red',
});
}else{
- updateAssetsByAnsible(dataList)
+ batchManageChoiceAssets(dataList, '批量更新', '批量更新资产:' ,'POST')
}
}
},