Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -214,24 +214,74 @@ if process_btn:
|
|
| 214 |
st.dataframe(df)
|
| 215 |
|
| 216 |
# --- Dashboard Cards ---
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
# --- Alert History ---
|
| 237 |
st.subheader("π Alert History")
|
|
|
|
| 214 |
st.dataframe(df)
|
| 215 |
|
| 216 |
# --- Dashboard Cards ---
|
| 217 |
+
# --- Dashboard Cards (Microsoft-style colored cards) ---
|
| 218 |
+
st.markdown("### π Compliance Dashboard")
|
| 219 |
+
|
| 220 |
+
# minimal CSS injected once for card styling
|
| 221 |
+
card_css = """
|
| 222 |
+
<style>
|
| 223 |
+
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
|
| 224 |
+
.card {
|
| 225 |
+
border-radius: 12px;
|
| 226 |
+
border: 2px solid rgba(0,0,0,0.12);
|
| 227 |
+
padding: 16px;
|
| 228 |
+
background: #fff;
|
| 229 |
+
box-shadow: 0 2px 6px rgba(0,0,0,0.06);
|
| 230 |
+
text-align: center;
|
| 231 |
+
}
|
| 232 |
+
.card .label { font-size: 14px; font-weight: 600; opacity: 0.8; margin-bottom: 6px; }
|
| 233 |
+
.card .value { font-size: 28px; font-weight: 800; }
|
| 234 |
+
|
| 235 |
+
.card.red { border-color: #B71C1C; background: #FFEBEE; }
|
| 236 |
+
.card.orange { border-color: #EF6C00; background: #FFF3E0; }
|
| 237 |
+
.card.purple { border-color: #6A1B9A; background: #F3E5F5; }
|
| 238 |
+
.card.blue { border-color: #01579B; background: #E1F5FE; }
|
| 239 |
+
.card.green { border-color: #1B5E20; background: #E8F5E9; }
|
| 240 |
+
.card.gray { border-color: #263238; background: #ECEFF1; }
|
| 241 |
+
</style>
|
| 242 |
+
"""
|
| 243 |
+
st.markdown(card_css, unsafe_allow_html=True)
|
| 244 |
+
|
| 245 |
+
# compute counts (kept same logic/variables you already use)
|
| 246 |
+
unapproved_count = int((df["anomalies"].str.contains("UNAPPROVED_QR", na=False)).sum())
|
| 247 |
+
on_phone_count = int((df["anomalies"].str.contains("ON_PHONE", na=False)).sum())
|
| 248 |
+
tampering_count = int((df["anomalies"].str.contains("TAMPERING", na=False)).sum())
|
| 249 |
+
roi_count = int((df["anomalies"].str.contains("OUTSIDE_ROI", na=False)).sum())
|
| 250 |
+
absence_count = int((df["anomalies"].str.contains("ABSENCE", na=False)).sum())
|
| 251 |
+
undecoded_count = int((df["anomalies"].str.contains("UNDECODED_QR", na=False)).sum())
|
| 252 |
+
|
| 253 |
+
# render: 2 rows x 3 cols, with subtle MS-style colors + borders
|
| 254 |
+
cards_html = f"""
|
| 255 |
+
<div class="dashboard-grid">
|
| 256 |
+
<div class="card red">
|
| 257 |
+
<div class="label">β Unauthorized QRs</div>
|
| 258 |
+
<div class="value">{unapproved_count}</div>
|
| 259 |
+
</div>
|
| 260 |
+
<div class="card orange">
|
| 261 |
+
<div class="label">π± On Phone</div>
|
| 262 |
+
<div class="value">{on_phone_count}</div>
|
| 263 |
+
</div>
|
| 264 |
+
<div class="card purple">
|
| 265 |
+
<div class="label">β οΈ Tampered</div>
|
| 266 |
+
<div class="value">{tampering_count}</div>
|
| 267 |
+
</div>
|
| 268 |
+
<div class="card blue">
|
| 269 |
+
<div class="label">π« Outside ROI</div>
|
| 270 |
+
<div class="value">{roi_count}</div>
|
| 271 |
+
</div>
|
| 272 |
+
<div class="card green">
|
| 273 |
+
<div class="label">β³ QR Missing</div>
|
| 274 |
+
<div class="value">{absence_count}</div>
|
| 275 |
+
</div>
|
| 276 |
+
<div class="card gray">
|
| 277 |
+
<div class="label">π Undecoded</div>
|
| 278 |
+
<div class="value">{undecoded_count}</div>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
"""
|
| 282 |
+
st.markdown(cards_html, unsafe_allow_html=True)
|
| 283 |
+
# --- end Dashboard Cards ---
|
| 284 |
+
|
| 285 |
|
| 286 |
# --- Alert History ---
|
| 287 |
st.subheader("π Alert History")
|