提交 dc0d2097 编写于 作者: J jinlong12

数据账户页面代码提交

上级 85dd18a9
...@@ -49,6 +49,7 @@ const contract = require('./routes/contract'); ...@@ -49,6 +49,7 @@ const contract = require('./routes/contract');
app.use('/contract', contract); app.use('/contract', contract);
const ledgers = require('./routes/ledgers'); const ledgers = require('./routes/ledgers');
app.use('/ledgers', ledgers); app.use('/ledgers', ledgers);
app.use('/keys', ledgers);
app.use('/blockHeight', overview); app.use('/blockHeight', overview);
app.use('/transactionAccount', overview); app.use('/transactionAccount', overview);
app.use('/userTotal', overview); app.use('/userTotal', overview);
......
...@@ -87,29 +87,104 @@ router.get('', function(req, res) { ...@@ -87,29 +87,104 @@ router.get('', function(req, res) {
}); });
Object.assign({ Object.assign({
"success": true, "data": {
"address": "www.jd.com",
"pubKey": {
"value": "UUi8Ku8aypHYnNkJRuFnkEYSuXT"
}
},
"success": true
});
res.send({
"data": {
"address": "www.jd.com",
"pubKey": {
"value": "UUi8Ku8aypHYnNkJRuFnkEYSuXT"
}
},
"success": true
});
});
// 获取数据账户中某些Key的结果
router.post('/keys', function(req, res) {
res.type('json');
let params = req.body,
ret = {};
const datas = _.times(100, function(i) {
let num = i + 1;
return {
test1: num + 100000,
test2: '测试' + num,
test4: _.random(10, 90) + '%',
test5: _.random(10, 90) + '%',
test6: _.random(10, 90) + '%',
test8: _.random(1, 10),
test9: _.random(1, 10),
test10: _.random(1, 10),
test11: _.random(1, 10),
test12: _.random(1, 10),
test14: _.random(10, 90) + '%',
test15: _.random(10, 90) + '%',
test16: _.random(1, 24),
test17: _.random(10, 90) + '%',
test18: _.random(1, 100000)
};
});
const pageIndex = params.currentPage,
pageSize = params.pageSize,
start = (pageIndex - 1) * pageSize,
end = pageIndex * pageSize,
data = datas.filter((obj, i) => {
if (i >= start && i < end) {
return true;
}
});
Object.assign({
"data": [ "data": [
{ {
"value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" "value": "value1",
"nil": false,
"key": "key1",
"type": "TEXT",
"version": 1
}, },
{ {
"value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" "value": "value2",
"nil": false,
"key": "key2",
"type": "TEXT",
"version": 2
} }
] ],
"success": true
}); });
res.send({ res.send({
"success": true,
"data": [ "data": [
{ {
"value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" "value": "value1",
"nil": false,
"key": "key1",
"type": "TEXT",
"version": 1
}, },
{ {
"value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" "value": "value2",
"nil": false,
"key": "key2",
"type": "TEXT",
"version": 2
} }
] ],
"success": true
});
}); });
});
// 区块高度 // 区块高度
router.get('/blockHeight', function(req, res) { router.get('/blockHeight', function(req, res) {
res.type('json'); res.type('json');
...@@ -1657,61 +1732,63 @@ router.get('/transactionHash', function(req, res) { ...@@ -1657,61 +1732,63 @@ router.get('/transactionHash', function(req, res) {
"hash": { "hash": {
"value": "fH9d8BYxU" "value": "fH9d8BYxU"
}, },
"ledgerHash": {
"value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9"
},
"operations": [ "operations": [
{ {
"writeSet": [ "accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t",
{ "writeSet": [{
"key": "Name",
"expectedVersion": 25, "expectedVersion": 25,
"value": "QUFB"
}
],
"accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t"
},
{
"writeSet": [
{
"key": "Name", "key": "Name",
"expectedVersion": 25,
"value": "QUFB" "value": "QUFB"
} }]
], }, {
"accountAddress": "undefined" "addressSignature": {
"digest": {
"algorithm": "ED25519",
"rawDigest": "d2FuZ3d1"
}, },
{ "pubKey": {
"writeSet": [ "value": "6gtyw9HjZbi"
{
"key": "Name",
"expectedVersion": 25,
"value": "QUFB"
} }
],
"accountAddress": "undefined"
}, },
{ "chainCode": "emhhbmdzYW4=",
"writeSet": [ "contractID": {
{ "address": "31kiRWCxNm8tYxhFK5wnDp3wNxLCuiVyDA7",
"key": "Name", "pubKey": {
"expectedVersion": 25, "value": "KXywstVY1tEAgEsc7kox48L"
"value": "QUFB" }
}
}, {
"args": "YXJncw==",
"contractAddress": "contract-address",
"event": "contract-event"
}, {
"accountID": {
"address": "31r5f9D8kCxkiat2GvRJfjNi1fnFvaWaBEu",
"pubKey": {
"value": "5CYw7ztKJRxVt6Mfgz6vSQ"
} }
],
"accountAddress": "undefined"
}, },
{ "addressSignature": {
"writeSet": [ "digest": {
{ "algorithm": "ED25519",
"key": "Name", "rawDigest": "emhhb2xpdQ=="
"expectedVersion": 25, },
"value": "QUFB" "pubKey": {
"value": "6gtyw9HjZbi"
} }
],
"accountAddress": "undefined"
} }
], }, {
"ledgerHash": { "userID": {
"value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9" "address": "321ZeecJ99N7RJGSHkRqkfBZDEAxRMHd6d5",
"pubKey": {
"value": "3qHAWiGwaF6FU2o7Lg"
} }
}
}
]
}, },
"endpointSignatures": [ "endpointSignatures": [
{ {
...@@ -1776,61 +1853,63 @@ router.get('/transactionHash', function(req, res) { ...@@ -1776,61 +1853,63 @@ router.get('/transactionHash', function(req, res) {
"hash": { "hash": {
"value": "fH9d8BYxU" "value": "fH9d8BYxU"
}, },
"ledgerHash": {
"value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9"
},
"operations": [ "operations": [
{ {
"writeSet": [ "accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t",
{ "writeSet": [{
"key": "Name",
"expectedVersion": 25, "expectedVersion": 25,
"value": "QUFB"
}
],
"accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t"
},
{
"writeSet": [
{
"key": "Name", "key": "Name",
"expectedVersion": 25,
"value": "QUFB" "value": "QUFB"
} }]
], }, {
"accountAddress": "undefined" "addressSignature": {
"digest": {
"algorithm": "ED25519",
"rawDigest": "d2FuZ3d1"
}, },
{ "pubKey": {
"writeSet": [ "value": "6gtyw9HjZbi"
{
"key": "Name",
"expectedVersion": 25,
"value": "QUFB"
} }
],
"accountAddress": "undefined"
}, },
{ "chainCode": "emhhbmdzYW4=",
"writeSet": [ "contractID": {
{ "address": "31kiRWCxNm8tYxhFK5wnDp3wNxLCuiVyDA7",
"key": "Name", "pubKey": {
"expectedVersion": 25, "value": "KXywstVY1tEAgEsc7kox48L"
"value": "QUFB" }
}
}, {
"args": "YXJncw==",
"contractAddress": "contract-address",
"event": "contract-event"
}, {
"accountID": {
"address": "31r5f9D8kCxkiat2GvRJfjNi1fnFvaWaBEu",
"pubKey": {
"value": "5CYw7ztKJRxVt6Mfgz6vSQ"
} }
],
"accountAddress": "undefined"
}, },
{ "addressSignature": {
"writeSet": [ "digest": {
{ "algorithm": "ED25519",
"key": "Name", "rawDigest": "emhhb2xpdQ=="
"expectedVersion": 25, },
"value": "QUFB" "pubKey": {
"value": "6gtyw9HjZbi"
} }
],
"accountAddress": "undefined"
} }
], }, {
"ledgerHash": { "userID": {
"value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9" "address": "321ZeecJ99N7RJGSHkRqkfBZDEAxRMHd6d5",
"pubKey": {
"value": "3qHAWiGwaF6FU2o7Lg"
}
} }
}
]
}, },
"endpointSignatures": [ "endpointSignatures": [
{ {
......
...@@ -429,27 +429,19 @@ ...@@ -429,27 +429,19 @@
<div><span>预期版本 :</span>&nbsp;&nbsp;&nbsp;v2</div> <div><span>预期版本 :</span>&nbsp;&nbsp;&nbsp;v2</div>
</div> </div>
</div> </div>
<div class="{styles.kv}"> <!-- <div class="{styles.kv}">
<div class="{styles.key}"> <div class="{styles.key}">
键 :&nbsp;&nbsp;&nbsp;UPcaZ1JRCehRwvuNS8Ty 键 :&nbsp;&nbsp;&nbsp;UPcaZ1JRCehRwvuNS8Ty
<div class="{styles.arrow} {styles.arrowBottom}"></div> <div class="{styles.arrow} {styles.arrowBottom}"></div>
</div> </div>
<!-- <div class="{styles.value}">
<div><span>值 :</span>&nbsp;&nbsp;&nbsp;xUPcaZ1JRCehR</div>
<div><span>预期版本 :</span>&nbsp;&nbsp;&nbsp;v2</div>
</div> -->
</div> </div>
<div class="{styles.kv}"> <div class="{styles.kv}">
<div class="{styles.key}"> <div class="{styles.key}">
键 :&nbsp;&nbsp;&nbsp;UPcaZ1JRCehRwvuNS8Ty 键 :&nbsp;&nbsp;&nbsp;UPcaZ1JRCehRwvuNS8Ty
<div class="{styles.arrow} {styles.arrowBottom}"></div> <div class="{styles.arrow} {styles.arrowBottom}"></div>
</div> </div>
<!-- <div class="{styles.value}">
<div><span>值 :</span>&nbsp;&nbsp;&nbsp;xUPcaZ1JRCehR</div>
<div><span>预期版本 :</span>&nbsp;&nbsp;&nbsp;v2</div>
</div> --> </div> -->
</div> </div>
</div>
<div class="{styles.optionTitle}"> <div class="{styles.optionTitle}">
合约发布 合约发布
......
...@@ -6,16 +6,20 @@ import '../../common/containerConfig'; ...@@ -6,16 +6,20 @@ import '../../common/containerConfig';
import 'flarej/lib/components/antd/button'; import 'flarej/lib/components/antd/button';
import 'flarej/lib/components/antd/breadcrumb'; import 'flarej/lib/components/antd/breadcrumb';
import 'flarej/lib/components/antd/table'; import 'flarej/lib/components/antd/table';
import 'flarej/lib/components/antd/input';
import 'flarej/lib/components/antd/select';
import { Message } from 'flarej/lib/components/antd/message'; import { Message } from 'flarej/lib/components/antd/message';
import { Select } from 'flarej/lib/components/antd/select';
import { autobind } from 'core-decorators'; import { autobind } from 'core-decorators';
import '../../components/header'; import '../../components/header';
import '../../components/sider'; import '../../components/sider';
import ContainerHoc from '../../components/higherOrders/container'; import ContainerHoc from '../../components/higherOrders/container';
import styles from './ledgers.m.less'; import styles from './ledgers.m.less';
import tmpls from './ledgers.t.html'; import tmpls from './ledgers.t.html';
import { observable } from 'mobx'; import { observable, toJS } from 'mobx';
import LedgersStore from '../../stores/LedgersStore'; import LedgersStore from '../../stores/LedgersStore';
const ledgersStore = new LedgersStore(); const ledgersStore = new LedgersStore();
const Option = Select.Option;
//页面容器组件 //页面容器组件
@inject('store') @inject('store')
...@@ -28,7 +32,6 @@ class Container extends Component { ...@@ -28,7 +32,6 @@ class Container extends Component {
render() { render() {
const { store } = this.props; const { store } = this.props;
store.test();
return this.props.tmpls[0](this, { return this.props.tmpls[0](this, {
store, store,
styles styles
...@@ -42,11 +45,17 @@ ContainerHoc('Container', Container, ledgersStore); ...@@ -42,11 +45,17 @@ ContainerHoc('Container', Container, ledgersStore);
@observer @observer
class DataTable extends Component { class DataTable extends Component {
@observable dataLedger = ''; // 合约账户 @observable dataLedger = ''; // 合约账户
@observable keys = []; // key数组
inputChange = (e) => { inputChange = (e) => {
this.dataLedger = e.target.value; this.dataLedger = e.target.value;
} }
keyChange = (e) => {
let str = e.target.value;
this.keys = str.split(',');
}
query = () => { query = () => {
const { store } = this.props; const { store } = this.props;
Promise.all([ Promise.all([
...@@ -58,8 +67,29 @@ class DataTable extends Component { ...@@ -58,8 +67,29 @@ class DataTable extends Component {
}); });
} }
queryKey = () => {
const { store } = this.props;
Promise.all([
store.getKeyData(this.keys)
]).then(
).catch((err) => {
console.log(err);
});
}
// 待确认
selectItem = () => (
<Select defaultValue = "1">
<Option value = "1">原始内容</Option>
<Option value = "2">转码内容</Option>
</Select>
)
render() { render() {
const { store } = this.props;
return tmpls.dataTable(this.state, this.props, this, { return tmpls.dataTable(this.state, this.props, this, {
store,
styles styles
}); });
} }
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
box-shadow: 0 0 4px 0 rgba(0,0,0,0.10); box-shadow: 0 0 4px 0 rgba(0,0,0,0.10);
border-radius: 6px; border-radius: 6px;
padding: 30px; padding: 30px;
height: 672px; min-height: 672px;
& .dataTitle { & .dataTitle {
font-family: MicrosoftYaHei; font-family: MicrosoftYaHei;
font-size: 14px; font-size: 14px;
...@@ -84,6 +84,72 @@ ...@@ -84,6 +84,72 @@
width: 90%; width: 90%;
} }
} }
& .keyContent {
padding: 0 30px;
& .queryLedger {
text-align: center;
padding-top: 40px;
font-family: MicrosoftYaHei;
font-size: 14px;
color: #666666;
& span {
font-weight: bold;
color: #151515;
}
}
& .inputQuery {
margin-bottom: 30px;
& .inputValue {
max-width: 718px;
width: 100%;
height: 36px;
line-height: 36px;
padding-left: 18px;
background: #FFFFFF;
border: 1px solid #CCCCCC;
border-radius: 4px;
color: #C8C8C7;
}
& .queryButton {
background: #5A77D3;
border-radius: 4px;
height: 36px;
margin-left: 40px;
color: #FFFFFF;
}
}
& .keyStates {
& .keyState {
& .key {
background: #ADC6FF;
border-radius: 4px;
height: 50px;
line-height: 50px;
color: #FFFFFF;
padding-left: 20px;
}
& .values {
padding: 0 20px;
& p {
padding: 4px 0;
font-family: MicrosoftYaHei;
font-size: 14px;
color: #92918D;
& span {
font-weight: bold;
font-size: 14px;
color: #67635D;
}
}
& .keyText {
min-height: 36px;
height: 36px;
margin-bottom: 14px;
}
}
}
}
}
} }
} }
} }
......
...@@ -14,30 +14,56 @@ ...@@ -14,30 +14,56 @@
<!-- 列表区域 --> <!-- 列表区域 -->
<div class="{styles.dataList}"> <div class="{styles.dataList}">
<p class="{styles.dataTitle}">数据信息</p> <p class="{styles.dataTitle}">数据信息</p>
<#if {{store.showLdegerList == 1}}>
<div class="{styles.dataTable}"> <div class="{styles.dataTable}">
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td>地址&nbsp;:</td> <td>地址&nbsp;:</td>
<td>{store.dataData.address || ''}</td> <td>{store.ledgerData.address || ''}</td>
</tr>
<tr>
<td>合约版本&nbsp;:</td>
<td>{store.dataData.chaincodeVersion || ''}</td>
</tr> </tr>
<tr> <tr>
<td>公钥内容&nbsp;:</td> <td>公钥内容&nbsp;:</td>
<td>{store.dataData.pubKey.value || ''}</td> <td>{store.ledgerData.pubKey.value || ''}</td>
</tr> </tr>
<tr> <tr>
<td>公钥算法&nbsp;:</td> <td>公钥算法&nbsp;:</td>
<td>{store.dataData.pubKey.algorithm || ''}</td> <td>{store.algorithm || ''}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="{styles.keyContent}">
<#if {{store.showKeyList == 1}}>
<p class="{styles.queryLedger}">
在账户&nbsp;<span>ESJKL1342j123NV</span>&nbsp;中查询
</p>
<div class="{styles.inputQuery}">
<ant-input class="{styles.inputValue}" onChange={keyChange} placeholder="请输入键,多个键之间用英文“,”隔开" />
<ant-Button class="{styles.queryButton}" icon="search" onClick={queryKey}>查询</ant-Button>
</div>
<div class="{styles.keyStates}">
<#each {{store.keyData}}>
<div class="{styles.keyState}">
<p class="{styles.key}">&nbsp;:&nbsp;<span>{{key}}</span></p>
<div class="{styles.values}">
<p>版本号&nbsp;:&nbsp;{{version}}</p>
<p>&nbsp;:&nbsp;</p>
<ant-TextArea class="{styles.keyText}" value={{value}}/>
<#if {{@item.value != ''}}>
<p>查看方式&nbsp;:&nbsp;
{selectItem()}
</p>
</#if>
</div>
</div>
</#each>
</div>
</#if>
</div> </div>
</div> </div>
</#if>
</div>
</div> </div>
<div class="{styles.hisFooter}"> <div class="{styles.hisFooter}">
......
...@@ -5,22 +5,12 @@ import { Notification } from 'flarej/lib/components/antd/notification'; ...@@ -5,22 +5,12 @@ import { Notification } from 'flarej/lib/components/antd/notification';
import { tranBase58 } from '../common/util'; import { tranBase58 } from '../common/util';
export default class LedgersStore { export default class LedgersStore {
@observable ledgerData = [ @observable showLdegerList = 1; // 1----->正常页面 0----->请求出错页面 -1----->异常页面
{ @observable showKeyList = 0; // 0----->隐藏页面 1----->显示页面
'key': 'key1', @observable showKeys = 0;
'nil': false, @observable ledgerData = {};
'type': 'TEXT', @observable algorithm = ''; // 公钥算法
'value': 'value1', @observable keyData = [];
'version': 1
},
{
'key': 'key2',
'nil': false,
'type': 'TEXT',
'value': 'value2',
'version': 2
}
]
@autobind @autobind
@action @action
...@@ -35,6 +25,27 @@ export default class LedgersStore { ...@@ -35,6 +25,27 @@ export default class LedgersStore {
} }
setLedgerData = (result) => { setLedgerData = (result) => {
console.log(result); let response = result && result.data ? result.data : {};
this.showKeyList = 1;
this.ledgerData = {...response};
this.algorithm = tranBase58(this.ledgerData['pubKey']['value']);
}
@autobind
@action
getKeyData(e) {
console.log(e);
fetchData(`${G_WEB_DOMAIN}/ledgers/keys`,
this.setKeyData,
'', { method: 'post',}, {e}
).catch(error => {
console.log(error);
});
}
setKeyData = (result) => {
let response = result && result.data ? result.data : [];
console.log(result, response);
this.keyData = {...response};
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册