Skip to content

Commit

Permalink
Added an optional USD price panel
Browse files Browse the repository at this point in the history
-New settings for the USD price panel were added to the config options
-Added USD price to the getsummary API
  • Loading branch information
joeuhren committed Dec 27, 2023
1 parent c03178e commit 8276f28
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Table of Contents
- **getlasttxs:** Returns transactions greater than a specific number of coins, starting from a particular offset
- **getcurrentprice:** Returns last known exchange price
- **getbasicstats:** Returns basic statistics about the coin including: block count, circulating supply, USD price, default market price and # of masternodes *\*# of masternodes is only applicable to masternode coins*
- **getsummary:** Returns a summary of coin data including: difficulty, hybrid difficulty, circulating supply, hash rate, default market price, network connection count, block count, count of online masternodes and count of offline masternodes *\*masternode counts are only applicable to masternode coins*
- **getsummary:** Returns a summary of coin data including: difficulty, hybrid difficulty, circulating supply, hash rate, default market price, USD price, network connection count, block count, count of online masternodes and count of offline masternodes *\*masternode counts are only applicable to masternode coins*
- **getnetworkpeers:** Returns the list of network peers that have connected to the explorer node in the last 24 hours
- **getmasternodelist:** Returns the complete list of masternodes on the network *\*only applicable to masternode coins*
- **getmasternoderewards:** Returns a list of masternode reward transactions for a specific address that arrived after a specific block height *\*only applicable to masternode coins*
Expand Down Expand Up @@ -173,6 +173,7 @@ Table of Contents
- **Masternodes:** Displays a count of online and unreachable masternodes *\*only applicable to masternode coins*
- **Coin Supply:** Displays the current circulating coin supply value
- **Price:** Displays the current market price (value measured using default market pair)
- **USD Price:** Displays the current market price (value measured in USD)
- **Market Cap:** Displays the current market cap value in (value measured using default market pair)
- **Logo:** Display an image of your coin logo
- Configurable network charts that can be independently displayed in the header of any page
Expand Down
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ app.use('/ext/getsummary', function(req, res) {
supply: (stats == null || stats.supply == null ? 0 : stats.supply),
hashrate: hashrate,
lastPrice: (stats == null || stats.last_price == null ? 0 : stats.last_price),
lastUSDPrice: (stats == null || stats.last_usd_price == null ? 0 : stats.last_usd_price),
connections: (connections ? connections : '-'),
blockcount: (blockcount ? blockcount : '-'),
masternodeCountOnline: (masternodestotal && mn_enabled != 0 ? mn_enabled : '-'),
Expand Down Expand Up @@ -857,6 +858,7 @@ var panelcount = (settings.shared_pages.page_header.panels.network_panel.enabled
(settings.shared_pages.page_header.panels.masternodes_panel.enabled == true && settings.shared_pages.page_header.panels.masternodes_panel.display_order > 0 ? 1 : 0) +
(settings.shared_pages.page_header.panels.coin_supply_panel.enabled == true && settings.shared_pages.page_header.panels.coin_supply_panel.display_order > 0 ? 1 : 0) +
(settings.shared_pages.page_header.panels.price_panel.enabled == true && settings.shared_pages.page_header.panels.price_panel.display_order > 0 ? 1 : 0) +
(settings.shared_pages.page_header.panels.usd_price_panel.enabled == true && settings.shared_pages.page_header.panels.usd_price_panel.display_order > 0 ? 1 : 0) +
(settings.shared_pages.page_header.panels.market_cap_panel.enabled == true && settings.shared_pages.page_header.panels.market_cap_panel.display_order > 0 ? 1 : 0) +
(settings.shared_pages.page_header.panels.logo_panel.enabled == true && settings.shared_pages.page_header.panels.logo_panel.display_order > 0 ? 1 : 0) +
(settings.shared_pages.page_header.panels.spacer_panel_1.enabled == true && settings.shared_pages.page_header.panels.spacer_panel_1.display_order > 0 ? 1 : 0) +
Expand All @@ -872,6 +874,7 @@ if (settings.shared_pages.page_header.panels.difficulty_panel.enabled == true &&
if (settings.shared_pages.page_header.panels.masternodes_panel.enabled == true && settings.shared_pages.page_header.panels.masternodes_panel.display_order > 0) panel_order.push({name: 'masternodes_panel', val: settings.shared_pages.page_header.panels.masternodes_panel.display_order});
if (settings.shared_pages.page_header.panels.coin_supply_panel.enabled == true && settings.shared_pages.page_header.panels.coin_supply_panel.display_order > 0) panel_order.push({name: 'coin_supply_panel', val: settings.shared_pages.page_header.panels.coin_supply_panel.display_order});
if (settings.shared_pages.page_header.panels.price_panel.enabled == true && settings.shared_pages.page_header.panels.price_panel.display_order > 0) panel_order.push({name: 'price_panel', val: settings.shared_pages.page_header.panels.price_panel.display_order});
if (settings.shared_pages.page_header.panels.usd_price_panel.enabled == true && settings.shared_pages.page_header.panels.usd_price_panel.display_order > 0) panel_order.push({name: 'usd_price_panel', val: settings.shared_pages.page_header.panels.usd_price_panel.display_order});
if (settings.shared_pages.page_header.panels.market_cap_panel.enabled == true && settings.shared_pages.page_header.panels.market_cap_panel.display_order > 0) panel_order.push({name: 'market_cap_panel', val: settings.shared_pages.page_header.panels.market_cap_panel.display_order});
if (settings.shared_pages.page_header.panels.logo_panel.enabled == true && settings.shared_pages.page_header.panels.logo_panel.display_order > 0) panel_order.push({name: 'logo_panel', val: settings.shared_pages.page_header.panels.logo_panel.display_order});
if (settings.shared_pages.page_header.panels.spacer_panel_1.enabled == true && settings.shared_pages.page_header.panels.spacer_panel_1.display_order > 0) panel_order.push({name: 'spacer_panel_1', val: settings.shared_pages.page_header.panels.spacer_panel_1.display_order});
Expand Down
10 changes: 10 additions & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ exports.shared_pages = {
// The panel will be disabled with a value of 0
"display_order": 4
},
// usd_price_panel: a collection of settings that pertain to the usd price panel which displays the current market price measured in USD
"usd_price_panel": {
// enabled: Enable/disable the usd price panel (true/false)
// If set to false, the usd price panel will be completely inaccessible
"enabled": false,
// display_order: Determine which order this panel is shown from 1-5
// 1 = far left panel, 5 = far right panel
// The panel will be disabled with a value of 0
"display_order": 0
},
// market_cap_panel: a collection of settings that pertain to the market cap panel which displays the current market cap value measured against the default market pair
"market_cap_panel": {
// enabled: Enable/disable the market cap panel (true/false)
Expand Down
10 changes: 10 additions & 0 deletions settings.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@
"price_panel": {
// enabled: Enable/disable the price panel (true/false)
// If set to false, the price panel will be completely inaccessible
"enabled": false,
// display_order: Determine which order this panel is shown from 1-5
// 1 = far left panel, 5 = far right panel
// The panel will be disabled with a value of 0
"display_order": 0
},
// usd_price_panel: a collection of settings that pertain to the usd price panel which displays the current market price measured in USD
"usd_price_panel": {
// enabled: Enable/disable the usd price panel (true/false)
// If set to false, the usd price panel will be completely inaccessible
"enabled": true,
// display_order: Determine which order this panel is shown from 1-5
// 1 = far left panel, 5 = far right panel
Expand Down
2 changes: 1 addition & 1 deletion views/info.pug
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ block content
p
div.fw-bold getsummary
div
em="Returns a summary of coin data including: difficulty, hybrid difficulty, circulating supply, hash rate, " + settings.markets_page.default_exchange.trading_pair.split('/')[1].toUpperCase() + " price, network connection count, block count" + (settings.api_page.public_apis.rpc.getmasternodecount.enabled == true && settings.api_cmds['getmasternodecount'] != null && settings.api_cmds['getmasternodecount'] != '' ? ', ' + 'count of online masternodes' + ', ' + 'count of offline masternodes' : '')
em="Returns a summary of coin data including: difficulty, hybrid difficulty, circulating supply, hash rate, " + settings.markets_page.default_exchange.trading_pair.split('/')[1].toUpperCase() + " price, USD price, network connection count, block count" + (settings.api_page.public_apis.rpc.getmasternodecount.enabled == true && settings.api_cmds['getmasternodecount'] != null && settings.api_cmds['getmasternodecount'] != '' ? ', ' + 'count of online masternodes' + ', ' + 'count of offline masternodes' : '')
a(href='/ext/getsummary') #{address}/ext/getsummary
if settings.api_page.public_apis.ext.getmasternodelist.enabled == true && settings.api_cmds['getmasternodelist'] != null && settings.api_cmds['getmasternodelist'] != ''
li
Expand Down
11 changes: 11 additions & 0 deletions views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ html(lang='en')
function getPricePanel() {
return '<div class="card-header"><strong>Price <span class="small fw-normal">(#{settings.markets_page.default_exchange.trading_pair.split('/')[1]})</span></strong></div><div class="card-body"><div id="pricePanelLoading" class="header-panel"><i class="fa-solid fa-spinner fa-spin-pulse"></i></div><div id="pricepanel" class="header-panel" style="display:none;"><span class="fa-solid fa-rocket"></span><label id="lastPrice">-</label></div></div>';
}
function getUSDPricePanel() {
return '<div class="card-header"><strong>Price <span class="small fw-normal">(USD)</span></strong></div><div class="card-body"><div id="usdPricePanelLoading" class="header-panel"><i class="fa-solid fa-spinner fa-spin-pulse"></i></div><div id="usdpricepanel" class="header-panel" style="display:none;"><span class="fa-solid fa-dollar-sign"></span><label id="lastUSDPrice">-</label></div></div>';
}
function getMarketCapPanel() {
return '<div class="card-header"><strong>Market Cap <span class="small fw-normal">(#{settings.markets_page.default_exchange.trading_pair.split('/')[1]})</span></strong></div><div class="card-body"><div id="marketCapPanelLoading" class="header-panel"><i class="fa-solid fa-spinner fa-spin-pulse"></i></div><div id="marketCapPanel" class="header-panel" style="display:none;"><span class="fa-solid fa-chart-line"></span><label id="marketCap"></label></div></div>';
}
Expand Down Expand Up @@ -336,6 +339,9 @@ html(lang='en')
case "price_panel":
sReturn = getPricePanel();
break;
case "usd_price_panel":
sReturn = getUSDPricePanel();
break;
case "market_cap_panel":
sReturn = getMarketCapPanel();
break;
Expand Down Expand Up @@ -427,6 +433,11 @@ html(lang='en')
splitParts = splitValue.split('.');
$("#lastPrice").html(splitParts[0] + '.<span class="decimal">' + splitParts[1] + '</span>');
showTopPanelData('pricepanel', 'pricePanelLoading');

splitValue = Number(json.lastUSDPrice).toLocaleString('en',{'minimumFractionDigits':2,'maximumFractionDigits':8,'useGrouping':true});
splitParts = splitValue.split('.');
$("#lastUSDPrice").html(splitParts[0] + '.<span class="decimal">' + splitParts[1] + '</span>');
showTopPanelData('usdpricepanel', 'usdPricePanelLoading');
}});
}
$(document).ready(function() {
Expand Down

0 comments on commit 8276f28

Please sign in to comment.