Commit 718fd6af authored by Luca Lamorte's avatar Luca Lamorte

Fix bug Save config

parent e99080b1
{"connected": false, "version": "0.0.1", "component": "gui_tt", "exchange": "default", "orchestrator": "http://finterop2", "url": "amqp://luca:luca@finterop1/session1"}
\ No newline at end of file
{"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
......@@ -51,7 +51,8 @@ def start_amqp_sniffer():
global app_cfg
amqp_listener = AmqpSniffer(app_cfg, socketio)
amqp_listener.start()
socketio.emit("change_cfg", json.dumps(app_cfg.get()), namespace=NAMESPACE)
logger.info("SEND CFG to GUI: %s" % app_cfg.get())
socketio.emit("change_cfg", "%s" %json.dumps(app_cfg.get()), namespace=NAMESPACE)
def allowed_file(filename):
......@@ -132,7 +133,7 @@ def test_message(config):
orchestrator=cfg["orchestrator"])
logger.info("Try to connect sniffer...")
socketio.emit("change_cfg", "warning#Configuration saved. Trying to connect ...", namespace=NAMESPACE)
socketio.emit("info", "warning#Configuration saved. Trying to connect ...", namespace=NAMESPACE)
socketio.start_background_task(target=start_amqp_sniffer)
except Exception as error:
logger.error("Exception in %s" % error)
......
......@@ -104,7 +104,7 @@ class Orchestrator:
:return:
"""
response = requests.patch("%s/sessions/%s" % (self.url, session_id),
json={"status": "started"})
json={"status": "stopped"})
return response.content.decode("utf-8")
......@@ -114,7 +114,7 @@ class Orchestrator:
:param session_id:
:return:
"""
jdata = json.loads(data)
url = "%s/sessions/%s" %(self.url, session_id)
# data = {
......@@ -125,7 +125,7 @@ class Orchestrator:
# }
response = requests.put(url=url,
json=data)
json=jdata)
return response.content.decode("utf-8")
......@@ -203,10 +203,10 @@ class Orchestrator:
else:
return json.dumps({"error": 'missing param user-id'})
elif cmd == 'session_add':
if 'sessionid' in params:
return self.create_session(params['sessionid'])
if 'sessionid' in params and 'body' in params:
return self.create_session(params['sessionid'], params['body'])
else:
return json.dumps({"error": 'missing param session-id'})
return json.dumps({"error": 'missing param session-id or body'})
elif cmd == 'session_read':
if 'sessionid' in params:
......
......@@ -38,9 +38,10 @@ $(document).ready(function() {
});
socket.on("change_cfg", function (data) {
console.log("Change config");
var msg = JSON.parse(data)
console.log("Connected? " + msg["connected"]);
send_alert("AMQP", "Configuration has been changed!", "info")
console.log(">"+data+"<")
var msg = JSON.parse(""+data)
console.log("Connected? " + msg['connected']);
if (msg["connected"] == true){
$('#amqp_icon').removeClass("glyphicon-remove").addClass("glyphicon-ok");
$('#amqp_status').text("Sniffer ON").css('color', 'greenyellow');
......
{
"users": [
"u1, f-interop"
],
"iuts": [],
"testing_tools": "f-interop/privacy",
"tests": []
}
\ No newline at end of file
......@@ -74,9 +74,9 @@
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"></span>
<strong>Config</strong>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" style="color:lawngreen">
Configuration
<span class="glyphicon glyphicon-chevron-down"></span>
</a>
<ul class="dropdown-menu">
......@@ -101,14 +101,16 @@
<li class="divider navbar-login-session-bg"></li>
<li><a href="#">Messages <span class="badge pull-right" id="total_msg"> 0 </span></a></li>
<li class="divider"></li>
<li><a href="#">RabbitMQ URL [AMQP_URL]<input type="text" class="form-control" aria-label="..." id="amqp_url"></a></li>
<li><a href="#">AMQP_URL<input type="text" class="form-control" aria-label="..." id="amqp_url" style="color:blue"></a></li>
<li class="divider"></li>
<li><a href="#"> Exchange [AMQP_EXCHANGE]<input type="text" class="form-control" aria-label="..." id="amqp_exchange"></a></li>
<li><a href="#"> AMQP_EXCHANGE<input type="text" class="form-control" aria-label="..." id="amqp_exchange" style="color:blue"></a></li>
<li class="divider"></li>
<li><a href="#"> Orchestrator<input type="text" class="form-control" aria-label="..." id="orcherstrator_url"></a></li>
<li><a href="#"> Orchestrator URL<input type="text" class="form-control" aria-label="..." id="orcherstrator_url" style="color:blue"></a></li>
<li> &nbsp; </li>
</ul>
</li>
</ul>
</ul>
</div>
......
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