Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic Access to Care Dash app #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions dash-app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output

import pandas as pd
import requests

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])

text_style = dict(textAlign='center', color='#4D8DC9', fontFamily='sans-serif', fontWeight=300)

colors = {
'background': '#F8F8F8',
'text': '#404040',
'accent': '#E7553C',
'darkblue': '#447099'
}

RSTUDIO_LOGO = "https://d33wubrfki0l68.cloudfront.net/1ac3f0e3753f18c7e2a8893957d1841fba1e3d08/48a33/wp-content/uploads/2018/10/rstudio-logo-flat.png"


search_bar = dbc.Row(
[
dbc.Input(id="state", value="NY", type="text"),
],
no_gutters=True,
className="ml-auto flex-nowrap mt-3 mt-md-0",
align="center",
)

app.layout = html.Div(style={'backgroundColor': colors['background']}, children=[

dbc.Navbar(
[
html.A(
# Use row and col to control vertical alignment of logo / brand
dbc.Row(
[
dbc.Col(html.Img(src=RSTUDIO_LOGO, height="30px")),
dbc.Col(dbc.NavbarBrand("Access to Hospital Care", className="ml-2")),
],
align="center",
no_gutters=True,
),
href="https://solutions.rstudio.com/",
),
dbc.Collapse(search_bar, navbar=True),
],
color="#447099",
dark=True,
),

html.Div(id="summary"),
html.Div(id="counties")
#dbc.Table.from_dataframe(counties, id='counties', striped=True, bordered=True, hover=True)

])

@app.callback(
Output("summary","children"),
[Input("state","value")]
)
def update_summary(value):
st_summary = requests.get('https://colorado.rstudio.com/rsc/access-to-care/api/summary?state=' + value)
summary = pd.DataFrame.from_dict(st_summary.json())
return dbc.Table.from_dataframe(summary, dark=True, striped=True, bordered=True, hover=True)

@app.callback(
Output("counties","children"),
[Input("state","value")]
)
def update_counties(value):
st_detail = requests.get('https://colorado.rstudio.com/rsc/access-to-care/api/state?state=' + value)
counties = pd.DataFrame.from_dict(st_detail.json())
return dbc.Table.from_dataframe(counties, striped=True, bordered=True, hover=True)

if __name__ == '__main__':
app.run_server(debug=True)
24 changes: 24 additions & 0 deletions dash-app/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 1,
"metadata": {
"appmode": "python-dash",
"entrypoint": "app"
},
"locale": "en_US.UTF-8",
"python": {
"version": "3.7.7",
"package_manager": {
"name": "pip",
"version": "20.0.2",
"package_file": "requirements.txt"
}
},
"files": {
"requirements.txt": {
"checksum": "94405065ec0890bb0ec7b36d315b807d"
},
"app.py": {
"checksum": "6739b4286d10c18de6b0bcf475499fb0"
}
}
}
6 changes: 6 additions & 0 deletions dash-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dash
dash_core_components
dash_html_components
dash_bootstrap_components
pandas
requests