feat: Sort table by value
All checks were successful
Build Docker / BuildImage (push) Successful in 36s

This commit is contained in:
Nathan Woodburn 2024-12-05 20:21:56 +11:00
parent 2008c2cfc4
commit 508acf2bc3
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
17 changed files with 96 additions and 68 deletions

View File

@ -1 +1 @@
{"timestamp": 1733379058.113869, "result": "120"}
{"timestamp": 1733390400.4615693, "result": "129.72815534"}

View File

@ -0,0 +1 @@
{"timestamp": 1733390401.1929479, "result": 3920.13}

View File

@ -1 +1 @@
{"timestamp": 1733383694.982534, "result": 1.2}
{"timestamp": 1733390448.2838762, "result": 1.22}

View File

@ -1 +1 @@
{"timestamp": 1733383633.5427628, "result": 4.2}
{"timestamp": 1733390447.3589993, "result": 4.19}

View File

@ -1 +1 @@
{"timestamp": 1733383572.4728422, "result": 249.28}
{"timestamp": 1733390400.7691364, "result": 249.8}

View File

@ -1 +1 @@
{"timestamp": 1733383570.7053297, "result": 234.41}
{"timestamp": 1733388581.604049, "result": 235.89}

View File

@ -1 +1 @@
{"timestamp": 1733383570.0432231, "result": 120.0}
{"timestamp": 1733390403.2274024, "result": 129.72815534}

View File

@ -1 +1 @@
{"timestamp": 1733379058.5102375, "result": 0.006512062}
{"timestamp": 1733390450.351181, "result": 0.005776758}

View File

@ -1 +1 @@
{"timestamp": 1733383570.8879113, "result": 2.4620696454199997}
{"timestamp": 1733390400.5671725, "result": 1.36267944462}

View File

@ -1 +1 @@
{"timestamp": 1733383571.9041255, "result": 1.001}
{"timestamp": 1733390400.5661695, "result": 1.001}

View File

@ -1 +1 @@
{"timestamp": 1733383633.5440447, "result": [{"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.039815492, "price": 249.28, "value": 9.92520584576, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 2.402337, "price": 4.2, "value": 10.0898154, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}]}
{"timestamp": 1733390451.4364688, "result": [{"mint": "jupSoLaHXQiZZTSfEWMTRRgpnyFm8f6sZdosWBjx93v", "balance": 0.039815492, "price": 249.8, "value": 9.9459099016, "name": "Jupiter Staked SOL", "symbol": "jupsol"}, {"mint": "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", "balance": 0.00255735, "price": 3920.13, "value": 10.0251444555, "name": "Ethereum (Wormhole)", "symbol": "eth"}, {"mint": "27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4", "balance": 2.402337, "price": 4.19, "value": 10.06579203, "name": "Jupiter Perpetuals Liquidity Provider Token", "symbol": "jlp"}]}

View File

@ -1 +1 @@
{"timestamp": 1733383694.9831324, "result": 121.85536329118}
{"timestamp": 1733390500.4894085, "result": 132.43410277172}

View File

@ -1 +1 @@
{"timestamp": 1733383634.1566763, "result": 82.815227}
{"timestamp": 1733390448.4887109, "result": 82.815227}

View File

@ -475,7 +475,6 @@ def parseDeposit(data):
mint_stWDBRN(stWDBRN_amount, transfer['fromUserAccount'])
def mint_stWDBRN(amount, to_user_account):
if amount < 0.5:
print(f"Skipping minting of {amount} stWDBRN to {to_user_account} as it is less than 0.5", flush=True)
return
@ -507,10 +506,6 @@ def mint_stWDBRN(amount, to_user_account):
to_Pubkey = account.value[0].pubkey
print(token.mint_to(to_Pubkey,wallet_keypair,int(amount*10**9)))
# endregion

Binary file not shown.

View File

@ -121,62 +121,93 @@
}
function populateTable(data) {
const tableContainer = document.getElementById('data-table');
tableContainer.innerHTML = ''; // Clear previous table data
const tableContainer = document.getElementById('data-table');
tableContainer.innerHTML = ''; // Clear previous table data
// Create table elements
const table = document.createElement('table');
table.style.margin = 'auto';
table.style.borderCollapse = 'collapse';
// Create table elements
const table = document.createElement('table');
table.style.margin = 'auto';
table.style.borderCollapse = 'collapse';
const thead = document.createElement('thead');
const tbody = document.createElement('tbody');
const thead = document.createElement('thead');
const tbody = document.createElement('tbody');
// Create table header
const headerRow = document.createElement('tr');
['Name', 'Amount', 'Value'].forEach(headerText => {
const th = document.createElement('th');
th.textContent = headerText;
th.style.border = '1px solid #ccc';
th.style.padding = '8px 20px';
th.style.backgroundColor = '#333';
th.style.color = 'white';
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
// Create table rows
for (const token in data) {
if (token !== 'total') {
const row = document.createElement('tr');
const nameCell = document.createElement('td');
nameCell.textContent = data[token].name;
nameCell.style.border = '1px solid #ccc';
nameCell.style.padding = '8px 20px';
const amountCell = document.createElement('td');
amountCell.textContent = `${data[token].amount} ${token}`;
amountCell.style.border = '1px solid #ccc';
amountCell.style.padding = '8px 20px';
const valueCell = document.createElement('td');
valueCell.textContent = data[token].value;
valueCell.style.border = '1px solid #ccc';
valueCell.style.padding = '8px 20px';
row.appendChild(nameCell);
row.appendChild(amountCell);
row.appendChild(valueCell);
tbody.appendChild(row);
}
}
table.appendChild(thead);
table.appendChild(tbody);
tableContainer.appendChild(table);
// Create table header
const headerRow = document.createElement('tr');
['Name', 'Amount', 'Value'].forEach((headerText, index) => {
const th = document.createElement('th');
th.textContent = headerText;
th.style.border = '1px solid #ccc';
th.style.padding = '8px 20px';
th.style.backgroundColor = '#333';
th.style.color = 'white';
if (headerText === 'Value') {
th.style.cursor = 'pointer'; // Make it clear this header is clickable
th.addEventListener('click', () => sortTableByValue(tbody));
}
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
// Create table rows
for (const token in data) {
if (token !== 'total') {
const row = document.createElement('tr');
const nameCell = document.createElement('td');
nameCell.textContent = data[token].name;
nameCell.style.border = '1px solid #ccc';
nameCell.style.padding = '8px 20px';
const amountCell = document.createElement('td');
amountCell.textContent = `${data[token].amount} ${token}`;
amountCell.style.border = '1px solid #ccc';
amountCell.style.padding = '8px 20px';
const valueCell = document.createElement('td');
valueCell.textContent = data[token].value;
valueCell.style.border = '1px solid #ccc';
valueCell.style.padding = '8px 20px';
row.appendChild(nameCell);
row.appendChild(amountCell);
row.appendChild(valueCell);
tbody.appendChild(row);
}
}
table.appendChild(thead);
table.appendChild(tbody);
tableContainer.appendChild(table);
sortTableByValue(tbody);
}
// Function to sort table rows by the "Value" column
function sortTableByValue(tbody) {
const rows = Array.from(tbody.querySelectorAll('tr'));
const sortedRows = rows.sort((a, b) => {
const valueA = parseFloat(a.children[2].textContent) || 0;
const valueB = parseFloat(b.children[2].textContent) || 0;
return valueA - valueB;
});
// Reverse order if already sorted in ascending order
const isDecending = tbody.getAttribute('data-sort-order') === 'desc';
if (!isDecending) {
sortedRows.reverse();
tbody.setAttribute('data-sort-order', 'desc');
} else {
tbody.setAttribute('data-sort-order', 'asc');
}
// Append sorted rows back to the tbody
tbody.innerHTML = '';
sortedRows.forEach(row => tbody.appendChild(row));
}
async function toggleChart() {
isPerTokenView = !isPerTokenView;

File diff suppressed because one or more lines are too long