chg: [server UI v0.2 show sample, analyzer queue]

pull/8/head
Terrtia 2019-02-04 13:46:06 +01:00
parent 9071b44c6d
commit e7c83391b4
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 51 additions and 3 deletions

View File

@ -220,7 +220,10 @@ def server_management():
last_updated = redis_server_metadata.hget('analyzer:{}'.format(analyzer_uuid), 'last_updated')
if last_updated is None:
last_updated = 'Never'
list_analyzer_uuid.append({'uuid': analyzer_uuid, 'size_limit': size_limit,'last_updated': last_updated})
len_queue = redis_server_analyzer.llen('analyzer:{}:{}'.format(type, analyzer_uuid))
if len_queue is None:
len_queue = 0
list_analyzer_uuid.append({'uuid': analyzer_uuid, 'size_limit': size_limit,'last_updated': last_updated, 'length': len_queue})
list_accepted_types.append({"id": int(type), "description": description, 'list_analyzer_uuid': list_analyzer_uuid})
@ -572,5 +575,19 @@ def whois_data():
else:
return 'Invalid IP'
# demo function
@app.route('/get_analyser_sample')
def get_analyser_sample():
type = request.args.get('type')
analyzer_uuid = request.args.get('analyzer_uuid')
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:
list_queue_res.append('{}\n'.format(res))
return jsonify(''.join(list_queue_res))
else:
return jsonify('Incorrect UUID')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=7000, threaded=True)

View File

@ -11,6 +11,7 @@
<!-- JS -->
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
@ -206,7 +207,7 @@
<th style="max-width: 800px;">uuid</th>
<th style="max-width: 800px;">last updated</th>
<th style="max-width: 800px;">Change max size limit</th>
<th style="max-width: 800px;">Delete Analyzer Queue</th>
<th style="max-width: 800px;">Analyzer Queue</th>
</tr>
</thead>
<tbody>
@ -225,8 +226,9 @@
</td>
<td>
<a href="{{ url_for('remove_analyzer') }}?redirect=1&type={{type['id']}}&analyzer_uuid={{analyzer['uuid']}}">
<button type="button mt-2" class="btn btn-outline-danger">Remove</button>
<button type="button" class="btn btn-outline-danger"><i class="fa fa-trash"></i></button>
</a>
<button type="button" class="btn btn-outline-info ml-3" onclick="get_analyser_sample('{{type['id']}}', '{{analyzer['uuid']}}');"><i class="fa fa-database"></i> {{analyzer['length']}}</button>
</td>
</tr>
{% endfor %}
@ -252,6 +254,26 @@
</div>
<div class="modal fade" id="modal_analyser_sample" tabindex="-1" role="dialog" aria-labelledby="AnalyserModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modal_analyser_sample_label"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="d-flex modal-body justify-content-center">
<pre id="analyzer_content">
</pre>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{% include 'navfooter.html' %}
</body>
@ -276,4 +298,13 @@ $(document).ready(function(){
);
});
function get_analyser_sample(type, analyzer_uuid){
$.getJSON( "{{url_for('get_analyser_sample')}}?type="+type+"&analyzer_uuid="+analyzer_uuid, function( data ) {
$( "#modal_analyser_sample_label" ).text("analyzer:"+type+":"+analyzer_uuid);
$( "#analyzer_content" ).text(data);
$( "#modal_analyser_sample" ).modal('show');
});
}
</script>