Really-amin's picture
Upload 325 files
b66240d verified
/**
* ═══════════════════════════════════════════════════════════════════
* CONFIGURATION FILE
* Dashboard Settings - Easy Customization
* ═══════════════════════════════════════════════════════════════════
*/
// πŸ”§ Main Backend Settings
window.DASHBOARD_CONFIG = {
// ═══════════════════════════════════════════════════════════════
// API and WebSocket URLs
// ═══════════════════════════════════════════════════════════════
// Auto-detect localhost and use port 7860, otherwise use current origin
BACKEND_URL: (() => {
const hostname = window.location.hostname;
if (hostname === 'localhost' || hostname === '127.0.0.1') {
return `http://${hostname}:7860`;
}
return window.location.origin || 'https://really-amin-datasourceforcryptocurrency.hf.space';
})(),
WS_URL: (() => {
const hostname = window.location.hostname;
let backendUrl;
if (hostname === 'localhost' || hostname === '127.0.0.1') {
backendUrl = `http://${hostname}:7860`;
} else {
backendUrl = window.location.origin || 'https://really-amin-datasourceforcryptocurrency.hf.space';
}
return backendUrl.replace('http://', 'ws://').replace('https://', 'wss://') + '/ws';
})(),
// ⏱️ Update Timing (milliseconds)
UPDATE_INTERVAL: 30000, // Every 30 seconds
CACHE_TTL: 60000, // 1 minute
HEARTBEAT_INTERVAL: 30000, // 30 seconds
// πŸ”„ Reconnection Settings
MAX_RECONNECT_ATTEMPTS: 5,
RECONNECT_DELAY: 3000, // 3 seconds
// ═══════════════════════════════════════════════════════════════
// Display Settings
// ═══════════════════════════════════════════════════════════════
// Number of items to display
MAX_COINS_DISPLAY: 20, // Number of coins in table
MAX_NEWS_DISPLAY: 20, // Number of news items
MAX_TRENDING_DISPLAY: 10, // Number of trending items
// Table settings
TABLE_ROWS_PER_PAGE: 10,
// ═══════════════════════════════════════════════════════════════
// Chart Settings
// ═══════════════════════════════════════════════════════════════
CHART: {
DEFAULT_SYMBOL: 'BTCUSDT',
DEFAULT_INTERVAL: '1h',
AVAILABLE_INTERVALS: ['1m', '5m', '15m', '1h', '4h', '1d'],
THEME: 'dark',
},
// ═══════════════════════════════════════════════════════════════
// AI Settings
// ═══════════════════════════════════════════════════════════════
AI: {
ENABLE_SENTIMENT: true,
ENABLE_NEWS_SUMMARY: true,
ENABLE_PRICE_PREDICTION: false, // Currently disabled
ENABLE_PATTERN_DETECTION: false, // Currently disabled
},
// ═══════════════════════════════════════════════════════════════
// Notification Settings
// ═══════════════════════════════════════════════════════════════
NOTIFICATIONS: {
ENABLE: true,
SHOW_PRICE_ALERTS: true,
SHOW_NEWS_ALERTS: true,
AUTO_DISMISS_TIME: 5000, // 5 seconds
},
// ═══════════════════════════════════════════════════════════════
// UI Settings
// ═══════════════════════════════════════════════════════════════
UI: {
DEFAULT_THEME: 'dark', // 'dark' or 'light'
ENABLE_ANIMATIONS: true,
ENABLE_SOUNDS: false,
LANGUAGE: 'en', // 'en' or 'fa'
RTL: false,
},
// ═══════════════════════════════════════════════════════════════
// Debug Settings
// ═══════════════════════════════════════════════════════════════
DEBUG: {
ENABLE_CONSOLE_LOGS: true,
ENABLE_PERFORMANCE_MONITORING: true,
SHOW_API_REQUESTS: true,
SHOW_WS_MESSAGES: false,
},
// ═══════════════════════════════════════════════════════════════
// Default Filters and Sorting
// ═══════════════════════════════════════════════════════════════
FILTERS: {
DEFAULT_MARKET_FILTER: 'all', // 'all', 'gainers', 'losers', 'trending'
DEFAULT_NEWS_FILTER: 'all', // 'all', 'bitcoin', 'ethereum', 'defi', 'nft'
DEFAULT_SORT: 'market_cap', // 'market_cap', 'volume', 'price', 'change'
SORT_ORDER: 'desc', // 'asc' or 'desc'
},
// ═══════════════════════════════════════════════════════════════
// HuggingFace Configuration
// ═══════════════════════════════════════════════════════════════
HF_TOKEN: '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',
HF_API_BASE: 'https://api-inference.huggingface.co/models',
// ═══════════════════════════════════════════════════════════════
// API Endpoints (Optional - if your backend differs)
// ═══════════════════════════════════════════════════════════════
ENDPOINTS: {
HEALTH: '/api/health',
MARKET: '/api/market/stats',
MARKET_PRICES: '/api/market/prices',
COINS_TOP: '/api/coins/top',
COIN_DETAILS: '/api/coins',
TRENDING: '/api/trending',
SENTIMENT: '/api/sentiment',
SENTIMENT_ANALYZE: '/api/sentiment/analyze',
NEWS: '/api/news/latest',
NEWS_SUMMARIZE: '/api/news/summarize',
STATS: '/api/stats',
PROVIDERS: '/api/providers',
PROVIDER_STATUS: '/api/providers/status',
CHART_HISTORY: '/api/charts/price',
CHART_ANALYZE: '/api/charts/analyze',
OHLCV: '/api/ohlcv',
QUERY: '/api/query',
DATASETS: '/api/datasets/list',
MODELS: '/api/models/list',
HF_HEALTH: '/api/hf/health',
HF_REGISTRY: '/api/hf/registry',
SYSTEM_STATUS: '/api/system/status',
SYSTEM_CONFIG: '/api/system/config',
CATEGORIES: '/api/categories',
RATE_LIMITS: '/api/rate-limits',
LOGS: '/api/logs',
ALERTS: '/api/alerts',
},
// ═══════════════════════════════════════════════════════════════
// WebSocket Events
// ═══════════════════════════════════════════════════════════════
WS_EVENTS: {
MARKET_UPDATE: 'market_update',
SENTIMENT_UPDATE: 'sentiment_update',
NEWS_UPDATE: 'news_update',
STATS_UPDATE: 'stats_update',
PRICE_UPDATE: 'price_update',
API_UPDATE: 'api_update',
STATUS_UPDATE: 'status_update',
SCHEDULE_UPDATE: 'schedule_update',
CONNECTED: 'connected',
DISCONNECTED: 'disconnected',
},
// ═══════════════════════════════════════════════════════════════
// Display Formats
// ═══════════════════════════════════════════════════════════════
FORMATS: {
CURRENCY: {
LOCALE: 'en-US',
STYLE: 'currency',
CURRENCY: 'USD',
},
DATE: {
LOCALE: 'en-US',
OPTIONS: {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
},
},
},
// ═══════════════════════════════════════════════════════════════
// Rate Limiting
// ═══════════════════════════════════════════════════════════════
RATE_LIMITS: {
API_REQUESTS_PER_MINUTE: 60,
SEARCH_DEBOUNCE_MS: 300,
},
// ═══════════════════════════════════════════════════════════════
// Storage Settings
// ═══════════════════════════════════════════════════════════════
STORAGE: {
USE_LOCAL_STORAGE: true,
SAVE_PREFERENCES: true,
STORAGE_PREFIX: 'hts_dashboard_',
},
};
// ═══════════════════════════════════════════════════════════════════
// Predefined Profiles
// ═══════════════════════════════════════════════════════════════════
window.DASHBOARD_PROFILES = {
// High Performance Profile
HIGH_PERFORMANCE: {
UPDATE_INTERVAL: 15000, // Faster updates
CACHE_TTL: 30000, // Shorter cache
ENABLE_ANIMATIONS: false, // No animations
MAX_COINS_DISPLAY: 50,
},
// Data Saver Profile
DATA_SAVER: {
UPDATE_INTERVAL: 60000, // Less frequent updates
CACHE_TTL: 300000, // Longer cache (5 minutes)
MAX_COINS_DISPLAY: 10,
MAX_NEWS_DISPLAY: 10,
},
// Presentation Profile
PRESENTATION: {
ENABLE_ANIMATIONS: true,
UPDATE_INTERVAL: 20000,
SHOW_API_REQUESTS: false,
ENABLE_CONSOLE_LOGS: false,
},
// Development Profile
DEVELOPMENT: {
DEBUG: {
ENABLE_CONSOLE_LOGS: true,
ENABLE_PERFORMANCE_MONITORING: true,
SHOW_API_REQUESTS: true,
SHOW_WS_MESSAGES: true,
},
UPDATE_INTERVAL: 10000,
},
};
// ═══════════════════════════════════════════════════════════════════
// Helper Function to Change Profile
// ═══════════════════════════════════════════════════════════════════
window.applyDashboardProfile = function (profileName) {
if (window.DASHBOARD_PROFILES[profileName]) {
const profile = window.DASHBOARD_PROFILES[profileName];
Object.assign(window.DASHBOARD_CONFIG, profile);
console.log(`βœ… Profile "${profileName}" applied`);
// Reload application with new settings
if (window.app) {
window.app.destroy();
window.app = new DashboardApp();
window.app.init();
}
} else {
console.error(`❌ Profile "${profileName}" not found`);
}
};
// ═══════════════════════════════════════════════════════════════════
// Helper Function to Change Backend URL
// ═══════════════════════════════════════════════════════════════════
window.changeBackendURL = function (httpUrl, wsUrl) {
window.DASHBOARD_CONFIG.BACKEND_URL = httpUrl;
window.DASHBOARD_CONFIG.WS_URL = wsUrl || httpUrl.replace('https://', 'wss://').replace('http://', 'ws://') + '/ws';
console.log('βœ… Backend URL changed:');
console.log(' HTTP:', window.DASHBOARD_CONFIG.BACKEND_URL);
console.log(' WS:', window.DASHBOARD_CONFIG.WS_URL);
// Reload application
if (window.app) {
window.app.destroy();
window.app = new DashboardApp();
window.app.init();
}
};
// ═══════════════════════════════════════════════════════════════════
// Save Settings to LocalStorage
// ═══════════════════════════════════════════════════════════════════
window.saveConfig = function () {
if (window.DASHBOARD_CONFIG.STORAGE.USE_LOCAL_STORAGE) {
try {
const configString = JSON.stringify(window.DASHBOARD_CONFIG);
localStorage.setItem(
window.DASHBOARD_CONFIG.STORAGE.STORAGE_PREFIX + 'config',
configString
);
console.log('βœ… Settings saved');
} catch (error) {
console.error('❌ Error saving settings:', error);
}
}
};
// ═══════════════════════════════════════════════════════════════════
// Load Settings from LocalStorage
// ═══════════════════════════════════════════════════════════════════
window.loadConfig = function () {
if (window.DASHBOARD_CONFIG.STORAGE.USE_LOCAL_STORAGE) {
try {
const configString = localStorage.getItem(
window.DASHBOARD_CONFIG.STORAGE.STORAGE_PREFIX + 'config'
);
if (configString) {
const savedConfig = JSON.parse(configString);
Object.assign(window.DASHBOARD_CONFIG, savedConfig);
console.log('βœ… Settings loaded');
}
} catch (error) {
console.error('❌ Error loading settings:', error);
}
}
};
// ═══════════════════════════════════════════════════════════════════
// Auto-load Settings on Page Load
// ═══════════════════════════════════════════════════════════════════
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
window.loadConfig();
});
} else {
window.loadConfig();
}
// ═══════════════════════════════════════════════════════════════════
// Console Usage Guide
// ═══════════════════════════════════════════════════════════════════
console.log(`
╔═══════════════════════════════════════════════════════════════╗
β•‘ HTS CRYPTO DASHBOARD - CONFIGURATION β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
πŸ“‹ Available Commands:
1. Change Profile:
applyDashboardProfile('HIGH_PERFORMANCE')
applyDashboardProfile('DATA_SAVER')
applyDashboardProfile('PRESENTATION')
applyDashboardProfile('DEVELOPMENT')
2. Change Backend:
changeBackendURL('https://your-backend.com')
3. Save/Load Settings:
saveConfig()
loadConfig()
4. View Current Settings:
console.log(DASHBOARD_CONFIG)
5. Manual Settings Change:
DASHBOARD_CONFIG.UPDATE_INTERVAL = 20000
saveConfig()
═══════════════════════════════════════════════════════════════════
`);