Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,53 @@
|
|
| 1 |
-
# app.py
|
| 2 |
-
|
| 3 |
import streamlit as st
|
| 4 |
from salesforce_integration import fetch_poles
|
| 5 |
import plotly.express as px
|
| 6 |
from modules.visuals import display_dashboard, display_charts
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
st.title("π‘ VIEP Smart Poles Dashboard (Salesforce Data)")
|
| 11 |
|
| 12 |
# Fetch Data
|
| 13 |
df = fetch_poles()
|
| 14 |
|
| 15 |
-
# Display Table
|
| 16 |
st.subheader("π Pole Table")
|
| 17 |
-
st.dataframe(df
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
st.subheader("β Energy Generation (Solar vs Wind)")
|
| 21 |
-
st.plotly_chart(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
display_dashboard(df)
|
| 26 |
-
display_charts(df)
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from salesforce_integration import fetch_poles
|
| 3 |
import plotly.express as px
|
| 4 |
from modules.visuals import display_dashboard, display_charts
|
| 5 |
|
|
|
|
|
|
|
| 6 |
st.title("π‘ VIEP Smart Poles Dashboard (Salesforce Data)")
|
| 7 |
|
| 8 |
# Fetch Data
|
| 9 |
df = fetch_poles()
|
| 10 |
|
| 11 |
+
# Display Table with extra fields
|
| 12 |
st.subheader("π Pole Table")
|
| 13 |
+
st.dataframe(df[[
|
| 14 |
+
"Name",
|
| 15 |
+
"Solar_Generation__c",
|
| 16 |
+
"Wind_Generation__c",
|
| 17 |
+
"Camera_Status__c",
|
| 18 |
+
"Longitude__c",
|
| 19 |
+
"Latitude__c",
|
| 20 |
+
"Last_Check_Time__c"
|
| 21 |
+
]])
|
| 22 |
+
|
| 23 |
+
# Energy Generation Chart
|
| 24 |
st.subheader("β Energy Generation (Solar vs Wind)")
|
| 25 |
+
st.plotly_chart(
|
| 26 |
+
px.bar(
|
| 27 |
+
df,
|
| 28 |
+
x="Name",
|
| 29 |
+
y=["Solar_Generation__c", "Wind_Generation__c"],
|
| 30 |
+
barmode="group",
|
| 31 |
+
title="Solar vs Wind Energy by Pole"
|
| 32 |
+
)
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
# Camera Status Visualization (Only once, horizontal bar)
|
| 36 |
+
st.subheader("π₯ Camera Status Overview")
|
| 37 |
+
camera_counts = df["Camera_Status__c"].value_counts().reset_index()
|
| 38 |
+
camera_counts.columns = ["Status", "Count"]
|
| 39 |
+
|
| 40 |
+
fig_camera_status = px.bar(
|
| 41 |
+
camera_counts,
|
| 42 |
+
x="Count",
|
| 43 |
+
y="Status",
|
| 44 |
+
orientation="h",
|
| 45 |
+
color="Status",
|
| 46 |
+
text="Count",
|
| 47 |
+
title="Camera Status Distribution"
|
| 48 |
+
)
|
| 49 |
+
st.plotly_chart(fig_camera_status)
|
| 50 |
+
|
| 51 |
+
# Custom Visuals
|
| 52 |
display_dashboard(df)
|
| 53 |
+
display_charts(df)
|