Watching SN that are online or offline Set Up HTML Structure: Create the basic HTML structure for your webpage. Include a container to hold the node status information. html Copy code
<title>Graft Service Nodes Status</title> const nodesStatus = await fetchNodesStatus();
nodesStatus.forEach(node => {
const nodeItem = document.createElement('div');
nodeItem.classList.add('node-status-item');
const nodeName = document.createElement('span');
nodeName.textContent = node.name;
nodeItem.appendChild(nodeName);
const nodeStatus = document.createElement('span');
nodeStatus.textContent = node.online ? 'Online' : 'Offline';
nodeStatus.classList.add(node.online ? 'online' : 'offline');
nodeItem.appendChild(nodeStatus);
const nodeAdditionalInfo = document.createElement('p');
nodeAdditionalInfo.textContent = `Additional Info: ${node.additionalInfo}`;
nodeItem.appendChild(nodeAdditionalInfo);
nodeStatusContainer.appendChild(nodeItem);
});
}
displayNodesStatus(); // Call the function to display nodes status initially
#nodeStatusContainer {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
}
.node-status-item {
padding: 10px;
border: 1px solid #ccc;
width: 250px;
text-align: center;
}
.online {
color: green;
}
.offline {
color: red;
}
Please note that the provided JavaScript code assumes that the API returns a JSON array of nodes, and each node object contains properties like name, online, and additionalInfo. Replace 'https://api.example.com/graft-nodes-status' with the actual API endpoint that provides the Graft Service Nodes' status data. Also, adjust the code according to the structure of the API response.