diff --git a/package.json b/package.json index fd4b0055..d5ce4bfe 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "init:autocomplete": "bdk fabric completion > $HOME/.bash_bdk", "build:console": "ts-node src/console.ts", "start:dev": "NODE_ENV=development nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' src/console.ts", - "start:ui": "NODE_ENV=ui nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' src/console.ts", + "start:dashboard": "NODE_ENV=dashboard nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' src/console.ts", "test": "NODE_ENV=testing BDK_PATH=$(pwd)/test/bdk BDK_DOCKER_HOST_PATH=$(pwd)/test/bdk mocha --reporter spec --require ts-node/register ./test/**/*.test.ts --exit", "test:dev": "nodemon --watch 'test/**/*.test.ts' -e ts,tsx --exec npm run test", "test:nyan": "NODE_ENV=testing mocha --reporter nyan --require ts-node/register ./test/**/*.test.ts --exit", diff --git a/src/bdk.ts b/src/bdk.ts index fae6bf61..1c6bcbd0 100755 --- a/src/bdk.ts +++ b/src/bdk.ts @@ -28,7 +28,7 @@ const argv = yargs .commandDir('quorum') .commandDir('wallet') .commandDir('hello') - .commandDir('ui') + .commandDir('dashboard') .strict() .demandCommand() .completion() diff --git a/src/ui/components/logo.tsx b/src/dashboard/components/logo.tsx similarity index 100% rename from src/ui/components/logo.tsx rename to src/dashboard/components/logo.tsx diff --git a/src/ui/components/nodeInfo.tsx b/src/dashboard/components/nodeInfo.tsx similarity index 94% rename from src/ui/components/nodeInfo.tsx rename to src/dashboard/components/nodeInfo.tsx index b2a0612d..9f392742 100644 --- a/src/ui/components/nodeInfo.tsx +++ b/src/dashboard/components/nodeInfo.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react' import { Box, Text, Newline } from 'ink' -import { NodeDetails } from '../models/type/ui.type' +import { NodeDetails } from '../models/type/dashboard.type' import { NodeContextService } from '../services/nodeContext' export default function NodeInfo (props: any) { diff --git a/src/ui/components/peerInfo.tsx b/src/dashboard/components/peerInfo.tsx similarity index 96% rename from src/ui/components/peerInfo.tsx rename to src/dashboard/components/peerInfo.tsx index 11c6954b..8f6f664b 100644 --- a/src/ui/components/peerInfo.tsx +++ b/src/dashboard/components/peerInfo.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react' import { Box, Text } from 'ink' import { NodeContextService } from '../services/nodeContext' -import { PeerInformation } from '../models/type/ui.type' +import { PeerInformation } from '../models/type/dashboard.type' export default function PeerInfo (props: any) { const apiUrl: string = props.apiUrl diff --git a/src/ui/components/status.tsx b/src/dashboard/components/status.tsx similarity index 97% rename from src/ui/components/status.tsx rename to src/dashboard/components/status.tsx index eeae2e56..6c633dfb 100644 --- a/src/ui/components/status.tsx +++ b/src/dashboard/components/status.tsx @@ -45,7 +45,7 @@ const NodeStatus = memo(function NodeStatus (props: any) { return ( - Node Status + Node Status Status: {state} diff --git a/src/ui/ui.tsx b/src/dashboard/dashboard.tsx similarity index 74% rename from src/ui/ui.tsx rename to src/dashboard/dashboard.tsx index 0fa53917..ab436a27 100644 --- a/src/ui/ui.tsx +++ b/src/dashboard/dashboard.tsx @@ -3,9 +3,9 @@ import { Argv } from 'yargs' import { render } from 'ink' import App from './views/app.js' -export const command = 'ui' +export const command = 'dashboard' -export const desc = '使用 ui 模式' +export const desc = '使用 dashboard 模式' export const builder = (yargs: Argv) => { return yargs } diff --git a/src/ui/models/type/ui.type.ts b/src/dashboard/models/type/dashboard.type.ts similarity index 100% rename from src/ui/models/type/ui.type.ts rename to src/dashboard/models/type/dashboard.type.ts diff --git a/src/ui/services/nodeContext.ts b/src/dashboard/services/nodeContext.ts similarity index 96% rename from src/ui/services/nodeContext.ts rename to src/dashboard/services/nodeContext.ts index b7da1fcc..5821090a 100644 --- a/src/ui/services/nodeContext.ts +++ b/src/dashboard/services/nodeContext.ts @@ -1,5 +1,5 @@ import fs from 'fs-extra' -import { NodeDetails, PeerInformation } from '../models/type/ui.type' +import { NodeDetails, PeerInformation } from '../models/type/dashboard.type' import axios from 'axios' export class NodeContextService { diff --git a/src/ui/views/app.tsx b/src/dashboard/views/app.tsx similarity index 89% rename from src/ui/views/app.tsx rename to src/dashboard/views/app.tsx index e3affde3..ed71c9e8 100644 --- a/src/ui/views/app.tsx +++ b/src/dashboard/views/app.tsx @@ -6,7 +6,8 @@ import NodeStatus from '../components/status' import NodeInfo from '../components/nodeInfo' import PeerInfo from '../components/peerInfo' import { NodeContextService } from '../services/nodeContext' -import { NodeListType } from '../models/type/ui.type' +import { NodeListType } from '../models/type/dashboard.type' +import { debounce } from '../../util' export default function App () { const { exit } = useApp() @@ -57,19 +58,19 @@ export default function App () { const [nodeType, setNodeType] = useState(NodeList[0].value) const [nodeName, setNodeName] = useState(NodeList[0].label) - const selectNode = (item: NodeListType) => { + const selectNode = debounce((item: NodeListType) => { setNodeType(item.value) setNodeName(item.label) - } + }, 100) return ( - Select Node: + Select Node: - + Current node: {nodeName} {nodeType}