mirror of https://github.com/jumpserver/jumpserver
Update import
parent
3aea994101
commit
a7476222a9
|
@ -84,6 +84,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block custom_foot_js %}
|
||||
<script src="{% static 'js/jquery.form.min.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
window.onload = function (){
|
||||
var tag_on = document.getElementsByName("tag_on");
|
||||
|
@ -159,24 +160,24 @@
|
|||
});
|
||||
|
||||
$('#btn_asset_import').click(function() {
|
||||
var $form = $('#fm_asset_import');
|
||||
$form.find('.help-block').remove();
|
||||
function success (data) {
|
||||
if (data.valid === false) {
|
||||
$('<span />', {class: 'help-block text-danger'}).html(data.msg).insertAfter($('#id_users'));
|
||||
} else {
|
||||
$('#id_created').html(data.created_info);
|
||||
$('#id_created_detail').html(data.created.join(', '));
|
||||
$('#id_updated').html(data.updated_info);
|
||||
$('#id_updated_detail').html(data.updated.join(', '));
|
||||
$('#id_failed').html(data.failed_info);
|
||||
$('#id_failed_detail').html(data.failed.join(', '));
|
||||
var $data_table = $('#asset_list_table').DataTable();
|
||||
$data_table.ajax.reload();
|
||||
var $form = $('#fm_asset_import');
|
||||
$form.find('.help-block').remove();
|
||||
function success (data) {
|
||||
if (data.valid === false) {
|
||||
$('<span />', {class: 'help-block text-danger'}).html(data.msg).insertAfter($('#id_assets'));
|
||||
} else {
|
||||
$('#id_created').html(data.created_info);
|
||||
$('#id_created_detail').html(data.created.join(', '));
|
||||
$('#id_updated').html(data.updated_info);
|
||||
$('#id_updated_detail').html(data.updated.join(', '));
|
||||
$('#id_failed').html(data.failed_info);
|
||||
$('#id_failed_detail').html(data.failed.join(', '));
|
||||
var $data_table = $('#asset_list_table').DataTable();
|
||||
$data_table.ajax.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
$form.ajaxSubmit({success: success});
|
||||
})
|
||||
$form.ajaxSubmit({success: success});
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -772,7 +772,7 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||
'cabinet_pos', 'number', 'status', 'type', 'env', 'sn', 'comment']
|
||||
header_min = ['hostname', 'ip', 'port', 'admin_user', 'comment']
|
||||
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'}
|
||||
return self.render_json_response(data)
|
||||
|
||||
|
@ -790,12 +790,12 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
|
|||
asset_dict['idc'] = idc
|
||||
|
||||
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_dict['type'] = asset_type
|
||||
|
||||
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()))
|
||||
asset_status = asset_display_status_map.get(asset_dict['status'], 'In use')
|
||||
asset_dict['status'] = asset_status
|
||||
|
|
|
@ -24,10 +24,10 @@ class TerminalSerializer(serializers.ModelSerializer):
|
|||
@staticmethod
|
||||
def get_is_alive(obj):
|
||||
log = obj.terminalheatbeat_set.last()
|
||||
if timezone.now() - log.date_created > timezone.timedelta(seconds=600):
|
||||
return False
|
||||
else:
|
||||
if log and timezone.now() - log.date_created < timezone.timedelta(seconds=600):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
class TerminalHeatbeatSerializer(serializers.ModelSerializer):
|
||||
|
|
Loading…
Reference in New Issue