-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout.py
More file actions
184 lines (179 loc) · 7.42 KB
/
layout.py
File metadata and controls
184 lines (179 loc) · 7.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from dash import dcc, html
import dash_bootstrap_components as dbc
import base64
import validation_api
from config import Config
def create_layout(app_version: str, svg_logo: str) -> html.Div:
"""
Creates the main Dash application layout.
Args:
app_version: The current application version string.
svg_logo: The raw SVG content string for the logo.
Returns:
The Dash HTML layout component.
"""
return html.Div(
className="app-container",
children=[
# Header
html.Div(
className="app-header",
children=[
# Left side: Logo and App Name
html.Div(
className="header-left",
children=[
html.Img(
src=f"data:image/svg+xml;base64,{base64.b64encode(svg_logo.encode('utf-8')).decode('utf-8')}",
className="app-logo",
),
html.H1("Validator UI", className="app-title"),
],
),
# Right side: Swagger Button and RSL Version
html.Div(
className="header-right",
children=[
html.A(
"Swagger API",
href="/apidocs",
target="_blank",
className="btn btn-outline-light btn-sm me-3",
role="button",
),
html.Div(
id="rsl-version",
children=f"App: {app_version} RSL: {validation_api.get_ruleset_version()}",
className="rsl-version",
),
],
),
],
),
# Main content
html.Div(
className="main-content",
children=[
dcc.Location(id="page-state", refresh=False),
# System Status Alert
dbc.Alert(
id="system-status-alert",
dismissable=False,
is_open=True,
fade=True,
),
# RSL Configuration (Bootstrap) - Now at the Top
dbc.Accordion(
id="rsl-accordion",
children=[
dbc.AccordionItem(
title="Upload RSL",
children=[
dcc.Upload(
id="upload-rsl",
children=html.Div(
[
"Drag and Drop or ",
html.A("Select RSL Zip File"),
]
),
className="upload-box",
multiple=False,
),
html.Div(id="rsl-upload-status"),
],
),
],
start_collapsed=True,
className="mb-3",
),
# Validation Controls
html.Div(
[
html.Label("Validation Gate:", className="me-2"),
dcc.Dropdown(
id="validation-gate-dropdown",
options=[
{"label": "Full", "value": "full"},
{"label": "Full IGM", "value": "full_igm"},
{"label": "Full CGM", "value": "full_cgm"},
{"label": "BDS", "value": "bds"},
],
value="full",
clearable=False,
className="validation-gate-dropdown",
disabled=True,
),
],
className="validation-gate-container",
),
dbc.Button(
"Validate",
id="btn-validate",
color="primary",
className="me-1",
outline=True,
disabled=True,
),
dbc.Button(
"Delete All",
id="btn-delete-all",
color="danger",
className="me-1",
outline=True,
),
dbc.Button(
"Delete All but BDS",
id="btn-delete-all-keep-bds",
color="warning",
className="me-1",
outline=True,
),
dcc.Interval(
id="progress-interval",
interval=Config.PROGRESS_POLL_INTERVAL_MS,
n_intervals=0,
disabled=True,
),
dbc.Progress(
id="validation-progress",
value=0,
striped=True,
animated=True,
className="progress-bar-container",
# style is handled dynamically via callback for display
style={"display": "none"},
),
dcc.Loading(
id="loading-upload",
type="default",
children=[
dcc.Upload(
id="upload-data",
children=html.Div(
[
"Drag and Drop or ",
html.A("Select Files"),
" for validation.",
]
),
className="upload-box",
multiple=True,
),
],
),
html.Div(id="uploaded-files"),
html.Div(id="folder-content"),
html.Div(id="download-validation-result"),
html.Div(
id="validation-result",
children=None,
className="validation-results",
),
],
),
],
)