Skip to content

Commit

Permalink
Merge branch 'master' of github.com:luisbarrancos/dashapps
Browse files Browse the repository at this point in the history
  • Loading branch information
luisbarrancos committed Dec 9, 2021
2 parents 5202a6e + 3021af1 commit cbe04ad
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 26 deletions.
1 change: 1 addition & 0 deletions LM_geomap_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
df = df[df["Year"] >= 2000]

countries = list(df.index.unique())
countries.sort()
country_options = [{"label": str(val), "value": str(val)} for val in countries]


Expand Down
1 change: 1 addition & 0 deletions LM_line_datafields.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
df = df[df["Year"] >= 2000]

countries = list(df.index.unique())
countries.sort()
country_options = [{"label": str(val), "value": str(val)} for val in countries]

# Year/range slider
Expand Down
1 change: 1 addition & 0 deletions LM_line_life_expectancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
df = df[df["Year"] >= 2000]

countries = list(df.index.unique())
countries.sort()
country_options = [{"label": str(val), "value": str(val)} for val in countries]


Expand Down
9 changes: 5 additions & 4 deletions LM_submit_social.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,11 @@ def mastodon(n_clicks, summary):

if n_clicks is None or n_clicks == 0:
raise PreventUpdate

# pass
status_code = post_to_mastodon(toot, tags)
app.logger.info("Tried posting, code = {}".format(status_code))
else:
#pass
status_code = post_to_mastodon(toot, tags)
app.logger.info("Tried posting, code = {}".format(status_code))
webbrowser.open(url="https://botsin.space/@deadlineproject",new=2, autoraise=True)

return None

Expand Down
35 changes: 17 additions & 18 deletions LM_user_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,22 @@ def generate_stats(dfc, dfu):
def start_countdown(target_date):
countdown = target_date - datetime.now()

def summarize_data(user_data_local):
# app.logger.info("========user_data_local=====")
# app.logger.info(user_data_local)
# app.logger.info("===========================")
df2 = pd.DataFrame({
"name": [user_data_local[0]],
"age": [user_data_local[1]],
"birthplace": [user_data_local[2]],
"residence": [user_data_local[3]],
"sex": [user_data_local[4]],
"veggie": [user_data_local[5]],
"driver": [user_data_local[6]],
"smoker": [user_data_local[7]],
},)


def summarize_data(user_data_local):
app.logger.info("========user_data_local=====")
app.logger.info(user_data_local)
app.logger.info("===========================")
df2 = pd.DataFrame(
{
"name": [user_data_local[0]],
"age": [user_data_local[1]],
"birthplace": [user_data_local[2]],
"residence": [user_data_local[3]],
"sex": [user_data_local[4]],
"veggie": [user_data_local[5]],
"driver": [user_data_local[6]],
"smoker": [user_data_local[7]],
},
)

data = generate_stats(df1, df2)

Expand Down Expand Up @@ -422,8 +421,8 @@ def trigger_stats_generation(user_data):
Output(component_id="div_submit", component_property="children"),
[Input("dccstore_summary", "data"), Input("url", "pathname")],
)
def update_display_summary(summary, urlpath):
app.logger.info(urlpath)
def update_display_summary(summary,urlpath):
# app.logger.info(urlpath)
# dynamically add restart/submit based on whether data exists
restart = (
dbc.Button(
Expand Down
25 changes: 21 additions & 4 deletions LM_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
# leading to nulls everywhere except the last 15 years or so for most cols
df = df[df["Year"] >= 2000]


countries = list(df.index.unique())
countries.sort()
country_options = [{"label": str(val), "value": str(val)} for val in countries]

# app.logger.info(country_options)
Expand Down Expand Up @@ -177,6 +179,7 @@
],
),
html.Br(),
html.Div(id="my-output", style={"color":"red", "textAlign":"center"}),
html.Div(
dbc.Button(
id="submit-button-state",
Expand All @@ -191,11 +194,10 @@
children="Submit",
color="Primary",
className="me-1",
href="/page1",
href="/page1"
),
className="d-grip gap-2 d-md-flex justify-content-md-end",
),
html.Div(id="my-output"),
html.Div(id="output_graph"),
html.Div(id="output_text", style={"textAlign": "center", "color": "blue"}),
],
Expand All @@ -208,14 +210,14 @@
def update_options_b(search_value):
if not search_value:
raise PreventUpdate
return [o for o in country_options if search_value in o["label"]]
return [o for o in country_options if search_value.lower() in o["label"].lower()]


@app.callback(Output("residence", "options"), Input("residence", "search_value"))
def update_options_r(search_value):
if not search_value:
raise PreventUpdate
return [o for o in country_options if search_value in o["label"]]
return [o for o in country_options if search_value.lower() in o["label"].lower()]


# every selection change will update our dccstore.
Expand Down Expand Up @@ -258,3 +260,18 @@ def sel_user_data(
user_data_local[7] = smoker
app.logger.info(user_data_local)
return user_data_local

# @app.callback(
# Output(component_id="my-output", component_property="children"),
# [
# Input(component_id="submit-button-state", component_property="n_clicks"),
# ],
# )
# def submit_user_details(n_clicks):
# # if n_clicks == 0:
# # raise PreventUpdate

# if '' in user_data_local:
# return "Please make sure all fields have been keyed in."
# else:
# return dcc.Location(pathname="/page5", id="my-output")

0 comments on commit cbe04ad

Please sign in to comment.