Skip to content

Commit 6a20862

Browse files
committed
Okay. Think this works.
1 parent 950eb6b commit 6a20862

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed

bittensor_cli/src/bittensor/templates/main-header.j2

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="header">
88
<meta charset="UTF-8">
99
<div class="wallet-info">
10-
<span class="wallet-name">{wallet_info["name"]}</span>
10+
<span class="wallet-name">{{ wallet_info.name }}</span>
1111
<div class="wallet-address-container" onclick="copyToClipboard('{{ coldkey }}', this)">
1212
<span class="wallet-address" title="Click to copy">{{ truncated_coldkey }}}</span>
1313
<span class="copy-indicator">Copy</span>
@@ -16,20 +16,20 @@
1616
<div class="stake-metrics">
1717
<div class="stake-metric">
1818
<span class="metric-label">Block</span>
19-
<span class="metric-value" style="color: #FF9900;">{{ block_number }}}</span>
19+
<span class="metric-value" style="color: #FF9900;">{{ block_number }}</span>
2020
</div>
2121
<div class="stake-metric">
2222
<span class="metric-label">Balance</span>
23-
<span class="metric-value">{wallet_info["balance"]:.4f} {root_symbol_html}</span>
23+
<span class="metric-value">{{ "%.4f"|format(wallet_info.balance) }} {{ root_symbol_html }}</span>
2424
</div>
2525
<div class="stake-metric">
2626
<span class="metric-label">Total Stake Value</span>
27-
<span class="metric-value">{wallet_info["total_ideal_stake_value"]:.4f} {root_symbol_html}</span>
27+
<span class="metric-value">{{ "%.4f"|format(wallet_info.total_ideal_stake_value) }} {{ root_symbol_html }}</span>
2828
</div>
2929
<div class="stake-metric">
3030
<span class="metric-label">Slippage Impact</span>
3131
<span class="metric-value slippage-value">
32-
{slippage_percentage:.2f}% <span class="slippage-detail">({wallet_info["total_slippage_value"]:.4f} {root_symbol_html})</span>
32+
{{ "%.2f"|format(slippage_percentage) }}% <span class="slippage-detail">({{ "%.4f"|format(wallet_info.total_slippage_value) }} {{ root_symbol_html }})</span>
3333
</span>
3434
</div>
3535
</div>

bittensor_cli/src/bittensor/templates/subnet-details.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{# TODO: This may be unused. #}
2+
13
<div id="subnet-modal" class="modal hidden">
24
<div class="modal-content">
35
<div class="modal-header">

bittensor_cli/src/commands/view.py

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
from bittensor_wallet import Wallet
1515
from bittensor_cli.src import defaults
1616

17-
root_symbol_html = f"&#x{ord('τ'):X};"
1817

19-
20-
env = Environment(loader=PackageLoader("bittensor"), autoescape=select_autoescape())
18+
ROOT_SYMBOL_HTML = f"&#x{ord('τ'):X};"
19+
env = Environment(
20+
loader=PackageLoader("bittensor_cli", "src/bittensor/templates"),
21+
autoescape=select_autoescape(),
22+
)
2123

2224

2325
async def display_network_dashboard(
@@ -41,30 +43,15 @@ async def display_network_dashboard(
4143

4244
if use_wry:
4345
console.print(
44-
"[dark_sea_green3]Opening dashboard in a window. Press Ctrl+C to close.[/dark_sea_green3]"
45-
)
46-
window = PyWry()
47-
window.send_html(
48-
html=html_content,
49-
title="Bittensor View",
50-
width=1200,
51-
height=800,
46+
"[dark_sea_green3]Opening dashboard in a window.[/dark_sea_green3]"
5247
)
53-
window.start()
54-
await asyncio.sleep(10)
55-
try:
56-
while True:
57-
if _has_exited(window):
58-
break
59-
await asyncio.sleep(1)
60-
except KeyboardInterrupt:
61-
console.print("\n[yellow]Closing Bittensor View...[/yellow]")
62-
finally:
63-
if not _has_exited(window):
64-
try:
65-
window.close()
66-
except Exception:
67-
pass
48+
with tempfile.NamedTemporaryFile(
49+
"w", delete=False, suffix=".html"
50+
) as dashboard_file:
51+
url = f"file://{dashboard_file.name}"
52+
dashboard_file.write(html_content)
53+
54+
webbrowser.open(url, new=1)
6855
else:
6956
if save_file:
7057
dir_path = os.path.expanduser(dashboard_path)
@@ -365,9 +352,10 @@ def generate_full_page(data: dict[str, Any]) -> str:
365352
template = env.get_template("view.j2")
366353

367354
return template.render(
368-
root_symbol_html=root_symbol_html,
355+
root_symbol_html=ROOT_SYMBOL_HTML,
369356
block_number=block_number,
370357
truncated_coldkey=truncated_coldkey,
371358
slippage_percentage=slippage_percentage,
359+
wallet_info=wallet_info,
372360
subnets=data["subnets"],
373361
)

0 commit comments

Comments
 (0)