p2p、分布式,区块链笔记(OrbitDB.ControlCenter 004): 在浏览器中运行 OrbitDB Control Center 默认界面:src\views\Databases.js

在这里插入图片描述

默认界面:src\views\Databases.js

  • 第一个更新的界面即为src\views\Databases.js

在这里插入图片描述

界面主体部分

  • {!appState.loading.programs ? ... : ...} 根据 appState.loading.programs 的布尔值选择渲染的内容:
    • 如果为 false,则渲染 ProgramList 组件,传入 programs: []handleRemoveDatabase 函数。handleRemoveDatabase会调用database的 removeDatabase(hash)移除数据。

    • 如果为 true,则渲染一个包含 SpinnerTextPane 组件,用于显示加载状态。

<Pane display='flex' justifyContent='center' overflow='auto'>
      <CreateDialog onCreate={createDB}/>
      <AddDialog onAdd={addDB}/>
      <Pane
        flex='1'
        overflow='auto'
        elevation={1}
        background='white'
        marginX={majorScale(6)}
      >
        {!appState.loading.programs 
          ? (<ProgramList
              programs={appState.programs}
              onRemove={handleRemoveDatabase}
            />)
          : (<Pane
              display='flex' 
              flexDirection='column' 
              alignItems='center' 
              marginTop={majorScale(3)}
              marginBottom={majorScale(1)}
            >
              <Spinner size={24}/>
              <Text marginY={majorScale(1)}>Loading...</Text>
            </Pane>)
        }
        <Pane
              display='flex' 
              flexDirection='column' 
              alignItems='center' 
              marginTop={majorScale(3)}
              marginBottom={majorScale(1)}
            >
              <Spinner size={24}/>
              <Text marginY={majorScale(1)}>Loading...</Text>
            </Pane>
      </Pane>
    </Pane>

ProgramList - - src\components\DatabaseList.js

Create按钮部分

  • 点击“Create”按钮执行handleCreateDatabase 函数:
  const handleCreateDatabase = () => {
    dispatch({ type: actions.DB.OPEN_CREATEDB_DIALOG })
  }
  • 在App.js中进行相应的状态更新:
      case actions.DB.OPEN_CREATEDB_DIALOG:
        return {
          ...state,
          createDBDialogOpen: true
        }
  • appState.createDBDialogOpen设置为true时,src\components\CreateDialog.js中的Dialog DOM对象就会显示到界面上:
    <Dialog
      isShown={appState.createDBDialogOpen}
      title='Create Database'
      onCloseComplete={() => dispatch({ type: actions.DB.CLOSE_CREATEDB_DIALOG })}
      cancelLabel='Cancel'
      confirmLabel='Create'
      onConfirm={close => handleSubmit(null, close)}
    >

在这里插入图片描述

src\components\AddDialog.js

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值