streamlit_src.views package
Submodules
streamlit_src.views.admin_view module
- class streamlit_src.views.admin_view.AdminView[source]
Bases:
UserViewA class to handle all user interface elements for the admin.
- confirm_checks(checks: Dict[str, bool]) bool[source]
Displays a confirmation checkbox for the user to confirm the requirements.
- Parameters:
checks – A dictionary of requirements and their current values.
- Returns:
True if all the requirements are confirmed, False otherwise.
- display_datatable(data: DataFrame, message: str) None[source]
Displays a table of the data.
- Parameters:
data – The data to be displayed.
message – The message to be displayed above the table.
- display_feature_importance(feature_importances: DataFrame) None[source]
Displays the feature importance graph using Plotly for better aesthetics.
- Parameters:
features – A list of feature names.
importance_values – A list of corresponding importance values.
- download_button(label: str, data: str, file_name: str) None[source]
Creates a download button for the user to download the data.
- Parameters:
label – The label of the button.
data – The data to be downloaded.
file_name – The name of the file to be downloaded.
- show_admin_pages() str[source]
Displays a dropdown for selecting different admin pages.
- Returns:
The selected page from the dropdown.
- Return type:
str
streamlit_src.views.home_view module
- class streamlit_src.views.home_view.HomeView[source]
Bases:
objectThe HomeView class manages the layout and logic for the home page, including the user and admin dashboard navigation.
- None
- prompt_admin_password() str[source]
Prompts the user for the admin password.
This method is responsible for prompting the user for the admin password when the user navigates to the admin dashboard. It displays a text input field in the sidebar with a placeholder saying “Enter Admin Password:”.
- Returns:
The password entered by the user.
- Return type:
str
streamlit_src.views.user_view module
- class streamlit_src.views.user_view.UserView[source]
Bases:
objectA class to handle all user interface elements.
- compare_to_who(warnings: list) None[source]
Compare the current pollutant concentrations with WHO guidelines and display the results.
- Parameters:
warnings (list) – A list of tuples containing the pollutant, message, and level (error or success) of the warning.
- data_not_available() None[source]
Show an error message indicating that data is not available.
This is shown when the current time is between 00:00 and 04:15, when the measurements aren’t accurate enough to produce a prediction. The data will be automatically updated at 04:15 with the prediction for the next three days.
- display_predictions_gaugeplot(gauge_plots: list) None[source]
Show a gauge plot of the predictions.
- Parameters:
gauge_plots (list) – A list of tuples containing the day, formatted date, and two plotly figures (for NO2 and O3).
- display_predictions_lineplot(fig: Figure) None[source]
Show a line plot of the predictions.
- Parameters:
fig (go.Figure) – The plotly figure to be displayed.
- error(message: str) None[source]
Show an error message.
- Parameters:
message (str) – The message to be displayed.
- print_sources(sources: list) None[source]
Print the sources used in the application.
- Parameters:
sources (list) – A list of tuples containing the source text and URL.
- quiz(question: str, options: list) tuple[source]
Ask a quiz question and return the answer and whether the answer was correct.
- Parameters:
question (str) – The question to be asked.
options (list) – A list of strings containing the options.
- Returns:
A tuple containing the answer and a boolean indicating whether the answer was correct.
- Return type:
tuple
- raise_awareness(random_fact: str, awareness_expanders: list, health_message: dict) None[source]
Raise awareness about air quality issues and provide health recommendations.
- Parameters:
random_fact (str) – A random fact about air quality.
awareness_expanders (list) – A list of tuples containing the title and content of the expanders.
health_message (dict) – A dictionary containing the health recommendation message and type (error or success).
- show_current_data(merged_data_df: DataFrame) None[source]
Show the current pollutant concentrations along with WHO guidelines.
- Parameters:
merged_data_df (pd.DataFrame) – A pandas DataFrame containing the current pollutant concentrations and WHO guidelines.
- success(message: str) None[source]
Show a success message.
- Parameters:
message (str) – The message to be displayed.
- two_columns_layout(ratio: float, left_function: Callable, right_function: Callable) None[source]
Divide the page into two columns and call the left and right functions within them.
- Parameters:
ratio (float) – The ratio of the left to the right column.
left_function (Callable) – The function to be called in the left column.
right_function (Callable) – The function to be called in the right column.