| 1234567891011121314151617181920212223242526272829303132333435 |
- from dash import html, dcc
- import dash_bootstrap_components as dbc
- from utils.file_utils import list_files_in_directory, get_file_metadata
- INTENT_DIR = './training/intents/'
- def IntentsLayout():
- intent_files = list_files_in_directory(INTENT_DIR)
- intent_table = generate_intent_table(intent_files)
-
- return html.Div([
- html.H2("Intent Management"),
- dbc.Button("Add New Intent", id="add-new-intent", color="primary", className="mb-3"),
- html.Div(id="new-intent-input"),
- intent_table,
- html.Div(id="intent-upload-status")
- ])
- def generate_intent_table(files):
- header = [
- html.Thead(html.Tr([html.Th("File Name"), html.Th("Length (s)"), html.Th("Size (KB)"), html.Th("Actions")]))
- ]
- rows = []
- for file in files:
- length, size = get_file_metadata(f"{INTENT_DIR}/{file}")
- rows.append(html.Tr([
- html.Td(file),
- html.Td(length),
- html.Td(size),
- html.Td(
- dbc.Button("Delete", id={'type': 'delete-button', 'index': file}, color='danger')
- )
- ]))
- return dbc.Table(header + [html.Tbody(rows)], bordered=True, hover=True)
|