Ronio Jerico Roque commited on
Commit
fc7ba35
·
1 Parent(s): e2a65de

Add client summary functionality and update button behavior in home page

Browse files
classes/client_summary.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from dotenv import load_dotenv
4
+ import os
5
+ import pandas as pd
6
+ import pandas._libs.tslibs.parsing
7
+ import time
8
+ import chardet
9
+ from helper.telemetry import collect_telemetry
10
+ from helper.upload_File import uploadFile
11
+ from helper.button_behaviour import hide_button
12
+ from helper.initialize_analyze_session import initialize_analyze_session
13
+
14
+
15
+ class CientSummary:
16
+ def __init__(self):
17
+ self.initialize()
18
+ self.row1()
19
+
20
+ def initialize(self):
21
+ # FOR ENV
22
+ load_dotenv()
23
+ if 'client_summary' not in st.session_state:
24
+ st.session_state['client_summary'] = ''
25
+
26
+ def process (self):
27
+ with st.spinner('Seo Analyst...', show_time=True):
28
+ st.write('')
29
+ client_summary = ""
30
+ # INITIALIZING SESSIONS
31
+ client_summary += f"Client Summary: {self.client_summary}\n"
32
+
33
+ debug_client_summary = {'data_field' : 'Client Summary', 'result': client_summary}
34
+
35
+ if self.client_summary:
36
+ st.session_state['client_summary'] = 'uploaded'
37
+ collect_telemetry(debug_client_summary)
38
+
39
+ def row1(self):
40
+ self.client_summary = st.text_area("Client Summary:", help="Name of business, nature of business, location, products/services")
41
+ session = st.session_state.analyze
42
+ if self.client_summary and session == 'clicked':
43
+ self.process()
44
+
45
+ if __name__ == "__main__":
46
+ st.set_page_config(layout="wide")
47
+
48
+ upload = uploadFile()
helper/upload_button.py CHANGED
@@ -4,7 +4,7 @@ def hide_button():
4
  st.markdown(
5
  """
6
  <style>
7
- .element-container:nth-of-type(3) button {
8
  display: none;
9
  }
10
  </style>
@@ -16,7 +16,7 @@ def unhide_button():
16
  st.markdown(
17
  """
18
  <style>
19
- element-container:nth-of-type(3) button {
20
  display: inline;
21
  }
22
  </style>
 
4
  st.markdown(
5
  """
6
  <style>
7
+ .element-container:nth-of-type(2) button {
8
  display: none;
9
  }
10
  </style>
 
16
  st.markdown(
17
  """
18
  <style>
19
+ element-container:nth-of-type(2) button {
20
  display: inline;
21
  }
22
  </style>
pages/home.py CHANGED
@@ -12,6 +12,7 @@ from classes.Youtube import YouTube
12
  from classes.Linkedin import Linkedin
13
  from classes.Tiktok import Tiktok
14
  from classes.website_and_tools import WebsiteAndTools
 
15
  import asyncio
16
  import time
17
  from helper.upload_button import hide_button, unhide_button
@@ -33,32 +34,28 @@ class DigitalFootprintDashboard:
33
  st.session_state['nature'] = ''
34
  if 'analyze' not in st.session_state:
35
  st.session_state['analyze'] = ''
36
-
37
  async def create_row1(self):
38
  """Create the first row with four columns"""
39
  col1, col2, col3, col4 = st.columns(4, border=True, gap="medium", vertical_alignment="top")
40
 
41
  with col1:
42
- txt = st.text_area(
43
- "Client Summary:",
44
- f"{st.session_state.nature}",
45
- help="Name of business, nature of business, location, products/services"
46
- )
47
- st.session_state.nature = txt
48
-
49
- upload_file_button = st.button("Upload File", st.session_state['analyze'])
50
- if upload_file_button == True:
51
  st.session_state["analyze"] = 'clicked'
52
  unhide_button()
53
  else:
54
  st.session_state["analyze"] = ''
55
 
56
- analyze_button = st.button("Analyze")
57
- if analyze_button == True:
58
  st.switch_page("pages/analyzing_page.py")
59
  else:
60
  hide_button()
61
-
 
 
62
  with col2:
63
  st.write("## Website Traffic")
64
  self.backlinks = SeoOffPageAnalyst(os.getenv('MODEL_Off_Page_Analyst'))
 
12
  from classes.Linkedin import Linkedin
13
  from classes.Tiktok import Tiktok
14
  from classes.website_and_tools import WebsiteAndTools
15
+ from classes.client_summary import CientSummary
16
  import asyncio
17
  import time
18
  from helper.upload_button import hide_button, unhide_button
 
34
  st.session_state['nature'] = ''
35
  if 'analyze' not in st.session_state:
36
  st.session_state['analyze'] = ''
37
+
38
  async def create_row1(self):
39
  """Create the first row with four columns"""
40
  col1, col2, col3, col4 = st.columns(4, border=True, gap="medium", vertical_alignment="top")
41
 
42
  with col1:
43
+
44
+ self.upload_file_button = st.button("Upload File", st.session_state['analyze'])
45
+ if self.upload_file_button == True:
 
 
 
 
 
 
46
  st.session_state["analyze"] = 'clicked'
47
  unhide_button()
48
  else:
49
  st.session_state["analyze"] = ''
50
 
51
+ self.analyze_button = st.button("Analyze")
52
+ if self.analyze_button == True:
53
  st.switch_page("pages/analyzing_page.py")
54
  else:
55
  hide_button()
56
+
57
+ self.client_summary = CientSummary()
58
+
59
  with col2:
60
  st.write("## Website Traffic")
61
  self.backlinks = SeoOffPageAnalyst(os.getenv('MODEL_Off_Page_Analyst'))