import gradio as gr import scripts.mo.ui_styled_html as styled from scripts.mo.environment import env def on_id_changed(record_id): if record_id is not None and record_id: record = env.storage.get_record_by_id(record_id) if record is None: return [ gr.HTML.update(value=f'Record with id {record_id} was not found.'), gr.HTML.update(visible=False), gr.Textbox.update(value=''), gr.Button.update(visible=False), gr.Button.update(visible=False) ] else: return [ gr.HTML.update(value=styled.record_details(record)), gr.HTML.update(visible=bool(record.description)), gr.Textbox.update(value=record.description), gr.Button.update(visible=True), gr.Button.update(visible=record.is_download_possible()) ] return [ gr.HTML.update(value=f'No record id passed.'), gr.HTML.update(visible=False), gr.Textbox.update(value=''), gr.Button.update(visible=False), gr.Button.update(visible=False) ] def details_ui_block(): with gr.Blocks(): details_id_box = gr.Textbox(label='details_id_box', elem_classes='mo-alert-warning', visible=False) with gr.Row(): back_button = gr.Button("Back") remove_button = gr.Button("Remove") edit_button = gr.Button('Edit') download_button = gr.Button("Download") content_widget = gr.HTML() description_html = '
Description:
' \ '