Upload 2 files
Browse files- app.py +171 -0
- ma_logo.png +0 -0
app.py
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import requests
|
4 |
+
from datetime import datetime
|
5 |
+
|
6 |
+
# SheetDB API Endpoint for Timecard Data
|
7 |
+
SHEETDB_API_URL_TIMECARD = "https://sheetdb.io/api/v1/jsh4nri7t8rko" # Replace with your SheetDB API URL for timecard
|
8 |
+
|
9 |
+
# Define password
|
10 |
+
PASSWORD = "ma_12345" # Replace with your desired password
|
11 |
+
|
12 |
+
# Hardcoded Metadata
|
13 |
+
METADATA = {
|
14 |
+
"Employee Names": [
|
15 |
+
"Ubaid Bashir", "Shoaib Ahmad", "Rumaan Hassan Alamgeer",
|
16 |
+
"Sana Sanaullah", "Aafreen Mushtaq", "Andleeb Gul"
|
17 |
+
],
|
18 |
+
"Project Names": [
|
19 |
+
"ICCL", "Reston", "Stormwater", "NISA Engineering",
|
20 |
+
"Paramount", "Preng", "Misc.", "Marketing"
|
21 |
+
],
|
22 |
+
"Project Codes": [
|
23 |
+
"US 001", "US 003", "US 004", "US 005", "US 006", "IND 001", "IND 007"
|
24 |
+
]
|
25 |
+
}
|
26 |
+
|
27 |
+
# Load timecard data from SheetDB
|
28 |
+
def load_data():
|
29 |
+
response = requests.get(SHEETDB_API_URL_TIMECARD)
|
30 |
+
if response.status_code == 200:
|
31 |
+
return pd.DataFrame(response.json())
|
32 |
+
else:
|
33 |
+
return pd.DataFrame(columns=["Employee Name", "Project Name", "Project Code", "Date", "Hours", "Notes"])
|
34 |
+
|
35 |
+
# Save timecard data to SheetDB
|
36 |
+
def save_data(employee_name, project_name, project_code, date, hours, notes):
|
37 |
+
new_entry = {
|
38 |
+
"Employee Name": employee_name,
|
39 |
+
"Project Name": project_name,
|
40 |
+
"Project Code": project_code,
|
41 |
+
"Date": str(date),
|
42 |
+
"Hours": hours,
|
43 |
+
"Notes": notes
|
44 |
+
}
|
45 |
+
response = requests.post(SHEETDB_API_URL_TIMECARD, json=new_entry)
|
46 |
+
if response.status_code == 201:
|
47 |
+
st.success("Entry added successfully!")
|
48 |
+
else:
|
49 |
+
st.error("Failed to add entry. Please try again.")
|
50 |
+
|
51 |
+
# Custom Cyberpunk CSS (Less Glowy)
|
52 |
+
st.markdown(
|
53 |
+
"""
|
54 |
+
<style>
|
55 |
+
/* General Styling */
|
56 |
+
body {
|
57 |
+
background-color: #000000;
|
58 |
+
color: #00FF00;
|
59 |
+
font-family: 'Courier New', monospace;
|
60 |
+
}
|
61 |
+
h1, h2, h3, h4, h5, h6 {
|
62 |
+
color: #00FF00;
|
63 |
+
font-family: 'Courier New', monospace;
|
64 |
+
}
|
65 |
+
.stButton button {
|
66 |
+
background-color: #00FF00;
|
67 |
+
color: #000000;
|
68 |
+
border: 2px solid #00FF00;
|
69 |
+
border-radius: 5px;
|
70 |
+
font-family: 'Courier New', monospace;
|
71 |
+
font-weight: bold;
|
72 |
+
}
|
73 |
+
.stButton button:hover {
|
74 |
+
background-color: #000000;
|
75 |
+
color: #00FF00;
|
76 |
+
border: 2px solid #00FF00;
|
77 |
+
}
|
78 |
+
.stTextInput input, .stSelectbox select, .stDateInput input, .stNumberInput input, .stTextArea textarea {
|
79 |
+
background-color: #000000;
|
80 |
+
color: #00FF00;
|
81 |
+
border: 2px solid #00FF00;
|
82 |
+
font-family: 'Courier New', monospace;
|
83 |
+
}
|
84 |
+
.stDataFrame {
|
85 |
+
background-color: #000000;
|
86 |
+
color: #00FF00;
|
87 |
+
border: 2px solid #00FF00;
|
88 |
+
}
|
89 |
+
.stSidebar {
|
90 |
+
background-color: #000000;
|
91 |
+
color: #00FF00;
|
92 |
+
border-right: 2px solid #00FF00;
|
93 |
+
}
|
94 |
+
.stMarkdown {
|
95 |
+
color: #00FF00;
|
96 |
+
}
|
97 |
+
/* Reduced Neon Glow Effect */
|
98 |
+
.neon-text {
|
99 |
+
color: #00FF00;
|
100 |
+
text-shadow: 0 0 3px #00FF00, 0 0 5px #00FF00;
|
101 |
+
}
|
102 |
+
.neon-border {
|
103 |
+
border: 2px solid #00FF00;
|
104 |
+
box-shadow: 0 0 3px #00FF00, 0 0 5px #00FF00;
|
105 |
+
}
|
106 |
+
</style>
|
107 |
+
""",
|
108 |
+
unsafe_allow_html=True
|
109 |
+
)
|
110 |
+
|
111 |
+
# Password authentication
|
112 |
+
if "authenticated" not in st.session_state:
|
113 |
+
st.session_state.authenticated = False
|
114 |
+
|
115 |
+
if not st.session_state.authenticated:
|
116 |
+
st.markdown("<h1 class='neon-text' style='text-align: center;'>Munshi Associates Dashboard</h1>", unsafe_allow_html=True)
|
117 |
+
st.markdown("<p class='neon-text'>Please enter the password to access the application.</p>", unsafe_allow_html=True)
|
118 |
+
password = st.text_input("Password", type="password")
|
119 |
+
|
120 |
+
if st.button("Login"):
|
121 |
+
if password == PASSWORD:
|
122 |
+
st.session_state.authenticated = True
|
123 |
+
st.success("Login successful!")
|
124 |
+
else:
|
125 |
+
st.error("Incorrect password. Please try again.")
|
126 |
+
else:
|
127 |
+
# Display company logo and title in the sidebar
|
128 |
+
st.sidebar.image("ma_logo.png") # Replace with your logo
|
129 |
+
st.sidebar.markdown("<h1 class='neon-text'>Munshi Associates Dashboard</h1>", unsafe_allow_html=True)
|
130 |
+
st.sidebar.markdown("<p class='neon-text'>Employee Timecard Management System</p>", unsafe_allow_html=True)
|
131 |
+
|
132 |
+
# Main section
|
133 |
+
st.markdown("<h1 class='neon-text'>Employee Time Card Management</h1>", unsafe_allow_html=True)
|
134 |
+
st.markdown("<p class='neon-text'>Welcome to the <strong>Munshi Associates Time Card Management System</strong></p>", unsafe_allow_html=True)
|
135 |
+
|
136 |
+
# Load metadata (hardcoded)
|
137 |
+
employee_names = METADATA["Employee Names"]
|
138 |
+
project_names = METADATA["Project Names"]
|
139 |
+
project_codes = METADATA["Project Codes"]
|
140 |
+
|
141 |
+
# Form for adding timecard entries
|
142 |
+
st.markdown("<h3 class='neon-text'>Add Timecard Entry</h3>", unsafe_allow_html=True)
|
143 |
+
with st.form("timecard_form"):
|
144 |
+
st.markdown("<p class='neon-text'>Fill out the form below to add a new entry.</p>", unsafe_allow_html=True)
|
145 |
+
col1, col2 = st.columns(2)
|
146 |
+
with col1:
|
147 |
+
employee_name = st.selectbox("Select Employee Name", employee_names)
|
148 |
+
project_name = st.selectbox("Select Project Name", project_names)
|
149 |
+
project_code = st.selectbox("Select Project Code", project_codes)
|
150 |
+
with col2:
|
151 |
+
date = st.date_input("Date", datetime.today())
|
152 |
+
hours = st.number_input("Hours Worked", min_value=0.0, step=0.5)
|
153 |
+
notes = st.text_area("Notes", placeholder="Add any relevant notes here...")
|
154 |
+
|
155 |
+
submitted = st.form_submit_button("Add Entry")
|
156 |
+
if submitted:
|
157 |
+
save_data(employee_name, project_name, project_code, date, hours, notes)
|
158 |
+
|
159 |
+
# Display existing timecard data
|
160 |
+
st.markdown("<h3 class='neon-text'>Existing Time Card Data</h3>", unsafe_allow_html=True)
|
161 |
+
data = load_data()
|
162 |
+
st.dataframe(data, use_container_width=True)
|
163 |
+
|
164 |
+
# Option to download the data
|
165 |
+
st.markdown("<h3 class='neon-text'>Download Time Card Data</h3>", unsafe_allow_html=True)
|
166 |
+
st.download_button(
|
167 |
+
label="Download CSV",
|
168 |
+
data=data.to_csv(index=False),
|
169 |
+
file_name="timecard_data.csv",
|
170 |
+
mime="text/csv"
|
171 |
+
)
|
ma_logo.png
ADDED
![]() |