feat: rename TFP to MC currency in dashboard UI and pools functionality

This commit is contained in:
mik-tf
2025-09-08 13:14:47 -04:00
parent 867d418ea7
commit 1c55ac0af3
4 changed files with 31 additions and 31 deletions

View File

@@ -1628,7 +1628,7 @@ impl DashboardController {
let price_per_hour = slice_data.get("price_hour")
.and_then(|v| v.as_f64())
.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
let user = Self::load_user_with_persistent_data(&session);

View File

@@ -38,7 +38,7 @@ class UserDashboard {
data: {
labels: ['Month 1', 'Month 2', 'Month 3', 'Month 4', 'Month 5', 'Month 6'],
datasets: [{
label: 'TFC Usage',
label: 'MC Usage',
data: this.userData.tfp_usage_trend || [0, 0, 0, 0, 0, 0],
borderColor: '#007bff',
backgroundColor: 'rgba(0, 123, 255, 0.1)',
@@ -58,7 +58,7 @@ class UserDashboard {
tooltip: {
callbacks: {
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>${app.rating}/5 ⭐</td>
<td>${app.deployments} active</td>
<td>${app.monthly_revenue} TFP/month</td>
<td>${app.monthly_revenue} MC/month</td>
<td>
<div class="btn-group">
<button class="btn btn-sm btn-outline-primary" onclick="manageApplication('${app.id}', '${app.name}')">Manage</button>
@@ -416,7 +416,7 @@ class UserDashboard {
</td>
<td><span class="badge bg-light text-dark">${service.category}</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>
<span class="text-warning">${stars}</span>
@@ -472,7 +472,7 @@ class UserDashboard {
<td>${resource.location}</td>
<td><span class="badge ${statusBadge}">${resource.status}</span></td>
<td>${resource.sla}</td>
<td>${resource.monthly_cost} TFP/month</td>
<td>${resource.monthly_cost} MC/month</td>
<td>
<div class="btn-group">
<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.location}</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>
<div class="btn-group">
<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 (vmDeploymentsElement) vmDeploymentsElement.textContent = vmDeployments;
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`);
}

View File

@@ -207,7 +207,7 @@
tfpAmountTFT.addEventListener('input', () => {
const amount = parseFloat(tfpAmountTFT.value) || 0;
const tftCost = amount * 0.5; // 1 MC = 0.5 TFT
const modal = document.getElementById('buyTFCWithTFTModal');
const modal = document.getElementById('buyMCWithTFTModal');
if (modal) {
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
// rows[0] -> Amount, rows[1] -> Cost
@@ -223,7 +223,7 @@
sellTfpAmountTFT.addEventListener('input', () => {
const amount = parseFloat(sellTfpAmountTFT.value) || 0;
const tftReceive = amount * 0.5; // 1 MC = 0.5 TFT
const modal = document.getElementById('sellTFCForTFTModal');
const modal = document.getElementById('sellMCForTFTModal');
if (modal) {
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
if (rows[0]) rows[0].textContent = `${amount} MC`;
@@ -238,7 +238,7 @@
tfpAmountPEAQ.addEventListener('input', () => {
const amount = parseFloat(tfpAmountPEAQ.value) || 0;
const peaqCost = amount * 2.0; // 1 MC = 2 PEAQ
const modal = document.getElementById('buyTFCWithPEAQModal');
const modal = document.getElementById('buyMCWithPEAQModal');
if (modal) {
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
if (rows[0]) rows[0].textContent = `${amount} MC`;
@@ -253,7 +253,7 @@
sellTfpAmountPEAQ.addEventListener('input', () => {
const amount = parseFloat(sellTfpAmountPEAQ.value) || 0;
const peaqReceive = amount * 2.0; // 1 MC = 2 PEAQ
const modal = document.getElementById('sellTFCForPEAQModal');
const modal = document.getElementById('sellMCForPEAQModal');
if (modal) {
const rows = modal.querySelectorAll('.alert .d-flex.justify-content-between .text-end');
if (rows[0]) rows[0].textContent = `${amount} MC`;
@@ -376,7 +376,7 @@
body: JSON.stringify({ amount, payment_method: '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();
} catch (e) {
if (e && e.status === 402) {
@@ -399,7 +399,7 @@
body: JSON.stringify({ amount, currency: 'TFT', payout_method: 'blockchain' }),
});
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();
} catch (e) {
if (e && e.status === 402) {
@@ -422,7 +422,7 @@
body: JSON.stringify({ amount, payment_method: '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();
} catch (e) {
if (e && e.status === 402) {
@@ -445,7 +445,7 @@
body: JSON.stringify({ amount, currency: 'PEAQ', payout_method: 'blockchain' }),
});
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();
} catch (e) {
if (e && e.status === 402) {

View File

@@ -244,7 +244,7 @@
</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-dialog">
<div class="modal-content">
@@ -301,7 +301,7 @@
</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-dialog">
<div class="modal-content">
@@ -359,7 +359,7 @@
</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-dialog">
<div class="modal-content">
@@ -406,12 +406,12 @@
</div>
</div>
<!-- Buy TFC Credits with TFT Modal -->
<div class="modal fade" id="buyTFCWithTFTModal" tabindex="-1" aria-labelledby="buyTFCWithTFTModalLabel" aria-hidden="true">
<!-- Buy MC Credits with TFT Modal -->
<div class="modal fade" id="buyMCWithTFTModal" tabindex="-1" aria-labelledby="buyMCWithTFTModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<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>
</div>
<div class="modal-body">
@@ -447,12 +447,12 @@
</div>
</div>
<!-- Sell TFC Credits for TFT Modal -->
<div class="modal fade" id="sellTFCForTFTModal" tabindex="-1" aria-labelledby="sellTFCForTFTModalLabel" aria-hidden="true">
<!-- Sell MC Credits for TFT Modal -->
<div class="modal fade" id="sellMCForTFTModal" tabindex="-1" aria-labelledby="sellMCForTFTModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<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>
</div>
<div class="modal-body">
@@ -489,12 +489,12 @@
</div>
</div>
<!-- Buy TFC Credits with PEAQ Modal -->
<div class="modal fade" id="buyTFCWithPEAQModal" tabindex="-1" aria-labelledby="buyTFCWithPEAQModalLabel" aria-hidden="true">
<!-- Buy MC Credits with PEAQ Modal -->
<div class="modal fade" id="buyMCWithPEAQModal" tabindex="-1" aria-labelledby="buyMCWithPEAQModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<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>
</div>
<div class="modal-body">
@@ -530,12 +530,12 @@
</div>
</div>
<!-- Sell TFC Credits for PEAQ Modal -->
<div class="modal fade" id="sellTFCForPEAQModal" tabindex="-1" aria-labelledby="sellTFCForPEAQModalLabel" aria-hidden="true">
<!-- Sell MC Credits for PEAQ Modal -->
<div class="modal fade" id="sellMCForPEAQModal" tabindex="-1" aria-labelledby="sellMCForPEAQModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<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>
</div>
<div class="modal-body">