From dc0d2097e1f06f3128aab01164538a02e674fd8e Mon Sep 17 00:00:00 2001 From: jinlong12 Date: Tue, 23 Oct 2018 15:35:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=B4=A6=E6=88=B7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 1 + server/routes/ledgers.js | 323 +++++++++++++++++++------------ src/pages/history/history.t.html | 12 +- src/pages/ledgers/container.js | 34 +++- src/pages/ledgers/ledgers.m.less | 68 ++++++- src/pages/ledgers/ledgers.t.html | 72 ++++--- src/stores/LedgersStore.js | 45 +++-- 7 files changed, 380 insertions(+), 175 deletions(-) diff --git a/server/app.js b/server/app.js index af708b0c..744e72bb 100644 --- a/server/app.js +++ b/server/app.js @@ -49,6 +49,7 @@ const contract = require('./routes/contract'); app.use('/contract', contract); const ledgers = require('./routes/ledgers'); app.use('/ledgers', ledgers); +app.use('/keys', ledgers); app.use('/blockHeight', overview); app.use('/transactionAccount', overview); app.use('/userTotal', overview); diff --git a/server/routes/ledgers.js b/server/routes/ledgers.js index 432f80e8..77e57a6d 100644 --- a/server/routes/ledgers.js +++ b/server/routes/ledgers.js @@ -87,29 +87,104 @@ router.get('', function(req, res) { }); Object.assign({ - "success": true, - "data": [ - { - "value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" - }, - { - "value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" - } - ] + "data": { + "address": "www.jd.com", + "pubKey": { + "value": "UUi8Ku8aypHYnNkJRuFnkEYSuXT" + } + }, + "success": true }); res.send({ - "success": true, - "data": [ - { - "value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" - }, - { - "value": "67nubBh1nBtv9otJTkWw89WXSq7XnxshL74u33f5ipNYS" - } - ] + "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": [ + { + "value": "value1", + "nil": false, + "key": "key1", + "type": "TEXT", + "version": 1 + }, + { + "value": "value2", + "nil": false, + "key": "key2", + "type": "TEXT", + "version": 2 + } + ], + "success": true + }); + + res.send({ + "data": [ + { + "value": "value1", + "nil": false, + "key": "key1", + "type": "TEXT", + "version": 1 + }, + { + "value": "value2", + "nil": false, + "key": "key2", + "type": "TEXT", + "version": 2 + } + ], + "success": true + }); + }); // 区块高度 router.get('/blockHeight', function(req, res) { res.type('json'); @@ -1655,63 +1730,65 @@ router.get('/transactionHash', function(req, res) { }, "transactionContent": { "hash": { - "value": "fH9d8BYxU" - }, + "value": "fH9d8BYxU" + }, + "ledgerHash": { + "value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9" + }, "operations": [ { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" + "accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t", + "writeSet": [{ + "expectedVersion": 25, + "key": "Name", + "value": "QUFB" + }] + }, { + "addressSignature": { + "digest": { + "algorithm": "ED25519", + "rawDigest": "d2FuZ3d1" + }, + "pubKey": { + "value": "6gtyw9HjZbi" } - ], - "accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" - } - ], - "accountAddress": "undefined" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" - } - ], - "accountAddress": "undefined" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" - } - ], - "accountAddress": "undefined" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" + }, + "chainCode": "emhhbmdzYW4=", + "contractID": { + "address": "31kiRWCxNm8tYxhFK5wnDp3wNxLCuiVyDA7", + "pubKey": { + "value": "KXywstVY1tEAgEsc7kox48L" + } + } + }, { + "args": "YXJncw==", + "contractAddress": "contract-address", + "event": "contract-event" + }, { + "accountID": { + "address": "31r5f9D8kCxkiat2GvRJfjNi1fnFvaWaBEu", + "pubKey": { + "value": "5CYw7ztKJRxVt6Mfgz6vSQ" + } + }, + "addressSignature": { + "digest": { + "algorithm": "ED25519", + "rawDigest": "emhhb2xpdQ==" + }, + "pubKey": { + "value": "6gtyw9HjZbi" } - ], - "accountAddress": "undefined" + } + }, { + "userID": { + "address": "321ZeecJ99N7RJGSHkRqkfBZDEAxRMHd6d5", + "pubKey": { + "value": "3qHAWiGwaF6FU2o7Lg" + } + } } - ], - "ledgerHash": { - "value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9" - } + ] }, "endpointSignatures": [ { @@ -1774,63 +1851,65 @@ router.get('/transactionHash', function(req, res) { }, "transactionContent": { "hash": { - "value": "fH9d8BYxU" - }, + "value": "fH9d8BYxU" + }, + "ledgerHash": { + "value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9" + }, "operations": [ { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" + "accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t", + "writeSet": [{ + "expectedVersion": 25, + "key": "Name", + "value": "QUFB" + }] + }, { + "addressSignature": { + "digest": { + "algorithm": "ED25519", + "rawDigest": "d2FuZ3d1" + }, + "pubKey": { + "value": "6gtyw9HjZbi" } - ], - "accountAddress": "31xnWp5RYLThS47S6yfwqbUW3toZrw5Mm3t" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" - } - ], - "accountAddress": "undefined" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" - } - ], - "accountAddress": "undefined" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" - } - ], - "accountAddress": "undefined" - }, - { - "writeSet": [ - { - "key": "Name", - "expectedVersion": 25, - "value": "QUFB" + }, + "chainCode": "emhhbmdzYW4=", + "contractID": { + "address": "31kiRWCxNm8tYxhFK5wnDp3wNxLCuiVyDA7", + "pubKey": { + "value": "KXywstVY1tEAgEsc7kox48L" + } + } + }, { + "args": "YXJncw==", + "contractAddress": "contract-address", + "event": "contract-event" + }, { + "accountID": { + "address": "31r5f9D8kCxkiat2GvRJfjNi1fnFvaWaBEu", + "pubKey": { + "value": "5CYw7ztKJRxVt6Mfgz6vSQ" + } + }, + "addressSignature": { + "digest": { + "algorithm": "ED25519", + "rawDigest": "emhhb2xpdQ==" + }, + "pubKey": { + "value": "6gtyw9HjZbi" } - ], - "accountAddress": "undefined" + } + }, { + "userID": { + "address": "321ZeecJ99N7RJGSHkRqkfBZDEAxRMHd6d5", + "pubKey": { + "value": "3qHAWiGwaF6FU2o7Lg" + } + } } - ], - "ledgerHash": { - "value": "6EqXXS9c1njm6XPorwgstGLd1rdAywbQKrTfoaxe4SYY9" - } + ] }, "endpointSignatures": [ { diff --git a/src/pages/history/history.t.html b/src/pages/history/history.t.html index acc4f479..9377b25f 100644 --- a/src/pages/history/history.t.html +++ b/src/pages/history/history.t.html @@ -429,26 +429,18 @@
预期版本 :   v2
-
+
键 :   UPcaZ1JRCehRwvuNS8Ty
- -
+ -->
diff --git a/src/pages/ledgers/container.js b/src/pages/ledgers/container.js index b0c20d8b..7d3bde31 100644 --- a/src/pages/ledgers/container.js +++ b/src/pages/ledgers/container.js @@ -6,16 +6,20 @@ import '../../common/containerConfig'; import 'flarej/lib/components/antd/button'; import 'flarej/lib/components/antd/breadcrumb'; 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 { Select } from 'flarej/lib/components/antd/select'; import { autobind } from 'core-decorators'; import '../../components/header'; import '../../components/sider'; import ContainerHoc from '../../components/higherOrders/container'; import styles from './ledgers.m.less'; import tmpls from './ledgers.t.html'; -import { observable } from 'mobx'; +import { observable, toJS } from 'mobx'; import LedgersStore from '../../stores/LedgersStore'; const ledgersStore = new LedgersStore(); +const Option = Select.Option; //页面容器组件 @inject('store') @@ -28,7 +32,6 @@ class Container extends Component { render() { const { store } = this.props; - store.test(); return this.props.tmpls[0](this, { store, styles @@ -42,11 +45,17 @@ ContainerHoc('Container', Container, ledgersStore); @observer class DataTable extends Component { @observable dataLedger = ''; // 合约账户 + @observable keys = []; // key数组 inputChange = (e) => { this.dataLedger = e.target.value; } + keyChange = (e) => { + let str = e.target.value; + this.keys = str.split(','); + } + query = () => { const { store } = this.props; Promise.all([ @@ -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 = () => ( + + ) + render() { + const { store } = this.props; return tmpls.dataTable(this.state, this.props, this, { + store, styles }); } diff --git a/src/pages/ledgers/ledgers.m.less b/src/pages/ledgers/ledgers.m.less index b8157275..536c2e9c 100644 --- a/src/pages/ledgers/ledgers.m.less +++ b/src/pages/ledgers/ledgers.m.less @@ -48,7 +48,7 @@ box-shadow: 0 0 4px 0 rgba(0,0,0,0.10); border-radius: 6px; padding: 30px; - height: 672px; + min-height: 672px; & .dataTitle { font-family: MicrosoftYaHei; font-size: 14px; @@ -84,6 +84,72 @@ 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; + } + } + } + } + } } } } diff --git a/src/pages/ledgers/ledgers.t.html b/src/pages/ledgers/ledgers.t.html index 0e37207f..a97303e5 100644 --- a/src/pages/ledgers/ledgers.t.html +++ b/src/pages/ledgers/ledgers.t.html @@ -14,29 +14,55 @@

数据信息

-
- - - - - - - - - - - - - - - - - - - -
地址 :{store.dataData.address || ''}
合约版本 :{store.dataData.chaincodeVersion || ''}
公钥内容 :{store.dataData.pubKey.value || ''}
公钥算法 :{store.dataData.pubKey.algorithm || ''}
-
- + <#if {{store.showLdegerList == 1}}> +
+ + + + + + + + + + + + + + + +
地址 :{store.ledgerData.address || ''}
公钥内容 :{store.ledgerData.pubKey.value || ''}
公钥算法 :{store.algorithm || ''}
+
+ <#if {{store.showKeyList == 1}}> +

+ 在账户 ESJKL1342j123NV 中查询 +

+
+ + 查询 +
+
+ <#each {{store.keyData}}> +
+

键 : {{key}}

+
+

版本号 : {{version}}

+

值 : 

+ + <#if {{@item.value != ''}}> +

查看方式 :  + {selectItem()} +

+ +
+
+ +
+ +
+ +
+
diff --git a/src/stores/LedgersStore.js b/src/stores/LedgersStore.js index e0ab5fd3..9bf7b7d5 100644 --- a/src/stores/LedgersStore.js +++ b/src/stores/LedgersStore.js @@ -5,22 +5,12 @@ import { Notification } from 'flarej/lib/components/antd/notification'; import { tranBase58 } from '../common/util'; export default class LedgersStore { - @observable ledgerData = [ - { - 'key': 'key1', - 'nil': false, - 'type': 'TEXT', - 'value': 'value1', - 'version': 1 - }, - { - 'key': 'key2', - 'nil': false, - 'type': 'TEXT', - 'value': 'value2', - 'version': 2 - } - ] + @observable showLdegerList = 1; // 1----->正常页面 0----->请求出错页面 -1----->异常页面 + @observable showKeyList = 0; // 0----->隐藏页面 1----->显示页面 + @observable showKeys = 0; + @observable ledgerData = {}; + @observable algorithm = ''; // 公钥算法 + @observable keyData = []; @autobind @action @@ -35,6 +25,27 @@ export default class LedgersStore { } 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 -- GitLab