SHELLAPANDIANGANHUNGING commited on
Commit
66072f5
·
verified ·
1 Parent(s): e50c059

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +215 -134
app.py CHANGED
@@ -31,6 +31,192 @@ except FileNotFoundError:
31
  st.warning(f"Logo file '{logo_path}' not found. Using placeholder text.")
32
  logo_html = '<div style="font-size: 18px; font-weight: bold; color: #2c3e50;">BTECH</div>'
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  # =================== GLOBAL CSS =====================
35
  st.markdown("""
36
  <style>
@@ -41,166 +227,60 @@ body {
41
  /* ===== HEADER WRAPPER ===== */
42
  .header-container {
43
  display: flex;
44
- justify-content: space-between;
45
  align-items: center;
46
  padding: 25px 35px;
47
- background: white; /* Latar belakang utama diubah menjadi putih */
48
- border-radius: 0 0 14px 14px; /* Rounded bottom only */
49
- box-shadow: 0 5px 18px rgba(0,0,0,0.15); /* Bayangan lebih lembut */
50
- border: 1px solid #e0e0e0; /* Border tipis untuk definisi */
51
  margin-bottom: 25px;
52
  position: relative;
53
- overflow: hidden; /* Ensure rounded corners clip content */
54
  }
55
 
56
- /* Optional: Subtle pattern or texture overlay (optional, can be removed) */
57
- /* .header-container::before {
58
- content: "";
59
- position: absolute;
60
- top: 0;
61
- left: 0;
62
- right: 0;
63
- bottom: 0;
64
- background: linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.03) 50%, rgba(255,255,255,0.03) 75%, transparent 75%, transparent);
65
- background-size: 20px 20px;
66
- pointer-events: none;
67
- } */
68
-
69
  /* ===== HEADER TEXT ===== */
70
  .header-title {
71
- color: #2c3e50; /* Teks header diubah agar kontras dengan latar putih */
72
- font-family: 'Segoe UI', sans-serif;
73
- flex-grow: 1; /* Allow text to take up available space */
74
- margin-right: 20px; /* Space between text and logo */
75
- text-align: left;
 
76
  }
77
 
78
  .header-title h1 {
79
  font-size: 2.7em;
80
  font-weight: 650;
81
  margin: 0;
82
- text-shadow: 1px 1px 2px rgba(0,0,0,0.1); /* Bayangan teks lebih lembut */
 
83
  }
84
 
85
  .header-title p {
86
  font-size: 1.25em;
87
- opacity: 0.85; /* Sedikit transparan untuk subjudul */
88
  margin-top: 6px;
89
  font-style: italic;
90
- color: #34495e; /* Warna subjudul disesuaikan */
91
  }
92
 
93
  /* ===== LOGO WRAPPER ===== */
94
  .header-logo {
95
  display: flex;
96
  align-items: center;
97
- justify-content: flex-end; /* Align logo to the right within its container */
98
- flex-shrink: 0; /* Prevent logo container from shrinking */
99
  }
100
 
101
- /* ===== LOGO STYLE ===== */
102
  .header-logo img {
103
  border-radius: 10px;
104
- border: 2px solid rgba(44, 62, 80, 0.15); /* Border logo disesuaikan */
105
- box-shadow: 0 3px 10px rgba(0,0,0,0.1); /* Bayangan logo lebih lembut */
106
- max-height: 80px; /* Set max height */
107
- max-width: 120px; /* Set max width */
108
- }
109
-
110
- /* ===== METRIC CARDS ===== */
111
- .metric-card {
112
- background: #ffffff;
113
- padding: 18px 22px;
114
- border-radius: 12px;
115
- border-left: 6px solid #1e3c72;
116
- box-shadow: 0 3px 8px rgba(0,0,0,0.10);
117
- transition: 0.25s ease-in-out;
118
- }
119
- .metric-card:hover {
120
- transform: translateY(-4px);
121
- box-shadow: 0 6px 15px rgba(0,0,0,0.18);
122
- }
123
-
124
- /* ===== INSIGHT BOX ===== */
125
- .insight-box {
126
- background: #fafafa;
127
- padding: 18px;
128
- border-radius: 12px;
129
- border-left: 6px solid #ff6b6b;
130
- margin: 15px 0;
131
- box-shadow: 0 2px 6px rgba(0,0,0,0.08);
132
- }
133
-
134
- /* ===== RISK MATRIX ===== */
135
- .risk-matrix {
136
- border-collapse: collapse;
137
- width: 100%;
138
- margin: 20px 0;
139
- }
140
- .risk-matrix th, .risk-matrix td {
141
- border: 1px solid #ddd;
142
- padding: 12px;
143
- text-align: center;
144
- }
145
- .risk-matrix th {
146
- background-color: #f2f2f2;
147
- }
148
- .critical { background-color: #ffcccc; font-weight: bold; }
149
- .high { background-color: #ffebcc; }
150
- .medium { background-color: #ffffcc; }
151
- .low { background-color: #e6ffe6; }
152
-
153
- /* ===== CHAT UI ===== */
154
- .chat-container {
155
- background: white;
156
- padding: 20px;
157
- border-radius: 12px;
158
- height: 400px;
159
- overflow-y: auto;
160
- border: 1px solid #ccc;
161
- }
162
- .user-message {
163
- background: #e3f2fd;
164
- color: black;
165
- padding: 12px;
166
- border-radius: 12px;
167
- margin: 10px 0;
168
- text-align: right;
169
- border: 1px solid #bbdefb;
170
- }
171
- .ai-message {
172
- background: #f5f5f5;
173
- color: black;
174
- padding: 12px;
175
- border-radius: 12px;
176
- margin: 10px 0;
177
- text-align: left;
178
- border: 1px solid #e0e0e0;
179
- }
180
-
181
- /* ===== INPUT BOX ===== */
182
- .chat-box, .user-question, .ai-answer {
183
- background: white;
184
- border: 1px solid #ccc;
185
- border-radius: 10px;
186
- padding: 12px;
187
- margin-bottom: 12px;
188
- }
189
-
190
- /* ===== FOOTER ===== */
191
- .footer {
192
- text-align: center;
193
- padding: 20px;
194
- color: gray;
195
- font-size: 0.9em;
196
- }
197
-
198
- /* ===== HOVER EFFECTS ===== */
199
- .metric-card:hover, .insight-box:hover {
200
- box-shadow: 0 6px 15px rgba(0,0,0,0.2);
201
- transition: all 0.3s ease-in-out;
202
  }
203
 
 
204
  </style>
205
  """, unsafe_allow_html=True)
206
 
@@ -212,14 +292,13 @@ st.markdown(f"""
212
  <p>Proactive Safety Intelligence for Mining Operations</p>
213
  </div>
214
  <div class="header-logo">
215
- {logo_html}
216
  </div>
217
  </div>
218
  """, unsafe_allow_html=True)
219
 
220
- # Sisa kode Anda (LOAD DATA, FILTERS, VISUALISASI, dll.) tetap sama di bawah ini
221
- # ... (Kode selanjutnya disalin dari bagian bawah file Anda, misalnya LOAD DATA ke bawah)
222
- # =================== LOAD DATA ======================
223
  @st.cache_data
224
  def load_data():
225
  try:
@@ -320,7 +399,6 @@ df_full_report = df.copy()
320
  # =================== FILTERS (Sidebar) =====================
321
  filter_dict = {}
322
 
323
- # ✅ Sidebar title — elegan, profesional, tanpa emoticon
324
  st.sidebar.markdown(
325
  """
326
  <div style="
@@ -328,7 +406,8 @@ st.sidebar.markdown(
328
  font-size: 1.35em;
329
  font-weight: 600;
330
  color: #2c3e50;
331
- padding: 8px 0 12px 0;
 
332
  border-bottom: 2px solid #3498db;
333
  margin-bottom: 16px;
334
  ">
@@ -338,6 +417,8 @@ st.sidebar.markdown(
338
  unsafe_allow_html=True
339
  )
340
 
 
 
341
  with st.sidebar.form("filters_form"):
342
  # ---------------- Date Range ----------------
343
  if 'date' in df.columns and not df['date'].isna().all():
 
31
  st.warning(f"Logo file '{logo_path}' not found. Using placeholder text.")
32
  logo_html = '<div style="font-size: 18px; font-weight: bold; color: #2c3e50;">BTECH</div>'
33
 
34
+ # # =================== GLOBAL CSS =====================
35
+ # st.markdown("""
36
+ # <style>
37
+ # body {
38
+ # background-color: #f6f8fa;
39
+ # }
40
+
41
+ # /* ===== HEADER WRAPPER ===== */
42
+ # .header-container {
43
+ # display: flex;
44
+ # justify-content: space-between;
45
+ # align-items: center;
46
+ # padding: 25px 35px;
47
+ # background: white; /* Latar belakang utama diubah menjadi putih */
48
+ # border-radius: 0 0 14px 14px; /* Rounded bottom only */
49
+ # box-shadow: 0 5px 18px rgba(0,0,0,0.15); /* Bayangan lebih lembut */
50
+ # border: 1px solid #e0e0e0; /* Border tipis untuk definisi */
51
+ # margin-bottom: 25px;
52
+ # position: relative;
53
+ # overflow: hidden; /* Ensure rounded corners clip content */
54
+ # }
55
+
56
+ # /* Optional: Subtle pattern or texture overlay (optional, can be removed) */
57
+ # /* .header-container::before {
58
+ # content: "";
59
+ # position: absolute;
60
+ # top: 0;
61
+ # left: 0;
62
+ # right: 0;
63
+ # bottom: 0;
64
+ # background: linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.03) 50%, rgba(255,255,255,0.03) 75%, transparent 75%, transparent);
65
+ # background-size: 20px 20px;
66
+ # pointer-events: none;
67
+ # } */
68
+
69
+ # /* ===== HEADER TEXT ===== */
70
+ # .header-title {
71
+ # color: #2c3e50; /* Teks header diubah agar kontras dengan latar putih */
72
+ # font-family: 'Segoe UI', sans-serif;
73
+ # flex-grow: 1; /* Allow text to take up available space */
74
+ # margin-right: 20px; /* Space between text and logo */
75
+ # text-align: left;
76
+ # }
77
+
78
+ # .header-title h1 {
79
+ # font-size: 2.7em;
80
+ # font-weight: 650;
81
+ # margin: 0;
82
+ # text-shadow: 1px 1px 2px rgba(0,0,0,0.1); /* Bayangan teks lebih lembut */
83
+ # }
84
+
85
+ # .header-title p {
86
+ # font-size: 1.25em;
87
+ # opacity: 0.85; /* Sedikit transparan untuk subjudul */
88
+ # margin-top: 6px;
89
+ # font-style: italic;
90
+ # color: #34495e; /* Warna subjudul disesuaikan */
91
+ # }
92
+
93
+ # /* ===== LOGO WRAPPER ===== */
94
+ # .header-logo {
95
+ # display: flex;
96
+ # align-items: center;
97
+ # justify-content: flex-end; /* Align logo to the right within its container */
98
+ # flex-shrink: 0; /* Prevent logo container from shrinking */
99
+ # }
100
+
101
+ # /* ===== LOGO STYLE ===== */
102
+ # .header-logo img {
103
+ # border-radius: 10px;
104
+ # border: 2px solid rgba(44, 62, 80, 0.15); /* Border logo disesuaikan */
105
+ # box-shadow: 0 3px 10px rgba(0,0,0,0.1); /* Bayangan logo lebih lembut */
106
+ # max-height: 80px; /* Set max height */
107
+ # max-width: 120px; /* Set max width */
108
+ # }
109
+
110
+ # /* ===== METRIC CARDS ===== */
111
+ # .metric-card {
112
+ # background: #ffffff;
113
+ # padding: 18px 22px;
114
+ # border-radius: 12px;
115
+ # border-left: 6px solid #1e3c72;
116
+ # box-shadow: 0 3px 8px rgba(0,0,0,0.10);
117
+ # transition: 0.25s ease-in-out;
118
+ # }
119
+ # .metric-card:hover {
120
+ # transform: translateY(-4px);
121
+ # box-shadow: 0 6px 15px rgba(0,0,0,0.18);
122
+ # }
123
+
124
+ # /* ===== INSIGHT BOX ===== */
125
+ # .insight-box {
126
+ # background: #fafafa;
127
+ # padding: 18px;
128
+ # border-radius: 12px;
129
+ # border-left: 6px solid #ff6b6b;
130
+ # margin: 15px 0;
131
+ # box-shadow: 0 2px 6px rgba(0,0,0,0.08);
132
+ # }
133
+
134
+ # /* ===== RISK MATRIX ===== */
135
+ # .risk-matrix {
136
+ # border-collapse: collapse;
137
+ # width: 100%;
138
+ # margin: 20px 0;
139
+ # }
140
+ # .risk-matrix th, .risk-matrix td {
141
+ # border: 1px solid #ddd;
142
+ # padding: 12px;
143
+ # text-align: center;
144
+ # }
145
+ # .risk-matrix th {
146
+ # background-color: #f2f2f2;
147
+ # }
148
+ # .critical { background-color: #ffcccc; font-weight: bold; }
149
+ # .high { background-color: #ffebcc; }
150
+ # .medium { background-color: #ffffcc; }
151
+ # .low { background-color: #e6ffe6; }
152
+
153
+ # /* ===== CHAT UI ===== */
154
+ # .chat-container {
155
+ # background: white;
156
+ # padding: 20px;
157
+ # border-radius: 12px;
158
+ # height: 400px;
159
+ # overflow-y: auto;
160
+ # border: 1px solid #ccc;
161
+ # }
162
+ # .user-message {
163
+ # background: #e3f2fd;
164
+ # color: black;
165
+ # padding: 12px;
166
+ # border-radius: 12px;
167
+ # margin: 10px 0;
168
+ # text-align: right;
169
+ # border: 1px solid #bbdefb;
170
+ # }
171
+ # .ai-message {
172
+ # background: #f5f5f5;
173
+ # color: black;
174
+ # padding: 12px;
175
+ # border-radius: 12px;
176
+ # margin: 10px 0;
177
+ # text-align: left;
178
+ # border: 1px solid #e0e0e0;
179
+ # }
180
+
181
+ # /* ===== INPUT BOX ===== */
182
+ # .chat-box, .user-question, .ai-answer {
183
+ # background: white;
184
+ # border: 1px solid #ccc;
185
+ # border-radius: 10px;
186
+ # padding: 12px;
187
+ # margin-bottom: 12px;
188
+ # }
189
+
190
+ # /* ===== FOOTER ===== */
191
+ # .footer {
192
+ # text-align: center;
193
+ # padding: 20px;
194
+ # color: gray;
195
+ # font-size: 0.9em;
196
+ # }
197
+
198
+ # /* ===== HOVER EFFECTS ===== */
199
+ # .metric-card:hover, .insight-box:hover {
200
+ # box-shadow: 0 6px 15px rgba(0,0,0,0.2);
201
+ # transition: all 0.3s ease-in-out;
202
+ # }
203
+
204
+ # </style>
205
+ # """, unsafe_allow_html=True)
206
+
207
+ # # =================== HEADER =====================
208
+ # st.markdown(f"""
209
+ # <div class="header-container">
210
+ # <div class="header-title">
211
+ # <h1>Safety Analysis and AI - Advanced Fatigue Analysis</h1>
212
+ # <p>Proactive Safety Intelligence for Mining Operations</p>
213
+ # </div>
214
+ # <div class="header-logo">
215
+ # {logo_html}
216
+ # </div>
217
+ # </div>
218
+ # """, unsafe_allow_html=True)
219
+
220
  # =================== GLOBAL CSS =====================
221
  st.markdown("""
222
  <style>
 
227
  /* ===== HEADER WRAPPER ===== */
228
  .header-container {
229
  display: flex;
230
+ justify-content: space-between; /* Logo di kanan, teks di tengah */
231
  align-items: center;
232
  padding: 25px 35px;
233
+ background: white;
234
+ border-radius: 0 0 14px 14px;
235
+ box-shadow: 0 5px 18px rgba(0,0,0,0.15);
236
+ border: 1px solid #e0e0e0;
237
  margin-bottom: 25px;
238
  position: relative;
 
239
  }
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  /* ===== HEADER TEXT ===== */
242
  .header-title {
243
+ flex: 1; /* Mengambil ruang sebanyak mungkin */
244
+ display: flex;
245
+ flex-direction: column;
246
+ align-items: center; /* Center horizontal */
247
+ justify-content: center; /* Center vertical */
248
+ text-align: center;
249
  }
250
 
251
  .header-title h1 {
252
  font-size: 2.7em;
253
  font-weight: 650;
254
  margin: 0;
255
+ text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
256
+ color: #2c3e50;
257
  }
258
 
259
  .header-title p {
260
  font-size: 1.25em;
261
+ opacity: 0.85;
262
  margin-top: 6px;
263
  font-style: italic;
264
+ color: #34495e;
265
  }
266
 
267
  /* ===== LOGO WRAPPER ===== */
268
  .header-logo {
269
  display: flex;
270
  align-items: center;
271
+ justify-content: flex-end;
272
+ flex-shrink: 0;
273
  }
274
 
 
275
  .header-logo img {
276
  border-radius: 10px;
277
+ border: 2px solid rgba(44, 62, 80, 0.15);
278
+ box-shadow: 0 3px 10px rgba(0,0,0,0.1);
279
+ max-height: 80px;
280
+ max-width: 120px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
282
 
283
+ /* Metric cards, insight box, dll. tetap sama... */
284
  </style>
285
  """, unsafe_allow_html=True)
286
 
 
292
  <p>Proactive Safety Intelligence for Mining Operations</p>
293
  </div>
294
  <div class="header-logo">
295
+ {logo_html} <!-- Logo tetap di kanan -->
296
  </div>
297
  </div>
298
  """, unsafe_allow_html=True)
299
 
300
+ # # ... (Kode selanjutnya disalin dari bagian bawah file Anda, misalnya LOAD DATA ke bawah)
301
+ # # =================== LOAD DATA ======================
 
302
  @st.cache_data
303
  def load_data():
304
  try:
 
399
  # =================== FILTERS (Sidebar) =====================
400
  filter_dict = {}
401
 
 
402
  st.sidebar.markdown(
403
  """
404
  <div style="
 
406
  font-size: 1.35em;
407
  font-weight: 600;
408
  color: #2c3e50;
409
+ padding: 10px 0 14px 0;
410
+ text-align: center;
411
  border-bottom: 2px solid #3498db;
412
  margin-bottom: 16px;
413
  ">
 
417
  unsafe_allow_html=True
418
  )
419
 
420
+ with st.sidebar.form("filters_form"):
421
+
422
  with st.sidebar.form("filters_form"):
423
  # ---------------- Date Range ----------------
424
  if 'date' in df.columns and not df['date'].isna().all():