diff --git a/packages/frontend/src/Connection.ts b/packages/frontend/src/Connection.ts index 169765c..b5a9b67 100644 --- a/packages/frontend/src/Connection.ts +++ b/packages/frontend/src/Connection.ts @@ -11,7 +11,9 @@ export class Connection { return new Connection(await Connection.socket(), update); } - private static readonly address = `ws://${window.location.hostname}:8080`; + private static readonly address = window.location.protocol === 'https:' + ? `wss://${window.location.hostname}/feed/` + : `ws://${window.location.hostname}:8080`; private static async socket(): Promise { let socket = await Connection.trySocket(); diff --git a/packages/frontend/src/components/Chain.css b/packages/frontend/src/components/Chain.css index 7955e1a..121502c 100644 --- a/packages/frontend/src/components/Chain.css +++ b/packages/frontend/src/components/Chain.css @@ -65,6 +65,7 @@ position: absolute; top: 50%; left: 50%; + cursor: pointer; } .Chain-node-list { diff --git a/packages/frontend/src/components/Chain.tsx b/packages/frontend/src/components/Chain.tsx index 65f342e..b2022c6 100644 --- a/packages/frontend/src/components/Chain.tsx +++ b/packages/frontend/src/components/Chain.tsx @@ -163,7 +163,7 @@ export class Chain extends React.Component { { - this.nodes().sort(sortNodes).map((node) => ) + this.nodes().sort(sortNodes).map((node) => ) } @@ -174,7 +174,7 @@ export class Chain extends React.Component { return Array.from(this.props.appState.nodes.values()); } - private pixelPosition(lat: Types.Latitude, lon: Types.Longitude): { left: number, top: number } { + private pixelPosition(lat: Types.Latitude, lon: Types.Longitude): Node.PixelPosition { const { map } = this.state; const left = Math.round(((lon + 180) / 360) * map.width + map.left) - 35; diff --git a/packages/frontend/src/components/Node.tsx b/packages/frontend/src/components/Node.tsx index 861e31b..66f94d1 100644 --- a/packages/frontend/src/components/Node.tsx +++ b/packages/frontend/src/components/Node.tsx @@ -5,30 +5,48 @@ import { Types, Maybe } from '@dotstats/common'; export namespace Node { export interface Props { - id: Types.NodeId, - nodeDetails: Types.NodeDetails, - nodeStats: Types.NodeStats, - blockDetails: Types.BlockDetails, - location: Maybe, + id: Types.NodeId; + nodeDetails: Types.NodeDetails; + nodeStats: Types.NodeStats; + blockDetails: Types.BlockDetails; + location: Maybe; + } + + export interface PixelPosition { + left: number; + top: number; + } + + export function Row(props: Props) { + const [name, implementation, version] = props.nodeDetails; + const [height, hash, blockTime, blockTimestamp, propagationTime] = props.blockDetails; + const [peers, txcount] = props.nodeStats; + + return ( + + {name} + {implementation} v{version} + {peers} + {txcount} + #{formatNumber(height)} + {trimHash(hash, 16)} + {secondsWithPrecision(blockTime/1000)} + {propagationTime === null ? '∞' : milliOrSecond(propagationTime as number)} + + + ); + } + + export function Location(props: Props & PixelPosition) { + const { left, top } = props; + + return ( + + ); } } - -export function Node(props: Node.Props) { - const [name, implementation, version] = props.nodeDetails; - const [height, hash, blockTime, blockTimestamp, propagationTime] = props.blockDetails; - const [peers, txcount] = props.nodeStats; - - return ( - - {name} - {implementation} v{version} - {peers} - {txcount} - #{formatNumber(height)} - {trimHash(hash, 16)} - {secondsWithPrecision(blockTime/1000)} - {propagationTime === null ? '∞' : milliOrSecond(propagationTime as number)} - - - ); -}