Skip to content

Commit

Permalink
Merge pull request #249 from fengyangsy/issue-#248
Browse files Browse the repository at this point in the history
Add create network page, close #248
  • Loading branch information
yeasy authored Jun 1, 2021
2 parents ee9b4a8 + d3a0dd9 commit 99859bf
Show file tree
Hide file tree
Showing 10 changed files with 340 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/api-engine/api/routes/network/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NetworkViewSet(viewsets.ViewSet):
def _genesis2base64(self, network):
"""
convert genesis.block to Base64
HTTP_201_CREATED
:param network: network id
:return: genesis block
:rtype: bytearray
Expand Down Expand Up @@ -72,7 +72,7 @@ def list(self, request):
serializer = NetworkQuery(data=request.GET)
if serializer.is_valid(raise_exception=True):
page = serializer.validated_data.get("page", 1)
per_page = serializer.validated_data.get("per_page", 10)
per_page = serializer.validated_data.ger_page", 10)
name = serializer.validated_data.get("name")
parameters = {}
if name:
Expand Down
6 changes: 6 additions & 0 deletions src/dashboard/config/router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export default [
name: 'network',
component: './Operator/Network/Network',
},
{
path: '/operator/network/newNetwork',
name: 'newNetwork',
component: './Operator/Network/newNetwork',
hideInMenu: true,
},
{
path: '/operator/userManagement',
name: 'userManagement',
Expand Down
18 changes: 18 additions & 0 deletions src/dashboard/mock/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,25 @@ function getNets(req, res) {
});
}

function createNet(req, res) {
const message = req.body;
const netInfo = {
id : Mock.Random.guid(),
name: message.name,
created_at: new Date(),
type: message.type,
version: message.version,
consensus: message.consensus,
db: message.db,
status: 'OK'
};
networks.data.push(netInfo);

res.send({...netInfo, success: true});
}

export default {
'GET /api/networks': getNets,
'POST /api/networks': createNet,
networks
};
1 change: 1 addition & 0 deletions src/dashboard/src/locales/en-US/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
'menu.operator.newNode.basicInfo': 'Input Node Basic Information',
'menu.operator.newNode.nodeInfo': 'Input Special Information For Node',
'menu.operator.network': 'network',
'menu.operator.newNetwork': 'New Network',
'menu.exception': 'Exception',
'menu.exception.not-permission': '403',
'menu.exception.not-find': '404',
Expand Down
16 changes: 15 additions & 1 deletion src/dashboard/src/locales/en-US/operatorNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@ export default {
'app.operator.network.delete.success': 'Delete Network {name} success',
'app.operator.network.form.delete.title': 'Delete Network',
'app.operator.network.form.delete.content': 'Confirm to delete network {name}',
'app.operator.network.table.header.version': 'Fabric version'
'app.operator.network.table.header.version': 'Fabric version',
'app.operator.newNetwork.title': 'New Network',
'app.operator.newNetwork.label.name': 'Network Name',
'app.operator.newNetwork.required.Name': 'Please input name.',
'app.operator.newNetwork.label.type': 'Type',
'app.operator.newNetwork.required.type': 'Please select the type.',
'app.operator.newNetwork.label.version': 'Version',
'app.operator.newNetwork.required.version': 'Please select the version.',
'app.operator.newNetwork.label.db': 'Status database',
'app.operator.newNetwork.required.db': 'Please select the database.',
'app.operator.newNetwork.label.consensus': 'Consensus',
'app.operator.newNetwork.required.consensus': 'Please select the consensus.',
'app.operator.newNetwork.label.description': 'Description',
'app.operator.newNetwork.success': 'Create network {name} success.',
'app.operator.newNetwork.fail': 'Create network {name} fail.',
};
1 change: 1 addition & 0 deletions src/dashboard/src/locales/zh-CN/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default {
'menu.operator.newNode.basicInfo': '输入节点基本信息',
'menu.operator.newNode.nodeInfo': '输入节点的特殊信息',
'menu.operator.network': '网络',
'menu.operator.newNetwork': '新建网络',
'menu.exception': '异常页',
'menu.exception.not-permission': '403',
'menu.exception.not-find': '404',
Expand Down
16 changes: 15 additions & 1 deletion src/dashboard/src/locales/zh-CN/operatorNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@ export default {
'app.operator.network.delete.success': '删除组织 {name} 成功',
'app.operator.network.form.delete.title': '删除网络',
'app.operator.network.form.delete.content': '确认删除网络 {name}',
'app.operator.network.table.header.version': '版本'
'app.operator.network.table.header.version': '版本',
'app.operator.newNetwork.title': '新建网络',
'app.operator.newNetwork.label.name': '网络名称',
'app.operator.newNetwork.required.Name': '请输入名称。',
'app.operator.newNetwork.label.type': '类型',
'app.operator.newNetwork.required.type': '请选择类型。',
'app.operator.newNetwork.label.version': '版本',
'app.operator.newNetwork.required.version': '请选择版本。',
'app.operator.newNetwork.label.db': '状态数据库',
'app.operator.newNetwork.required.db': '请选择数据库。',
'app.operator.newNetwork.label.consensus': '共识',
'app.operator.newNetwork.required.consensus': '请选择共识类型。',
'app.operator.newNetwork.label.description': '描述',
'app.operator.newNetwork.success': '创建网络 {name} 成功。',
'app.operator.newNetwork.fail': '创建网络 {name} 失败。',
};
8 changes: 6 additions & 2 deletions src/dashboard/src/pages/Operator/Network/Network.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SPDX-License-Identifier: Apache-2.0
*/
import React, { PureComponent, Fragment } from 'react';
import { connect, injectIntl } from 'umi';
import { connect, injectIntl, history } from 'umi';
import { Card, Button, Modal, message, Divider } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import moment from 'moment';
Expand Down Expand Up @@ -51,6 +51,10 @@ class Network extends PureComponent {
});
};

newNetwork = () => {
history.push('/operator/network/newNetwork');
};

render() {
const { selectedRows } = this.state;
const {
Expand Down Expand Up @@ -116,7 +120,7 @@ class Network extends PureComponent {
<Card bordered={false}>
<div className={styles.tableList}>
<div className={styles.tableListOperator}>
<Button type="primary" >
<Button type="primary" onClick={()=>this.newNetwork()} >
<PlusOutlined />
{intl.formatMessage({ id: 'form.button.new', defaultMessage: 'New' })}
</Button>
Expand Down
Loading

0 comments on commit 99859bf

Please sign in to comment.