Merge pull request #1660 from rasika/fix-1659

Adding notification for the user on a Websocket handshake failure
application-manager-new
Milan Perera 7 years ago committed by GitHub
commit 6d88fd86bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,6 +52,10 @@
</span>
</span> View Device Analytics
</a>
<div class="hide" id="websocker-onerror">
Realtime Analytics for $sensorType not available. Failed to connect to the websocket. Please make sure; '<a style="color: white" href="$webSocketURL">$webSocketURL</a>' is available and re-try again.
</div>
<!-- /statistics -->
{{#zone "bottomJs"}}
{{js "js/moment.min.js"}}

@ -114,6 +114,17 @@ function connect(wsConnection, target, chartData, graph, sensorType) {
chartData.shift();
graph.update();
};
wsConnection.onerror = function (event) {
var websocketURL = event.currentTarget.url;
websocketURL = websocketURL.replace("wss://","https://");
var uriParts = websocketURL.split("/");
websocketURL = uriParts[0] + "//" + uriParts[2];
var errorMsg = $("#websocker-onerror").html();
errorMsg = errorMsg.replace(new RegExp('\\$sensorType', 'g'), sensorType);
errorMsg = errorMsg.replace(new RegExp('\\$webSocketURL', 'g'), websocketURL);
$(graph.element).parent().html("<div class='alert alert-danger'>" + errorMsg + "</div>");
$(graph.element).hide();
};
}
if (sensorType == "temperature") {
wsConnectionTemperature = wsConnection;

@ -37,6 +37,9 @@
<i class="fw fw-statistics fw-stack-1x"></i>
</span> View Device Analytics
</a>
<div class="hide" id="websocker-onerror">
Realtime Analytics is not available. Failed to connect to the websocket. Please make sure; '<a style="color: white" href="$webSocketURL">$webSocketURL</a>' is available and re-try again.
</div>
<!-- /statistics -->
{{#zone "bottomJs"}}
{{js "js/moment.min.js"}}

@ -104,6 +104,16 @@ function connect(wsConnection, target, chartData, graph) {
chartData.shift();
graph.update();
};
wsConnection.onerror = function (event) {
var websocketURL = event.currentTarget.url;
websocketURL = websocketURL.replace("wss://","https://");
var uriParts = websocketURL.split("/");
websocketURL = uriParts[0] + "//" + uriParts[2];
var errorMsg = $("#websocker-onerror").html();
errorMsg = errorMsg.replace(new RegExp('\\$webSocketURL', 'g'), websocketURL);
$(graph.element).parent().html("<div class='alert alert-danger'>" + errorMsg + "</div>");
$(graph.element).hide();
};
}
}

Loading…
Cancel
Save