atodorov284 commited on
Commit
7b24758
·
1 Parent(s): b2381d4

Flake8 checks and hashlib is a standard lib, remove from reqs.

Browse files
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ
 
streamlit_src/app.py CHANGED
@@ -1,4 +1,4 @@
1
  from controllers.home_controller import HomeController
2
-
3
  if __name__ == "__main__":
4
  HomeController()
 
1
  from controllers.home_controller import HomeController
2
+
3
  if __name__ == "__main__":
4
  HomeController()
streamlit_src/controllers/admin_controller.py CHANGED
@@ -1,13 +1,14 @@
1
  from models.air_quality_model import AirQualityModel
2
  from views.admin_view import AdminView
3
 
 
4
  class AdminController:
5
  def __init__(self):
6
  self.model = AirQualityModel()
7
  self.view = AdminView()
8
 
9
  def show_dashboard(self):
10
- return
11
  # Get today's data and predictions
12
  today_data = self.model.get_today_data()
13
  next_three_days = self.model.next_three_day_predictions()
@@ -15,7 +16,7 @@ class AdminController:
15
  # WHO Guidelines
16
  who_guidelines = {
17
  "Pollutant": ["NO2 (µg/m³)", "O3 (µg/m³)"],
18
- "WHO Guideline": [self.model.WHO_NO2_LEVEL, self.model.WHO_O3_LEVEL]
19
  }
20
 
21
  # Display current data and predictions
@@ -23,7 +24,9 @@ class AdminController:
23
  self.view.display_predictions(next_three_days)
24
 
25
  # Compare to WHO guidelines
26
- self.view.compare_to_who(today_data, self.model.WHO_NO2_LEVEL, self.model.WHO_O3_LEVEL)
27
-
 
 
28
  def welcome_back(self):
29
- self.view.welcome_back()
 
1
  from models.air_quality_model import AirQualityModel
2
  from views.admin_view import AdminView
3
 
4
+
5
  class AdminController:
6
  def __init__(self):
7
  self.model = AirQualityModel()
8
  self.view = AdminView()
9
 
10
  def show_dashboard(self):
11
+ return
12
  # Get today's data and predictions
13
  today_data = self.model.get_today_data()
14
  next_three_days = self.model.next_three_day_predictions()
 
16
  # WHO Guidelines
17
  who_guidelines = {
18
  "Pollutant": ["NO2 (µg/m³)", "O3 (µg/m³)"],
19
+ "WHO Guideline": [self.model.WHO_NO2_LEVEL, self.model.WHO_O3_LEVEL],
20
  }
21
 
22
  # Display current data and predictions
 
24
  self.view.display_predictions(next_three_days)
25
 
26
  # Compare to WHO guidelines
27
+ self.view.compare_to_who(
28
+ today_data, self.model.WHO_NO2_LEVEL, self.model.WHO_O3_LEVEL
29
+ )
30
+
31
  def welcome_back(self):
32
+ self.view.welcome_back()
streamlit_src/controllers/home_controller.py CHANGED
@@ -5,15 +5,18 @@ from controllers.admin_controller import AdminController
5
  from views.home_view import HomeView
6
  import hashlib
7
 
 
8
  class HomeController:
9
- __ADMIN_PASSWORD_HASH = '240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9'
 
 
10
 
11
  def __init__(self):
12
  self.home_view = HomeView()
13
  self.user_controller = UserController()
14
  self.admin_controller = AdminController()
15
  self._run()
16
-
17
  def _hash_password(self, password):
18
  """Hash the input password using SHA-256."""
19
  return hashlib.sha256(password.encode()).hexdigest()
 
5
  from views.home_view import HomeView
6
  import hashlib
7
 
8
+
9
  class HomeController:
10
+ __ADMIN_PASSWORD_HASH = (
11
+ "240be518fabd2724ddb6f04eeb1da5967448d7e831c08c8fa822809f74c720a9"
12
+ )
13
 
14
  def __init__(self):
15
  self.home_view = HomeView()
16
  self.user_controller = UserController()
17
  self.admin_controller = AdminController()
18
  self._run()
19
+
20
  def _hash_password(self, password):
21
  """Hash the input password using SHA-256."""
22
  return hashlib.sha256(password.encode()).hexdigest()
streamlit_src/models/air_quality_model.py CHANGED
@@ -1,25 +1,28 @@
1
  import pandas as pd
2
  import numpy as np
3
 
4
- class AirQualityModel():
 
5
  def __init__(self) -> None:
6
-
7
  self.WHO_NO2_LEVEL = 25
8
  self.WHO_O3_LEVEL = 100
9
  pass
10
-
11
  def get_today_data(self):
12
  today_data = {
13
  "NO2 (µg/m³)": np.random.uniform(20, 60), # Simulated data
14
- "O3 (µg/m³)": np.random.uniform(50, 120) # Simulated data
15
  }
16
  return today_data
17
 
18
  # Function to retrieve predictions for the next three days (replace with actual model predictions)
 
19
  def next_three_day_predictions(self):
20
- next_three_days = pd.DataFrame({
21
- "Day": ["Day 1", "Day 2", "Day 3"],
22
- "NO2 (µg/m³)": np.random.uniform(20, 60, 3),
23
- "O3 (µg/m³)": np.random.uniform(50, 120, 3)
24
- })
25
- return next_three_days
 
 
 
1
  import pandas as pd
2
  import numpy as np
3
 
4
+
5
+ class AirQualityModel:
6
  def __init__(self) -> None:
 
7
  self.WHO_NO2_LEVEL = 25
8
  self.WHO_O3_LEVEL = 100
9
  pass
10
+
11
  def get_today_data(self):
12
  today_data = {
13
  "NO2 (µg/m³)": np.random.uniform(20, 60), # Simulated data
14
+ "O3 (µg/m³)": np.random.uniform(50, 120), # Simulated data
15
  }
16
  return today_data
17
 
18
  # Function to retrieve predictions for the next three days (replace with actual model predictions)
19
+
20
  def next_three_day_predictions(self):
21
+ next_three_days = pd.DataFrame(
22
+ {
23
+ "Day": ["Day 1", "Day 2", "Day 3"],
24
+ "NO2 (µg/m³)": np.random.uniform(20, 60, 3),
25
+ "O3 (µg/m³)": np.random.uniform(50, 120, 3),
26
+ }
27
+ )
28
+ return next_three_days
streamlit_src/views/admin_view.py CHANGED
@@ -4,25 +4,28 @@ import pandas as pd
4
  from datetime import date
5
  import time
6
 
 
7
  class AdminView:
8
  def show_current_data(self, today_data, who_guidelines):
9
- return
10
- st.sidebar.markdown(f"ADMIN Today's Date: **{date.today().strftime('%B %d, %Y')}**")
 
 
11
  st.sidebar.markdown("### Current Pollutant Concentrations")
12
  today_data_df = pd.DataFrame([today_data])
13
  st.sidebar.dataframe(today_data_df.style.hide(axis="index"))
14
-
15
  st.sidebar.markdown("### WHO Guidelines")
16
  who_guidelines_df = pd.DataFrame(who_guidelines)
17
  st.sidebar.dataframe(who_guidelines_df.style.hide(axis="index"))
18
 
19
  def display_predictions(self, next_three_days):
20
- return
21
  st.markdown("### Predictions for the Next 3 Days")
22
  st.line_chart(next_three_days.set_index("Day"))
23
 
24
  def compare_to_who(self, today_data, no2_level, o3_level):
25
- return
26
  if today_data["NO2 (µg/m³)"] > no2_level:
27
  st.sidebar.error("⚠️ NO2 levels are above WHO guidelines!")
28
  else:
@@ -32,10 +35,10 @@ class AdminView:
32
  st.sidebar.error("⚠️ O3 levels are above WHO guidelines!")
33
  else:
34
  st.sidebar.success("✅ O3 levels are within safe limits.")
35
-
36
  def welcome_back(self):
37
  st.empty()
38
  placeholder = st.empty()
39
  placeholder.success("Welcome back!")
40
  time.sleep(2)
41
- placeholder.empty()
 
4
  from datetime import date
5
  import time
6
 
7
+
8
  class AdminView:
9
  def show_current_data(self, today_data, who_guidelines):
10
+ return
11
+ st.sidebar.markdown(
12
+ f"ADMIN Today's Date: **{date.today().strftime('%B %d, %Y')}**"
13
+ )
14
  st.sidebar.markdown("### Current Pollutant Concentrations")
15
  today_data_df = pd.DataFrame([today_data])
16
  st.sidebar.dataframe(today_data_df.style.hide(axis="index"))
17
+
18
  st.sidebar.markdown("### WHO Guidelines")
19
  who_guidelines_df = pd.DataFrame(who_guidelines)
20
  st.sidebar.dataframe(who_guidelines_df.style.hide(axis="index"))
21
 
22
  def display_predictions(self, next_three_days):
23
+ return
24
  st.markdown("### Predictions for the Next 3 Days")
25
  st.line_chart(next_three_days.set_index("Day"))
26
 
27
  def compare_to_who(self, today_data, no2_level, o3_level):
28
+ return
29
  if today_data["NO2 (µg/m³)"] > no2_level:
30
  st.sidebar.error("⚠️ NO2 levels are above WHO guidelines!")
31
  else:
 
35
  st.sidebar.error("⚠️ O3 levels are above WHO guidelines!")
36
  else:
37
  st.sidebar.success("✅ O3 levels are within safe limits.")
38
+
39
  def welcome_back(self):
40
  st.empty()
41
  placeholder = st.empty()
42
  placeholder.success("Welcome back!")
43
  time.sleep(2)
44
+ placeholder.empty()
streamlit_src/views/home_view.py CHANGED
@@ -1,18 +1,18 @@
1
  import streamlit as st
2
 
 
3
  class HomeView:
4
-
5
  def __init__(self):
6
  self.set_layout()
7
-
8
  def set_layout(self):
9
  st.set_page_config(page_title="Air Quality Monitoring Dashboard", layout="wide")
10
  st.sidebar.title("Air Quality Monitoring")
11
-
12
  def show_dashboard_switch(self):
13
  page = st.sidebar.radio("Go to", ["User Dashboard", "Admin Dashboard"])
14
  return page
15
-
16
  def prompt_admin_password(self):
17
  st.sidebar.markdown("### Admin Access Required")
18
- return st.sidebar.text_input("Enter Admin Password:", type="password")
 
1
  import streamlit as st
2
 
3
+
4
  class HomeView:
 
5
  def __init__(self):
6
  self.set_layout()
7
+
8
  def set_layout(self):
9
  st.set_page_config(page_title="Air Quality Monitoring Dashboard", layout="wide")
10
  st.sidebar.title("Air Quality Monitoring")
11
+
12
  def show_dashboard_switch(self):
13
  page = st.sidebar.radio("Go to", ["User Dashboard", "Admin Dashboard"])
14
  return page
15
+
16
  def prompt_admin_password(self):
17
  st.sidebar.markdown("### Admin Access Required")
18
+ return st.sidebar.text_input("Enter Admin Password:", type="password")
streamlit_src/views/user_view.py CHANGED
@@ -3,13 +3,14 @@ import streamlit as st
3
  import pandas as pd
4
  from datetime import date
5
 
 
6
  class UserView:
7
  def show_current_data(self, today_data, who_guidelines):
8
  st.sidebar.markdown(f"Today's Date: **{date.today().strftime('%B %d, %Y')}**")
9
  st.sidebar.markdown("### Current Pollutant Concentrations")
10
  today_data_df = pd.DataFrame([today_data])
11
  st.sidebar.dataframe(today_data_df.style.hide(axis="index"))
12
-
13
  st.sidebar.markdown("### WHO Guidelines")
14
  who_guidelines_df = pd.DataFrame(who_guidelines)
15
  st.sidebar.dataframe(who_guidelines_df.style.hide(axis="index"))
 
3
  import pandas as pd
4
  from datetime import date
5
 
6
+
7
  class UserView:
8
  def show_current_data(self, today_data, who_guidelines):
9
  st.sidebar.markdown(f"Today's Date: **{date.today().strftime('%B %d, %Y')}**")
10
  st.sidebar.markdown("### Current Pollutant Concentrations")
11
  today_data_df = pd.DataFrame([today_data])
12
  st.sidebar.dataframe(today_data_df.style.hide(axis="index"))
13
+
14
  st.sidebar.markdown("### WHO Guidelines")
15
  who_guidelines_df = pd.DataFrame(who_guidelines)
16
  st.sidebar.dataframe(who_guidelines_df.style.hide(axis="index"))