提交 2827a640 编写于 作者: B Bai

[Update] 更新命令批量执行资产树(将没有ssh协议的资产设置为nocheck)

上级 c21505e9
......@@ -98,4 +98,5 @@ class TreeNodeSerializer(serializers.Serializer):
isParent = serializers.BooleanField(default=False)
open = serializers.BooleanField(default=False)
iconSkin = serializers.CharField(max_length=128, allow_blank=True)
nocheck = serializers.BooleanField(default=False)
meta = serializers.JSONField()
......@@ -138,11 +138,11 @@
}
},
callback: {
onCheck: onCheck
onCheck: onCheck,
onClick: onClick,
}
};
$.get(url, function (data, status) {
$.fn.zTree.init($("#assetTree"), setting, data);
zTree = $.fn.zTree.getZTreeObj("assetTree");
......@@ -152,25 +152,29 @@
});
});
}
function onClick(event, treeId, treeNode, clickFlag){
if (treeNode.meta.type === 'asset'){
let protocolsStr = treeNode.meta.asset.protocols + '';
if (protocolsStr.indexOf('ssh/') === -1){
toastr.warning("{% trans "Asset configuration does not include the SSH protocol" %}");
}
}
}
function getSelectedAssetsNode() {
var nodes = zTree.getCheckedNodes(true);
var assetsNodeId = [];
var assetsNode = [];
nodes.forEach(function (node) {
if (node.meta.type === 'asset' && !node.isHidden) {
var protocols = node.meta.asset.protocols;
protocols.forEach(function (val) {
if (assetsNodeId.indexOf(node.id) === -1 && val.indexOf("ssh") > -1) {
assetsNodeId.push(node.id);
assetsNode.push(node)
}
});
var protocolsStr = node.meta.asset.protocols + '';
if (assetsNodeId.indexOf(node.id) === -1 && protocolsStr.indexOf('ssh') > -1){
assetsNodeId.push(node.id);
assetsNode.push(node)
}
}
});
return assetsNode;
}
function onCheck(e, treeId, treeNode) {
var nodes = getSelectedAssetsNode();
var nodes_names = nodes.map(function (node) {
......
......@@ -481,6 +481,7 @@ class ParserNode:
'isParent': False,
'open': False,
'iconSkin': icon_skin,
'nocheck': not asset.has_protocol('ssh'),
'meta': {
'type': 'asset',
'asset': {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册