Skip to content

pffs1802/rustchain-live-widget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š RustChain Network Dashboard Widget

An embeddable, real-time dashboard widget that displays live RustChain network statistics.

✨ Features

  • βœ… Zero Dependencies - Pure vanilla JavaScript, no frameworks
  • πŸ“Š Live Data - Fetches from RustChain API endpoints
  • 🎨 Dark Theme - Beautiful gradient design that matches modern sites
  • πŸ“± Mobile Responsive - Adapts to any screen size
  • πŸ”„ Auto-Refresh - Updates every 60 seconds
  • πŸ’« Animated Visualizations - Rotating logo, pulsing background, blinking miner indicators
  • πŸ”— Click-Through - Direct link to block explorer
  • ⚑ Lightweight - Single HTML file, ~12KB

πŸš€ Quick Start

Standalone Usage

Simply open rustchain-widget.html in any modern browser:

# Serve locally
python3 -m http.server 8000
# Then visit: http://localhost:8000/rustchain-widget.html

Embed via <iframe>

<iframe 
    src="https://your-domain.com/rustchain-widget.html" 
    width="420" 
    height="400" 
    frameborder="0"
    style="border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);">
</iframe>

Embed via <script> tag

<div id="rustchain-widget-container"></div>
<script>
    fetch('https://your-domain.com/rustchain-widget.html')
        .then(res => res.text())
        .then(html => {
            document.getElementById('rustchain-widget-container').innerHTML = html;
        });
</script>

πŸ“‘ API Endpoints Used

The widget fetches data from these RustChain API endpoints:

  1. Health Check - https://50.28.86.131/health

    • Network status (healthy/degraded)
  2. Epoch Info - https://50.28.86.131/epoch

    • Current epoch number
    • Total RTC distributed (if available)
  3. Active Miners - https://50.28.86.131/api/miners

    • Count of active miners
    • Miner details

πŸ“Š Displayed Metrics

Metric Source Description
Current Epoch /epoch Current epoch number
Active Miners /api/miners Number of active miners
Network Status /health Healthy / Degraded / Offline
Total RTC Distributed /epoch Cumulative RTC distributed (if available)

🎨 Customization

Change Colors

Edit the CSS variables in the <style> section:

/* Primary color (orange) */
color: #ff6b35;

/* Background gradient */
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);

/* Status colors */
.status-online { color: #4cd137; }     /* Green */
.status-degraded { color: #ffb800; }   /* Yellow */
.status-offline { color: #ff4757; }    /* Red */

Adjust Refresh Interval

Change the REFRESH_INTERVAL constant in JavaScript:

const REFRESH_INTERVAL = 30000; // 30 seconds instead of 60

Customize Widget Size

Modify the .rustchain-widget CSS:

.rustchain-widget {
    max-width: 500px;  /* Make wider */
    padding: 30px;     /* More padding */
}

πŸ”§ JavaScript API

Control the widget programmatically:

// Manual refresh
window.RustChainWidget.refresh();

// Start auto-refresh (60s interval)
window.RustChainWidget.startAutoRefresh();

// Stop auto-refresh
window.RustChainWidget.stopAutoRefresh();

🌐 CORS Handling

The RustChain API endpoints use self-signed SSL certificates and have CORS enabled.

If you encounter CORS issues when embedding:

  1. Host on the same domain as your site
  2. Use a CORS proxy (not recommended for production)
  3. Run via HTTPS (mixed content blocking)

The widget includes error handling for network failures and will retry on the next refresh cycle.

πŸ“± Mobile Responsive

The widget automatically adapts to mobile screens:

  • Smaller font sizes on <480px screens
  • Maintains readability and touch targets
  • Gracefully handles narrow viewports

β™Ώ Accessibility

  • Semantic HTML structure
  • High contrast text
  • Color is not the only indicator (icons + text for status)
  • Keyboard navigation support

🎭 Animations

The widget includes several smooth animations:

  1. Rotating Logo - 8-second rotation cycle
  2. Pulsing Background - 4-second fade in/out
  3. Blinking Miner Dots - 2-second blink cycle
  4. Hover Effects - Link underline on hover

Animations are CSS-based (no JavaScript) for performance.

πŸ“Έ Screenshots

Desktop View

Desktop Widget

Mobile View

Mobile Widget

Embedded Example

Embedded Widget

πŸ”— Links

πŸ“¦ Deployment

GitHub Pages

  1. Fork this repo
  2. Enable GitHub Pages in Settings β†’ Pages
  3. Select branch: main, folder: /rustchain-widget
  4. Your widget will be live at: https://username.github.io/repo/rustchain-widget.html

Netlify Drop

  1. Drag the rustchain-widget folder to Netlify Drop
  2. Get instant HTTPS URL

Cloudflare Pages

  1. Connect your repo
  2. Build command: (none needed)
  3. Output directory: rustchain-widget

πŸ§ͺ Browser Compatibility

Tested and working on:

  • βœ… Chrome 90+
  • βœ… Firefox 88+
  • βœ… Safari 14+
  • βœ… Edge 90+
  • βœ… Opera 76+

Requires ES6 support (async/await, fetch API).

πŸ› οΈ Technical Details

Tech Stack:

  • Pure HTML5
  • CSS3 (Grid, Flexbox, Animations)
  • Vanilla JavaScript ES6+

No Dependencies:

  • No jQuery
  • No React/Vue/Svelte
  • No build tools required
  • No package.json

Size:

  • HTML + CSS + JS: ~12KB
  • Minified: ~8KB
  • Gzipped: ~3KB

πŸ“„ License

MIT License - Free to use, modify, and distribute.

πŸ‘¨β€πŸ’» Author

Created by Pffs1802 for RustChain Bounty #178


πŸŽ‰ Bonus Features Included

βœ… Animated Miner Activity Visualization - Blinking dots when miners are active βœ… Click-Through to Block Explorer - Direct link to explorer βœ… Auto-Refresh Every 60 Seconds - Configurable interval

All bonus requirements met! 🎯


Questions or issues? Open an issue on GitHub or comment on the bounty issue.

Enjoy the widget! β›οΈβœ¨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages