Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
|
|
|
| 4 |
|
| 5 |
# Color mapping
|
| 6 |
STATUS_COLORS = {
|
|
@@ -9,24 +10,41 @@ STATUS_COLORS = {
|
|
| 9 |
"Done": "#e6ffe6"
|
| 10 |
}
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def load_assignees():
|
|
|
|
| 14 |
assignees = []
|
| 15 |
try:
|
| 16 |
-
with open(
|
| 17 |
lines = [line.strip() for line in f.readlines() if line.strip()]
|
| 18 |
-
|
| 19 |
-
# Parse the format from your example
|
| 20 |
for line in lines:
|
| 21 |
if '-' in line:
|
| 22 |
name_part = line.split('-')[0].strip()
|
| 23 |
if ' ' in name_part:
|
| 24 |
-
|
| 25 |
-
assignees.append(name)
|
| 26 |
except FileNotFoundError:
|
| 27 |
st.error("Assignee.txt file not found!")
|
| 28 |
return assignees
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Initialize task database
|
| 31 |
if 'tasks' not in st.session_state:
|
| 32 |
st.session_state.tasks = pd.DataFrame(columns=[
|
|
@@ -41,10 +59,7 @@ with st.sidebar:
|
|
| 41 |
st.header("➕ Add New Task")
|
| 42 |
title = st.text_input("Task Title")
|
| 43 |
description = st.text_area("Description")
|
| 44 |
-
|
| 45 |
-
# Assignee dropdown from txt file
|
| 46 |
-
assignee = st.selectbox("Assignee", assignee_list)
|
| 47 |
-
|
| 48 |
status = st.selectbox("Status", ["To Do", "In Progress", "Done"])
|
| 49 |
due_date = st.date_input("Due Date")
|
| 50 |
|
|
@@ -60,6 +75,7 @@ with st.sidebar:
|
|
| 60 |
st.session_state.tasks,
|
| 61 |
pd.DataFrame([new_task])
|
| 62 |
], ignore_index=True)
|
|
|
|
| 63 |
|
| 64 |
# Function to create styled task cards (same as before)
|
| 65 |
def task_card(title, description, assignee, status, due_date):
|
|
@@ -107,6 +123,7 @@ for idx, task in st.session_state.tasks.iterrows():
|
|
| 107 |
|
| 108 |
if new_status != task['Status']:
|
| 109 |
st.session_state.tasks.at[idx, 'Status'] = new_status
|
|
|
|
| 110 |
st.rerun()
|
| 111 |
|
| 112 |
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from datetime import datetime
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
# Color mapping
|
| 7 |
STATUS_COLORS = {
|
|
|
|
| 10 |
"Done": "#e6ffe6"
|
| 11 |
}
|
| 12 |
|
| 13 |
+
# File paths
|
| 14 |
+
TASKS_FILE = "tasks.csv"
|
| 15 |
+
ASSIGNEE_FILE = "Assignee.txt"
|
| 16 |
+
|
| 17 |
+
def load_tasks():
|
| 18 |
+
"""Load tasks from CSV file"""
|
| 19 |
+
if os.path.exists(TASKS_FILE):
|
| 20 |
+
return pd.read_csv(TASKS_FILE, parse_dates=['Due Date'])
|
| 21 |
+
return pd.DataFrame(columns=[
|
| 22 |
+
'Title', 'Description', 'Assignee', 'Status', 'Due Date'
|
| 23 |
+
])
|
| 24 |
+
|
| 25 |
+
def save_tasks():
|
| 26 |
+
"""Save tasks to CSV file"""
|
| 27 |
+
st.session_state.tasks.to_csv(TASKS_FILE, index=False)
|
| 28 |
+
|
| 29 |
def load_assignees():
|
| 30 |
+
"""Load assignees from text file"""
|
| 31 |
assignees = []
|
| 32 |
try:
|
| 33 |
+
with open(ASSIGNEE_FILE, "r") as f:
|
| 34 |
lines = [line.strip() for line in f.readlines() if line.strip()]
|
|
|
|
|
|
|
| 35 |
for line in lines:
|
| 36 |
if '-' in line:
|
| 37 |
name_part = line.split('-')[0].strip()
|
| 38 |
if ' ' in name_part:
|
| 39 |
+
assignees.append(name_part)
|
|
|
|
| 40 |
except FileNotFoundError:
|
| 41 |
st.error("Assignee.txt file not found!")
|
| 42 |
return assignees
|
| 43 |
|
| 44 |
+
# Initialize session state
|
| 45 |
+
if 'tasks' not in st.session_state:
|
| 46 |
+
st.session_state.tasks = load_tasks()
|
| 47 |
+
|
| 48 |
# Initialize task database
|
| 49 |
if 'tasks' not in st.session_state:
|
| 50 |
st.session_state.tasks = pd.DataFrame(columns=[
|
|
|
|
| 59 |
st.header("➕ Add New Task")
|
| 60 |
title = st.text_input("Task Title")
|
| 61 |
description = st.text_area("Description")
|
| 62 |
+
assignee = st.selectbox("Assignee", load_assignees())
|
|
|
|
|
|
|
|
|
|
| 63 |
status = st.selectbox("Status", ["To Do", "In Progress", "Done"])
|
| 64 |
due_date = st.date_input("Due Date")
|
| 65 |
|
|
|
|
| 75 |
st.session_state.tasks,
|
| 76 |
pd.DataFrame([new_task])
|
| 77 |
], ignore_index=True)
|
| 78 |
+
save_tasks()
|
| 79 |
|
| 80 |
# Function to create styled task cards (same as before)
|
| 81 |
def task_card(title, description, assignee, status, due_date):
|
|
|
|
| 123 |
|
| 124 |
if new_status != task['Status']:
|
| 125 |
st.session_state.tasks.at[idx, 'Status'] = new_status
|
| 126 |
+
save_tasks() # Save after updating
|
| 127 |
st.rerun()
|
| 128 |
|
| 129 |
st.markdown("</div>", unsafe_allow_html=True)
|