uiux(@cockpit/explorer): render timestamp of transactions

This commit is contained in:
Pascal Precht 2019-03-26 12:47:22 +09:00 committed by Iuri Matias
parent 2c948b2729
commit 4c3ec26fff
5 changed files with 20 additions and 1 deletions

View File

@ -63,6 +63,7 @@
"classnames": "2.2.6", "classnames": "2.2.6",
"connected-react-router": "4.5.0", "connected-react-router": "4.5.0",
"css-loader": "1.0.0", "css-loader": "1.0.0",
"date-fns": "1.30.1",
"dotenv": "6.0.0", "dotenv": "6.0.0",
"dotenv-expand": "4.2.0", "dotenv-expand": "4.2.0",
"embark-api-client": "^4.0.0", "embark-api-client": "^4.0.0",

View File

@ -24,7 +24,7 @@ const Blocks = ({blocks, changePage, currentPage, numberOfPages}) => (
</CardTitleIdenticon> </CardTitleIdenticon>
<Row> <Row>
<Col> <Col>
<strong>Mined On</strong> <strong>Mined on:</strong>
<div>{new Date(block.timestamp * 1000).toLocaleString()}</div> <div>{new Date(block.timestamp * 1000).toLocaleString()}</div>
</Col> </Col>
<Col> <Col>

View File

@ -2,11 +2,14 @@ import React from 'react';
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {Row, Col, Card, CardHeader, CardBody} from 'reactstrap'; import {Row, Col, Card, CardHeader, CardBody} from 'reactstrap';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import isToday from 'date-fns/is_today';
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import DebugButton from './DebugButton'; import DebugButton from './DebugButton';
import CardTitleIdenticon from './CardTitleIdenticon'; import CardTitleIdenticon from './CardTitleIdenticon';
import Pagination from "./Pagination"; import Pagination from "./Pagination";
const Transactions = ({transactions, contracts, changePage, currentPage, numberOfPages}) => ( const Transactions = ({transactions, contracts, changePage, currentPage, numberOfPages}) => (
<Row> <Row>
<Col> <Col>
@ -45,6 +48,15 @@ const Transactions = ({transactions, contracts, changePage, currentPage, numberO
<strong>Type</strong> <strong>Type</strong>
<div>{transaction.to ? "Contract Call" : "Contract Creation"}</div> <div>{transaction.to ? "Contract Call" : "Contract Creation"}</div>
</Col> </Col>
<Col md={6}>
<strong>Mined on:</strong>
<div>
{isToday(new Date(transaction.timestamp * 1000)) ?
distanceInWordsToNow(new Date(transaction.timestamp * 1000), {addSuffix: true}) :
new Date(transaction.timestamp * 1000).toLocaleString()
}
</div>
</Col>
</Row> </Row>
</div> </div>
))} ))}

View File

@ -74,6 +74,7 @@ class TransactionsContainer extends Component {
const txsLength = txs.length; const txsLength = txs.length;
block.transactions.forEach((tx, idx) => { block.transactions.forEach((tx, idx) => {
txs[txsLength + idx + offset] = tx; txs[txsLength + idx + offset] = tx;
txs[txsLength + idx + offset].timestamp = block.timestamp;
}); });
return txs; return txs;
}, []); }, []);

View File

@ -6862,6 +6862,11 @@ date-and-time@0.6.2:
resolved "https://registry.yarnpkg.com/date-and-time/-/date-and-time-0.6.2.tgz#ffca5b488bafa32f7ed0aa505e7983519d413f92" resolved "https://registry.yarnpkg.com/date-and-time/-/date-and-time-0.6.2.tgz#ffca5b488bafa32f7ed0aa505e7983519d413f92"
integrity sha512-hwObpAj7BtK8ElQCvOV7V3yEfcD+15QNjV44IeGqkmYyOCoU7/eIgOHvPlwBhlOKGbzosEn/DCrwUr1/NnLoiA== integrity sha512-hwObpAj7BtK8ElQCvOV7V3yEfcD+15QNjV44IeGqkmYyOCoU7/eIgOHvPlwBhlOKGbzosEn/DCrwUr1/NnLoiA==
date-fns@1.30.1:
version "1.30.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==
date-now@^0.1.4: date-now@^0.1.4:
version "0.1.4" version "0.1.4"
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"