mirror of https://github.com/jumpserver/jumpserver
[Update] 修改资产树节点(数量)总显示此节点下的资产总数
parent
3a2973023c
commit
5b53cfb4dd
|
@ -42,14 +42,7 @@ __all__ = [
|
|||
class NodeViewSet(BulkModelViewSet):
|
||||
queryset = Node.objects.all()
|
||||
permission_classes = (IsSuperUser,)
|
||||
# serializer_class = serializers.NodeSerializer
|
||||
|
||||
def get_serializer_class(self):
|
||||
show_current_asset = self.request.query_params.get('show_current_asset')
|
||||
if show_current_asset:
|
||||
return serializers.NodeCurrentSerializer
|
||||
else:
|
||||
return serializers.NodeSerializer
|
||||
serializer_class = serializers.NodeSerializer
|
||||
|
||||
def perform_create(self, serializer):
|
||||
child_key = Node.root().get_next_child_key()
|
||||
|
|
|
@ -9,7 +9,7 @@ from .asset import AssetGrantedSerializer
|
|||
|
||||
__all__ = [
|
||||
'NodeSerializer', "NodeGrantedSerializer", "NodeAddChildrenSerializer",
|
||||
"NodeAssetsSerializer", "NodeCurrentSerializer",
|
||||
"NodeAssetsSerializer",
|
||||
]
|
||||
|
||||
|
||||
|
@ -77,12 +77,6 @@ class NodeSerializer(serializers.ModelSerializer):
|
|||
return fields
|
||||
|
||||
|
||||
class NodeCurrentSerializer(NodeSerializer):
|
||||
@staticmethod
|
||||
def get_assets_amount(obj):
|
||||
return obj.get_assets().count()
|
||||
|
||||
|
||||
class NodeAssetsSerializer(serializers.ModelSerializer):
|
||||
assets = serializers.PrimaryKeyRelatedField(many=True, queryset=Asset.objects.all())
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ function initTree2() {
|
|||
};
|
||||
|
||||
var zNodes = [];
|
||||
$.get("{% url 'api-assets:node-list' %}?show_current_asset=1", function(data, status){
|
||||
$.get("{% url 'api-assets:node-list' %}", function(data, status){
|
||||
$.each(data, function (index, value) {
|
||||
value["pId"] = value["parent"];
|
||||
{#value["open"] = true;#}
|
||||
|
|
|
@ -399,8 +399,7 @@ function initTree() {
|
|||
};
|
||||
|
||||
var zNodes = [];
|
||||
var query_params = {'show_current_asset': getCookie('show_current_asset')};
|
||||
$.get("{% url 'api-assets:node-list' %}", query_params, function(data, status){
|
||||
$.get("{% url 'api-assets:node-list' %}", function(data, status){
|
||||
$.each(data, function (index, value) {
|
||||
value["pId"] = value["parent"];
|
||||
if (value["key"] === "0") {
|
||||
|
@ -436,7 +435,7 @@ $(document).ready(function(){
|
|||
initTable();
|
||||
initTree();
|
||||
|
||||
if(getCookie('show_current_asset') === 'yes'){
|
||||
if(getCookie('show_current_asset') === '1'){
|
||||
$('#show_all_asset').css('display', 'inline-block');
|
||||
}
|
||||
else{
|
||||
|
@ -564,7 +563,7 @@ $(document).ready(function(){
|
|||
hideRMenu();
|
||||
$(this).css('display', 'none');
|
||||
$('#show_all_asset').css('display', 'inline-block');
|
||||
setCookie('show_current_asset', 'yes');
|
||||
setCookie('show_current_asset', '1');
|
||||
location.reload();
|
||||
})
|
||||
.on('click', '.btn-show-all-asset', function(){
|
||||
|
|
Loading…
Reference in New Issue