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

Commit 6369d25

Browse files
committed
2 parents 0c3af4f + 99a00fc commit 6369d25

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

js/languages/en-US.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,13 @@
371371
"purgeBtn": "Purge Files",
372372
"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.",
373373
"purgeError": "There was an error, your cached files may not have been deleted.",
374-
"purgeComplete": "Your cached files have been deleted."
374+
"purgeComplete": "Your cached files have been deleted.",
375+
"blockData": "Block Data",
376+
"blockDataHelper": "Show data useful for debugging.",
377+
"blockDataBtn": "Show Block Data",
378+
"blockDataError": "There was an error, your block data could not be retrieved.",
379+
"blockDataTitle": "Your Block Data",
380+
"blockDataCopy": "Copy to your Clipboard"
375381
},
376382
"transaction": {
377383
"sectionName": "Transactions",

js/templates/modals/settings/advanced.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ <h2 class="h4 clrT"><%= ob.polyT('settings.advancedTab.transaction.sectionName')
165165
</div>
166166
</div>
167167
</div>
168+
<div class="flexRow gutterH">
169+
<div class="col3">
170+
<label>
171+
<%= ob.polyT('settings.advancedTab.server.blockData') %>
172+
</label>
173+
<div class="clrT2 txSm">
174+
<%= ob.polyT('settings.advancedTab.server.blockDataHelper') %>
175+
</div>
176+
</div>
177+
<div class="col9">
178+
<div class="flexVCent gutterH">
179+
<%= ob.processingButton({
180+
className: `btn clrP clrBr clrSh2 js-blockData ${ob.isGettingBlockData ? 'processing' : ''}`,
181+
btnText: ob.polyT('settings.advancedTab.server.blockDataBtn'),
182+
}) %>
183+
</div>
184+
</div>
185+
</div>
168186
</form>
169187
</div>
170188
</div>

js/views/modals/Settings/Advanced.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import app from '../../../app';
33
import loadTemplate from '../../../utils/loadTemplate';
44
import baseVw from '../../baseVw';
55
import { openSimpleMessage } from '../SimpleMessage';
6+
import Dialog from '../../modals/Dialog';
7+
import { clipboard } from 'electron';
68

79
export default class extends baseVw {
810
constructor(options = {}) {
@@ -32,6 +34,7 @@ export default class extends baseVw {
3234
'click .js-showConnectionManagement': 'showConnectionManagement',
3335
'click .js-resync': 'clickResync',
3436
'click .js-purge': 'clickPurge',
37+
'click .js-blockData': 'clickBlockData',
3538
};
3639
}
3740

@@ -101,6 +104,46 @@ export default class extends baseVw {
101104
});
102105
}
103106

107+
clickBlockData() {
108+
this.showBlockData();
109+
}
110+
111+
/**
112+
* Calls the server to retrieve and display information about the block the transactions are on
113+
*/
114+
showBlockData() {
115+
this.getCachedEl('.js-blockData').addClass('processing');
116+
117+
this.blockData = $.get(app.getServerUrl('wallet/status'))
118+
.always(() => {
119+
this.getCachedEl('.js-blockData').removeClass('processing');
120+
})
121+
.fail((xhr) => {
122+
const failReason = xhr.responseJSON && xhr.responseJSON.reason || '';
123+
openSimpleMessage(
124+
app.polyglot.t('settings.advancedTab.server.blockDataError'),
125+
failReason);
126+
})
127+
.done((data) => {
128+
const buttons = [{
129+
text: app.polyglot.t('settings.advancedTab.server.blockDataCopy'),
130+
fragment: 'copyBlockData',
131+
}];
132+
const message = `<p><b>Best Hash:</b><br> ${data.bestHash}</p><p><b>Height:</b><br>` +
133+
`${data.height}</p>`;
134+
const blockDataDialog = new Dialog({
135+
title: app.polyglot.t('settings.advancedTab.server.blockDataTitle'),
136+
message,
137+
buttons,
138+
showCloseButton: true,
139+
removeOnClose: true,
140+
}).render().open();
141+
this.listenTo(blockDataDialog, 'click-copyBlockData', () => {
142+
clipboard.writeText(`Best Hash: ${data.bestHash} Height: ${data.height}`);
143+
});
144+
});
145+
}
146+
104147

105148
save() {
106149
this.localSettings.set(this.getFormData(this.$localFields));
@@ -179,6 +222,7 @@ export default class extends baseVw {
179222
},
180223
isSyncing: this.resync && this.resync.state() === 'pending',
181224
isPurging: this.purge && this.purge.state() === 'pending',
225+
isGettingBlockData: this.blockData && this.blockData.state() === 'pending',
182226
...this.settings.toJSON(),
183227
...this.localSettings.toJSON(),
184228
}));

0 commit comments

Comments
 (0)