import {LitElement, html} from './lit-all.min.js'; import * as tfrpc from '/static/tfrpc.js'; class TfTabConnectionsElement extends LitElement { static get properties() { return { broadcasts: {type: Array}, identities: {type: Array}, connections: {type: Array}, users: {type: Object}, } } constructor() { super(); let self = this; this.broadcasts = []; this.identities = []; this.connections = []; this.users = {}; tfrpc.rpc.getAllIdentities().then(function(identities) { self.identities = identities || []; }); } _emit_change() { let changed_event = new Event('change', { srcElement: this, }); this.dispatchEvent(changed_event); } changed(event) { this.selected = event.srcElement.value; tfrpc.rpc.localStorageSet('whoami', this.selected); this._emit_change(); } render_connection_summary(connection) { if (connection.address && connection.port) { return html`(${connection.address}:${connection.port})`; } else if (connection.tunnel) { return html`(room peer)`; } else { return JSON.stringify(connection); } } render_room_peers(connection) { let self = this; let peers = this.broadcasts.filter(x => x.tunnel?.id == connection); if (peers.length) { return html`