Feat: add navigation

This commit is contained in:
Bertrand Benjamin 2024-07-28 12:29:14 +02:00
parent d8f2fb52e1
commit 74882ae572
6 changed files with 104 additions and 65 deletions

View File

View File

@ -0,0 +1,55 @@
from ..libs.stage.stage import AbstractStage
from dash import html, dcc
def html_list_schema(stage:AbstractStage, with_tables=True):
""" Build html list of schema in stage """
ul_classes = "ml-2"
schema_baseurl = f"/stg/{stage.name}/schema/"
if with_tables:
return html.Ul(
[
html.Li(
children = [
dcc.Link(
schema,
href=schema_baseurl + schema,
className="text-lg hover:underline"
),
html_list_table(stage, schema)
],
className=""
) for schema in stage.schemas()
],
className=ul_classes
)
return html.Ul(
[
html.Li(
dcc.Link(
schema,
href=schema_baseurl + schema,
className="text-lg hover:underline"
),
) for schema in stage.schemas()
],
className=ul_classes
)
def html_list_table(stage:AbstractStage, schema:str):
""" Build html list of table in stage """
table_baseurl = f"/stg/{stage.name}/schm/{schema}/table/"
return html.Ul(
[
html.Li(
dcc.Link(
table,
href=table_baseurl + table,
className="hover:underline"
),
) for table in stage.tables(schema=schema)
],
className="ml-4"
)

View File

@ -1,60 +1,6 @@
from dash import html, dcc from dash import html, dcc
from ..datalake import stages from ..datalake import stages
from ..libs.stage.stage import AbstractStage from ..components.lists import html_list_schema
def html_list_schema(stage:AbstractStage, with_tables=True):
""" Build html list of schema in stage """
ul_classes = "ml-2"
schema_baseurl = f"/stg/{stage.name}/schema/"
if with_tables:
return html.Ul(
[
html.Li(
children = [
dcc.Link(
schema,
href=schema_baseurl + schema,
className="text-lg text-bold"
),
html_list_table(stage, schema)
],
className=""
) for schema in stage.schemas()
],
className=ul_classes
)
return html.Ul(
[
html.Li(
dcc.Link(
schema,
href=schema_baseurl + schema,
className="text-lg text-bold"
),
) for schema in stage.schemas()
],
className=ul_classes
)
def html_list_table(stage:AbstractStage, schema:str):
""" Build html list of table in stage """
table_baseurl = f"/stg/{stage.name}/schm/{schema}/table/"
return html.Ul(
[
html.Li(
dcc.Link(
table,
href=table_baseurl + table,
className="text-lg text-bold"
),
) for table in stage.tables(schema=schema)
],
className="ml-4"
)
layout = html.Div([ layout = html.Div([

View File

@ -1,11 +1,24 @@
from dash import html from dash import html, dcc
from ..datalake import stages from ..datalake import stages
from ..libs.stage.stage import AbstractStage from ..libs.stage.stage import AbstractStage
def layout(stage_name=None, schema_name=None): def layout(stage_name=None, schema_name=None):
stage = stages[stage_name]
return html.Div([ return html.Div([
html.H2(f"Stage - {stage_name}"), html.H2([
html.H3(f"Schema - {schema_name}"), dcc.Link(
f"{stage.name}",
href=f"/stage/{stage.name}",
className="hover:underline"
),
html.Span(" > "),
html.Span(
f"{schema_name}",
),
],
className="text-2xl p-4 py-2"
),
]) ])

View File

@ -1,10 +1,18 @@
from dash import html from dash import html, dcc
from ..datalake import stages from ..datalake import stages
from ..libs.stage.stage import AbstractStage from ..libs.stage.stage import AbstractStage
from ..components.lists import html_list_schema
def layout(stage_name=None): def layout(stage_name=None):
stage = stages[stage_name] stage = stages[stage_name]
return html.Div([ return html.Div([
html.H2(f"Stage - {stage_name}")
]) html.H2(
f"{stage.name}",
className="text-2xl p-4 py-2"
),
html_list_schema(stage)
],
className = "flex flex-col"
)

View File

@ -1,13 +1,30 @@
from dash import html from dash import html, dcc
from ..datalake import stages from ..datalake import stages
from ..libs.stage.stage import AbstractStage from ..libs.stage.stage import AbstractStage
def layout(stage_name=None, schema_name=None, table_name=None): def layout(stage_name=None, schema_name=None, table_name=None):
stage = stages[stage_name]
return html.Div([ return html.Div([
html.H2(f"Stage - {stage_name}"), html.H2([
html.H3(f"Schema - {schema_name}"), dcc.Link(
html.H4(f"Table - {table_name}"), f"{stage.name}",
href=f"/stage/{stage.name}",
className="hover:underline"
),
html.Span(" > "),
dcc.Link(
f"{schema_name}",
href=f"/stg/{stage.name}/schema/{schema_name}",
className="hover:underline"
),
html.Span(" > "),
html.Span(table_name),
],
className="text-2xl p-4 py-2"
),
]) ])