class CustomNodeGroup extends HTMLElement {
connectedCallback() {
const title = this.getAttribute('title') || 'Nodes';
const status = this.getAttribute('status') || 'operational';
const count = this.getAttribute('count') || '0';
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
${title}
${status.charAt(0).toUpperCase() + status.slice(1)} (${count})
${this.generateNodeItems(title, count)}
`;
}
generateNodeItems(group, count) {
const nodes = [];
const groupPrefix = group.split(' ')[0].toLowerCase();
for (let i = 1; i <= parseInt(count); i++) {
const latency = Math.floor(Math.random() * 500) + 50;
const latencyClass = latency <= 300 ? 'latency-normal' :
latency <= 700 ? 'latency-warning' : 'latency-high';
nodes.push(`
${groupPrefix}-node-${i}
${groupPrefix.toUpperCase()} • us-east-1
${latency} ms
`);
}
return nodes.join('');
}
}
customElements.define('custom-node-group', CustomNodeGroup);