Demo1 / app.py
savigdor's picture
nnn
59ecc5c
import panel as pn
from panel.template import FastListTemplate
from CyberIndexDashboard import CyberIndexDashboard
main_area = pn.Column("")
ext="External"
def main():
global main_area
pn.extension('echarts','tabulator')
pn.config.sizing_mode="stretch_width"
# Instantiate pages and add them to the pages dictionarqy
pages = {
"CEIDashboard": CyberIndexDashboard("Region","CEI","CEI Avg."),
"GCIDashboard": CyberIndexDashboard("Region","GCI","GCI Avg."),
"NCSIDashboard": CyberIndexDashboard("Region","NCSI","NCSI Avg."),
"DDLDashboard": CyberIndexDashboard("Region","DDL","DDL Avg."),
}
# Create the main area and display the first page
sidebar = None
data_source_info = pn.pane.Markdown("""
***The data describes cyber attacks split by continent***
***Data is taken from [Kaggle](https://www.kaggle.com/datasets/katerynameleshenko/cyber-security-indexes)!***
""")
# Function to show the selected page
# Define buttons to navigate between pages
#Dashboard_button = pn.widgets.Button(name="Dashboard", button_type="primary")
# Set up button click callbacks
#Dashboard_button.on_click(lambda event: show_page(pages["Dashboard"]))
#@pn.depends(x, y, color)
#def plot(xval, yval, colorval):
# return autompg.hvplot.scatter(xval, yval, c=colorval)
#sidebar = pn.Column(Dashboard_button)
#radio_button_group = pn.widgets.RadioButtonGroup(
# name='Index', options=["NCSI", 'CEI','GCI', 'DDL'],button_type='success',orientation='vertical',value='NCSI')
radio_button_group = pn.widgets.ToggleGroup(name='Index', options=['NCSI', 'CEI','GCI', 'DDL'], behavior="radio",button_type='primary',orientation='vertical')
def page_selector(radio_button_group,main_area):
print("radio_button_group.value="+radio_button_group)
main_area.clear()
main_area.append(pages[radio_button_group+"Dashboard"].view())
return pages[radio_button_group+"Dashboard"]
#p = pn.bind(page_selector,radio_button_group,main_area)
def update(event):
global main_area
main_area.clear()
main_area.append(pages[radio_button_group.value+"Dashboard"].view())
radio_button_group.param.watch(update,'value',onlychanged=True)
radio_button_group.param.trigger('value')
sidebar = pn.Column(pn.Row(radio_button_group),pn.Row(data_source_info))
#main_area = pn.Column(pages["NCSIDashboard"].view())
def show_page(page_instance,main_area):
globals
main_area.clear()
main_area.append(page_instance.view())
return main_area
#main_area = pn.bind(show_page,a_page,main_area)
# Create the Material Template and set the sidebar and main area
template = FastListTemplate(
title="Cyber Operations Instances",
sidebar=[sidebar],
main=[main_area],
)
pn.state.cache["template"] = template
pn.state.cache["modal"] = template.modal
# Serve the Panel app
template.servable()
main()