mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-06 19:38:54 +00:00
Update import
This commit is contained in:
parent
3aea994101
commit
a7476222a9
@ -84,6 +84,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block custom_foot_js %}
|
{% block custom_foot_js %}
|
||||||
|
<script src="{% static 'js/jquery.form.min.js' %}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.onload = function (){
|
window.onload = function (){
|
||||||
var tag_on = document.getElementsByName("tag_on");
|
var tag_on = document.getElementsByName("tag_on");
|
||||||
@ -163,7 +164,7 @@
|
|||||||
$form.find('.help-block').remove();
|
$form.find('.help-block').remove();
|
||||||
function success (data) {
|
function success (data) {
|
||||||
if (data.valid === false) {
|
if (data.valid === false) {
|
||||||
$('<span />', {class: 'help-block text-danger'}).html(data.msg).insertAfter($('#id_users'));
|
$('<span />', {class: 'help-block text-danger'}).html(data.msg).insertAfter($('#id_assets'));
|
||||||
} else {
|
} else {
|
||||||
$('#id_created').html(data.created_info);
|
$('#id_created').html(data.created_info);
|
||||||
$('#id_created_detail').html(data.created.join(', '));
|
$('#id_created_detail').html(data.created.join(', '));
|
||||||
|
@ -772,7 +772,7 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||||||
'cabinet_pos', 'number', 'status', 'type', 'env', 'sn', 'comment']
|
'cabinet_pos', 'number', 'status', 'type', 'env', 'sn', 'comment']
|
||||||
header_min = ['hostname', 'ip', 'port', 'admin_user', 'comment']
|
header_min = ['hostname', 'ip', 'port', 'admin_user', 'comment']
|
||||||
header = [col.value for col in next(rows)]
|
header = [col.value for col in next(rows)]
|
||||||
if header not in header_all and header_min not in header:
|
if not set(header).issubset(set(header_all)) and not set(header).issuperset(set(header_min)):
|
||||||
data = {'valid': False, 'msg': 'Must be same format as template or export file'}
|
data = {'valid': False, 'msg': 'Must be same format as template or export file'}
|
||||||
return self.render_json_response(data)
|
return self.render_json_response(data)
|
||||||
|
|
||||||
@ -790,12 +790,12 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||||||
asset_dict['idc'] = idc
|
asset_dict['idc'] = idc
|
||||||
|
|
||||||
if asset_dict.get('type'):
|
if asset_dict.get('type'):
|
||||||
asset_display_type_map = dict(zip(dict(Asset.TYPE_CHOICES).values, dict(Asset.TYPE_CHOICES).keys()))
|
asset_display_type_map = dict(zip(dict(Asset.TYPE_CHOICES).values(), dict(Asset.TYPE_CHOICES).keys()))
|
||||||
asset_type = asset_display_type_map.get(asset_dict['type'], 'Server')
|
asset_type = asset_display_type_map.get(asset_dict['type'], 'Server')
|
||||||
asset_dict['type'] = asset_type
|
asset_dict['type'] = asset_type
|
||||||
|
|
||||||
if asset_dict.get('status'):
|
if asset_dict.get('status'):
|
||||||
asset_display_status_map = dict(zip(dict(Asset.STATUS_CHOICES).values,
|
asset_display_status_map = dict(zip(dict(Asset.STATUS_CHOICES).values(),
|
||||||
dict(Asset.STATUS_CHOICES).keys()))
|
dict(Asset.STATUS_CHOICES).keys()))
|
||||||
asset_status = asset_display_status_map.get(asset_dict['status'], 'In use')
|
asset_status = asset_display_status_map.get(asset_dict['status'], 'In use')
|
||||||
asset_dict['status'] = asset_status
|
asset_dict['status'] = asset_status
|
||||||
|
@ -24,10 +24,10 @@ class TerminalSerializer(serializers.ModelSerializer):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_is_alive(obj):
|
def get_is_alive(obj):
|
||||||
log = obj.terminalheatbeat_set.last()
|
log = obj.terminalheatbeat_set.last()
|
||||||
if timezone.now() - log.date_created > timezone.timedelta(seconds=600):
|
if log and timezone.now() - log.date_created < timezone.timedelta(seconds=600):
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class TerminalHeatbeatSerializer(serializers.ModelSerializer):
|
class TerminalHeatbeatSerializer(serializers.ModelSerializer):
|
||||||
|
Loading…
Reference in New Issue
Block a user