Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jjeffryes committed Aug 4, 2017
2 parents 0c3af4f + 99a00fc commit 6369d25
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,13 @@
"purgeBtn": "Purge Files",
"purgeToolTip": "OpenBazaar shares cached content you have viewed with other users. If you have viewed text or images you don't want to share this button will delete them. This will not affect any files that belong to you.",
"purgeError": "There was an error, your cached files may not have been deleted.",
"purgeComplete": "Your cached files have been deleted."
"purgeComplete": "Your cached files have been deleted.",
"blockData": "Block Data",
"blockDataHelper": "Show data useful for debugging.",
"blockDataBtn": "Show Block Data",
"blockDataError": "There was an error, your block data could not be retrieved.",
"blockDataTitle": "Your Block Data",
"blockDataCopy": "Copy to your Clipboard"
},
"transaction": {
"sectionName": "Transactions",
Expand Down
18 changes: 18 additions & 0 deletions js/templates/modals/settings/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@ <h2 class="h4 clrT"><%= ob.polyT('settings.advancedTab.transaction.sectionName')
</div>
</div>
</div>
<div class="flexRow gutterH">
<div class="col3">
<label>
<%= ob.polyT('settings.advancedTab.server.blockData') %>
</label>
<div class="clrT2 txSm">
<%= ob.polyT('settings.advancedTab.server.blockDataHelper') %>
</div>
</div>
<div class="col9">
<div class="flexVCent gutterH">
<%= ob.processingButton({
className: `btn clrP clrBr clrSh2 js-blockData ${ob.isGettingBlockData ? 'processing' : ''}`,
btnText: ob.polyT('settings.advancedTab.server.blockDataBtn'),
}) %>
</div>
</div>
</div>
</form>
</div>
</div>
Expand Down
44 changes: 44 additions & 0 deletions js/views/modals/Settings/Advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import app from '../../../app';
import loadTemplate from '../../../utils/loadTemplate';
import baseVw from '../../baseVw';
import { openSimpleMessage } from '../SimpleMessage';
import Dialog from '../../modals/Dialog';
import { clipboard } from 'electron';

export default class extends baseVw {
constructor(options = {}) {
Expand Down Expand Up @@ -32,6 +34,7 @@ export default class extends baseVw {
'click .js-showConnectionManagement': 'showConnectionManagement',
'click .js-resync': 'clickResync',
'click .js-purge': 'clickPurge',
'click .js-blockData': 'clickBlockData',
};
}

Expand Down Expand Up @@ -101,6 +104,46 @@ export default class extends baseVw {
});
}

clickBlockData() {
this.showBlockData();
}

/**
* Calls the server to retrieve and display information about the block the transactions are on
*/
showBlockData() {
this.getCachedEl('.js-blockData').addClass('processing');

this.blockData = $.get(app.getServerUrl('wallet/status'))
.always(() => {
this.getCachedEl('.js-blockData').removeClass('processing');
})
.fail((xhr) => {
const failReason = xhr.responseJSON && xhr.responseJSON.reason || '';
openSimpleMessage(
app.polyglot.t('settings.advancedTab.server.blockDataError'),
failReason);
})
.done((data) => {
const buttons = [{
text: app.polyglot.t('settings.advancedTab.server.blockDataCopy'),
fragment: 'copyBlockData',
}];
const message = `<p><b>Best Hash:</b><br> ${data.bestHash}</p><p><b>Height:</b><br>` +
`${data.height}</p>`;
const blockDataDialog = new Dialog({
title: app.polyglot.t('settings.advancedTab.server.blockDataTitle'),
message,
buttons,
showCloseButton: true,
removeOnClose: true,
}).render().open();
this.listenTo(blockDataDialog, 'click-copyBlockData', () => {
clipboard.writeText(`Best Hash: ${data.bestHash} Height: ${data.height}`);
});
});
}


save() {
this.localSettings.set(this.getFormData(this.$localFields));
Expand Down Expand Up @@ -179,6 +222,7 @@ export default class extends baseVw {
},
isSyncing: this.resync && this.resync.state() === 'pending',
isPurging: this.purge && this.purge.state() === 'pending',
isGettingBlockData: this.blockData && this.blockData.state() === 'pending',
...this.settings.toJSON(),
...this.localSettings.toJSON(),
}));
Expand Down

0 comments on commit 6369d25

Please sign in to comment.