From 4914864e3f98b744be35be1fb97f3fff6e5ce7e5 Mon Sep 17 00:00:00 2001 From: Willy Bruns Date: Sat, 24 Sep 2016 00:37:02 -0700 Subject: [PATCH 1/4] merge --- js/about/preferences.js | 7 +++++-- less/about/preferences.less | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/js/about/preferences.js b/js/about/preferences.js index 31b96301a5d..30c78355696 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -471,6 +471,7 @@ class PaymentHistory extends ImmutableComponent { + @@ -523,10 +524,12 @@ class PaymentHistoryRow extends ImmutableComponent { render () { var date = this.formattedDate var totalAmountStr = `${this.totalAmount} ${this.currency}` + var receiptFileName = `brave_ledger${this.numericDateStr}.csv` return - {date} - {totalAmountStr} + {date} + {totalAmountStr} + {receiptFileName} } } diff --git a/less/about/preferences.less b/less/about/preferences.less index 0b0790b4274..895d95521f4 100644 --- a/less/about/preferences.less +++ b/less/about/preferences.less @@ -580,7 +580,6 @@ div.nextPaymentSubmission { .modal .dialog.paymentHistory { padding: 0px; - width: 450px; .dialog-header { background-color: #EEE; @@ -684,7 +683,7 @@ div.nextPaymentSubmission { font-weight: 500; border-bottom: 2px solid @lightGray; text-align: left; - width: 25%; + width: 18%; } td { text-align: left; From 8de675a08531edbad4545f6cf13bcc23ee76ea58 Mon Sep 17 00:00:00 2001 From: Willy Bruns Date: Sat, 24 Sep 2016 01:37:14 -0700 Subject: [PATCH 2/4] Add CSV export of contribution breakdown to Payment History dialog for issue #3477 - Adds "Receipt Link" column to Payment History dialog - Clicking link opens CSV with 5 columns breaking down your contribution by Publisher: "Publisher","Votes","Fraction","BTC","USD" - depends on ledger-client changes NOT in master: see branch: https://github.com/willy-b/ledger-client/tree/support-browser-laptop-3477 specifically https://github.com/willy-b/ledger-client/commit/8c9e728de1f8f1b801dcba4baddc876f54c9167a --- app/ledger.js | 13 +++++++++++++ js/about/aboutActions.js | 4 ++++ js/about/preferences.js | 15 +++++++++++++-- js/constants/messages.js | 1 + 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/ledger.js b/app/ledger.js index 8ac9dfc9cc5..1f345a0fcbf 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -286,6 +286,19 @@ if (ipc) { if (balanceTimeoutId) clearTimeout(balanceTimeoutId) balanceTimeoutId = setTimeout(getBalance, 5 * msecs.second) }) + + ipc.on(messages.OPEN_LEDGER_TRANSACTION_CSV, (event, viewingIds, csvFilename) => { + if (client) { + var txCsvText = client._getTransactionCSVText(viewingIds) + csvFilename = csvFilename || 'ledgerCsvExport.csv' + + let savePath = pathName(csvFilename) + + fs.writeFileSync(savePath, txCsvText) + const win = electron.BrowserWindow.getFocusedWindow() + win.webContents.send(messages.SHORTCUT_NEW_FRAME, ('file://' + savePath), { singleFrame: true }) + } + }) } /* diff --git a/js/about/aboutActions.js b/js/about/aboutActions.js index cde4175a0be..91647ebded9 100644 --- a/js/about/aboutActions.js +++ b/js/about/aboutActions.js @@ -176,6 +176,10 @@ const AboutActions = { ipc.send(messages.LEDGER_CREATE_WALLET) }, + receiptLinkClick: function (viewingId, receiptFileName) { + ipc.send(messages.OPEN_LEDGER_TRANSACTION_CSV, viewingId, receiptFileName) + }, + setLedgerEnabled: function (enabled) { ipc.send(messages.LEDGER_ENABLE, enabled) }, diff --git a/js/about/preferences.js b/js/about/preferences.js index 30c78355696..0d66079039e 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -521,15 +521,26 @@ class PaymentHistoryRow extends ImmutableComponent { return (fiatAmount && typeof fiatAmount === 'number' ? fiatAmount.toFixed(2) : '0.00') } + get viewingId () { + return this.transaction.get('viewingId') + } + + get receiptFileName () { + return `brave_ledger${this.numericDateStr}.csv` + } + + onReceiptLinkClick () { + aboutActions.receiptLinkClick(this.viewingId, this.receiptFileName) + } + render () { var date = this.formattedDate var totalAmountStr = `${this.totalAmount} ${this.currency}` - var receiptFileName = `brave_ledger${this.numericDateStr}.csv` return {date} {totalAmountStr} - {receiptFileName} + {this.receiptFileName} } } diff --git a/js/constants/messages.js b/js/constants/messages.js index 20bc5b1607a..0a5e95692ee 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -152,6 +152,7 @@ const messages = { LEDGER_PUBLISHER: _, LEDGER_UPDATED: _, LEDGER_CREATE_WALLET: _, + OPEN_LEDGER_TRANSACTION_CSV: _, CHECK_BITCOIN_HANDLER: _, ADD_FUNDS_CLOSED: _ } From cb947260b283aa7cd50d74d44862c597227e8066 Mon Sep 17 00:00:00 2001 From: Willy Bruns Date: Sat, 24 Sep 2016 19:09:20 -0700 Subject: [PATCH 3/4] Payment history receipt link minor changes - link is now an element - added an error check to OPEN_LEDGER_TRANSACTION_CSV handler in app/ledger.js for #3477 --- app/ledger.js | 8 +++++++- js/about/preferences.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/ledger.js b/app/ledger.js index 1f345a0fcbf..c533bec5dfb 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -290,13 +290,19 @@ if (ipc) { ipc.on(messages.OPEN_LEDGER_TRANSACTION_CSV, (event, viewingIds, csvFilename) => { if (client) { var txCsvText = client._getTransactionCSVText(viewingIds) + csvFilename = csvFilename || 'ledgerCsvExport.csv' let savePath = pathName(csvFilename) + // create CSV fs.writeFileSync(savePath, txCsvText) + + // navigate to CSV const win = electron.BrowserWindow.getFocusedWindow() - win.webContents.send(messages.SHORTCUT_NEW_FRAME, ('file://' + savePath), { singleFrame: true }) + if (win && win.webContents) { + win.webContents.send(messages.SHORTCUT_NEW_FRAME, ('file://' + savePath), { singleFrame: true }) + } } }) } diff --git a/js/about/preferences.js b/js/about/preferences.js index 0d66079039e..ccd3ca32073 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -540,7 +540,7 @@ class PaymentHistoryRow extends ImmutableComponent { return {date} {totalAmountStr} - {this.receiptFileName} + {this.receiptFileName} } } From 17151f8b5ebe00beaccefae8c89e41f9423e4905 Mon Sep 17 00:00:00 2001 From: Willy Bruns Date: Mon, 26 Sep 2016 18:23:00 -0700 Subject: [PATCH 4/4] Payment History receipt link downloads a data URL for #3477 --- app/ledger.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/ledger.js b/app/ledger.js index c533bec5dfb..270fbe343fb 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -53,6 +53,7 @@ const appStore = require('../js/stores/appStore') const eventStore = require('../js/stores/eventStore') const rulesolver = require('./extensions/brave/content/scripts/pageInformation.js') const ledgerUtil = require('./common/lib/ledgerUtil') +const base64Encode = require('../js/lib/base64').encode // TBD: remove these post beta [MTR] const logPath = 'ledger-log.json' @@ -289,19 +290,12 @@ if (ipc) { ipc.on(messages.OPEN_LEDGER_TRANSACTION_CSV, (event, viewingIds, csvFilename) => { if (client) { - var txCsvText = client._getTransactionCSVText(viewingIds) + let txCsvText = client._getTransactionCSVText(viewingIds) + let txCsvTextDataURI = 'data:text/csv;base64,' + base64Encode(txCsvText) - csvFilename = csvFilename || 'ledgerCsvExport.csv' - - let savePath = pathName(csvFilename) - - // create CSV - fs.writeFileSync(savePath, txCsvText) - - // navigate to CSV const win = electron.BrowserWindow.getFocusedWindow() if (win && win.webContents) { - win.webContents.send(messages.SHORTCUT_NEW_FRAME, ('file://' + savePath), { singleFrame: true }) + win.webContents.downloadURL(txCsvTextDataURI) } } })