Skip to content

Commit

Permalink
better login process
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuttlas90 committed Jul 14, 2024
1 parent 84a7ee8 commit f766b75
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 31 deletions.
5 changes: 4 additions & 1 deletion login.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ def check_local_token():
st.session_state["token"] = local_saved_token
else:
local_storage.deleteItem("saved_token")
_login()
else:
_login()

def login():
def _login():
"""start login process of a user"""
get_email = st.form("get_email")
get_email.text_input('ایمیل خود را وارد کنید',
Expand Down
8 changes: 3 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas as pd
import altair as alt

from login import check_local_token, login
from login import check_local_token
from request import vasahm_query
from menu import add_menu
from text_constant import MAIN_PAGE
Expand All @@ -17,7 +17,7 @@
page_title="وسهم",
page_icon="./assets/favicon.ico",
initial_sidebar_state='expanded')
st.session_state.ver = '0.1.7'
st.session_state.ver = '0.1.8'

STREAMLIT_STATIC_PATH = Path(st.__path__[0]) / "static/static"
CSS_PATH = STREAMLIT_STATIC_PATH / "media/"
Expand Down Expand Up @@ -49,9 +49,7 @@ def sfmono():
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

check_local_token()
if "token" not in st.session_state:
login()
else:
if "token" in st.session_state:
df = pd.read_csv("data.csv").dropna()
list_of_name = df['name'].to_list()
name = st.sidebar.selectbox("لیست سهام", options = list_of_name)
Expand Down
7 changes: 6 additions & 1 deletion pages/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
with open("style.css", encoding="utf-8") as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
add_menu()
if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')


st.subheader('changelog: `version 0.1.8`', divider='rainbow')
st.markdown('''
* افزودن صفحه بررسی و مقایسه صندوقهای اهرمی
* رفع باگهای کوچک''', unsafe_allow_html=False, help=None)
st.subheader('changelog: `version 0.1.7`', divider='rainbow')
st.markdown('''
* تغییر فرآیند لاگین کردن
Expand Down
2 changes: 0 additions & 2 deletions pages/leveraged_funds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
with open( "style.css", encoding='UTF-8') as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
add_menu()

# st.sidebar.image(image="./assets/logo.png")
if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

Expand Down
2 changes: 0 additions & 2 deletions pages/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
with open( "style.css", encoding='UTF-8') as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
add_menu()

# st.sidebar.image(image="./assets/logo.png")
if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

Expand Down
11 changes: 4 additions & 7 deletions pages/monthly_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pages.helper.query import Queries

from login import check_local_token, login
from login import check_local_token
from request import vasahm_query
from slider import create_range_slider
from menu import add_menu
Expand All @@ -19,14 +19,11 @@
with open( "style.css", encoding='UTF-8') as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
add_menu()


st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')
if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

check_local_token()
if "token" not in st.session_state:
login()
else:
if "token" in st.session_state:
queries = Queries()
has_error, data = vasahm_query(queries.QUERY_MONTHLY_COMPARE)
if has_error:
Expand Down
9 changes: 4 additions & 5 deletions pages/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd
import altair as alt

from login import check_local_token, login
from login import check_local_token
from request import index_price_history, index_price_history2
from request import vasahm_query
from menu import add_menu
Expand All @@ -20,7 +20,8 @@
with open("style.css", encoding="utf-8") as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
add_menu()

if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

df = pd.read_csv("data.csv").dropna()
list_of_name = df['name'].to_list()
Expand Down Expand Up @@ -72,9 +73,7 @@ def create_form():
portfolio_analyzer.form_submit_button("بررسی عملکرد سبد", on_click=add_submit_state)

check_local_token()
if "token" not in st.session_state:
login()
else:
if "token" in st.session_state:
if "porto_submition" not in st.session_state:
st.number_input('تعداد سهام موجود در سبد خود را وارد کنید',
min_value=1,
Expand Down
3 changes: 0 additions & 3 deletions pages/simple_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
with open( "style.css", encoding='UTF-8') as css:
st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
add_menu()


# st.sidebar.image(image="./assets/logo.png")
if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

Expand Down
9 changes: 4 additions & 5 deletions pages/workbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import streamlit as st
import pandas as pd

from login import check_local_token, login
from login import check_local_token
from request import vasahm_query
from menu import add_menu

Expand All @@ -19,12 +19,11 @@


add_menu()
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')
if "ver" in st.session_state:
st.sidebar.header(f'Vasahm DashBoard `{st.session_state.ver}`')

check_local_token()
if "token" not in st.session_state:
login()
else:
if "token" in st.session_state:

txt = st.text_area(
"Text to analyze",
Expand Down

0 comments on commit f766b75

Please sign in to comment.