meshtensor-cli 9.18.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- meshtensor_cli/__init__.py +22 -0
- meshtensor_cli/cli.py +10742 -0
- meshtensor_cli/doc_generation_helper.py +4 -0
- meshtensor_cli/src/__init__.py +1085 -0
- meshtensor_cli/src/commands/__init__.py +0 -0
- meshtensor_cli/src/commands/axon/__init__.py +0 -0
- meshtensor_cli/src/commands/axon/axon.py +132 -0
- meshtensor_cli/src/commands/crowd/__init__.py +0 -0
- meshtensor_cli/src/commands/crowd/contribute.py +621 -0
- meshtensor_cli/src/commands/crowd/contributors.py +200 -0
- meshtensor_cli/src/commands/crowd/create.py +783 -0
- meshtensor_cli/src/commands/crowd/dissolve.py +219 -0
- meshtensor_cli/src/commands/crowd/refund.py +233 -0
- meshtensor_cli/src/commands/crowd/update.py +418 -0
- meshtensor_cli/src/commands/crowd/utils.py +124 -0
- meshtensor_cli/src/commands/crowd/view.py +991 -0
- meshtensor_cli/src/commands/governance/__init__.py +0 -0
- meshtensor_cli/src/commands/governance/governance.py +794 -0
- meshtensor_cli/src/commands/liquidity/__init__.py +0 -0
- meshtensor_cli/src/commands/liquidity/liquidity.py +699 -0
- meshtensor_cli/src/commands/liquidity/utils.py +202 -0
- meshtensor_cli/src/commands/proxy.py +700 -0
- meshtensor_cli/src/commands/stake/__init__.py +0 -0
- meshtensor_cli/src/commands/stake/add.py +799 -0
- meshtensor_cli/src/commands/stake/auto_staking.py +306 -0
- meshtensor_cli/src/commands/stake/children_hotkeys.py +865 -0
- meshtensor_cli/src/commands/stake/claim.py +770 -0
- meshtensor_cli/src/commands/stake/list.py +738 -0
- meshtensor_cli/src/commands/stake/move.py +1211 -0
- meshtensor_cli/src/commands/stake/remove.py +1466 -0
- meshtensor_cli/src/commands/stake/wizard.py +323 -0
- meshtensor_cli/src/commands/subnets/__init__.py +0 -0
- meshtensor_cli/src/commands/subnets/mechanisms.py +515 -0
- meshtensor_cli/src/commands/subnets/price.py +733 -0
- meshtensor_cli/src/commands/subnets/subnets.py +2908 -0
- meshtensor_cli/src/commands/sudo.py +1294 -0
- meshtensor_cli/src/commands/tc/__init__.py +0 -0
- meshtensor_cli/src/commands/tc/tc.py +190 -0
- meshtensor_cli/src/commands/treasury/__init__.py +0 -0
- meshtensor_cli/src/commands/treasury/treasury.py +194 -0
- meshtensor_cli/src/commands/view.py +354 -0
- meshtensor_cli/src/commands/wallets.py +2311 -0
- meshtensor_cli/src/commands/weights.py +467 -0
- meshtensor_cli/src/meshtensor/__init__.py +0 -0
- meshtensor_cli/src/meshtensor/balances.py +313 -0
- meshtensor_cli/src/meshtensor/chain_data.py +1263 -0
- meshtensor_cli/src/meshtensor/extrinsics/__init__.py +0 -0
- meshtensor_cli/src/meshtensor/extrinsics/mev_shield.py +174 -0
- meshtensor_cli/src/meshtensor/extrinsics/registration.py +1861 -0
- meshtensor_cli/src/meshtensor/extrinsics/root.py +550 -0
- meshtensor_cli/src/meshtensor/extrinsics/serving.py +255 -0
- meshtensor_cli/src/meshtensor/extrinsics/transfer.py +239 -0
- meshtensor_cli/src/meshtensor/meshtensor_interface.py +2598 -0
- meshtensor_cli/src/meshtensor/minigraph.py +254 -0
- meshtensor_cli/src/meshtensor/networking.py +12 -0
- meshtensor_cli/src/meshtensor/templates/main-filters.j2 +24 -0
- meshtensor_cli/src/meshtensor/templates/main-header.j2 +36 -0
- meshtensor_cli/src/meshtensor/templates/neuron-details.j2 +111 -0
- meshtensor_cli/src/meshtensor/templates/price-multi.j2 +113 -0
- meshtensor_cli/src/meshtensor/templates/price-single.j2 +99 -0
- meshtensor_cli/src/meshtensor/templates/subnet-details-header.j2 +49 -0
- meshtensor_cli/src/meshtensor/templates/subnet-details.j2 +32 -0
- meshtensor_cli/src/meshtensor/templates/subnet-metrics.j2 +57 -0
- meshtensor_cli/src/meshtensor/templates/subnets-table.j2 +28 -0
- meshtensor_cli/src/meshtensor/templates/table.j2 +267 -0
- meshtensor_cli/src/meshtensor/templates/view.css +1058 -0
- meshtensor_cli/src/meshtensor/templates/view.j2 +43 -0
- meshtensor_cli/src/meshtensor/templates/view.js +1053 -0
- meshtensor_cli/src/meshtensor/utils.py +2007 -0
- meshtensor_cli/version.py +23 -0
- meshtensor_cli-9.18.1.dist-info/METADATA +261 -0
- meshtensor_cli-9.18.1.dist-info/RECORD +74 -0
- meshtensor_cli-9.18.1.dist-info/WHEEL +4 -0
- meshtensor_cli-9.18.1.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<div class="subnet-header">
|
|
2
|
+
<div class="header-row">
|
|
3
|
+
<button class="back-button">← Back</button>
|
|
4
|
+
<div class="toggle-group">
|
|
5
|
+
<label class="toggle-label">
|
|
6
|
+
<input type="checkbox" id="stake-toggle" onchange="toggleStakeView()">
|
|
7
|
+
Show Stakes
|
|
8
|
+
</label>
|
|
9
|
+
<label class="toggle-label">
|
|
10
|
+
<input type="checkbox" id="verbose-toggle" onchange="toggleVerboseNumbers()">
|
|
11
|
+
Precise Numbers
|
|
12
|
+
</label>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="subnet-title-row">
|
|
17
|
+
<div class="title-price">
|
|
18
|
+
<h2 id="subnet-title"></h2>
|
|
19
|
+
<div class="subnet-price" id="subnet-price"></div>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="network-visualization-container">
|
|
22
|
+
<div class="network-visualization">
|
|
23
|
+
<canvas id="network-canvas" width="700" height="80"></canvas>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="network-metrics">
|
|
28
|
+
<div class="metric-card network-card">
|
|
29
|
+
<div class="metric-label">Moving Price</div>
|
|
30
|
+
<div id="network-moving-price" class="metric-value"></div>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="metric-card network-card">
|
|
33
|
+
<div class="metric-label">Registration</div>
|
|
34
|
+
<div id="network-registration" class="metric-value registration-status"></div>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="metric-card network-card">
|
|
37
|
+
<div class="metric-label">CR Weights</div>
|
|
38
|
+
<div id="network-cr" class="metric-value cr-status"></div>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="metric-card network-card">
|
|
41
|
+
<div class="metric-label">Neurons</div>
|
|
42
|
+
<div id="network-neurons" class="metric-value"></div>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="metric-card network-card">
|
|
45
|
+
<div class="metric-label">Blocks Since Step</div>
|
|
46
|
+
<div id="network-blocks-since-step" class="metric-value"></div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{# TODO: This may be unused. #}
|
|
2
|
+
|
|
3
|
+
<div id="subnet-modal" class="modal hidden">
|
|
4
|
+
<div class="modal-content">
|
|
5
|
+
<div class="modal-header">
|
|
6
|
+
<h2 class="subnet-title"></h2>
|
|
7
|
+
<button class="close-button" onclick="closeSubnetModal()">×</button>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="subnet-overview">
|
|
10
|
+
<div class="overview-item">
|
|
11
|
+
<span class="label">Price</span>
|
|
12
|
+
<span class="value price"></span>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="overview-item">
|
|
15
|
+
<span class="label">Market Cap</span>
|
|
16
|
+
<span class="value market-cap"></span>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="overview-item">
|
|
19
|
+
<span class="label">Emission Rate</span>
|
|
20
|
+
<span class="value emission"></span>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="overview-item">
|
|
23
|
+
<span class="label">Your Total Stake</span>
|
|
24
|
+
<span class="value total-stake"></span>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="stakes-section">
|
|
28
|
+
<h3>Your Stakes</h3>
|
|
29
|
+
<div class="stakes-list"></div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<div class="metrics-section">
|
|
2
|
+
<div class="metrics-group market-metrics">
|
|
3
|
+
<div class="metric-card">
|
|
4
|
+
<div class="metric-label">Market Cap</div>
|
|
5
|
+
<div id="subnet-market-cap" class="metric-value"></div>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="metric-card">
|
|
8
|
+
<div class="metric-label">Total Stake</div>
|
|
9
|
+
<div id="subnet-total-stake" class="metric-value"></div>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="metric-card">
|
|
12
|
+
<div class="metric-label">Alpha Reserves</div>
|
|
13
|
+
<div id="network-alpha-in" class="metric-value"></div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="metric-card">
|
|
16
|
+
<div class="metric-label">Tao Reserves</div>
|
|
17
|
+
<div id="network-tau-in" class="metric-value"></div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="metric-card">
|
|
20
|
+
<div class="metric-label">Emission</div>
|
|
21
|
+
<div id="subnet-emission" class="metric-value"></div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div class="stakes-container">
|
|
26
|
+
<div class="stakes-header">
|
|
27
|
+
<h3 class="view-header">Metagraph</h3>
|
|
28
|
+
<div class="button-group">
|
|
29
|
+
<button class="manage-button add-stake-button" disabled title="Coming soon">
|
|
30
|
+
Add Stake (Coming soon)
|
|
31
|
+
</button>
|
|
32
|
+
<button class="manage-button export-csv-button" disabled title="Coming soon">
|
|
33
|
+
Export CSV (Coming soon)
|
|
34
|
+
</button>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div class="stakes-table-container">
|
|
39
|
+
<table class="stakes-table">
|
|
40
|
+
<thead>
|
|
41
|
+
<tr>
|
|
42
|
+
<th>Hotkey</th>
|
|
43
|
+
<th>Amount</th>
|
|
44
|
+
<th>Value</th>
|
|
45
|
+
<th>Value (w/ slippage)</th>
|
|
46
|
+
<th>Alpha emission</th>
|
|
47
|
+
<th>Tao emission</th>
|
|
48
|
+
<th>Registered</th>
|
|
49
|
+
<th>Actions</th>
|
|
50
|
+
</tr>
|
|
51
|
+
</thead>
|
|
52
|
+
<tbody id="stakes-table-body">
|
|
53
|
+
</tbody>
|
|
54
|
+
</table>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<div class="subnets-table-container">
|
|
2
|
+
<table class="subnets-table">
|
|
3
|
+
<thead>
|
|
4
|
+
<tr>
|
|
5
|
+
<th class="sortable" onclick="sortMainTable(0)">Subnet</th>
|
|
6
|
+
<th class="sortable" onclick="sortMainTable(1)">Price</th>
|
|
7
|
+
<th class="sortable" onclick="sortMainTable(2)" data-sort="desc">Market Cap</th>
|
|
8
|
+
<th class="sortable" onclick="sortMainTable(3)">Your Stake</th>
|
|
9
|
+
<th class="sortable" onclick="sortMainTable(4)">Emission</th>
|
|
10
|
+
<th>Status</th>
|
|
11
|
+
</tr>
|
|
12
|
+
</thead>
|
|
13
|
+
<tbody>
|
|
14
|
+
{% for subnet in subnets %}
|
|
15
|
+
{% set total_your_stake = subnet.your_stakes|sum(attribute="amount") %}
|
|
16
|
+
{% set stake_status = 'Staked' if total_your_stake > 0 else 'Not Staked' %}
|
|
17
|
+
<tr class="subnet-row" onclick="showSubnetPage({{subnet.netuid}})">
|
|
18
|
+
<td class="subnet-name" data-value="{{subnet.netuid}}"><span style="color: #FF9900">{{subnet.netuid}}</span> - {{subnet.name}}</td>
|
|
19
|
+
<td class="price" data-value="{{subnet.price}}"><span class="formatted-number" data-value="{{subnet.price}}" data-symbol="{{subnet.symbol}}"></span></td>
|
|
20
|
+
<td class="market-cap" data-value="{{subnet.market_cap}}"><span class="formatted-number" data-value="{{subnet.market_cap}}" data-symbol="{{root_symbol_html}}"></span></td>
|
|
21
|
+
<td class="your-stake" data-value="{{total_your_stake}}"><span class="formatted-number" data-value="{{total_your_stake}}" data-symbol="{{subnet.symbol}}"></span></td>
|
|
22
|
+
<td class="emission" data-value="{{subnet.emission}}"><span class="formatted-number" data-value="{{subnet.emission}}" data-symbol="{{root_symbol_html}}"></span></td>
|
|
23
|
+
<td class="stake-status-cell"><span class="stake-status {{'staked' if total_your_stake > 0 else 'unstaked'}}">{{stake_status}}</span></td>
|
|
24
|
+
</tr>
|
|
25
|
+
{% endfor %}
|
|
26
|
+
</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>{{ title }}</title>
|
|
6
|
+
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400&display=swap" rel="stylesheet">
|
|
7
|
+
<link href="https://unpkg.com/tabulator-tables@6.2.5/dist/css/tabulator.min.css" rel="stylesheet">
|
|
8
|
+
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
|
|
9
|
+
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@6.2.5/dist/js/tabulator.min.js"></script>
|
|
10
|
+
</head>
|
|
11
|
+
<style>
|
|
12
|
+
.tabulator {
|
|
13
|
+
font-family: 'DM Mono', monospace !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.tabulator .tabulator-header .tabulator-col {
|
|
17
|
+
font-family: 'DM Mono', monospace !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.tabulator .tabulator-tableHolder .tabulator-row .tabulator-cell {
|
|
21
|
+
font-family: 'DM Mono', monospace !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.tabulator .tabulator-header {
|
|
25
|
+
background-color: #282A2D !important;
|
|
26
|
+
color: white !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.tabulator .tabulator-header .tabulator-col {
|
|
30
|
+
background-color: #282A2D !important;
|
|
31
|
+
color: white !important;
|
|
32
|
+
padding: 16px 12px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tabulator .tabulator-tableHolder .tabulator-row .tabulator-cell {
|
|
36
|
+
padding: 16px 12px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.tabulator .tabulator-tableHolder .tabulator-row:nth-child(even) {
|
|
40
|
+
background-color: #f2f2f2;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tabulator .tabulator-tableHolder .tabulator-row:hover {
|
|
44
|
+
background-color: #ddd;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Apply styles only to the filter section selects */
|
|
48
|
+
.filter-section select {
|
|
49
|
+
-webkit-appearance: none;
|
|
50
|
+
-moz-appearance: none;
|
|
51
|
+
appearance: none;
|
|
52
|
+
padding: 8px;
|
|
53
|
+
border: 1px solid #DBDDE1;
|
|
54
|
+
border-radius: 4px;
|
|
55
|
+
font-family: 'DM Mono', monospace;
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
color: #0E1013;
|
|
58
|
+
background-repeat: no-repeat;
|
|
59
|
+
background-position: right 10px center;
|
|
60
|
+
background-size: 10px;
|
|
61
|
+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%230E1013" d="M2 0L0 2h4z"/></svg>');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Specific styles for each select element */
|
|
65
|
+
.filter-section #filter-field {
|
|
66
|
+
background-color: #F0F0F0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.filter-section #filter-type {
|
|
70
|
+
background-color: #E8E8E8;
|
|
71
|
+
border: 1px solid #C0C0C0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.filter-section #filter-value {
|
|
75
|
+
background-color: #FFFFFF;
|
|
76
|
+
border: 1px solid #DBDDE1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
</style>
|
|
80
|
+
<body style="margin: 0; padding: 0;">
|
|
81
|
+
<!-- Header Bar -->
|
|
82
|
+
<div style="position: relative; width: 1648px; height: 48px; margin: 32px auto 0 auto; background-color: white; color: #282A2D;">
|
|
83
|
+
<!-- Tao Symbol on the Left -->
|
|
84
|
+
<div style="position: absolute; width: 48px; height: 48px; left: 16px; top: 0; text-align: center;
|
|
85
|
+
font-family: 'GFS Neohellenic', serif; font-weight: 400; font-size: 48px; line-height: 48px; color: #282A2D;">
|
|
86
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
87
|
+
<svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34.44 36.91">
|
|
88
|
+
<path d="M20.88,28.32V13.19c0-3.78-3.12-6.86-6.9-6.86V30.51c0,4.81,4.08,6.4,6.6,6.4,2.09,0,3.27-.36,4.69-1.36-3.98-.42-4.39-2.82-4.39-7.23Z"/>
|
|
89
|
+
<path d="M6.29,0C2.82,0,0,2.87,0,6.34H28.15c3.47,0,6.29-2.87,6.29-6.34H6.29Z"/>
|
|
90
|
+
</svg>
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
<!-- Table Info slightly off-center and constrained to one line -->
|
|
94
|
+
<div style="position: absolute; left: 25%; transform: translateX(-25%); top: 12px; width: 60%;
|
|
95
|
+
font-family: 'DM Mono', monospace; font-weight: 400; font-size: 12px; letter-spacing: 0.05em;
|
|
96
|
+
text-transform: uppercase; color: #282A2D; white-space: nowrap;">
|
|
97
|
+
{{ table_info }}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<!-- Filter Section -->
|
|
102
|
+
<div class="filter-section"
|
|
103
|
+
style="display: flex; flex-direction: row; align-items: center; gap: 16px; padding: 16px; border: 1px dashed #0E1013; border-radius: 5px; width: fit-content; margin: 20px auto; box-sizing: border-box;">
|
|
104
|
+
|
|
105
|
+
<!-- Filter Field -->
|
|
106
|
+
<div style="display: flex; flex-direction: column; gap: 4px; flex-grow: 0;">
|
|
107
|
+
<label for="filter-field"
|
|
108
|
+
style="font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">
|
|
109
|
+
Filter Field
|
|
110
|
+
</label>
|
|
111
|
+
<select id="filter-field">
|
|
112
|
+
<option></option>
|
|
113
|
+
{% for col in column_names %}
|
|
114
|
+
<option value="{{ col }}">{{ col }}</option>
|
|
115
|
+
{% endfor %}
|
|
116
|
+
</select>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<!-- Filter Type -->
|
|
120
|
+
<div style="display: flex; flex-direction: column; gap: 4px; flex-grow: 0;">
|
|
121
|
+
<label for="filter-type"
|
|
122
|
+
style="font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">
|
|
123
|
+
Filter Type
|
|
124
|
+
</label>
|
|
125
|
+
<select id="filter-type">
|
|
126
|
+
<option value="=">=</option>
|
|
127
|
+
<option value="<"><</option>
|
|
128
|
+
<option value="<="><=</option>
|
|
129
|
+
<option value=">">></option>
|
|
130
|
+
<option value=">=">>=</option>
|
|
131
|
+
<option value="!=">!=</option>
|
|
132
|
+
<option value="like">like</option>
|
|
133
|
+
</select>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<!-- Filter Value -->
|
|
137
|
+
<div style="display: flex; flex-direction: column; gap: 4px; flex-grow: 0;">
|
|
138
|
+
<label for="filter-value"
|
|
139
|
+
style="font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">
|
|
140
|
+
Filter Value
|
|
141
|
+
</label>
|
|
142
|
+
<input id="filter-value" type="text" placeholder="value to filter"
|
|
143
|
+
style="padding: 8px; border: 1px solid #DBDDE1; border-radius: 4px; background: #FFFFFF; font-family: 'DM Mono'; font-size: 12px; color: #0E1013;">
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<!-- Clear Button -->
|
|
147
|
+
<div style="display: flex; align-items: flex-end; flex-grow: 0;">
|
|
148
|
+
<button id="filter-clear"
|
|
149
|
+
style="padding: 8px 16px; border: 1px solid #DBDDE1; border-radius: 4px; background: #FFFFFF; font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">
|
|
150
|
+
Clear Filter
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<!-- Table Placeholder (for reference) -->
|
|
157
|
+
<div id="my-table" style="width: 1648px; margin: 20px auto;">
|
|
158
|
+
<!-- Table content will go here -->
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<div style="margin: 20px auto; text-align: center;">
|
|
162
|
+
<button id="download-csv" style="padding: 8px 16px; border: 1px solid #DBDDE1; border-radius: 4px; background: #FFFFFF; font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">Download CSV</button>
|
|
163
|
+
<button id="download-json" style="padding: 8px 16px; border: 1px solid #DBDDE1; border-radius: 4px; background: #FFFFFF; font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">Download JSON</button>
|
|
164
|
+
<button id="download-xlsx" style="padding: 8px 16px; border: 1px solid #DBDDE1; border-radius: 4px; background: #FFFFFF; font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">Download XLSX</button>
|
|
165
|
+
<button id="download-html" style="padding: 8px 16px; border: 1px solid #DBDDE1; border-radius: 4px; background: #FFFFFF; font-family: 'DM Mono'; font-size: 12px; text-transform: uppercase; color: #0E1013;">Download HTML</button>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
</body>
|
|
169
|
+
|
|
170
|
+
<script>
|
|
171
|
+
const columns = {{ columns|safe }};
|
|
172
|
+
columns.forEach(column => {
|
|
173
|
+
if (column.customFormatter === "millify") {
|
|
174
|
+
column.formatter = millify;
|
|
175
|
+
delete column.customFormatter;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
const None = null;
|
|
179
|
+
const table = new Tabulator("#my-table",
|
|
180
|
+
{
|
|
181
|
+
columns: columns,
|
|
182
|
+
data: {{ rows|safe }},
|
|
183
|
+
pagination: "local",
|
|
184
|
+
paginationSize: 50,
|
|
185
|
+
paginationSizeSelector: [50, 100, 150, 200],
|
|
186
|
+
movableColumns: true,
|
|
187
|
+
paginationCounter: "rows",
|
|
188
|
+
layout: "fitDataFill",
|
|
189
|
+
{% if tree %} dataTree: true, {% endif %}
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
//Define variables for input elements
|
|
193
|
+
const fieldEl = document.getElementById("filter-field");
|
|
194
|
+
const typeEl = document.getElementById("filter-type");
|
|
195
|
+
const valueEl = document.getElementById("filter-value");
|
|
196
|
+
|
|
197
|
+
//Custom filter example
|
|
198
|
+
function customFilter(data) {
|
|
199
|
+
return data.car && data.rating < 3;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
//Trigger setFilter function with correct parameters
|
|
203
|
+
function updateFilter() {
|
|
204
|
+
var filterVal = fieldEl.options[fieldEl.selectedIndex].value;
|
|
205
|
+
var typeVal = typeEl.options[typeEl.selectedIndex].value;
|
|
206
|
+
|
|
207
|
+
var filter = filterVal == "function" ? customFilter : filterVal;
|
|
208
|
+
|
|
209
|
+
if (filterVal == "function") {
|
|
210
|
+
typeEl.disabled = true;
|
|
211
|
+
valueEl.disabled = true;
|
|
212
|
+
} else {
|
|
213
|
+
typeEl.disabled = false;
|
|
214
|
+
valueEl.disabled = false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (filterVal) {
|
|
218
|
+
table.setFilter(filter, typeVal, valueEl.value);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function millify(cell, formatterParams, onRendered) {
|
|
223
|
+
const millNames = ["", "K", "M", "B", "T"];
|
|
224
|
+
const n = cell.getValue();
|
|
225
|
+
const nAbs = Math.abs(n);
|
|
226
|
+
const millIdx = Math.max(0, Math.min(millNames.length - 1, Math.floor(nAbs === 0 ? 0 : Math.log10(nAbs) / 3)));
|
|
227
|
+
|
|
228
|
+
return (n / Math.pow(10, 3 * millIdx)).toFixed(2) + millNames[millIdx];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
//Update filters on value change
|
|
232
|
+
document.getElementById("filter-field").addEventListener("change", updateFilter);
|
|
233
|
+
document.getElementById("filter-type").addEventListener("change", updateFilter);
|
|
234
|
+
document.getElementById("filter-value").addEventListener("keyup", updateFilter);
|
|
235
|
+
|
|
236
|
+
//Clear filters on "Clear Filters" button click
|
|
237
|
+
document.getElementById("filter-clear").addEventListener("click", function () {
|
|
238
|
+
fieldEl.value = "";
|
|
239
|
+
typeEl.value = "=";
|
|
240
|
+
valueEl.value = "";
|
|
241
|
+
|
|
242
|
+
table.clearFilter();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
//trigger download of data.csv file
|
|
246
|
+
document.getElementById("download-csv").addEventListener("click", function () {
|
|
247
|
+
table.download("csv", "{{ title }}.csv");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
//trigger download of data.json file
|
|
251
|
+
document.getElementById("download-json").addEventListener("click", function () {
|
|
252
|
+
table.download("json", "{{ title }}.json");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
//trigger download of data.xlsx file
|
|
256
|
+
document.getElementById("download-xlsx").addEventListener("click", function () {
|
|
257
|
+
table.download("xlsx", "{{ title }}.xlsx", {sheetName: "My Data"});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
//trigger download of data.html file
|
|
261
|
+
document.getElementById("download-html").addEventListener("click", function () {
|
|
262
|
+
table.download("html", "{{ title }}.html", {style: true});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
</script>
|
|
266
|
+
|
|
267
|
+
</html>
|