3 Commits

Author SHA1 Message Date
Logan Cusano
c0927601b9 Update toast creator to display proper date string 2023-07-16 01:54:13 -04:00
Logan Cusano
ef45cf6539 Only show heartbeat toast once HTTP request is complete 2023-07-16 01:51:25 -04:00
Logan Cusano
23bea5f74e Update heartbeat function location and name 2023-07-16 01:50:01 -04:00
4 changed files with 5 additions and 8 deletions

View File

@@ -1,3 +0,0 @@
function sendNodeHeartbeat(nodeId) {
console.log(nodeId);
}

View File

@@ -44,7 +44,7 @@ function createToast(notificationMessage){
toastTitle.appendChild(document.createTextNode("Server Notification")); toastTitle.appendChild(document.createTextNode("Server Notification"));
const toastTime = document.createElement('small'); const toastTime = document.createElement('small');
toastTime.appendChild(document.createTextNode(Date.now().toLocaleString())); toastTime.appendChild(document.createTextNode(new Date(Date.now()).toLocaleString()));
const toastClose = document.createElement('button'); const toastClose = document.createElement('button');
toastClose.type = 'button'; toastClose.type = 'button';
@@ -80,13 +80,13 @@ function createToast(notificationMessage){
$('.toast').toast('show'); $('.toast').toast('show');
} }
function checkInByNodeId(nodeId){ function sendNodeHeartbeat(nodeId){
const Http = new XMLHttpRequest(); const Http = new XMLHttpRequest();
const url='/nodes/'+nodeId; const url='/nodes/'+nodeId;
Http.open("GET", url); Http.open("GET", url);
Http.send(); Http.send();
Http.onreadystatechange = (e) => { Http.onloadend = (e) => {
console.log(Http.responseText) console.log(Http.responseText)
createToast(Http.responseText); createToast(Http.responseText);
} }

View File

@@ -7,5 +7,5 @@
</div> </div>
</div> </div>
<%- include('partials/bodyEnd.ejs') %> <%- include('partials/bodyEnd.ejs') %>
<script src="/res/js/controller.js"></script> <script src="/res/js/node.js"></script>
<%- include('partials/htmlFooter.ejs') %> <%- include('partials/htmlFooter.ejs') %>

View File

@@ -30,7 +30,7 @@
<!-- Leave Server button --> <!-- Leave Server button -->
<a type="button" class="btn btn-danger <% if(!node.online) { %>disabled<% } %>" href="#" onclick="leaveServer()">Leave Server</a> <a type="button" class="btn btn-danger <% if(!node.online) { %>disabled<% } %>" href="#" onclick="leaveServer()">Leave Server</a>
<!-- Checkin with client button --> <!-- Checkin with client button -->
<a type="button" class="btn btn-secondary" href="#" onclick="checkInByNodeId('<%=node.id%>')">Check-in with Node</a> <a type="button" class="btn btn-secondary" href="#" onclick="sendNodeHeartbeat('<%=node.id%>')">Check-in with Node</a>
</div> </div>
</div> </div>