Add config variable for ssl. #424
This commit is contained in:
parent
5822ea84a6
commit
4de9a00942
4 changed files with 16 additions and 5 deletions
|
|
@ -74,3 +74,6 @@ MAPTILER_API_KEY=map_tiler_api_key
|
|||
|
||||
# API version
|
||||
API_VERSION=insert_api_version_here
|
||||
|
||||
# SSL
|
||||
SSL_ENABLE=true_or_false
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@ twig:
|
|||
mqtt_host: "%env(MQTT_WS_HOST)%"
|
||||
mqtt_port: "%env(MQTT_WS_PORT)%"
|
||||
dashboard_enable: "%env(DASHBOARD_ENABLE)%"
|
||||
ssl_enable: "%env(SSL_ENABLE)%"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
class MapEventHandler {
|
||||
constructor(options, dashmap) {
|
||||
constructor(options, dashmap, ssl) {
|
||||
this.options = options;
|
||||
this.dashmap = dashmap;
|
||||
this.ssl = ssl;
|
||||
}
|
||||
|
||||
connect(user_id, host, port) {
|
||||
|
|
@ -11,7 +12,7 @@ class MapEventHandler {
|
|||
|
||||
this.mqtt = new Paho.MQTT.Client(host, port, client_id);
|
||||
var options = {
|
||||
// useSSL: true,
|
||||
useSSL: this.ssl,
|
||||
timeout: 3,
|
||||
invocationContext: this,
|
||||
onSuccess: this.onConnect.bind(this),
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ function initMap(r_markers, c_markers, icons) {
|
|||
return dashmap;
|
||||
}
|
||||
|
||||
function initEventHandler(dashmap) {
|
||||
function initEventHandler(dashmap, icons, ssl) {
|
||||
var options = {
|
||||
'track_jo': 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 }});
|
||||
}
|
||||
|
||||
|
|
@ -94,8 +95,13 @@ var icons = {
|
|||
var r_markers = {};
|
||||
var c_markers = {};
|
||||
|
||||
var ssl = false;
|
||||
{% if ssl_enable == 'true' %}
|
||||
ssl = true;
|
||||
{% endif %}
|
||||
|
||||
var dashmap = initMap(r_markers, c_markers, icons);
|
||||
initEventHandler(dashmap, icons);
|
||||
initEventHandler(dashmap, icons, ssl);
|
||||
{% endif %}
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue