File size: 1,905 Bytes
e8f0e8e
a8dd4c3
e8f0e8e
a8dd4c3
e8f0e8e
 
8514584
e8f0e8e
 
8ea7afe
e8f0e8e
 
8514584
 
a8dd4c3
 
 
 
 
 
8514584
 
e8f0e8e
 
a8dd4c3
 
e8f0e8e
 
 
 
 
 
 
 
 
 
 
 
a8dd4c3
e8f0e8e
 
a8dd4c3
e8f0e8e
8514584
e8f0e8e
8514584
e8f0e8e
8ea7afe
 
 
 
a8dd4c3
 
8514584
8ea7afe
e8f0e8e
8514584
 
e8f0e8e
86ef349
8514584
 
 
 
 
86ef349
 
 
a8dd4c3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import dash
from dash import html, dcc
import plotly.graph_objects as go
import pandas as pd
import random

# Constants
SITES = ['Hyderabad', 'Kurnool', 'Bangalore', 'Warangal']
POLES_PER_SITE = 12
ALERT_THRESHOLD = 80

def generate_data():
    data = []
    for site in SITES:
        for i in range(1, POLES_PER_SITE + 1):
            data.append({
                "Site": site,
                "Pole": f"P{i}",
                "Status": random.randint(0, 100)
            })
    return pd.DataFrame(data)

df = generate_data()

def create_heatmap(df):
    pivot_df = df.pivot(index="Site", columns="Pole", values="Status")
    fig = go.Figure(data=go.Heatmap(
        z=pivot_df.values,
        x=pivot_df.columns,
        y=pivot_df.index,
        colorscale="Viridis",
        zmin=0,
        zmax=100
    ))
    fig.update_layout(title="Pole Status Heatmap", height=500)
    return fig

app = dash.Dash(__name__)
server = app.server  # For Hugging Face Spaces

app.layout = html.Div([
    html.H1("Pole Management Dashboard", style={"textAlign": "center"}),
    dcc.Graph(figure=create_heatmap(df)),

    html.Div([
        html.H3("🚨 Red Alert Poles:", style={"textAlign": "center", "color": "red"}),
        html.Div([
            html.Span(f"{row['Site']} - {row['Pole']}", style={
                "animation": "blinker 1s linear infinite",
                "color": "red",
                "fontWeight": "bold",
                "fontSize": "18px",
                "margin": "8px",
                "display": "inline-block"
            })
            for _, row in df[df["Status"] > ALERT_THRESHOLD].iterrows()
        ], style={"textAlign": "center"})
    ]),

    dcc.Markdown('''
    <style>
    @keyframes blinker {
        50% { opacity: 0; }
    }
    </style>
    ''', dangerously_allow_html=True)
])

if __name__ == "__main__":
    app.run_server(debug=False, host="0.0.0.0", port=7860)