Add config variable for ssl. #424

This commit is contained in:
Korina Cordero 2020-06-24 07:10:45 +00:00
parent 5822ea84a6
commit 4de9a00942
4 changed files with 16 additions and 5 deletions

View file

@ -74,3 +74,6 @@ MAPTILER_API_KEY=map_tiler_api_key
# API version # API version
API_VERSION=insert_api_version_here API_VERSION=insert_api_version_here
# SSL
SSL_ENABLE=true_or_false

View file

@ -8,3 +8,4 @@ twig:
mqtt_host: "%env(MQTT_WS_HOST)%" mqtt_host: "%env(MQTT_WS_HOST)%"
mqtt_port: "%env(MQTT_WS_PORT)%" mqtt_port: "%env(MQTT_WS_PORT)%"
dashboard_enable: "%env(DASHBOARD_ENABLE)%" dashboard_enable: "%env(DASHBOARD_ENABLE)%"
ssl_enable: "%env(SSL_ENABLE)%"

View file

@ -1,7 +1,8 @@
class MapEventHandler { class MapEventHandler {
constructor(options, dashmap) { constructor(options, dashmap, ssl) {
this.options = options; this.options = options;
this.dashmap = dashmap; this.dashmap = dashmap;
this.ssl = ssl;
} }
connect(user_id, host, port) { connect(user_id, host, port) {
@ -11,7 +12,7 @@ class MapEventHandler {
this.mqtt = new Paho.MQTT.Client(host, port, client_id); this.mqtt = new Paho.MQTT.Client(host, port, client_id);
var options = { var options = {
// useSSL: true, useSSL: this.ssl,
timeout: 3, timeout: 3,
invocationContext: this, invocationContext: this,
onSuccess: this.onConnect.bind(this), onSuccess: this.onConnect.bind(this),

View file

@ -45,7 +45,7 @@ function initMap(r_markers, c_markers, icons) {
return dashmap; return dashmap;
} }
function initEventHandler(dashmap) { function initEventHandler(dashmap, icons, ssl) {
var options = { var options = {
'track_jo': true, 'track_jo': true,
'track_rider': true, 'track_rider': true,
@ -58,7 +58,8 @@ function initEventHandler(dashmap) {
}, },
}; };
var event_handler = new MapEventHandler(options, dashmap); console.log(ssl);
var event_handler = new MapEventHandler(options, dashmap, ssl);
event_handler.connect('{{ app.user.getID }}', '{{ mqtt_host }}', {{ mqtt_port }}); event_handler.connect('{{ app.user.getID }}', '{{ mqtt_host }}', {{ mqtt_port }});
} }
@ -94,8 +95,13 @@ var icons = {
var r_markers = {}; var r_markers = {};
var c_markers = {}; var c_markers = {};
var ssl = false;
{% if ssl_enable == 'true' %}
ssl = true;
{% endif %}
var dashmap = initMap(r_markers, c_markers, icons); var dashmap = initMap(r_markers, c_markers, icons);
initEventHandler(dashmap, icons); initEventHandler(dashmap, icons, ssl);
{% endif %} {% endif %}
</script> </script>