Skip to content

Commit

Permalink
Closes #2476
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Schiessl <stefan.schiessl@blockchainprojectsbv.com>
  • Loading branch information
Stefan Schiessl committed Feb 20, 2019
1 parent 93d76f3 commit 83edcc3
Showing 1 changed file with 49 additions and 11 deletions.
60 changes: 49 additions & 11 deletions app/components/Account/RecentTransactions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class RecentTransactions extends React.Component {
.then(res => res.json())
.then(result => {
var ops = result.map(r => {
console.log(r);
return {
id: r.account_history.operation_id,
op: {
Expand Down Expand Up @@ -236,6 +235,14 @@ class RecentTransactions extends React.Component {
let accountName = (await FetchChain("getAccount", account)).get("name");
let recordData = {};

function pad(number, length) {
let str = "" + number;
while (str.length < length) {
str = "0" + str;
}
return str;
}

while (true) {
let res = await this._getAccountHistoryES(account, limit, start);
if (!res.length) break;
Expand All @@ -260,7 +267,6 @@ class RecentTransactions extends React.Component {
data.amount = data.amount_;
break;
}

switch (type) {
default:
recordData[trx_id] = {
Expand All @@ -281,8 +287,37 @@ class RecentTransactions extends React.Component {
}
recordData = report.groupEntries(recordData);
let parsedData = report.parseData(recordData, account, accountName);

let formatDate = function(d) {
return (
("0" + d.getDate()).slice(-2) +
"." +
("0" + (d.getMonth() + 1)).slice(-2) +
"." +
d.getFullYear() +
" " +
("0" + d.getHours()).slice(-2) +
":" +
("0" + d.getMinutes()).slice(-2) +
":" +
("0" + d.getSeconds()).slice(-2) +
" GMT" +
((d.getTimezoneOffset() < 0 ? "+" : "-") + // Note the reversed sign!
pad(
parseInt(
Math.floor(Math.abs(d.getTimezoneOffset() / 60))
),
2
) +
pad(Math.abs(d.getTimezoneOffset() % 60), 2))
);
};

let csvString = "";
for (let line of parsedData) {
if (line.length >= 11 && line[10] instanceof Date) {
line[10] = formatDate(line[10]);
}
csvString += line.join(",") + "\n";
}
let blob = new Blob([csvString], {type: "text/csv;charset=utf-8"});
Expand Down Expand Up @@ -421,7 +456,7 @@ class RecentTransactions extends React.Component {
<div className={cnames("inline-block")}>
{this.props.showFilters ? (
<Tooltip
placement="left"
placement="bottom"
title={counterpart.translate(
"tooltip.filter_ops"
)}
Expand All @@ -443,17 +478,20 @@ class RecentTransactions extends React.Component {
) : null}
</div>
{historyCount > 0 ? (
<a
className="inline-block"
onClick={this._generateCSV.bind(this)}
data-tip={counterpart.translate(
<Tooltip
placement="bottom"
title={counterpart.translate(
"transaction.csv_tip"
)}
data-place="bottom"
style={{marginLeft: "1rem"}}
>
<Icon name="excel" size="1_5x" />
</a>
<a
className="inline-block"
onClick={this._generateCSV.bind(this)}
style={{marginLeft: "1rem"}}
>
<Icon name="excel" size="1_5x" />
</a>
</Tooltip>
) : null}
</div>
{this.state.accountHistoryError && (
Expand Down

0 comments on commit 83edcc3

Please sign in to comment.