File size: 4,117 Bytes
94d0dc9
 
6670df7
57d7bf6
c014c03
94d0dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d4079e
94d0dc9
 
 
930d8f3
2b1beee
0e6992d
2b1beee
d92e35a
 
 
 
94d0dc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0561fb
 
94d0dc9
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import streamlit as st
import pyrebase
from streamlit_option_menu import option_menu 

import annotator


# APP PAGE SETTINGS

st.set_page_config(page_title="BAMSCAPE", page_icon=":bird:", layout='wide', initial_sidebar_state='auto')

st.markdown("""
     <style>
       .css-o18uir.e16nr0p33 {
         margin-top: -75px;
       }
     </style>
   """, unsafe_allow_html=True)

st.markdown(
    """
      <style>
          div.stButton > button {background-color: #64B5F6;}
          div.Controls_container__LTeAA > button {background: purple !important;}
          .block-container {
                  padding-top: 2.5rem;
                  padding-bottom: 0rem;
                  padding-left: 5rem;
                  padding-right: 5rem;
              }

          iframe[title="streamlit_text_label.label_select"] .ant-btn {background: orange !important;}
          iframe[title="streamlit_text_label.label_select"] .ant-btn-primary {background: orange !important;}
          .ant-btn {background: violet !important;}
          .ant-btn-primary {background: violet !important;}
          button.ant-btn {background: violet !important;}
          button.ant-btn-primary {background: violet !important;}
      </style>
    """, unsafe_allow_html=True
)

# MAIN PAGE HEADER

col1, col2 = st.columns((1, 10))
with col1:
    st.image('bioacoustics_logo_large2.gif', width=90)
with col2:
    st.header(':green[Brazilian Team] &mdash;' ' ' ':violet[_Bioacoustics_ :bird:]')


# FIREBASE KEYS AND AUTHENTICATION

firebaseConfig = {
    'apiKey': st.secrets["config_firebase"][10:49],
    'authDomain': st.secrets["config_firebase"][65:92],
    'projectId': st.secrets["config_firebase"][107:118],
    'databaseURL': st.secrets["config_firebase"][135:183],
    'storageBucket': st.secrets["config_firebase"][202:225],
    'messagingSenderId': st.secrets["config_firebase"][248:259],
    'appId': st.secrets["config_firebase"][270:310],
    'measurementId': st.secrets["config_firebase"][329:341],
}

fire = pyrebase.initialize_app(firebaseConfig)
auth = fire.auth()

# DATABASE

db = fire.database()
storage = fire.storage()

# MAIN APP

if 'useremail' not in st.session_state:
    st.session_state.useremail = ''


def f():
    try:
        auth.sign_in_with_email_and_password(email, password)
        st.session_state.signout = True
        st.session_state.signedout = True
        st.session_state.useremail = email
    except:
        st.text(' ')


def t():
    st.session_state.signout = False
    st.session_state.signedout = False


if 'signedout' not in st.session_state:
    st.session_state['signedout'] = False

if 'signout' not in st.session_state:
    st.session_state['signout'] = False

if not st.session_state['signedout']:
    st.subheader(':orange[Please, log-in to access the interface]')
    email = st.text_input(':blue[E-mail]', placeholder='Enter your e-mail')
    password = st.text_input(':blue[Password]', placeholder='Enter your password', type='password')

    if st.button('Login', on_click=f):
        try:
            auth.sign_in_with_email_and_password(email, password)
            st.session_state.useremail = email
            st.session_state.signout = True
            st.session_state.signedout = True

        except:
            st.warning('Login failed, please enter a valid email/password')

if st.session_state.signout:
    username = st.session_state.useremail
    username = username.split('@')[0]
    st.subheader(f':blue[Hello]' + ' ' + f':gray[{username}]' + ' ' + '👋🏻')
    st.button('Sign out', on_click=t)
    st.markdown('#####')
    bio = option_menu(menu_title=None,
                      options=['Home', 'Database', 'Identification'],
                      icons=['house', 'volume-up', 'layers'],
                      default_index=0,
                      styles={"nav-link": {"font-size": "17px", "text-align": "left", "margin": "0px"},
                              "nav-link-selected": {"background-color": "orange"}},
                      orientation='horizontal')

    if bio == 'Identification':
        annotator.iden()

    st.markdown('#')