Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
2 |
|
3 |
# Configure page first
|
4 |
st.set_page_config(
|
@@ -8,7 +11,7 @@ st.set_page_config(
|
|
8 |
menu_items={
|
9 |
'Get Help': 'https://github.com',
|
10 |
'Report a bug': "https://github.com",
|
11 |
-
'About': "# Task Management System v3.
|
12 |
}
|
13 |
)
|
14 |
|
@@ -21,7 +24,6 @@ st.markdown("""
|
|
21 |
max-width: 1400px;
|
22 |
}
|
23 |
|
24 |
-
/* Gradient Header */
|
25 |
.header {
|
26 |
background: linear-gradient(135deg, #2c3e50, #3498db);
|
27 |
color: white;
|
@@ -31,7 +33,6 @@ st.markdown("""
|
|
31 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
32 |
}
|
33 |
|
34 |
-
/* Status Badges */
|
35 |
.status-badge {
|
36 |
padding: 6px 14px;
|
37 |
border-radius: 20px;
|
@@ -44,20 +45,6 @@ st.markdown("""
|
|
44 |
.pending { background: #fff3cd; color: #856404; }
|
45 |
.in-progress { background: #cce5ff; color: #004085; }
|
46 |
.completed { background: #d4edda; color: #155724; }
|
47 |
-
|
48 |
-
/* Progress Bars */
|
49 |
-
.progress-container {
|
50 |
-
background: #f0f0f0;
|
51 |
-
border-radius: 10px;
|
52 |
-
height: 10px;
|
53 |
-
overflow: hidden;
|
54 |
-
}
|
55 |
-
|
56 |
-
.progress-bar {
|
57 |
-
height: 100%;
|
58 |
-
background: #3498db;
|
59 |
-
transition: width 0.3s ease;
|
60 |
-
}
|
61 |
</style>
|
62 |
""", unsafe_allow_html=True)
|
63 |
|
@@ -87,7 +74,7 @@ def create_default_admin(auth):
|
|
87 |
st.error(f"Admin setup error: {str(e)}")
|
88 |
|
89 |
def main():
|
90 |
-
# Initialize Firebase
|
91 |
db, auth = initialize_firebase()
|
92 |
create_default_admin(auth)
|
93 |
|
@@ -114,12 +101,14 @@ def main():
|
|
114 |
if st.form_submit_button("π Login"):
|
115 |
try:
|
116 |
user = auth.get_user_by_email(email)
|
117 |
-
user_doc = db.collection("users").document(user.uid).get()
|
|
|
|
|
118 |
st.session_state.update({
|
119 |
"authenticated": True,
|
120 |
"email": user.email,
|
121 |
"user_uid": user.uid,
|
122 |
-
"is_admin":
|
123 |
})
|
124 |
st.rerun()
|
125 |
except Exception as e:
|
@@ -143,7 +132,7 @@ def main():
|
|
143 |
st.error(f"β οΈ Registration failed: {str(e)}")
|
144 |
return
|
145 |
|
146 |
-
#
|
147 |
st.markdown(f"""
|
148 |
<div class='header'>
|
149 |
<h1>π To-Do List Management System</h1>
|
@@ -341,7 +330,7 @@ def main():
|
|
341 |
else:
|
342 |
st.info("π No tasks to edit")
|
343 |
|
344 |
-
# Project Management
|
345 |
elif menu == "ποΈ Project Management" and st.session_state.is_admin:
|
346 |
st.subheader("ποΈ Project Management")
|
347 |
projects = [p.id for p in db.collection("projects").stream()]
|
|
|
1 |
import streamlit as st
|
2 |
+
from datetime import datetime
|
3 |
+
import pandas as pd
|
4 |
+
import plotly.express as px
|
5 |
|
6 |
# Configure page first
|
7 |
st.set_page_config(
|
|
|
11 |
menu_items={
|
12 |
'Get Help': 'https://github.com',
|
13 |
'Report a bug': "https://github.com",
|
14 |
+
'About': "# Task Management System v3.3"
|
15 |
}
|
16 |
)
|
17 |
|
|
|
24 |
max-width: 1400px;
|
25 |
}
|
26 |
|
|
|
27 |
.header {
|
28 |
background: linear-gradient(135deg, #2c3e50, #3498db);
|
29 |
color: white;
|
|
|
33 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
34 |
}
|
35 |
|
|
|
36 |
.status-badge {
|
37 |
padding: 6px 14px;
|
38 |
border-radius: 20px;
|
|
|
45 |
.pending { background: #fff3cd; color: #856404; }
|
46 |
.in-progress { background: #cce5ff; color: #004085; }
|
47 |
.completed { background: #d4edda; color: #155724; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
</style>
|
49 |
""", unsafe_allow_html=True)
|
50 |
|
|
|
74 |
st.error(f"Admin setup error: {str(e)}")
|
75 |
|
76 |
def main():
|
77 |
+
# Initialize Firebase
|
78 |
db, auth = initialize_firebase()
|
79 |
create_default_admin(auth)
|
80 |
|
|
|
101 |
if st.form_submit_button("π Login"):
|
102 |
try:
|
103 |
user = auth.get_user_by_email(email)
|
104 |
+
user_doc = db.collection("users").document(user.uid).get()
|
105 |
+
custom_claims = user.custom_claims or {}
|
106 |
+
|
107 |
st.session_state.update({
|
108 |
"authenticated": True,
|
109 |
"email": user.email,
|
110 |
"user_uid": user.uid,
|
111 |
+
"is_admin": custom_claims.get('admin', False) or user_doc.get('is_admin') or False
|
112 |
})
|
113 |
st.rerun()
|
114 |
except Exception as e:
|
|
|
132 |
st.error(f"β οΈ Registration failed: {str(e)}")
|
133 |
return
|
134 |
|
135 |
+
# Main Application
|
136 |
st.markdown(f"""
|
137 |
<div class='header'>
|
138 |
<h1>π To-Do List Management System</h1>
|
|
|
330 |
else:
|
331 |
st.info("π No tasks to edit")
|
332 |
|
333 |
+
# Project Management
|
334 |
elif menu == "ποΈ Project Management" and st.session_state.is_admin:
|
335 |
st.subheader("ποΈ Project Management")
|
336 |
projects = [p.id for p in db.collection("projects").stream()]
|