import { LitElement, html, css } from 'https://cdn.jsdelivr.net/npm/lit-html@3.1.0/lit-html.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`
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... |