Skip to content

Commit

Permalink
Adicionado o dropdown que permite escolher os cursos na barra lateral
Browse files Browse the repository at this point in the history
  • Loading branch information
Oesterd committed Mar 6, 2024
1 parent a07186d commit eebde0e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 56 deletions.
52 changes: 5 additions & 47 deletions src/Reusables/Sidebars.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
def pg1():
content = \
html.Div([
html.Div(
[
html.H2("Opções", style={"color": "black"}),
],
style={'text-align': 'center'}
),

html.Div([
dmc.Select(id='dropdown11', label='Escolha o eixo x:', value='Média aluno',
data=list(Ops2.keys()), clearable=False),
Expand Down Expand Up @@ -80,13 +73,6 @@ def pg1():
def pg2():
content = \
html.Div([
html.Div(
[
html.H2("Opções", style={"color": "black"}),
],
style={'text-align': 'center'}
),

html.Div([
html.Div([
dmc.Select(id='dropdown20', label='Escolha o eixo x:', value='Renda (R$)',
Expand Down Expand Up @@ -135,13 +121,6 @@ def pg2():
def pg3():
content = \
html.Div([
html.Div(
[
html.H2("Opções", style={"color": "black"}),
],
style={'text-align': 'center'}
),

html.Div([
dmc.Select(
id='dropdown31', label='Tipo de gráfico:', value='stpf',
Expand All @@ -163,18 +142,6 @@ def pg4():

content = \
html.Div([
html.Div(
[
html.H2("Opções", style={"color": "black"}),
],
style={'text-align': 'center'}
),

html.Div([
dmc.Select(id='dropdown40', label='Escolha o curso', value='Curso1',
data=['Curso1', 'Curso2'], clearable=False)
]),

html.Div([
dmc.MultiSelect(id='Mdropdown41', label='Escolha a(s) disciplina(s)', value=[],
data=Disc, searchable=True, clearable=True)
Expand All @@ -190,7 +157,8 @@ def pg4():
dmc.Select(id='dropdown41', label='Escolha o eixo y:', value='Média turma',
data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False),
]),
]
],
style={'display': 'flex', 'flexDirection': 'column', 'gap': 20, 'flex': 1}
)

return content
Expand All @@ -201,14 +169,6 @@ def pg4():
def pg5():
content = \
html.Div([
html.Div(
[
html.H2("Opções", style={"color": "black"}),
],
style={'text-align': 'center'}
),


html.Div([
dmc.MultiSelect(id='Mdropdown51', label='Escolha a(s) disciplina(s)', value=[],
data=Disc, searchable=True, clearable=True)
Expand All @@ -222,10 +182,8 @@ def pg5():


html.Div([
html.Div([
dmc.Select(id='dropdown51', label='Escolha o eixo y:', value='Média turma',
data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False),
]),
dmc.Select(id='dropdown51', label='Escolha o eixo y:', value='Média turma',
data=['Média turma', 'AP', 'RM', 'RF', 'RMF'], clearable=False),
]),


Expand All @@ -252,7 +210,7 @@ def pg5():

],
style={'display': 'flex', 'flexDirection': 'column', 'gap': 20, 'flex': 1}
),
)

return content

Expand Down
40 changes: 31 additions & 9 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def read_data(ID, Sheet):
)



navwidth = '0px'


Expand Down Expand Up @@ -164,6 +163,21 @@ def read_data(ID, Sheet):
fixed=False,
hidden=True,
width={"base": navwidth},
children=[
html.Div(
[
html.H2("Opções", style={"color": "black"}),
],
style={'text-align': 'center'}
),

dmc.Select(id='Curso', label='Escolha o curso',
data=['Curso1', 'Curso2'], value='Curso1'),

html.Br(),

html.Div(id='sidebar-div', children=[])
],
position='right',
style={
"overflow": "auto",
Expand Down Expand Up @@ -213,15 +227,16 @@ def read_data(ID, Sheet):
Output('Dados_notas', 'data'),
Output('Dados_turmas', 'data'),
Input('Intervalo', 'n_intervals'),
Input('Curso', 'value'),
)
def gather_data(n_intervals):
def gather_data(n_intervals, curso):


Dados_notas = read_data(ID_notas, 'Sheet1')
Notas_df = Dados_notas.iloc[:, 0:10]
Notas_df = Notas_df.to_dict('records')

Turmas_df = read_data(ID_turmas, Turmas_sheet)
Turmas_df = read_data(ID_turmas, curso)
Turmas_df['Turma'] = pd.to_datetime(Turmas_df['Turma'], format='%Y/%m')
Turmas_df['Turma'] = Turmas_df['Turma'].dt.date
Turmas_df = Turmas_df.to_dict('records')
Expand All @@ -231,12 +246,14 @@ def gather_data(n_intervals):


@callback(
Output('sidebar', 'children'),
Output('sidebar-div', 'children'),
Output('Intervalo2', 'n_intervals'),
State('Intervalo2', 'n_intervals'),
Output('Curso', 'disabled'),
Input('url', 'pathname'),
State('Intervalo2', 'n_intervals'),
State('Curso', 'disabled'),
)
def nav_content(n, url):
def nav_content(url, n, disabled):


content = {
Expand All @@ -247,16 +264,21 @@ def nav_content(n, url):
'/pg5': pg5(),
}.get(url)


# O uso de intervalo como Input do callback em cada página previne um trigger indesejado
# enquanto o layout da página está incompleto, evitando mensagens de erro
if n <= 50:
n += 1
else:
n = 0

if url == '/pg3':
disabled = True

else:
disabled = False


return content, n
return content, n, disabled



Expand All @@ -279,4 +301,4 @@ def drawer_demo(opened, width):


if __name__ == "__main__":
app.run(debug=False, host="0.0.0.0")
app.run(debug=True, host="localhost")

0 comments on commit eebde0e

Please sign in to comment.