8000 Add loading widgets by edan-bainglass · Pull Request #193 · aiidalab/aiidalab-home · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 78 add 8000 itions & 32 deletions code_setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@
"</style>\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"\n",
"\n",
"class LoadingWidget(ipw.HBox):\n",
" \"\"\"Widget for displaying a loading spinner.\"\"\"\n",
"\n",
" def __init__(self, message=\"Loading\", **kwargs):\n",
" super().__init__(\n",
" children=[\n",
" ipw.Label(message),\n",
" ipw.HTML(\"<i class='fa fa-spinner fa-spin fa-2x fa-fw'/>\"),\n",
" ],\n",
" layout=ipw.Layout(justify_content=\"center\"),\n",
" **kwargs,\n",
" )\n",
" self.add_class(\"loading\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -87,24 +111,12 @@
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"from aiidalab_widgets_base.computational_resources import ResourceSetupBaseWidget\n",
"from aiidalab_widgets_base.utils import StatusHTML\n",
"\n",
"setup_message = StatusHTML(clear_after=15)\n",
"\n",
"widget = ResourceSetupBaseWidget()\n",
"ipw.dlink(\n",
" (widget, \"message\"),\n",
" (setup_message, \"message\"),\n",
")\n",
"\n",
"ipw.VBox(\n",
"new_codes_widget_container = ipw.VBox(\n",
" children=[\n",
" widget,\n",
" setup_message,\n",
" ]\n",
")"
" LoadingWidget(\"Loading resource setup widget\"),\n",
" ],\n",
")\n",
"display(new_codes_widget_container)"
]
},
{
Expand All @@ -118,6 +130,44 @@
"Below are the available codes in the AiiDA database. Use the controls to filter the list by label, executable path, and visibility. You can mark individual codes as _hidden_ to exclude them from code selectors used in apps (note that some apps may enforce the inclusion of hidden codes). Click **Unhide all** to include all codes. If codes are deleted from the database, click **Refresh codes** to reflect the change in the list.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"available_codes_widget_container = ipw.VBox(\n",
" children=[\n",
" LoadingWidget(\"Loading available codes\"),\n",
" ],\n",
")\n",
"display(available_codes_widget_container)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as ipw\n",
"from aiidalab_widgets_base.computational_resources import ResourceSetupBaseWidget\n",
"from aiidalab_widgets_base.utils import StatusHTML\n",
"\n",
"setup_message = StatusHTML(clear_after=15)\n",
"\n",
"widget = ResourceSetupBaseWidget()\n",
"ipw.dlink(\n",
" (widget, \"message\"),\n",
" (setup_message, \"message\"),\n",
")\n",
"\n",
"new_codes_widget_container.children = [\n",
" widget,\n",
" setup_message,\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -146,14 +196,10 @@
")\n",
"refresh_button.on_click(lambda _: render())\n",
"\n",
"display(\n",
" ipw.VBox(\n",
" children=[\n",
" refresh_button,\n",
" output,\n",
" ]\n",
" )\n",
")\n",
"available_codes_widget_container.children = [\n",
" refresh_button,\n",
" output,\n",
"]\n",
"\n",
"render()"
]
Expand All @@ -164,15 +210,15 @@
"metadata": {},
"outputs": [],
"source": [
"def on_code_setup_message_change(change):\n",
" if \"created\" in change[\"new\"]:\n",
" render()\n",
"# def on_code_setup_message_change(change):\n",
"# if \"created\" in change[\"new\"]:\n",
"# render()\n",
"\n",
"\n",
"widget.aiida_code_setup.observe(\n",
" on_code_setup_message_change,\n",
" \"message\",\n",
")"
"# widget.aiida_code_setup.observe(\n",
"# on_code_setup_message_change,\n",
"# \"message\",\n",
"# )"
]
}
],
Expand Down
0