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/slice-configuration/{id}", web::put().to(DashboardController::update_slice_configuration))
.route("/dashboard/service-provider-data", web::get().to(DashboardController::service_provider_data_api)) .route("/dashboard/service-provider-data", web::get().to(DashboardController::service_provider_data_api))
// Resource provider management API routes // Resource provider management API routes
.route("/dashboard/resource_provider-nodes", web::post().to(DashboardController::add_resource_provider_node)) .route("/dashboard/resource_provider-nodes", web::post().to(DashboardController::add_farm_node))
.route("/dashboard/resource_provider-nodes-enhanced", web::post().to(DashboardController::add_resource_provider_node_enhanced)) .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::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}", web::put().to(DashboardController::update_node_comprehensive))
.route("/dashboard/resource_provider-nodes/{id}/status", web::put().to(DashboardController::update_node_status)) .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 /// 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 nodes = self.get_resource_provider_nodes(user_email);
let earnings = self.get_resource_provider_earnings(user_email); let earnings = self.get_resource_provider_earnings(user_email);
@@ -962,7 +962,7 @@ impl ResourceProviderService {
allocated_base_slices += node_allocated_slices; allocated_base_slices += node_allocated_slices;
} }
FarmerStatistics { ResourceProviderStatistics {
total_nodes, total_nodes,
online_nodes, online_nodes,
total_capacity, total_capacity,
@@ -1077,7 +1077,7 @@ impl ResourceProviderService {
// Initialize resource_provider settings if needed // Initialize resource_provider settings if needed
if persistent_data.resource_provider_settings.is_none() { 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, auto_accept_reserved_slices: true,
maintenance_window: "02:00-04:00 UTC".to_string(), maintenance_window: "02:00-04:00 UTC".to_string(),
notification_email: None, notification_email: None,
@@ -2986,7 +2986,7 @@ pub struct DefaultSliceFormat {
/// ResourceProvider statistics summary /// ResourceProvider statistics summary
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FarmerStatistics { pub struct ResourceProviderStatistics {
pub total_nodes: i32, pub total_nodes: i32,
pub online_nodes: i32, pub online_nodes: i32,
pub total_capacity: NodeCapacity, pub total_capacity: NodeCapacity,

View File

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

View File

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