mirror of https://github.com/jumpserver/jumpserver
[Update] 修复页面bug和popover的问题
parent
444f494c0b
commit
8ddda8e5af
|
@ -33,11 +33,16 @@ class AssetCreateForm(OrgModelForm):
|
|||
return
|
||||
nodes_field = self.fields['nodes']
|
||||
if self.instance:
|
||||
nodes_field.choices = ((n.id, n.full_value) for n in
|
||||
self.instance.nodes.all())
|
||||
nodes_field.choices = [(n.id, n.full_value) for n in
|
||||
self.instance.nodes.all()]
|
||||
else:
|
||||
nodes_field.choices = []
|
||||
|
||||
def add_nodes_initial(self, node):
|
||||
nodes_field = self.fields['nodes']
|
||||
nodes_field.choices.append((node.id, node.full_value))
|
||||
nodes_field.initial = [node]
|
||||
|
||||
class Meta:
|
||||
model = Asset
|
||||
fields = [
|
||||
|
|
|
@ -37,19 +37,22 @@ class TreeMixin:
|
|||
def tree(cls):
|
||||
from ..utils import TreeService
|
||||
tree_updated_time = cache.get(cls.tree_updated_time_cache_key, 0)
|
||||
now = time.time()
|
||||
# 什么时候重新初始化 _tree_service
|
||||
if not cls.tree_created_time or \
|
||||
tree_updated_time > cls.tree_created_time:
|
||||
logger.debug("Create node tree")
|
||||
tree = TreeService.new()
|
||||
cls.tree_created_time = time.time()
|
||||
cls.tree_assets_created_time = time.time()
|
||||
cls.tree_created_time = now
|
||||
cls.tree_assets_created_time = now
|
||||
cls._tree_service = tree
|
||||
return tree
|
||||
# 是否要重新初始化节点资产
|
||||
node_assets_updated_time = cache.get(cls.tree_assets_cache_key, 0)
|
||||
if not cls.tree_assets_created_time or \
|
||||
node_assets_updated_time > cls.tree_assets_created_time:
|
||||
cls._tree_service.init_assets_async()
|
||||
cls.tree_assets_created_time = time.time()
|
||||
cls._tree_service.init_assets()
|
||||
cls.tree_assets_created_time = now
|
||||
logger.debug("Refresh node tree assets")
|
||||
return cls._tree_service
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class AssetCreateView(PermissionsMixin, FormMixin, TemplateView):
|
|||
node = get_object_or_none(Node, id=node_id)
|
||||
else:
|
||||
node = Node.org_root()
|
||||
form["nodes"].initial = node
|
||||
form.add_nodes_initial(node)
|
||||
return form
|
||||
|
||||
def get_protocol_formset(self):
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#search_btn {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-control {
|
||||
height: 30px;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
#search_btn {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-control {
|
||||
height: 30px;
|
||||
}
|
||||
.select2-selection__rendered span.select2-selection, .select2-container .select2-selection--single {
|
||||
height: 30px !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
#search_btn {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-control {
|
||||
height: 30px;
|
||||
}
|
||||
.select2-selection__rendered span.select2-selection, .select2-container .select2-selection--single {
|
||||
height: 30px !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
#search_btn {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-control {
|
||||
height: 30px;
|
||||
}
|
||||
.select2-selection__rendered span.select2-selection, .select2-container .select2-selection--single {
|
||||
height: 30px !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -44,8 +44,9 @@ class IDInCacheFilterMixin(object):
|
|||
return queryset
|
||||
cache_key = KEY_CACHE_RESOURCES_ID.format(spm)
|
||||
resources_id = cache.get(cache_key)
|
||||
if resources_id and isinstance(resources_id, list):
|
||||
queryset = queryset.filter(id__in=resources_id)
|
||||
if not resources_id or not isinstance(resources_id, list):
|
||||
queryset = queryset.none()
|
||||
queryset = queryset.filter(id__in=resources_id)
|
||||
return queryset
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ def run_ansible_task(tid, callback=None, **kwargs):
|
|||
logger.error("No task found")
|
||||
|
||||
|
||||
@shared_task(soft_time_limit=60)
|
||||
@shared_task(soft_time_limit=60, queue="ansible")
|
||||
def run_command_execution(cid, **kwargs):
|
||||
execution = get_object_or_none(CommandExecution, id=cid)
|
||||
if execution:
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
|
||||
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
|
||||
<style>
|
||||
.form-control {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
#search_btn {
|
||||
margin-bottom: 0;
|
||||
|
@ -88,13 +91,6 @@
|
|||
<script src="{% static "js/plugins/footable/footable.all.min.js" %}"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
{#$('table').DataTable({#}
|
||||
{# "searching": false,#}
|
||||
{# "paging": false,#}
|
||||
{# "bInfo" : false,#}
|
||||
{# "order": []#}
|
||||
{# });#}
|
||||
{#$('.footable').footable();#}
|
||||
$('.select2').select2({
|
||||
dropdownAutoWidth : true,
|
||||
width: 'auto'
|
||||
|
@ -114,9 +110,10 @@ $(document).ready(function() {
|
|||
data_list.pop();
|
||||
}
|
||||
var html = createPopover(data_list);
|
||||
console.log(html);
|
||||
$(this).html(html);
|
||||
});
|
||||
$('[data-toggle="popover"]').popover();
|
||||
$('[data-toggle=popover]').popover({html : true});
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -35,6 +35,10 @@ class OrgBulkModelViewSet(IDInCacheFilterMixin, BulkModelViewSet):
|
|||
return queryset
|
||||
|
||||
def allow_bulk_destroy(self, qs, filtered):
|
||||
if qs.count() <= filtered.count():
|
||||
return False
|
||||
if self.request.query_params.get('spm', ''):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -76,10 +76,9 @@ $(document).ready(function () {
|
|||
if(!$("body").hasClass('body-small')) {
|
||||
fix_height();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$("[data-toggle=popover]")
|
||||
.popover();
|
||||
$("[data-toggle=popover]").popover();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -774,8 +774,7 @@ function createPopover(dataset, title, callback) {
|
|||
});
|
||||
dataset = new_dataset;
|
||||
}
|
||||
var data_content = dataset.join("</br>");
|
||||
|
||||
var data_content = dataset.join("<br>");
|
||||
var html = "<a data-toggle='popover' data-content='" + data_content + "'>" + dataset.length + "</a>";
|
||||
return html;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue