X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Freport%2Freport.py;h=8330f8721eb8999ff40f0a4ae9ccc5024e656881;hp=d22a0b6705a50110a83f50b50e1d26c6669b687f;hb=3343fe81729eb4005319ca15b1e6881630d38c5b;hpb=b2cb835b34c7404b2aaee3ec30700c67537da66d diff --git a/resources/tools/dash/app/pal/report/report.py b/resources/tools/dash/app/pal/report/report.py index d22a0b6705..8330f8721e 100644 --- a/resources/tools/dash/app/pal/report/report.py +++ b/resources/tools/dash/app/pal/report/report.py @@ -11,21 +11,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Instantiate the Report Dash application. +"""Instantiate the Report Dash applocation. """ - import dash -from dash import dcc -from dash import html -from dash import dash_table -import numpy as np -import pandas as pd +import dash_bootstrap_components as dbc -from .data import create_dataframe -from .layout import html_layout +from .layout import Layout -def init_report(server): +def init_report(server, releases): """Create a Plotly Dash dashboard. :param server: Flask server. @@ -37,40 +31,19 @@ def init_report(server): dash_app = dash.Dash( server=server, routes_pathname_prefix=u"/report/", - external_stylesheets=[ - u"/static/dist/css/styles.css", - u"https://fonts.googleapis.com/css?family=Lato", - ], + external_stylesheets=[dbc.themes.LUX], ) - # Load DataFrame - df = create_dataframe() - # Custom HTML layout - dash_app.index_string = html_layout - - # Create Layout - dash_app.layout = html.Div( - children=[ - create_data_table(df), - ], - id=u"dash-container", + layout = Layout( + app=dash_app, + releases=releases, + html_layout_file="pal/templates/report_layout.jinja2", + graph_layout_file="pal/report/layout.yaml", + data_spec_file="pal/data/data.yaml", + tooltip_file="pal/data/tooltips.yaml" ) - return dash_app.server - + dash_app.index_string = layout.html_layout + dash_app.layout = layout.add_content() -def create_data_table(df): - """Create Dash datatable from Pandas DataFrame. - - DEMO - """ - - table = dash_table.DataTable( - id=u"database-table", - columns=[{u"name": i, u"id": i} for i in df.columns], - data=df.to_dict(u"records"), - sort_action=u"native", - sort_mode=u"native", - page_size=5, - ) - return table + return dash_app.server