feat: rename TFP to MC currency in dashboard UI and pools functionality
This commit is contained in:
@@ -1628,7 +1628,7 @@ impl DashboardController {
|
|||||||
let price_per_hour = slice_data.get("price_hour")
|
let price_per_hour = slice_data.get("price_hour")
|
||||||
.and_then(|v| v.as_f64())
|
.and_then(|v| v.as_f64())
|
||||||
.map(|p| rust_decimal::Decimal::from_f64_retain(p).unwrap_or(rust_decimal::Decimal::new(50, 2)))
|
.map(|p| rust_decimal::Decimal::from_f64_retain(p).unwrap_or(rust_decimal::Decimal::new(50, 2)))
|
||||||
.unwrap_or(rust_decimal::Decimal::new(50, 2)); // Fallback to 0.50 TFC/hour only if no price provided
|
.unwrap_or(rust_decimal::Decimal::new(50, 2)); // Fallback to 0.50 MC/hour only if no price provided
|
||||||
|
|
||||||
// Load user data to get resource_provider name
|
// Load user data to get resource_provider name
|
||||||
let user = Self::load_user_with_persistent_data(&session);
|
let user = Self::load_user_with_persistent_data(&session);
|
||||||
|
@@ -38,7 +38,7 @@ class UserDashboard {
|
|||||||
data: {
|
data: {
|
||||||
labels: ['Month 1', 'Month 2', 'Month 3', 'Month 4', 'Month 5', 'Month 6'],
|
labels: ['Month 1', 'Month 2', 'Month 3', 'Month 4', 'Month 5', 'Month 6'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'TFC Usage',
|
label: 'MC Usage',
|
||||||
data: this.userData.tfp_usage_trend || [0, 0, 0, 0, 0, 0],
|
data: this.userData.tfp_usage_trend || [0, 0, 0, 0, 0, 0],
|
||||||
borderColor: '#007bff',
|
borderColor: '#007bff',
|
||||||
backgroundColor: 'rgba(0, 123, 255, 0.1)',
|
backgroundColor: 'rgba(0, 123, 255, 0.1)',
|
||||||
@@ -58,7 +58,7 @@ class UserDashboard {
|
|||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: function(context) {
|
label: function(context) {
|
||||||
return `TFC Usage: ${context.raw} TFC`;
|
return `MC Usage: ${context.raw} MC`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ class UserDashboard {
|
|||||||
<td><span class="badge ${statusBadge}">${app.status}</span></td>
|
<td><span class="badge ${statusBadge}">${app.status}</span></td>
|
||||||
<td>${app.rating}/5 ⭐</td>
|
<td>${app.rating}/5 ⭐</td>
|
||||||
<td>${app.deployments} active</td>
|
<td>${app.deployments} active</td>
|
||||||
<td>${app.monthly_revenue} TFP/month</td>
|
<td>${app.monthly_revenue} MC/month</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-sm btn-outline-primary" onclick="manageApplication('${app.id}', '${app.name}')">Manage</button>
|
<button class="btn btn-sm btn-outline-primary" onclick="manageApplication('${app.id}', '${app.name}')">Manage</button>
|
||||||
@@ -416,7 +416,7 @@ class UserDashboard {
|
|||||||
</td>
|
</td>
|
||||||
<td><span class="badge bg-light text-dark">${service.category}</span></td>
|
<td><span class="badge bg-light text-dark">${service.category}</span></td>
|
||||||
<td><span class="badge ${statusBadge}">${service.status}</span></td>
|
<td><span class="badge ${statusBadge}">${service.status}</span></td>
|
||||||
<td>${service.price_per_hour} TFP</td>
|
<td>${service.price_per_hour} MC</td>
|
||||||
<td>${service.clients}</td>
|
<td>${service.clients}</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="text-warning">${stars}</span>
|
<span class="text-warning">${stars}</span>
|
||||||
@@ -472,7 +472,7 @@ class UserDashboard {
|
|||||||
<td>${resource.location}</td>
|
<td>${resource.location}</td>
|
||||||
<td><span class="badge ${statusBadge}">${resource.status}</span></td>
|
<td><span class="badge ${statusBadge}">${resource.status}</span></td>
|
||||||
<td>${resource.sla}</td>
|
<td>${resource.sla}</td>
|
||||||
<td>${resource.monthly_cost} TFP/month</td>
|
<td>${resource.monthly_cost} MC/month</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-sm btn-outline-primary" onclick="manageResource('${resource.id}')">Details</button>
|
<button class="btn btn-sm btn-outline-primary" onclick="manageResource('${resource.id}')">Details</button>
|
||||||
@@ -525,7 +525,7 @@ class UserDashboard {
|
|||||||
<td>${rental.specs}</td>
|
<td>${rental.specs}</td>
|
||||||
<td>${rental.location}</td>
|
<td>${rental.location}</td>
|
||||||
<td><span class="badge ${statusBadge}">${rental.status}</span></td>
|
<td><span class="badge ${statusBadge}">${rental.status}</span></td>
|
||||||
<td>${rental.monthly_cost} TFP/month</td>
|
<td>${rental.monthly_cost} MC/month</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-sm btn-outline-primary" onclick="manageSliceRental('${rental.id}')">Manage</button>
|
<button class="btn btn-sm btn-outline-primary" onclick="manageSliceRental('${rental.id}')">Manage</button>
|
||||||
@@ -558,7 +558,7 @@ class UserDashboard {
|
|||||||
if (activeRentalsElement) activeRentalsElement.textContent = activeRentals;
|
if (activeRentalsElement) activeRentalsElement.textContent = activeRentals;
|
||||||
if (vmDeploymentsElement) vmDeploymentsElement.textContent = vmDeployments;
|
if (vmDeploymentsElement) vmDeploymentsElement.textContent = vmDeployments;
|
||||||
if (k8sDeploymentsElement) k8sDeploymentsElement.textContent = k8sDeployments;
|
if (k8sDeploymentsElement) k8sDeploymentsElement.textContent = k8sDeployments;
|
||||||
if (monthlyCostElement) monthlyCostElement.textContent = `${totalMonthlyCost} TFP`;
|
if (monthlyCostElement) monthlyCostElement.textContent = `${totalMonthlyCost} MC`;
|
||||||
|
|
||||||
console.log(`📊 Updated slice rental stats: ${activeRentals} active, ${vmDeployments} VM, ${k8sDeployments} K8s, ${totalMonthlyCost} TFP/month`);
|
console.log(`📊 Updated slice rental stats: ${activeRentals} active, ${vmDeployments} VM, ${k8sDeployments} K8s, ${totalMonthlyCost} TFP/month`);
|
||||||
}
|
}
|
||||||
|
@@ -207,7 +207,7 @@
|
|||||||
tfpAmountTFT.addEventListener('input', () => {
|
tfpAmountTFT.addEventListener('input', () => {
|
||||||
const amount = parseFloat(tfpAmountTFT.value) || 0;
|
const amount = parseFloat(tfpAmountTFT.value) || 0;
|
||||||
const tftCost = amount * 0.5; // 1 MC = 0.5 TFT
|
const tftCost = amount * 0.5; // 1 MC = 0.5 TFT
|
||||||
const modal = document.getElementById('buyTFCWithTFTModal');
|
const modal = document.getElementById('buyMCWithTFTModal');
|
||||||
if (modal) {
|
if (modal) {
|
||||||
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
||||||
// rows[0] -> Amount, rows[1] -> Cost
|
// rows[0] -> Amount, rows[1] -> Cost
|
||||||
@@ -223,7 +223,7 @@
|
|||||||
sellTfpAmountTFT.addEventListener('input', () => {
|
sellTfpAmountTFT.addEventListener('input', () => {
|
||||||
const amount = parseFloat(sellTfpAmountTFT.value) || 0;
|
const amount = parseFloat(sellTfpAmountTFT.value) || 0;
|
||||||
const tftReceive = amount * 0.5; // 1 MC = 0.5 TFT
|
const tftReceive = amount * 0.5; // 1 MC = 0.5 TFT
|
||||||
const modal = document.getElementById('sellTFCForTFTModal');
|
const modal = document.getElementById('sellMCForTFTModal');
|
||||||
if (modal) {
|
if (modal) {
|
||||||
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
||||||
if (rows[0]) rows[0].textContent = `${amount} MC`;
|
if (rows[0]) rows[0].textContent = `${amount} MC`;
|
||||||
@@ -238,7 +238,7 @@
|
|||||||
tfpAmountPEAQ.addEventListener('input', () => {
|
tfpAmountPEAQ.addEventListener('input', () => {
|
||||||
const amount = parseFloat(tfpAmountPEAQ.value) || 0;
|
const amount = parseFloat(tfpAmountPEAQ.value) || 0;
|
||||||
const peaqCost = amount * 2.0; // 1 MC = 2 PEAQ
|
const peaqCost = amount * 2.0; // 1 MC = 2 PEAQ
|
||||||
const modal = document.getElementById('buyTFCWithPEAQModal');
|
const modal = document.getElementById('buyMCWithPEAQModal');
|
||||||
if (modal) {
|
if (modal) {
|
||||||
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
||||||
if (rows[0]) rows[0].textContent = `${amount} MC`;
|
if (rows[0]) rows[0].textContent = `${amount} MC`;
|
||||||
@@ -253,7 +253,7 @@
|
|||||||
sellTfpAmountPEAQ.addEventListener('input', () => {
|
sellTfpAmountPEAQ.addEventListener('input', () => {
|
||||||
const amount = parseFloat(sellTfpAmountPEAQ.value) || 0;
|
const amount = parseFloat(sellTfpAmountPEAQ.value) || 0;
|
||||||
const peaqReceive = amount * 2.0; // 1 MC = 2 PEAQ
|
const peaqReceive = amount * 2.0; // 1 MC = 2 PEAQ
|
||||||
const modal = document.getElementById('sellTFCForPEAQModal');
|
const modal = document.getElementById('sellMCForPEAQModal');
|
||||||
if (modal) {
|
if (modal) {
|
||||||
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
|
||||||
if (rows[0]) rows[0].textContent = `${amount} MC`;
|
if (rows[0]) rows[0].textContent = `${amount} MC`;
|
||||||
@@ -376,7 +376,7 @@
|
|||||||
body: JSON.stringify({ amount, payment_method: 'TFT' }),
|
body: JSON.stringify({ amount, payment_method: 'TFT' }),
|
||||||
});
|
});
|
||||||
showSuccessToast(`Purchased ${amount} MC with TFT`);
|
showSuccessToast(`Purchased ${amount} MC with TFT`);
|
||||||
const modal = document.getElementById('buyTFCWithTFTModal');
|
const modal = document.getElementById('buyMCWithTFTModal');
|
||||||
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e && e.status === 402) {
|
if (e && e.status === 402) {
|
||||||
@@ -399,7 +399,7 @@
|
|||||||
body: JSON.stringify({ amount, currency: 'TFT', payout_method: 'blockchain' }),
|
body: JSON.stringify({ amount, currency: 'TFT', payout_method: 'blockchain' }),
|
||||||
});
|
});
|
||||||
showSuccessToast(`Sold ${amount} MC for TFT`);
|
showSuccessToast(`Sold ${amount} MC for TFT`);
|
||||||
const modal = document.getElementById('sellTFCForTFTModal');
|
const modal = document.getElementById('sellMCForTFTModal');
|
||||||
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e && e.status === 402) {
|
if (e && e.status === 402) {
|
||||||
@@ -422,7 +422,7 @@
|
|||||||
body: JSON.stringify({ amount, payment_method: 'PEAQ' }),
|
body: JSON.stringify({ amount, payment_method: 'PEAQ' }),
|
||||||
});
|
});
|
||||||
showSuccessToast(`Purchased ${amount} MC with PEAQ`);
|
showSuccessToast(`Purchased ${amount} MC with PEAQ`);
|
||||||
const modal = document.getElementById('buyTFCWithPEAQModal');
|
const modal = document.getElementById('buyMCWithPEAQModal');
|
||||||
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e && e.status === 402) {
|
if (e && e.status === 402) {
|
||||||
@@ -445,7 +445,7 @@
|
|||||||
body: JSON.stringify({ amount, currency: 'PEAQ', payout_method: 'blockchain' }),
|
body: JSON.stringify({ amount, currency: 'PEAQ', payout_method: 'blockchain' }),
|
||||||
});
|
});
|
||||||
showSuccessToast(`Sold ${amount} MC for PEAQ`);
|
showSuccessToast(`Sold ${amount} MC for PEAQ`);
|
||||||
const modal = document.getElementById('sellTFCForPEAQModal');
|
const modal = document.getElementById('sellMCForPEAQModal');
|
||||||
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
if (modal && window.bootstrap) bootstrap.Modal.getOrCreateInstance(modal).hide();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e && e.status === 402) {
|
if (e && e.status === 402) {
|
||||||
|
@@ -244,7 +244,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Buy TFC Credits Modal -->
|
<!-- Buy MC Credits Modal -->
|
||||||
<div class="modal fade" id="buyCreditsModal" tabindex="-1" aria-labelledby="buyCreditsModalLabel" aria-hidden="true">
|
<div class="modal fade" id="buyCreditsModal" tabindex="-1" aria-labelledby="buyCreditsModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Sell TFC Credits Modal -->
|
<!-- Sell MC Credits Modal -->
|
||||||
<div class="modal fade" id="sellCreditsModal" tabindex="-1" aria-labelledby="sellCreditsModalLabel" aria-hidden="true">
|
<div class="modal fade" id="sellCreditsModal" tabindex="-1" aria-labelledby="sellCreditsModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -359,7 +359,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Stake TFC Credits Modal -->
|
<!-- Stake MC Credits Modal -->
|
||||||
<div class="modal fade" id="stakeCreditsModal" tabindex="-1" aria-labelledby="stakeCreditsModalLabel" aria-hidden="true">
|
<div class="modal fade" id="stakeCreditsModal" tabindex="-1" aria-labelledby="stakeCreditsModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -406,12 +406,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Buy TFC Credits with TFT Modal -->
|
<!-- Buy MC Credits with TFT Modal -->
|
||||||
<div class="modal fade" id="buyTFCWithTFTModal" tabindex="-1" aria-labelledby="buyTFCWithTFTModalLabel" aria-hidden="true">
|
<div class="modal fade" id="buyMCWithTFTModal" tabindex="-1" aria-labelledby="buyMCWithTFTModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header bg-success text-white">
|
<div class="modal-header bg-success text-white">
|
||||||
<h5 class="modal-title" id="buyTFCWithTFTModalLabel">Buy Mycelium Credits (MC) with TFT</h5>
|
<h5 class="modal-title" id="buyMCWithTFTModalLabel">Buy Mycelium Credits (MC) with TFT</h5>
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@@ -447,12 +447,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Sell TFC Credits for TFT Modal -->
|
<!-- Sell MC Credits for TFT Modal -->
|
||||||
<div class="modal fade" id="sellTFCForTFTModal" tabindex="-1" aria-labelledby="sellTFCForTFTModalLabel" aria-hidden="true">
|
<div class="modal fade" id="sellMCForTFTModal" tabindex="-1" aria-labelledby="sellMCForTFTModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header bg-success text-white">
|
<div class="modal-header bg-success text-white">
|
||||||
<h5 class="modal-title" id="sellTFCForTFTModalLabel">Sell Mycelium Credits (MC) for TFT</h5>
|
<h5 class="modal-title" id="sellMCForTFTModalLabel">Sell Mycelium Credits (MC) for TFT</h5>
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@@ -489,12 +489,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Buy TFC Credits with PEAQ Modal -->
|
<!-- Buy MC Credits with PEAQ Modal -->
|
||||||
<div class="modal fade" id="buyTFCWithPEAQModal" tabindex="-1" aria-labelledby="buyTFCWithPEAQModalLabel" aria-hidden="true">
|
<div class="modal fade" id="buyMCWithPEAQModal" tabindex="-1" aria-labelledby="buyMCWithPEAQModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header bg-info text-white">
|
<div class="modal-header bg-info text-white">
|
||||||
<h5 class="modal-title" id="buyTFCWithPEAQModalLabel">Buy Mycelium Credits (MC) with PEAQ</h5>
|
<h5 class="modal-title" id="buyMCWithPEAQModalLabel">Buy Mycelium Credits (MC) with PEAQ</h5>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@@ -530,12 +530,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Sell TFC Credits for PEAQ Modal -->
|
<!-- Sell MC Credits for PEAQ Modal -->
|
||||||
<div class="modal fade" id="sellTFCForPEAQModal" tabindex="-1" aria-labelledby="sellTFCForPEAQModalLabel" aria-hidden="true">
|
<div class="modal fade" id="sellMCForPEAQModal" tabindex="-1" aria-labelledby="sellMCForPEAQModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header bg-info text-white">
|
<div class="modal-header bg-info text-white">
|
||||||
<h5 class="modal-title" id="sellTFCForPEAQModalLabel">Sell Mycelium Credits (MC) for PEAQ</h5>
|
<h5 class="modal-title" id="sellMCForPEAQModalLabel">Sell Mycelium Credits (MC) for PEAQ</h5>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
Reference in New Issue
Block a user