Skip to content

Commit

Permalink
feat: use landing page as ui default card
Browse files Browse the repository at this point in the history
  • Loading branch information
dfguerrerom committed Aug 31, 2023
1 parent c9da838 commit 0c4c750
Showing 1 changed file with 20 additions and 189 deletions.
209 changes: 20 additions & 189 deletions ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@
},
"outputs": [],
"source": [
"from sepal_ui import sepalwidgets as sw\n",
"from component.tile.reclassify import *\n",
"from component import model\n",
"from component import tile\n",
"from component.message import cm"
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Create an appBar\n",
"app_bar = sw.AppBar(cm.app.title)"
"from sepal_ui import sepalwidgets as sw\n",
"from component.tile.reclassify import *\n",
"from component import model\n",
"from component import tile\n",
"from component.message import cm"
]
},
{
Expand All @@ -31,10 +33,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Create a footer\n",
"# the footer will be display in the bottom of the page\n",
"# it's not a mandatory feature\n",
"app_footer = sw.Footer(cm.app.footer.format(2020))"
"# Create an appBar\n",
"app_bar = sw.AppBar(cm.app.title)"
]
},
{
Expand All @@ -49,55 +49,6 @@
"disclaimer_tile = tile.TileDisclaimer()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# hack of the about_tile to create a licence tile\n",
"licence_tile = sw.TileAbout(\"utils/EULA.md\")\n",
"licence_tile._metadata[\"mount_id\"] = \"licence_tile\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"acc_model = model.AccModel()\n",
"acc_title = sw.Tile(acc_model.tile_id, cm.acc.title, [sw.Markdown(cm.acc.description)])\n",
"acc_convert = tile.ConvertByte(acc_model, 4)\n",
"acc_process = tile.AccTile(acc_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dist_model = model.DistModel()\n",
"dist_title = sw.Tile(\n",
" dist_model.tile_id, cm.dist.title, [sw.Markdown(cm.dist.description)]\n",
")\n",
"dist_convert = tile.ConvertByte(dist_model, 2)\n",
"dist_process = tile.DistTile(dist_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fad_model = model.FadModel()\n",
"fad_title = sw.Tile(fad_model.tile_id, cm.fad.title, [sw.Markdown(cm.fad.description)])\n",
"fad_convert = tile.ConvertByte(fad_model, 4)\n",
"fad_process = tile.FadTile(fad_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -106,66 +57,9 @@
},
"outputs": [],
"source": [
"frag_model = model.FragModel()\n",
"frag_title = sw.Tile(\n",
" frag_model.tile_id, cm.frag.title, [sw.Markdown(cm.frag.description)]\n",
")\n",
"frag_convert = tile.ConvertByte(frag_model, 4)\n",
"frag_process = tile.FragTile(frag_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lm_model = model.LmModel()\n",
"lm_title = sw.Tile(lm_model.tile_id, cm.lm.title, [sw.Markdown(cm.lm.description)])\n",
"lm_convert = tile.ConvertByte(lm_model, 3)\n",
"lm_process = tile.LmTile(lm_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mspa_model = model.MspaModel()\n",
"mspa_title = sw.Tile(\n",
" mspa_model.tile_id, cm.mspa.title, [sw.Markdown(cm.mspa.description)]\n",
")\n",
"mspa_convert = tile.ConvertByte(mspa_model, 2)\n",
"mspa_process = tile.MspaTile(mspa_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"p223_model = model.P223Model()\n",
"p223_title = sw.Tile(\n",
" p223_model.tile_id, cm.p223.title, [sw.Markdown(cm.p223.description)]\n",
")\n",
"p223_convert = tile.ConvertByte(p223_model, 5)\n",
"p223_process = tile.P223Tile(p223_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"parc_model = model.ParcModel()\n",
"parc_title = sw.Tile(\n",
" parc_model.tile_id, cm.parc.title, [sw.Markdown(cm.parc.description)]\n",
")\n",
"parc_convert = tile.ConvertByte(parc_model, 0)\n",
"parc_process = tile.ParcTile(parc_model)"
"# hack of the about_tile to create a licence tile\n",
"licence_tile = sw.TileAbout(\"utils/EULA.md\")\n",
"licence_tile._metadata[\"mount_id\"] = \"licence_tile\""
]
},
{
Expand All @@ -176,31 +70,8 @@
},
"outputs": [],
"source": [
"rss_model = model.RssModel()\n",
"rss_title = sw.Tile(rss_model.tile_id, cm.rss.title, [sw.Markdown(cm.rss.description)])\n",
"rss_convert = tile.ConvertByte(rss_model, 2)\n",
"rss_process = tile.RssTile(rss_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"spa_model = model.SpaModel()\n",
"spa_title = sw.Tile(spa_model.tile_id, cm.spa.title, [sw.Markdown(cm.spa.description)])\n",
"spa_convert = tile.ConvertByte(spa_model, 2)\n",
"spa_process = tile.SpaTile(spa_model)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"reclass_ui = ReclassifyUI()"
"from component.tile.landing_tile import LandingTile\n",
"landing_tile = LandingTile()"
]
},
{
Expand All @@ -211,37 +82,7 @@
"source": [
"# Gather all the partial tiles that you created previously\n",
"app_content = [\n",
" acc_title,\n",
" acc_convert,\n",
" acc_process,\n",
" dist_title,\n",
" dist_convert,\n",
" dist_process,\n",
" fad_title,\n",
" fad_convert,\n",
" fad_process,\n",
" frag_title,\n",
" frag_convert,\n",
" frag_process,\n",
" lm_title,\n",
" lm_convert,\n",
" lm_process,\n",
" mspa_title,\n",
" mspa_convert,\n",
" mspa_process,\n",
" p223_title,\n",
" p223_convert,\n",
" p223_process,\n",
" parc_title,\n",
" parc_convert,\n",
" parc_process,\n",
" rss_title,\n",
" rss_convert,\n",
" rss_process,\n",
" spa_title,\n",
" spa_convert,\n",
" spa_process,\n",
" reclass_ui,\n",
" landing_tile,\n",
" about_tile,\n",
" disclaimer_tile,\n",
" licence_tile,\n",
Expand All @@ -258,17 +99,7 @@
"# use the DrawerItem widget from sepalwidget (name_of_drawer, icon, the id of the widgets you want to display)\n",
"# use the display_tile() method to link the times with the drawer items\n",
"items = [\n",
" sw.DrawerItem(cm.app.drawer_item.acc, \"mdi-cogs\", card=acc_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.dist, \"mdi-cogs\", card=dist_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.fad, \"mdi-cogs\", card=fad_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.frag, \"mdi-cogs\", card=frag_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.lm, \"mdi-cogs\", card=lm_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.mspa, \"mdi-cogs\", card=mspa_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.p223, \"mdi-cogs\", card=p223_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.parc, \"mdi-cogs\", card=parc_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.rss, \"mdi-cogs\", card=rss_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.spa, \"mdi-cogs\", card=spa_model.tile_id),\n",
" sw.DrawerItem(cm.app.drawer_item.rcl, \"mdi-cogs\", card=\"reclassify\"),\n",
" sw.DrawerItem(\"GWB processes\", \"mdi-cogs\", card=\"landing_tile\"),\n",
" sw.DrawerItem(cm.app.drawer_item.about, \"mdi-help-circle\", card=\"about_tile\"),\n",
" sw.DrawerItem(cm.app.drawer_item.licence, \"mdi-gavel\", card=\"licence_tile\"),\n",
"]\n",
Expand All @@ -292,7 +123,7 @@
"source": [
"# build the Html final app by gathering everything\n",
"app = sw.App(\n",
" tiles=app_content, appBar=app_bar, footer=app_footer, navDrawer=app_drawer\n",
" tiles=app_content, appBar=app_bar, navDrawer=app_drawer\n",
").show_tile(\n",
" \"about_tile\"\n",
") # id of the tile you want to display"
Expand Down

0 comments on commit 0c4c750

Please sign in to comment.