feat: rename farmer to resource provider in JS functions and structs

This commit is contained in:
mik-tf
2025-09-07 09:35:04 -04:00
parent c8e28cf8ed
commit 63c0e936d6
4 changed files with 22 additions and 22 deletions

View File

@@ -117,8 +117,8 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
.route("/dashboard/slice-configuration/{id}", web::put().to(DashboardController::update_slice_configuration))
.route("/dashboard/service-provider-data", web::get().to(DashboardController::service_provider_data_api))
// Resource provider management API routes
.route("/dashboard/resource_provider-nodes", web::post().to(DashboardController::add_resource_provider_node))
.route("/dashboard/resource_provider-nodes-enhanced", web::post().to(DashboardController::add_resource_provider_node_enhanced))
.route("/dashboard/resource_provider-nodes", web::post().to(DashboardController::add_farm_node))
.route("/dashboard/resource_provider-nodes-enhanced", web::post().to(DashboardController::add_farm_node_enhanced))
.route("/dashboard/resource_provider-nodes/{id}", web::get().to(DashboardController::get_node_details))
.route("/dashboard/resource_provider-nodes/{id}", web::put().to(DashboardController::update_node_comprehensive))
.route("/dashboard/resource_provider-nodes/{id}/status", web::put().to(DashboardController::update_node_status))

View File

@@ -890,7 +890,7 @@ impl ResourceProviderService {
}
/// Get resource_provider statistics
pub fn get_resource_provider_statistics(&self, user_email: &str) -> FarmerStatistics {
pub fn get_resource_provider_statistics(&self, user_email: &str) -> ResourceProviderStatistics {
let nodes = self.get_resource_provider_nodes(user_email);
let earnings = self.get_resource_provider_earnings(user_email);
@@ -962,7 +962,7 @@ impl ResourceProviderService {
allocated_base_slices += node_allocated_slices;
}
FarmerStatistics {
ResourceProviderStatistics {
total_nodes,
online_nodes,
total_capacity,
@@ -1077,7 +1077,7 @@ impl ResourceProviderService {
// Initialize resource_provider settings if needed
if persistent_data.resource_provider_settings.is_none() {
persistent_data.resource_provider_settings = Some(crate::models::user::FarmerSettings {
persistent_data.resource_provider_settings = Some(crate::models::user::ResourceProviderSettings {
auto_accept_reserved_slices: true,
maintenance_window: "02:00-04:00 UTC".to_string(),
notification_email: None,
@@ -2986,7 +2986,7 @@ pub struct DefaultSliceFormat {
/// ResourceProvider statistics summary
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FarmerStatistics {
pub struct ResourceProviderStatistics {
pub total_nodes: i32,
pub online_nodes: i32,
pub total_capacity: NodeCapacity,

View File

@@ -49,7 +49,7 @@ pub struct UserPersistentData {
// ResourceProvider-specific data
pub nodes: Vec<crate::models::user::FarmNode>,
pub resource_provider_earnings: Vec<crate::models::user::EarningsRecord>,
pub resource_provider_settings: Option<crate::models::user::FarmerSettings>,
pub resource_provider_settings: Option<crate::models::user::ResourceProviderSettings>,
#[serde(default)]
pub slice_products: Vec<crate::models::product::Product>,
// User activity tracking
@@ -63,7 +63,7 @@ pub struct UserPersistentData {
#[serde(default)]
pub active_product_rentals: Vec<ProductRental>,
#[serde(default)]
pub resource_provider_rental_earnings: Vec<crate::models::user::FarmerRentalEarning>,
pub resource_provider_rental_earnings: Vec<crate::models::user::ResourceProviderRentalEarning>,
#[serde(default)]
pub node_rentals: Vec<crate::models::user::NodeRental>,
// Node groups for resource_provider organization
@@ -1316,7 +1316,7 @@ impl UserPersistence {
}
/// Get resource_provider settings for a user
pub fn get_resource_provider_settings(user_email: &str) -> Option<crate::models::user::FarmerSettings> {
pub fn get_resource_provider_settings(user_email: &str) -> Option<crate::models::user::ResourceProviderSettings> {
if let Some(data) = Self::load_user_data(user_email) {
data.resource_provider_settings
} else {

View File

@@ -9,7 +9,7 @@ if (window.resourceProviderDashboardInitialized) {
console.log('🚜 ResourceProvider Dashboard JavaScript loaded - Automatic Slice System');
// Initialize dashboard
initializeFarmerDashboard();
initializeResourceProviderDashboard();
initializeAutomaticSliceManagement(); // NEW: Initialize automatic slice management
initializeNodeManagement();
initializeStakingManagement();
@@ -1175,11 +1175,11 @@ function createSimpleIndividualPricingForms() {
/**
* Initialize resource_provider dashboard functionality
*/
function initializeFarmerDashboard() {
function initializeResourceProviderDashboard() {
console.log('🚜 Initializing resource_provider dashboard');
// Load resource_provider data
loadFarmerData();
loadResourceProviderData();
// Load slice templates
loadSliceTemplates();
@@ -1188,7 +1188,7 @@ function initializeFarmerDashboard() {
loadNodeGroups();
// Set up periodic data refresh
setInterval(loadFarmerData, 30000); // Refresh every 30 seconds
setInterval(loadResourceProviderData, 30000); // Refresh every 30 seconds
setInterval(loadSliceTemplates, 60000); // Refresh slice templates every minute
setInterval(loadNodeGroups, 60000); // Refresh node groups every minute
}
@@ -2913,7 +2913,7 @@ function resetSliceConfigurationForm() {
/**
* Load resource_provider data from API
*/
async function loadFarmerData() {
async function loadResourceProviderData() {
try {
const data = await window.apiJson('/api/dashboard/resource_provider-data');
console.log('🚜 Loaded resource_provider data:', data);
@@ -3968,7 +3968,7 @@ async function addGridNodes() {
// Reload resource_provider data and node groups with small delay for backend processing
setTimeout(async () => {
await loadFarmerData();
await loadResourceProviderData();
await loadNodeGroups(); // FARMER FIX: Refresh node groups table after adding new nodes
await loadWalletBalance(); // Refresh wallet balance after staking
await updateStakingDisplay(); // Refresh staking statistics after staking
@@ -4157,7 +4157,7 @@ async function confirmNodeDeletion() {
// Reload resource_provider data and node groups with small delay for backend processing
setTimeout(() => {
loadFarmerData();
loadResourceProviderData();
loadNodeGroups(); // FARMER FIX: Refresh node groups table after node deletion
}, 100);
@@ -4927,7 +4927,7 @@ async function saveNodeConfiguration() {
// Reload resource_provider data and node groups with small delay for backend processing
setTimeout(async () => {
await loadFarmerData();
await loadResourceProviderData();
await loadNodeGroups(); // FARMER FIX: Refresh node groups table after node configuration changes
await loadWalletBalance(); // Refresh wallet balance after staking changes
await updateStakingDisplay(); // Refresh staking statistics after staking changes
@@ -6587,7 +6587,7 @@ async function deleteCustomNodeGroup(groupId) {
console.log('📦 Custom group deleted:', result);
showNotification('Custom node group deleted successfully', 'success');
modal.hide();
setTimeout(() => { loadNodeGroups(); try { loadExistingGroups(); } catch (_) {} loadFarmerData(); }, 100);
setTimeout(() => { loadNodeGroups(); try { loadExistingGroups(); } catch (_) {} loadResourceProviderData(); }, 100);
} catch (error) {
console.error('📦 Error deleting custom group:', error);
showNotification('Failed to delete custom group', 'error');
@@ -6727,7 +6727,7 @@ async function assignNodeToGroup(nodeId, groupId) {
// FARMER FIX: Add small delay to ensure backend processing is complete
setTimeout(() => {
loadFarmerData(); // Reload to show updated assignments
loadResourceProviderData(); // Reload to show updated assignments
loadNodeGroups(); // Reload to update group statistics
}, 100);
@@ -7658,7 +7658,7 @@ async function stakeOnNode(nodeId, modal) {
modal.hide();
// Refresh resource_provider data to show updated staking
await loadFarmerData();
await loadResourceProviderData();
// Update wallet balance display
await loadWalletBalance();
@@ -7713,7 +7713,7 @@ async function unstakeFromNode(nodeId) {
showNotification(`Successfully unstaked ${returnedAmount} TFP from node`, 'success');
// Refresh resource_provider data to show updated staking
await loadFarmerData();
await loadResourceProviderData();
// Update wallet balance display
await loadWalletBalance();
@@ -7848,7 +7848,7 @@ async function updateNodeStaking(nodeId, modal) {
modal.hide();
// Refresh resource_provider data to show updated staking
await loadFarmerData();
await loadResourceProviderData();
// Update wallet balance display
await loadWalletBalance();