Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -44,27 +44,21 @@ def load_catalog():
|
|
44 |
}
|
45 |
return pd.DataFrame(products)
|
46 |
|
47 |
-
#
|
48 |
@st.cache_data
|
49 |
-
def filter_catalog(catalog,
|
50 |
filtered = catalog
|
51 |
-
if
|
52 |
-
|
|
|
53 |
if cyber_approved is not None:
|
54 |
filtered = filtered[filtered["Cyber Approved"] == cyber_approved]
|
55 |
if accessibility_approved is not None:
|
56 |
filtered = filtered[filtered["Accessibility Approved"] == accessibility_approved]
|
57 |
if privacy_approved is not None:
|
58 |
filtered = filtered[filtered["Privacy Approved"] == privacy_approved]
|
59 |
-
if search_query:
|
60 |
-
filtered = filtered[filtered["Product Name"].str.contains(search_query, case=False)]
|
61 |
return filtered
|
62 |
|
63 |
-
# Load the catalog
|
64 |
-
catalog = load_catalog()
|
65 |
-
|
66 |
-
|
67 |
-
# Assuming load_catalog is defined and loads data correctly
|
68 |
catalog = load_catalog()
|
69 |
|
70 |
|
@@ -75,22 +69,16 @@ catalog = load_catalog()
|
|
75 |
st.title("Enterprise Software Product Catalog")
|
76 |
st.write("This is the source of truth for app approval statuses within the enterprise.")
|
77 |
|
78 |
-
# Sidebar for
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
# Apply
|
86 |
-
filtered_catalog = filter_catalog(
|
87 |
-
catalog,
|
88 |
-
category=category,
|
89 |
-
cyber_approved=cyber_approved,
|
90 |
-
accessibility_approved=accessibility_approved,
|
91 |
-
privacy_approved=privacy_approved,
|
92 |
-
search_query=search_query
|
93 |
-
)
|
94 |
|
95 |
# Display the filtered product catalog
|
96 |
-
st.
|
|
|
|
44 |
}
|
45 |
return pd.DataFrame(products)
|
46 |
|
47 |
+
# Enhanced function to filter the catalog based on multiple attributes
|
48 |
@st.cache_data
|
49 |
+
def filter_catalog(catalog, search_query=None, cyber_approved=None, accessibility_approved=None, privacy_approved=None):
|
50 |
filtered = catalog
|
51 |
+
if search_query:
|
52 |
+
# Filtering by checking if the search_query is in any of the specified attributes
|
53 |
+
filtered = filtered[filtered.apply(lambda row: search_query.lower() in str(row).lower(), axis=1)]
|
54 |
if cyber_approved is not None:
|
55 |
filtered = filtered[filtered["Cyber Approved"] == cyber_approved]
|
56 |
if accessibility_approved is not None:
|
57 |
filtered = filtered[filtered["Accessibility Approved"] == accessibility_approved]
|
58 |
if privacy_approved is not None:
|
59 |
filtered = filtered[filtered["Privacy Approved"] == privacy_approved]
|
|
|
|
|
60 |
return filtered
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
catalog = load_catalog()
|
63 |
|
64 |
|
|
|
69 |
st.title("Enterprise Software Product Catalog")
|
70 |
st.write("This is the source of truth for app approval statuses within the enterprise.")
|
71 |
|
72 |
+
# Sidebar for Advanced Search and Filtering
|
73 |
+
with st.sidebar.expander("Advanced Search Options"):
|
74 |
+
search_query = st.text_input("Search by Any Attribute", key='search_query')
|
75 |
+
cyber_approved = st.checkbox("Cyber Approved", key='cyber_approved')
|
76 |
+
accessibility_approved = st.checkbox("Accessibility Approved", key='accessibility_approved')
|
77 |
+
privacy_approved = st.checkbox("Privacy Approved", key='privacy_approved')
|
78 |
|
79 |
+
# Apply the enhanced filter based on user input
|
80 |
+
filtered_catalog = filter_catalog(catalog, search_query, cyber_approved, accessibility_approved, privacy_approved)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# Display the filtered product catalog
|
83 |
+
st.header("Product Catalog")
|
84 |
+
st.dataframe(filtered_catalog)
|