mirror of
https://repository.entgra.net/community/product-iots.git
synced 2025-09-16 23:32:19 +00:00
Merge pull request #1660 from rasika/fix-1659
Adding notification for the user on a Websocket handshake failure
This commit is contained in:
commit
6d88fd86bd
@ -52,6 +52,10 @@
|
|||||||
</span>
|
</span>
|
||||||
</span> View Device Analytics
|
</span> View Device Analytics
|
||||||
</a>
|
</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 -->
|
<!-- /statistics -->
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
{{js "js/moment.min.js"}}
|
{{js "js/moment.min.js"}}
|
||||||
|
|||||||
@ -114,6 +114,17 @@ function connect(wsConnection, target, chartData, graph, sensorType) {
|
|||||||
chartData.shift();
|
chartData.shift();
|
||||||
graph.update();
|
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") {
|
if (sensorType == "temperature") {
|
||||||
wsConnectionTemperature = wsConnection;
|
wsConnectionTemperature = wsConnection;
|
||||||
|
|||||||
@ -37,6 +37,9 @@
|
|||||||
<i class="fw fw-statistics fw-stack-1x"></i>
|
<i class="fw fw-statistics fw-stack-1x"></i>
|
||||||
</span> View Device Analytics
|
</span> View Device Analytics
|
||||||
</a>
|
</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 -->
|
<!-- /statistics -->
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
{{js "js/moment.min.js"}}
|
{{js "js/moment.min.js"}}
|
||||||
|
|||||||
@ -104,6 +104,16 @@ function connect(wsConnection, target, chartData, graph) {
|
|||||||
chartData.shift();
|
chartData.shift();
|
||||||
graph.update();
|
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…
Reference in New Issue
Block a user