mirror of https://github.com/D4-project/d4-core
fix: [server UI v0.2 server management] fix max len input
parent
64bc6153cb
commit
e3b1e28206
|
@ -26,6 +26,8 @@ port_redis_stream = 6379
|
|||
default_max_entries_by_stream = 10000
|
||||
analyzer_list_max_default_size = 10000
|
||||
|
||||
default_analyzer_max_line_len = 3000
|
||||
|
||||
json_type_description_path = os.path.join(os.environ['D4_HOME'], 'web/static/json/type.json')
|
||||
|
||||
redis_server_stream = redis.StrictRedis(
|
||||
|
@ -233,6 +235,7 @@ def server_management():
|
|||
list_accepted_types.append({"id": int(type), "description": description, 'list_analyzer_uuid': list_analyzer_uuid})
|
||||
|
||||
return render_template("server_management.html", list_accepted_types=list_accepted_types,
|
||||
default_analyzer_max_line_len=default_analyzer_max_line_len,
|
||||
blacklisted_ip=blacklisted_ip, unblacklisted_ip=unblacklisted_ip,
|
||||
blacklisted_uuid=blacklisted_uuid, unblacklisted_uuid=unblacklisted_uuid)
|
||||
|
||||
|
@ -585,14 +588,24 @@ def whois_data():
|
|||
def get_analyser_sample():
|
||||
type = request.args.get('type')
|
||||
analyzer_uuid = request.args.get('analyzer_uuid')
|
||||
max_line_len = 3000
|
||||
max_line_len = request.args.get('max_line_len')
|
||||
# get max_line_len
|
||||
if max_line_len is not None and max_line_len!= 'undefined':
|
||||
try:
|
||||
max_line_len = int(max_line_len)
|
||||
except:
|
||||
max_line_len = default_analyzer_max_line_len
|
||||
if max_line_len < 1:
|
||||
max_line_len = default_analyzer_max_line_len
|
||||
else:
|
||||
max_line_len = default_analyzer_max_line_len
|
||||
if is_valid_uuid_v4(analyzer_uuid):
|
||||
list_queue = redis_server_analyzer.lrange('analyzer:{}:{}'.format(type, analyzer_uuid), 0 ,10)
|
||||
list_queue_res = []
|
||||
for res in list_queue:
|
||||
#limit line len
|
||||
if len(res) > max_line_len:
|
||||
res = res[:1000]
|
||||
res = '{} [...]'.format(res[:max_line_len])
|
||||
list_queue_res.append('{}\n'.format(res))
|
||||
return jsonify(''.join(list_queue_res))
|
||||
else:
|
||||
|
|
|
@ -270,6 +270,12 @@
|
|||
</pre>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="d-sm-flex align-self-sm-start mr-auto">
|
||||
<input class="form-control w-25 mr-sm-2" type="number" id="max_line_len" value="{{default_analyzer_max_line_len}}" min="1" max="10000">
|
||||
<button type="button" class="btn btn-primary" onclick="change_analyser_sample_max_len();">
|
||||
Change Line Size
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -302,11 +308,16 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
|
||||
function get_analyser_sample(type, analyzer_uuid){
|
||||
$.getJSON( "{{url_for('get_analyser_sample')}}?type="+type+"&analyzer_uuid="+analyzer_uuid, function( data ) {
|
||||
function get_analyser_sample(type, analyzer_uuid, max_line_len){
|
||||
$.getJSON( "{{url_for('get_analyser_sample')}}?type="+type+"&analyzer_uuid="+analyzer_uuid+"&max_line_len="+max_line_len, function( data ) {
|
||||
$( "#modal_analyser_sample_label" ).text("analyzer:"+type+":"+analyzer_uuid);
|
||||
$( "#analyzer_content" ).text(data);
|
||||
$( "#modal_analyser_sample" ).modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function change_analyser_sample_max_len(){
|
||||
var analyzer_data_info=$('#modal_analyser_sample_label').text().split(":");
|
||||
get_analyser_sample(analyzer_data_info[1], analyzer_data_info[2], $('#max_line_len').val());
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue