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 @st.cache_data 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": [random.choice([True, False]) for _ in range(50)], "Accessibility Approved": [random.choice([True, False]) for _ in range(50)], "Privacy Approved": [random.choice([True, False]) for _ in range(50)], "Review Date": [random_date() for _ in range(50)], "Review Status": [random.choice(["Approved", "Under Review", "Not Approved"]) for _ in range(50)], "Not Approved Reason": [None if status != "Not Approved" else random.choice(["Security Concern", "Licensing Issue", "Privacy Issue", "Compliance Requirement"]) for status in ["Approved", "Under Review", "Not Approved"]*8 + ["Not Approved"]] } return pd.DataFrame(products) # Function to filter the catalog based on multiple attributes with AND logic @st.cache_data def filter_catalog(catalog, search_query=None, selected_category=None, cyber_approved=None, accessibility_approved=None, privacy_approved=None,review_status=None): filtered = catalog if search_query: filtered = filtered[filtered.apply(lambda row: search_query.lower() in str(row).lower(), axis=1)] if selected_category and selected_category != 'All': filtered = filtered[filtered["Category"] == selected_category] if cyber_approved: filtered = filtered[filtered["Cyber Approved"] == True] if accessibility_approved: filtered = filtered[filtered["Accessibility Approved"] == True] if privacy_approved: filtered = filtered[filtered["Privacy Approved"] == True] if review_status and review_status != 'All': filtered = filtered[filtered["Review Status"] == review_status] return filtered catalog = load_catalog() # 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 Advanced Search and Filtering with st.sidebar: st.header("Advanced Search Options") search_query = st.text_input("Search by Any Attribute", key='search_query') selected_category = st.selectbox("Select Category", ['All'] + list(catalog["Category"].unique()), key='search_category') cyber_approved = st.checkbox("Cyber Approved", key='cyber_approved') accessibility_approved = st.checkbox("Accessibility Approved", key='accessibility_approved') privacy_approved = st.checkbox("Privacy Approved", key='privacy_approved') # Dropdown for selecting review status review_status_options = ['All', 'Approved', 'Under Review', 'Not Approved'] review_status = st.selectbox("Select Review Status", options=review_status_options, key='review_status') # Apply the enhanced filter based on user input filtered_catalog = filter_catalog(catalog, search_query, selected_category, cyber_approved, accessibility_approved, privacy_approved, review_status) # Display the filtered product catalog st.header("Product Catalog") st.dataframe(filtered_catalog)