Skip to content

Commit

Permalink
feat(dashboard): handle regions for azure
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrooot committed Mar 25, 2024
1 parent 443d5c6 commit f3af004
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
3 changes: 3 additions & 0 deletions dashboard/pages/compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def load_csv_files(csv_files):
# Select Region - Dropdown

select_region_dropdown_list = ["All"]
# Handle the case where the column REGION or LOCATION is empty
data["REGION"] = data["REGION"].fillna("-")
data["LOCATION"] = data["LOCATION"].fillna("-")
# Append to the list the unique values of the column REGION or LOCATION if it exists
if "REGION" in data.columns:
select_region_dropdown_list = select_region_dropdown_list + list(
Expand Down
33 changes: 17 additions & 16 deletions dashboard/pages/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ def load_csv_files(csv_files):
account_dropdown = create_account_dropdown(accounts)

# Region Dropdown
# Handle the case where the region is null
data["REGION"] = data["REGION"].fillna("-")
regions = ["All"] + list(data["REGION"].unique())
region_dropdown = create_region_dropdown(regions)

Expand Down Expand Up @@ -379,23 +381,22 @@ def filter_data(cloud_account_values, region_account_values, assessment_value):
# Filter REGION
# Check if filtered data contains an aws account
# TODO - Handle azure locations
if not filtered_data["PROVIDER"].str.contains("azure").any():
if region_account_values == ["All"]:
updated_region_account_values = filtered_data["REGION"].unique()
elif "All" in region_account_values and len(region_account_values) > 1:
# Remove 'All' from the list
region_account_values.remove("All")
updated_region_account_values = region_account_values

elif len(region_account_values) == 0:
updated_region_account_values = filtered_data["REGION"].unique()
region_account_values = ["All"]
else:
updated_region_account_values = region_account_values
if region_account_values == ["All"]:
updated_region_account_values = filtered_data["REGION"].unique()
elif "All" in region_account_values and len(region_account_values) > 1:
# Remove 'All' from the list
region_account_values.remove("All")
updated_region_account_values = region_account_values

filtered_data = filtered_data[
filtered_data["REGION"].isin(updated_region_account_values)
]
elif len(region_account_values) == 0:
updated_region_account_values = filtered_data["REGION"].unique()
region_account_values = ["All"]
else:
updated_region_account_values = region_account_values

filtered_data = filtered_data[
filtered_data["REGION"].isin(updated_region_account_values)
]

region_filter_options = ["All"] + list(copy_data["REGION"].unique())

Expand Down

0 comments on commit f3af004

Please sign in to comment.