import { LitElement, html, css } from 'https://cdn.jsdelivr.net/gh/lit/dist@3/core/lit-all.min.js'; window.customElements.define('chain-connectivity', class MyElement extends LitElement { constructor() { super(); this.data = []; this.loadData(); } loadData() { const eventSource = new EventSource('/api/debug/chain-state-sse'); eventSource.onmessage = (event) => { this.data.push(JSON.parse(event.data)); }; eventSource.onerror = (error) => { console.error('Error:', error); loadData(); }; }; static get styles() { return [css` :host { box-sizing: border-box; /* Don't forgert this to include padding/border inside width calculation */ } table { border-collapse: collapse; } table td, table th { border-left: 1px solid #f0f0f0; padding: 1px 5px; } table tr td:first-child, table tr th:first-child { border-left: none; } .success { color: green; } .warning { color: yellow; } .error { color: red; } `]; } render = () => html` ${this.data.map(item => html` `)}
RPC Address Reachability Sync Status Version
{{.Address}} ${item.Address} ${item.Reachable ? html`ok` : html`FAIL`} ${item.SyncState === "ok" ? html`ok` : html`${item.SyncState}`} ${item.Version}
Data incoming...
` });