Commit fca35a29 authored by Luca Lamorte's avatar Luca Lamorte

Fix minor bugs

parent 718fd6af
{"url": "amqp://luca:luca@finterop1/session1", "orchestrator": "http://finterop2", "exchange": "default", "connected": false, "version": "0.0.1", "component": "gui_tt"}
\ No newline at end of file
{"url": "amqp://luca:luca@finterop1/session1", "exchange": "default", "component": "gui_tt", "connected": false, "version": "0.0.1", "orchestrator": "http://finterop2"}
\ No newline at end of file
......@@ -256,25 +256,40 @@ def session_templates(name):
return response
@app.route('/verdict/<type>')
def verdicts(type):
@app.route('/verdict/<output>')
def verdicts(output):
global amqp_listener
if type == "html":
verdict = amqp_listener.get_verdict()
if verdict:
return create_device_table(verdict)
if not amqp_listener:
return "NO AMQP LISTENER"
logger.debug("Get verdict type %s" % output)
try:
if output == "html":
verdict = amqp_listener.get_verdict()
if verdict:
return create_device_table(verdict)
else:
return ""
else:
return ""
else:
response = app.response_class(
response=json.dumps(amqp_listener.get_verdict()),
status=200,
mimetype='application/json'
)
return response
except Exception as error:
logger.debug("Error while sending back the verdict ", error)
response = app.response_class(
response=amqp_listener.get_verdict(),
response=json.dumps({'message', "%s"%error}),
status=200,
mimetype='application/json'
)
return response
@app.route('/api_orch', methods=['POST'])
def api_orch():
......
......@@ -13,7 +13,6 @@ class AmqpSniffer(threading.Thread):
def __init__(self, configuration, socketio):
threading.Thread.__init__(self)
# queues & default exchange declaration
self.message_count = 0
......@@ -30,7 +29,7 @@ class AmqpSniffer(threading.Thread):
routing_key='#')
# Hello world message
self.channel.basic_publish(
body=json.dumps({'_type': 'gui.info', 'value': 'GUI is up!'}),
body=json.dumps({'_type': 'gui_sniff.info', 'value': 'AMQP GUI Sniffer is up!'}),
routing_key='control.gui.info',
exchange=AMQP_EXCHANGE,
properties = pika.BasicProperties(
......@@ -118,7 +117,11 @@ class AmqpSniffer(threading.Thread):
logger.debug('* * * * * * * * * * * * * * * * * * * * * ')
def get_verdict(self):
return self.verdict
if self.verdict == None:
return {}
else:
return self.verdict
......
......@@ -73,11 +73,18 @@ $(document).ready(function() {
$.get( "/verdict/json", function( data ) {
if (data == "")
return
console.log(data)
var issues = parseInt(data["anomalies"])
$("#privacy_alert").removeClass( "hide" );
$("#num_issues").html(issues + " Privacy Issues")
try {
data = JSON.parse(data)
console.log("Anomalies:"+ data["anomalies"])
var issues = parseInt(data["anomalies"])
$("#privacy_alert").removeClass("hide");
$("#num_issues").html(issues + " Privacy Issues")
}catch (err){
console.log("error reading verdict")
}
});
......@@ -169,16 +176,17 @@ function checkPrivacyMessage(msg){
$("#privacy_alert").removeClass( "hide" );
$("#num_issues").html(issues + " Privacy Issues")
}
}
}
function show_verdict(){
$.get( "verdict/html", function( data ) {
$( "#info").html( data );
$.get( "html/verdict", function( data ) {
console.log("VERDICT:"+data)
$("#add_page_here").html( data );
$.get( "verdict/html", function( data ) {
$("#vedict_secion").html(data);
});
});
}
......
......@@ -67,8 +67,8 @@
<ul class="nav navbar-nav navbar-right">
<li class="hide" id="privacy_alert">
<a href="#" class="yellow" onclick="show_verdict()">
<li class="show" id="privacy_alert">
<a href="#" onClick="show_verdict()" class="yellow" onclick="show_verdict()">
<span class="glyphicon glyphicon-warning-sign"></span>
<span id="num_issues"> </span>
</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment