Custom Flight Analytics Dashboard with Dark UI, Rare Flights Filter, and Quick Jump Controls

Hi everyone,

I wanted to share a custom dashboard I’ve been building for my flight tracking setup called “SHIRAKAMI Flight Analytics”. It connects to my receiver database to visualize flight stats with a clean, dark-themed UI.

Here are a few features I recently added:

  • Timeframe Tabs: Easily switch between Today, Current Month, Current Year, and All-Time rankings.

  • :sparkles: Rare (1-time) Tab: Instantly filter and highlight aircraft that have only been spotted once (great for catching rare visitors!).

  • Smooth Jump Controls: Added “Jump to Top (Max)” and “Jump to Bottom (Min)” buttons so it’s super easy to quickly check top and bottom records in long lists.

Here is a quick look at the interface:

Let me know what you think or if you have any feature ideas! Always happy to talk flight tracking.

Cheers, SHIRAKAMI JP7DVX

1 Like

Optimized the layout into a sleek, compact widget style. Fits right on the desktop and looks super clean!

1 Like

Excellent :+1: :+1: :+1:

1 Like

Small update: Switched to HEX-only tracking! Since the same aircraft can change callsigns or fly ferry/training flights throughout the day, filtering by HEX ID gives an accurate, noise-free flight count.

1 Like

SHIRAKAMI Flight Analytics Update! :airplane::bar_chart:

Refined the desktop widget layout to track aircraft more accurately.

What’s new:

  • HEX-Centric Tracking: Switched to unique HEX ID counts to prevent duplication noise from callsign changes or ferry/training flights.

  • Callsign History Line: Added a clean sequence of all callsigns used by the aircraft during the day right under the HEX badge (maxing out around 4 flights/day here in Aomori/Hirosaki!).

Fits right on the desktop and looks super clean. Let me know what you think!

1 Like

SHIRAKAMI Analytics Update: HEX-Centric Tracking with RARE Callsign Insights! :airplane::sparkles:

Hi everyone! Following up on my lightweight 280px desktop dashboard for tracking flights around the Aomori/Hirosaki region, I’ve just polished up the UI.

Latest Updates:

  • HEX-Centric Core: Accurate flight counts per aircraft, completely avoiding callsign-reuse noise.

  • Smart Callsign Display: Enabled for both TODAY (active flight sequences) and RARE (one-time visitors) tabs, letting you instantly see what callsign a rare aircraft used!

  • Clean Long-Term Views: Monthly, Yearly, and All-Time tabs focus purely on HEX IDs and counts to keep the slim 280px layout ultra-readable.

Screenshot attached! Let me know what you think of this setup! :backhand_index_pointing_down:

1 Like

Minor update! :rocket:

Added a ‘YESTERDAY’ tab right next to TODAY to easily check the previous day’s traffic, and fine-tuned the callsign display width to 250px so that longer sequences (up to 7 flights) fit neatly without truncation.

Screenshot attached! Let me know what you think.

1 Like

Sharing the script! :hammer_and_wrench::airplane:

Many of you asked about the setup, so I’m sharing the Python script (mini_ranking.py) that powers the SHIRAKAMI dashboard.

import os
import sqlite3
from datetime import datetime, timedelta
import webbrowser

ESPRIMO_HOST = "192.168.0.58"
ESPRIMO_USER = "yukio"
REMOTE_DB_PATH = "~/flight_traffic.db"
LOCAL_DB_FILE = "flight_traffic.db"
HTML_FILE = "flight_ranking.html"

def fetch_db_from_esprimo():
    cmd = f"scp -q {ESPRIMO_USER}@{ESPRIMO_HOST}:{REMOTE_DB_PATH} {LOCAL_DB_FILE}"
    return os.system(cmd) == 0

def get_ranking_data(cursor, date_filter_sql, having_sql="", include_callsigns=False):
    if include_callsigns:
        query = f"""
            SELECT 
                hex, 
                COUNT(*) as flight_count,
                GROUP_CONCAT(DISTINCT flight) as callsigns
            FROM flights
            WHERE {date_filter_sql}
            GROUP BY hex
            {having_sql}
            ORDER BY flight_count DESC;
        """
    else:
        query = f"""
            SELECT 
                hex, 
                COUNT(*) as flight_count,
                NULL as callsigns
            FROM flights
            WHERE {date_filter_sql}
            GROUP BY hex
            {having_sql}
            ORDER BY flight_count DESC;
        """
    return list(cursor.execute(query))

def generate_html(today_data, yesterday_data, month_data, year_data, total_data, rare_data, update_time, month_name, year_str):
    def render_rows(rows, show_callsigns=False):
        if not rows:
            return '<tr><td colspan="3" class="no-data">(No data available)</td></tr>'
        html = ""
        for i, row in enumerate(rows, 1):
            hex_id, count, callsigns = row
            
            if show_callsigns:
                cs_list = [cs.strip() for cs in (callsigns or "").split(",") if cs.strip() and cs.strip() != "N/A"]
                cs_display = " / ".join(cs_list) if cs_list else "<i>N/A</i>"
                html += f"""
                <tr>
                    <td class="rank-num">#{i}</td>
                    <td>
                        <div class="hex-row">
                            <span class="hex-badge">{hex_id}</span>
                        </div>
                        <div class="callsign-history" title="{cs_display}">✈️ {cs_display}</div>
                    </td>
                    <td class="text-right"><span class="count-badge">{count}</span></td>
                </tr>
                """
            else:
                html += f"""
                <tr>
                    <td class="rank-num">#{i}</td>
                    <td>
                        <div class="hex-row">
                            <span class="hex-badge">{hex_id}</span>
                        </div>
                    </td>
                    <td class="text-right"><span class="count-badge">{count}</span></td>
                </tr>
                """
        return html

    html_content = f"""<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SHIRAKAMI Flight Analytics</title>
    <style>
        body {{
            background-color: #0f172a;
            color: #e2e8f0;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            margin: 0;
            padding: 8px;
        }}
        .container {{
            max-width: 400px;
            margin: 0 auto;
        }}
        header {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #334155;
            padding-bottom: 6px;
            margin-bottom: 8px;
        }}
        h1 {{
            margin: 0;
            font-size: 13px;
            color: #38bdf8;
            letter-spacing: 0.3px;
        }}
        .timestamp {{
            font-size: 8px;
            color: #94a3b8;
        }}
        /* タブメニュー */
        .tabs {{
            display: flex;
            gap: 2px;
            margin-bottom: 8px;
            flex-wrap: nowrap;
            overflow-x: auto;
            padding-bottom: 2px;
        }}
        .tab-btn {{
            background-color: #1e293b;
            color: #94a3b8;
            border: 1px solid #334155;
            padding: 4px 5px;
            border-radius: 4px;
            font-size: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
            white-space: nowrap;
        }}
        .tab-btn:hover {{
            background-color: #334155;
            color: #f8fafc;
        }}
        .tab-btn.active {{
            background-color: #0284c7;
            color: #ffffff;
            border-color: #38bdf8;
            box-shadow: 0 2px 6px rgba(56, 189, 248, 0.2);
        }}
        .tab-btn.rare-tab.active {{
            background-color: #7c3aed;
            border-color: #a855f7;
            box-shadow: 0 2px 6px rgba(168, 85, 247, 0.3);
        }}
        /* パネル */
        .panel {{
            display: none;
            background-color: #1e293b;
            border: 1px solid #334155;
            border-radius: 6px;
            padding: 8px 10px;
            box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
        }}
        .panel.active {{
            display: block;
        }}
        .scroll-control-bar {{
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 6px;
        }}
        .scroll-control-bar.bottom {{
            margin-bottom: 0;
            margin-top: 6px;
        }}
        .jump-btn {{
            background-color: #334155;
            color: #cbd5e1;
            border: 1px solid #475569;
            padding: 2px 5px;
            border-radius: 3px;
            font-size: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }}
        .jump-btn:hover {{
            background-color: #0284c7;
            color: #ffffff;
            border-color: #38bdf8;
        }}
        .panel-info {{
            font-size: 8px;
            color: #64748b;
        }}
        .table-scroll {{
            max-height: 320px;
            overflow-y: auto;
            padding-right: 2px;
        }}
        .table-scroll::-webkit-scrollbar {{
            width: 3px;
        }}
        .table-scroll::-webkit-scrollbar-track {{
            background: #1e293b;
        }}
        .table-scroll::-webkit-scrollbar-thumb {{
            background: #475569;
            border-radius: 2px;
        }}
        table {{
            width: 100%;
            border-collapse: collapse;
            font-size: 11px;
        }}
        th, td {{
            padding: 5px 4px;
            text-align: left;
            border-bottom: 1px solid #334155;
            vertical-align: middle;
        }}
        th {{
            color: #94a3b8;
            font-weight: 600;
            font-size: 8px;
            text-transform: uppercase;
            letter-spacing: 0.3px;
            background-color: #1e293b;
            position: sticky;
            top: 0;
            z-index: 10;
        }}
        .rank-num {{
            font-weight: bold;
            color: #38bdf8;
            width: 24px;
        }}
        .hex-row {{
            display: flex;
            align-items: center;
            gap: 6px;
        }}
        .hex-badge {{
            background-color: #334155;
            padding: 1px 5px;
            border-radius: 3px;
            font-family: monospace;
            font-size: 9px;
            font-weight: bold;
            color: #f1f5f9;
        }}
        .callsign-history {{
            font-size: 8px;
            color: #38bdf8;
            margin-top: 3px;
            font-family: monospace;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 300px;
        }}
        .count-badge {{
            color: #4ade80;
            font-weight: bold;
            font-size: 12px;
        }}
        .text-right {{
            text-align: right;
        }}
        .no-data {{
            text-align: center;
            color: #64748b;
            padding: 10px;
        }}
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>✈️ SHIRAKAMI Analytics</h1>
            <div class="timestamp">{update_time}</div>
        </header>
        
        <!-- タブ -->
        <div class="tabs">
            <button class="tab-btn active" onclick="switchTab(event, 'today')">Today</button>
            <button class="tab-btn" onclick="switchTab(event, 'yesterday')">Yesterday</button>
            <button class="tab-btn" onclick="switchTab(event, 'month')">{month_name}</button>
            <button class="tab-btn" onclick="switchTab(event, 'year')">{year_str}</button>
            <button class="tab-btn" onclick="switchTab(event, 'total')">All</button>
            <button class="tab-btn rare-tab" onclick="switchTab(event, 'rare')">✨ Rare</button>
        </div>
        
        <!-- Today -->
        <div id="today" class="panel active">
            <div class="scroll-control-bar">
                <span class="panel-info">📊 Today</span>
                <button class="jump-btn" onclick="jumpTo('today-scroll', 'bottom')">⬇️ Bottom</button>
            </div>
            <div id="today-scroll" class="table-scroll">
                <table>
                    <tr><th>#</th><th>HEX & Callsigns</th><th class="text-right">Flights</th></tr>
                    {render_rows(today_data, show_callsigns=True)}
                </table>
            </div>
            <div class="scroll-control-bar bottom">
                <button class="jump-btn" onclick="jumpTo('today-scroll', 'top')">⬆️ Top</button>
                <span class="panel-info">End</span>
            </div>
        </div>
        
        <!-- Yesterday -->
        <div id="yesterday" class="panel">
            <div class="scroll-control-bar">
                <span class="panel-info">📊 Yesterday</span>
                <button class="jump-btn" onclick="jumpTo('yesterday-scroll', 'bottom')">⬇️ Bottom</button>
            </div>
            <div id="yesterday-scroll" class="table-scroll">
                <table>
                    <tr><th>#</th><th>HEX & Callsigns</th><th class="text-right">Flights</th></tr>
                    {render_rows(yesterday_data, show_callsigns=True)}
                </table>
            </div>
            <div class="scroll-control-bar bottom">
                <button class="jump-btn" onclick="jumpTo('yesterday-scroll', 'top')">⬆️ Top</button>
                <span class="panel-info">End</span>
            </div>
        </div>
        
        <!-- Month -->
        <div id="month" class="panel">
            <div class="scroll-control-bar">
                <span class="panel-info">📊 {month_name}</span>
                <button class="jump-btn" onclick="jumpTo('month-scroll', 'bottom')">⬇️ Bottom</button>
            </div>
            <div id="month-scroll" class="table-scroll">
                <table>
                    <tr><th>#</th><th>HEX ID</th><th class="text-right">Flights</th></tr>
                    {render_rows(month_data, show_callsigns=False)}
                </table>
            </div>
            <div class="scroll-control-bar bottom">
                <button class="jump-btn" onclick="jumpTo('month-scroll', 'top')">⬆️ Top</button>
                <span class="panel-info">End</span>
            </div>
        </div>
        
        <!-- Year -->
        <div id="year" class="panel">
            <div class="scroll-control-bar">
                <span class="panel-info">📊 {year_str}</span>
                <button class="jump-btn" onclick="jumpTo('year-scroll', 'bottom')">⬇️ Bottom</button>
            </div>
            <div id="year-scroll" class="table-scroll">
                <table>
                    <tr><th>#</th><th>HEX ID</th><th class="text-right">Flights</th></tr>
                    {render_rows(year_data, show_callsigns=False)}
                </table>
            </div>
            <div class="scroll-control-bar bottom">
                <button class="jump-btn" onclick="jumpTo('year-scroll', 'top')">⬆️ Top</button>
                <span class="panel-info">End</span>
            </div>
        </div>
        
        <!-- Total -->
        <div id="total" class="panel">
            <div class="scroll-control-bar">
                <span class="panel-info">📊 All-Time</span>
                <button class="jump-btn" onclick="jumpTo('total-scroll', 'bottom')">⬇️ Bottom</button>
            </div>
            <div id="total-scroll" class="table-scroll">
                <table>
                    <tr><th>#</th><th>HEX ID</th><th class="text-right">Flights</th></tr>
                    {render_rows(total_data, show_callsigns=False)}
                </table>
            </div>
            <div class="scroll-control-bar bottom">
                <button class="jump-btn" onclick="jumpTo('total-scroll', 'top')">⬆️ Top</button>
                <span class="panel-info">End</span>
            </div>
        </div>

        <!-- Rare -->
        <div id="rare" class="panel">
            <div class="scroll-control-bar">
                <span class="panel-info">✨ Rare</span>
                <button class="jump-btn" onclick="jumpTo('rare-scroll', 'bottom')">⬇️ Bottom</button>
            </div>
            <div id="rare-scroll" class="table-scroll">
                <table>
                    <tr><th>#</th><th>HEX & Callsigns</th><th class="text-right">Flights</th></tr>
                    {render_rows(rare_data, show_callsigns=True)}
                </table>
            </div>
            <div class="scroll-control-bar bottom">
                <button class="jump-btn" onclick="jumpTo('rare-scroll', 'top')">⬆️ Top</button>
                <span class="panel-info">End</span>
            </div>
        </div>
    </div>

    <script>
        function switchTab(evt, tabName) {{
            const panels = document.getElementsByClassName("panel");
            for (let p of panels) {{
                p.classList.remove("active");
            }}
            const buttons = document.getElementsByClassName("tab-btn");
            for (let b of buttons) {{
                b.classList.remove("active");
            }}
            document.getElementById(tabName).classList.add("active");
            evt.currentTarget.classList.add("active");
        }}

        function jumpTo(elementId, position) {{
            const elem = document.getElementById(elementId);
            if (position === 'top') {{
                elem.scrollTo({{ top: 0, behavior: 'smooth' }});
            }} else {{
                elem.scrollTo({{ top: elem.scrollHeight, behavior: 'smooth' }});
            }}
        }}
    </script>
</body>
</html>
"""
    with open(HTML_FILE, "w", encoding="utf-8") as f:
        f.write(html_content)

def main():
    if not fetch_db_from_esprimo():
        print("❌ Failed to fetch database from ESPRIMO.")
        return
        
    conn = sqlite3.connect(LOCAL_DB_FILE)
    cursor = conn.cursor()
    
    now = datetime.now()
    today_str = now.strftime("%Y-%m-%d")
    yesterday_str = (now - timedelta(days=1)).strftime("%Y-%m-%d")
    month_str = now.strftime("%Y-%m")
    year_str = now.strftime("%Y")
    month_name = now.strftime("%b").upper()
    
    today_data = get_ranking_data(cursor, f"first_seen LIKE '{today_str}%'", include_callsigns=True)
    yesterday_data = get_ranking_data(cursor, f"first_seen LIKE '{yesterday_str}%'", include_callsigns=True)
    month_data = get_ranking_data(cursor, f"first_seen LIKE '{month_str}%'", include_callsigns=False)
    year_data = get_ranking_data(cursor, f"first_seen LIKE '{year_str}%'", include_callsigns=False)
    total_data = get_ranking_data(cursor, "1=1", include_callsigns=False)
    rare_data = get_ranking_data(cursor, "1=1", "HAVING flight_count = 1", include_callsigns=True)
    
    conn.close()
    
    generate_html(today_data, yesterday_data, month_data, year_data, total_data, rare_data, now.strftime('%Y-%m-%d %H:%M:%S'), month_name, year_str)
    
    html_path = os.path.abspath(HTML_FILE)
    webbrowser.open(f"file://{html_path}")

if __name__ == "__main__":
    main()