nvtbsdwell / app.py
smomtaz's picture
Update app.py
b048f50 verified
Raw
History Blame Contribute Delete
6.56 kB
from shared import app_dir
from utils import create_nav_button
from shiny import App, ui
import shinyswatch
from server import create_server
import numpy as np
from shinywidgets import output_widget, render_widget
app_ui = ui.page_fluid(
ui.tags.style("""
.big-table {
font-size: 22px; /* Increase font size */
padding: 25px; /* Add padding for spacing */
width: 100%; /* Make the card take full width */
overflow-x: auto; /* Enable horizontal scrolling if needed */
}
.big-table table {
width: 100%; /* Make table take full width within card */
}
.title-logo-container {
display: flex;
align-items: center;
gap: 15px; /* Add some space between the logo and title */
}
.title-logo-container img {
max-height: 50px; /* Adjust logo size */
height: auto;
}
.title-logo-container h1 {
margin: 0;
font-size: 28px; /* Adjust title font size */
font-weight: bold; /* Make it bold */
}
"""),
ui.page_fillable(
ui.page_sidebar(
ui.sidebar(
ui.div(
ui.output_image("clientlogo"),
style="display: inline-block; overflow: hidden; max-height: 75px; width: 90%;"
),
ui.card(
create_nav_button(
button_icon="house",
button_label_text="Homepage",
button_link="https://rsginc-nvtbs.hf.space",
#button_cls="btn btn-secondary"
),
create_nav_button(
button_icon = "route",
button_label_text = "Origin-Destination",
button_link = "https://rsginc-nvtbsod.hf.space",
#button_cls="btn btn-secondary"
),
# create_nav_button(
# button_icon = "car",
# button_label_text = "Auto Travel",
# button_link = "https://www.rsginc.com"
# ),
create_nav_button(
button_icon = "house-laptop",
button_label_text = "Home-Work Location",
button_link = "https://rsginc-nvtbsdwell.hf.space",
button_cls="btn btn-secondary"
),
create_nav_button(
button_icon = "clipboard-question",
button_label_text = "Survey",
button_link = "https://rsginc-nvtbssurvey.hf.space"
),
),
ui.div(
ui.output_image("rsglogo"),
style="display: inline-block; overflow: hidden; max-height: 40px; width: 50%;"
),
open="desktop",
),
ui.include_css(app_dir / "styles.css"),
ui.div(
ui.tags.div(
ui.h1("NAPA Valley Travels", style="margin: 0; font-size: 28px; font-weight: bold;"),
class_="title-logo-container"
),
style="padding-bottom: 20px;"
),
# Tabs inside a card
ui.card(
ui.tags.h5("NAPA Resident and Worker's Home-Work trips", style="text-align: center; font-weight: bold; margin-bottom: 15px;"), # Add card title
ui.navset_card_underline(
ui.nav_panel(
"Home and Work Locations",
ui.tags.div(
ui.HTML("""
<div class='tableauPlaceholder' id='viz1738051129521' style='position: relative'><noscript><a href='#'><img alt='Dashboard 1 ' src='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;aX&#47;aX7_K9zB1_P3q6V8m2_N5L0t7_J9y4G2c&#47;Dashboard1&#47;1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='aX7_K9zB1_P3q6V8m2_N5L0t7_J9y4G2c&#47;Dashboard1' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='https:&#47;&#47;public.tableau.com&#47;static&#47;images&#47;aX&#47;aX7_K9zB1_P3q6V8m2_N5L0t7_J9y4G2c&#47;Dashboard1&#47;1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='language' value='en-US' /><param name='filter' value='publish=yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1738051129521'); var vizElement = divElement.getElementsByTagName('object')[0]; if ( divElement.offsetWidth > 800 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else { vizElement.style.width='100%';vizElement.style.height='1127px';} var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>
"""
),
),
),
),
style="padding: 10px; margin-top: 20px;",
class_="tabbed-card",
),
)
),
theme=shinyswatch.theme.spacelab,
)
app = App(app_ui, create_server(app_dir))
if __name__ == "__main__":
import asyncio
try:
app.run() # Use this for environments without a running event loop
except RuntimeError as e:
if "asyncio.run()" in str(e):
asyncio.run(app.start()) # Fallback for environments with an active event loop