2024-07-27 17:19:36 +00:00
|
|
|
from dash import html, dcc
|
2024-07-27 15:39:09 +00:00
|
|
|
from ..datalake import stages
|
|
|
|
from ..libs.stage.stage import AbstractStage
|
|
|
|
|
|
|
|
|
|
|
|
def html_list_schema(stage:AbstractStage, with_tables=True):
|
|
|
|
""" Build html list of schema in stage """
|
2024-07-27 16:45:20 +00:00
|
|
|
ul_classes = "ml-2"
|
2024-07-27 17:19:36 +00:00
|
|
|
schema_baseurl = f"/stg/{stage.name}/schema/"
|
2024-07-27 15:39:09 +00:00
|
|
|
if with_tables:
|
|
|
|
return html.Ul(
|
|
|
|
[
|
|
|
|
html.Li(
|
|
|
|
children = [
|
2024-07-27 17:19:36 +00:00
|
|
|
dcc.Link(
|
2024-07-27 16:45:20 +00:00
|
|
|
schema,
|
2024-07-27 17:19:36 +00:00
|
|
|
href=schema_baseurl + schema,
|
2024-07-27 16:45:20 +00:00
|
|
|
className="text-lg text-bold"
|
|
|
|
),
|
2024-07-27 15:39:09 +00:00
|
|
|
html_list_table(stage, schema)
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className=""
|
2024-07-27 15:39:09 +00:00
|
|
|
) for schema in stage.schemas()
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className=ul_classes
|
2024-07-27 15:39:09 +00:00
|
|
|
)
|
|
|
|
return html.Ul(
|
|
|
|
[
|
2024-07-27 16:45:20 +00:00
|
|
|
html.Li(
|
2024-07-27 17:19:36 +00:00
|
|
|
dcc.Link(
|
|
|
|
schema,
|
|
|
|
href=schema_baseurl + schema,
|
|
|
|
className="text-lg text-bold"
|
|
|
|
),
|
|
|
|
) for schema in stage.schemas()
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className=ul_classes
|
2024-07-27 15:39:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def html_list_table(stage:AbstractStage, schema:str):
|
|
|
|
""" Build html list of table in stage """
|
2024-07-27 17:19:36 +00:00
|
|
|
table_baseurl = f"/stg/{stage.name}/schm/{schema}/table/"
|
2024-07-27 15:39:09 +00:00
|
|
|
return html.Ul(
|
|
|
|
[
|
2024-07-27 17:19:36 +00:00
|
|
|
html.Li(
|
|
|
|
dcc.Link(
|
|
|
|
table,
|
|
|
|
href=table_baseurl + table,
|
|
|
|
className="text-lg text-bold"
|
|
|
|
),
|
|
|
|
) for table in stage.tables(schema=schema)
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className="ml-4"
|
2024-07-27 15:39:09 +00:00
|
|
|
)
|
|
|
|
|
2024-07-27 13:55:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
layout = html.Div([
|
2024-07-27 15:39:09 +00:00
|
|
|
html.Div(children=[
|
|
|
|
html.Ul(
|
|
|
|
children=[
|
|
|
|
html.Li(
|
|
|
|
children=[
|
2024-07-27 17:19:36 +00:00
|
|
|
dcc.Link(
|
2024-07-27 16:45:20 +00:00
|
|
|
stagename,
|
2024-07-27 17:19:36 +00:00
|
|
|
href=f"/stage/{stagename}",
|
2024-07-27 16:45:20 +00:00
|
|
|
className="text-2xl text-center p-2 bg-amber-100 rounded shadow"
|
2024-07-27 17:19:36 +00:00
|
|
|
),
|
2024-07-27 15:39:09 +00:00
|
|
|
html_list_schema(stage)
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className="flex-1 bg-gray-100 rounded flex flex-col shadow"
|
2024-07-27 15:39:09 +00:00
|
|
|
) for stagename, stage in stages.items()
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className="flex flex-row space-x-2"
|
2024-07-27 15:39:09 +00:00
|
|
|
)
|
2024-07-27 16:45:20 +00:00
|
|
|
],
|
|
|
|
className="w-full mt-4 px-2"
|
|
|
|
),
|
2024-07-27 13:55:20 +00:00
|
|
|
])
|