import React from 'react'; import './App.css'; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; import Pond from "./Pond"; import SingleNode from "./SingleNode"; class Index extends React.Component { constructor(props) { super(props) this.state = {rpcUrl: "ws://127.0.0.1:1234/rpc/v0", rpcToken: ''} const initialState = JSON.parse(window.localStorage.getItem('saved-nodes')) if (initialState) { this.state.nodes = initialState } else { this.state.nodes = [] } } componentDidUpdate(prevProps, prevState, snapshot) { window.localStorage.setItem('saved-nodes', JSON.stringify(this.state.nodes)) } onAdd = () => { this.setState({addingNode: true}) } update = (name) => (e) => this.setState({ [name]: e.target.value }) tokenOk = () => { let m = this.state.rpcToken.match(/\.(.+)\./) // TODO: eww if(m && atob(m[1]) === '{"Allow":["read","write","sign","admin"]}') { return ( -Token OK-
) } return -Expecting valid admin token- } addNode = async () => { this.setState(p => ({nodes: [...p.nodes, {addr: this.state.rpcUrl, token: this.state.rpcToken}], addingNode: true})) } render() { return (
{ this.state.nodes.map((node, i) =>
{i}. {node.addr} [OPEN UI]
) }
Open Pond
) } } class App extends React.Component { constructor(props) { super(props) } render() { return ( ) } } export default App