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