connected/disconnected toasts

This commit is contained in:
Giulio De Pasquale 2020-12-10 16:54:49 +00:00
parent 9955ddf08e
commit 277fe2ae02
2 changed files with 104 additions and 89 deletions

View File

@ -28,7 +28,11 @@ $(document).ready(function () {
})
socket.on("connect", function(socket) {
console.log("Connected");
$("#connectedtoast").toast("show")
});
socket.on("disconnect", function(socket) {
$("#disconnectedtoast").toast("show")
});
socket.on("new_tick", function(data) {

View File

@ -15,7 +15,7 @@
<title>Hello world!</title>
<body class="h-100 d-flex flex-column">
<main class="container my-2 border h-100">
<main class="container my-2 border h-100">
<div class="row row-cols-auto justify-content-center my-2" id="statistics">
<div class="card bg-light mx-auto" style="max-width: 25rem;">
@ -104,22 +104,33 @@
</div>
</div>
</div>
</main>
</main>
<div class="toast">
<div class="toast-container hide">
<div class="toast mx-2 my-2 bg-success hide" id="connectedtoast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
Toast Header
</div>
<div class="toast-body">
Some text inside the toast body
</div>
<strong class="me-auto">Connected!</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> </div>
<!-- <div class="toast-body bg-light">-->
<!-- You are connected to the server.-->
<!-- </div>-->
</div>
<footer class="footer mt-auto py-3 bg-light border-top">
<div class="container text-center">
<span class="text-muted">Made with love by the Pepe</span>
<div class="toast mx-2 my-2 bg-danger hide" id="disconnectedtoast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<strong class="me-auto">Disconnected!</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button> </div>
<!-- <div class="toast-body bg-light">-->
<!-- You got disconnected from the server.-->
<!-- </div>-->
</div>
</footer>
</div>
<footer class="footer mt-auto py-3 bg-light border-top">
<div class="container text-center">
<span class="text-muted">Made with ❤️ by the Pepe</span>
</div>
</footer>
</body>
</html>