import { LitElement, html, css } from 'https://cdn.jsdelivr.net/gh/lit/dist@3/all/lit-all.min.js'; import RPCCall from '/lib/jsonrpc.mjs'; window.customElements.define('chain-connectivity', class MyElement extends LitElement { constructor() { super(); this.data = []; this.loadData(); } async loadData() { const blockDelay = await RPCCall('BlockDelaySecs') await this.updateData(); setInterval(this.update, blockDelay * 1000); }; async updateData() { this.data = await RPCCall('SyncerState'); console.log(this.data); super.requestUpdate(); } static get styles() { return [css` :host { box-sizing: border-box; /* Don't forgert this to include padding/border inside width calculation */ } .success { color: green; } .warning { color: yellow; } .error { color: red; } `]; } render = () => html` ${this.data.map(item => html` `)}
RPC Address Reachability Sync Status Version
${item.Address} ${item.Reachable ? html`ok` : html`FAIL`} ${item.SyncState === "ok" ? html`ok` : html`${item.SyncState}`} ${item.Version}
` });