Spaces:
Build error
Build error
import streamlit as st | |
import pandas as pd | |
import random | |
from datetime import datetime, timedelta | |
# Helper function to generate a random date within the last year | |
def random_date(): | |
start_date = datetime.now() - timedelta(days=365) | |
random_days = random.randint(0, 365) | |
return (start_date + timedelta(days=random_days)).strftime("%Y-%m-%d") | |
# Function to load and cache the product catalog | |
def load_catalog(): | |
products = { | |
"Product Name": [ | |
"Notepad++", "WinRAR", "7-Zip", "CCleaner", "TeamViewer", | |
"FileZilla", "PuTTY", "WinSCP", "Everything", "Greenshot", | |
"Visual Studio Code", "JetBrains IntelliJ IDEA", "Sublime Text", "Atom", "Eclipse", | |
"PyCharm", "NetBeans", "Xcode", "Android Studio", "GitLab", | |
"Norton Antivirus", "McAfee Total Protection", "Kaspersky Internet Security", "Bitdefender Antivirus Plus", "Avast Free Antivirus", | |
"Sophos Home", "Trend Micro Antivirus+", "ESET NOD32 Antivirus", "F-Secure SAFE", "Malwarebytes", | |
"Microsoft Office 365", "Google Workspace", "Slack", "Trello", "Asana", | |
"Zoom", "Evernote", "Notion", "Dropbox", "Adobe Acrobat Reader", | |
"Adobe Photoshop", "Adobe Illustrator", "Adobe Premiere Pro", "Final Cut Pro", "Sketch", | |
"Blender", "Autodesk Maya", "CorelDRAW", "GIMP", "Inkscape" | |
], | |
"Category": [ | |
"Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools", | |
"Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools", "Utility Tools", | |
"Development Tools", "Development Tools", "Development Tools", "Development Tools", "Development Tools", | |
"Development Tools", "Development Tools", "Development Tools", "Development Tools", "Development Tools", | |
"Security Software", "Security Software", "Security Software", "Security Software", "Security Software", | |
"Security Software", "Security Software", "Security Software", "Security Software", "Security Software", | |
"Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software", | |
"Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software", "Productivity Software", | |
"Creative Software", "Creative Software", "Creative Software", "Creative Software", "Creative Software", | |
"Creative Software", "Creative Software", "Creative Software", "Creative Software", "Creative Software" | |
], | |
"Cyber Approved": [True] * 50, | |
"Accessibility Approved": [True] * 50, | |
"Privacy Approved": [True] * 50, | |
"Review Date": [datetime.now().strftime("%Y-%m-%d")] * 50 | |
} | |
return pd.DataFrame(products) | |
# Cached function for filtering the catalog | |
def filter_catalog(catalog, category=None, cyber_approved=None, accessibility_approved=None, privacy_approved=None, search_query=None): | |
filtered = catalog | |
if category: | |
filtered = filtered[filtered["Category"].isin(category)] | |
if cyber_approved is not None: | |
filtered = filtered[filtered["Cyber Approved"] == cyber_approved] | |
if accessibility_approved is not None: | |
filtered = filtered[filtered["Accessibility Approved"] == accessibility_approved] | |
if privacy_approved is not None: | |
filtered = filtered[filtered["Privacy Approved"] == privacy_approved] | |
if search_query: | |
filtered = filtered[filtered["Product Name"].str.contains(search_query, case=False)] | |
return filtered | |
# Load the catalog | |
catalog = load_catalog() | |
# Assuming load_catalog is defined and loads data correctly | |
catalog = load_catalog() | |
# Quick check to ensure 'Category' column exists | |
if 'Category' not in catalog.columns: | |
st.error("The 'Category' column is missing from the DataFrame.") | |
else: | |
category = st.sidebar.multiselect("Filter by Category", options=catalog["Category"].unique()) | |
# Streamlit app layout | |
st.title("Enterprise Software Product Catalog") | |
st.write("This is the source of truth for app approval statuses within the enterprise.") | |
# Sidebar for filters | |
category = st.sidebar.multiselect("Filter by Category", options=catalog["Category"].unique()) | |
cyber_approved = st.sidebar.checkbox("Cyber Approved", value=True, key="cyber") | |
accessibility_approved = st.sidebar.checkbox("Accessibility Approved", value=True, key="accessibility") | |
privacy_approved = st.sidebar.checkbox("Privacy Approved", value=True, key="privacy") | |
search_query = st.sidebar.text_input("Search Products", key="search") | |
# Apply filters based on user input | |
filtered_catalog = filter_catalog( | |
catalog, | |
category=category, | |
cyber_approved=cyber_approved, | |
accessibility_approved=accessibility_approved, | |
privacy_approved=privacy_approved, | |
search_query=search_query | |
) | |
# Display the filtered product catalog | |
st.dataframe(filtered_catalog) | |