Skip to content

Commit

Permalink
fix: few design updates for the AssetManager (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Jan 8, 2025
2 parents f6bd1b8 + 27e25bb commit afd3d93
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 40 deletions.
13 changes: 0 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ repos:
- id: ruff
stages: [pre-commit]

- repo: https://github.com/PyCQA/doc8
rev: "v1.1.1"
hooks:
- id: doc8
stages: [pre-commit]

# crash on ipyvuetify
#- repo: https://github.com/FHPythonUtils/LicenseCheck
# rev: "2023.5.1"
# hooks:
# - id: licensecheck
# stages: [commit]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
Expand Down
16 changes: 5 additions & 11 deletions example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"metadata": {},
"outputs": [],
"source": [
"tm = TaskManager()\n",
"tm.to_sidecar()"
"#tm = TaskManager()\n",
"#tm.to_sidecar()"
]
},
{
Expand All @@ -64,11 +64,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"dataset = (\n",
Expand All @@ -87,8 +83,6 @@
" ]\n",
"}\n",
"\n",
"m.setCenter(22.2, 21.2, 0)\n",
"\n",
"m.addLayer(dataset, visualization, 'Air temperature [K] at 2m height')"
]
},
Expand All @@ -109,7 +103,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -123,7 +117,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.6"
}
},
"nbformat": 4,
Expand Down
33 changes: 20 additions & 13 deletions ipygee/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,18 @@ def __init__(self):
# fmt: off

# add a line of buttons to reload and add new projects
self.w_new = v.Btn(color="error", children="NEW", elevation=2, class_="ma-1", disabled=True)
self.w_reload = v.Btn(children=[v.Icon(color="primary", children="mdi-reload")], elevation=2, class_="ma-1")
self.w_search = v.Btn(children=[v.Icon(color="primary", children="mdi-magnify")], elevation=2, class_="ma-1", disabled=True)
self.w_new = v.Btn(color="error", children="NEW", elevation=2, class_="ml-1", disabled=True, small=True)
self.w_reload = v.Btn(children=[v.Icon(color="primary", children="mdi-reload", small=True)], elevation=2, class_="ma-1", small=True)
self.w_search = v.Btn(children=[v.Icon(color="primary", children="mdi-magnify", small=True)], elevation=2, class_="mr-1", disabled=True, small=True)
w_main_line = v.Flex(children=[self.w_new, self.w_reload, self.w_search])

# generate the asset selector and the CRUD buttons
self.w_selected = v.TextField(readonly=True, placeholder="Selected item", v_model="", clearable=True, outlined=True, class_="ma-1")
self.w_view = v.Btn(children=[v.Icon(color="primary", children="mdi-eye")], disabled=True)
self.w_copy = v.Btn(children=[v.Icon(color="primary", children="mdi-content-copy")], disabled=True)
self.w_move = v.Btn(children=[v.Icon(color="primary", children="mdi-file-move")], disabled=True)
self.w_delete = v.Btn(children=[v.Icon(color="primary", children="mdi-trash-can")], disabled=True)
self.w_selected = v.TextField(readonly=True, label="Selected item", v_model="", clearable=True, outlined=True, class_="mt-1")
self.w_view = v.Btn(children=[v.Icon(color="primary", children="mdi-eye", small=True)], disabled=True, small=True)
self.w_copy = v.Btn(children=[v.Icon(color="primary", children="mdi-content-copy", small=True)], disabled=True, small=True)
self.w_move = v.Btn(children=[v.Icon(color="primary", children="mdi-file-move", small=True)], disabled=True, small=True)
self.w_delete = v.Btn(children=[v.Icon(color="primary", children="mdi-trash-can", small=True)], disabled=True, small=True)
w_btn_list = v.ItemGroup(class_="ma-1 v-btn-toggle",children=[self.w_view, self.w_copy, self.w_move, self.w_delete])
w_selected_line = v.Layout(row=True, children=[w_btn_list, self.w_selected], class_="ma-1")

# generate the initial list
w_group = v.ListItemGroup(children=self.get_items(), v_model="")
Expand All @@ -107,7 +106,7 @@ def __init__(self):

super().__init__(children=[
self.w_delete_dialog, self.w_move_dialog, self.w_asset_dialog, self.w_create_dialog,
w_main_line, w_selected_line, self.w_card
w_main_line, w_btn_list, self.w_selected, self.w_card
], v_model="", class_="ma-1")
# fmt: on

Expand All @@ -121,6 +120,7 @@ def __init__(self):
t.link((self, "selected_item"), (self, "v_model"))
self.w_list.children[0].observe(self.on_item_select, "v_model")
self.w_reload.on_event("click", self.on_reload)
self.w_delete_dialog.observe(self.on_reload, "value")
self.w_copy.on_event("click", self.on_copy)
self.w_delete.on_event("click", self.on_delete)
self.w_selected.observe(self.activate_buttons, "v_model")
Expand Down Expand Up @@ -190,7 +190,9 @@ def get_items(self) -> List[v.ListItem]:
icon = ICON_STYLE[type]["icon"]
color = ICON_STYLE[type]["color"]

action = v.ListItemAction(children=[v.Icon(color=color, children=[icon])], class_="mr-1")
action = v.ListItemAction(
children=[v.Icon(color=color, small=True, children=[icon])], class_="mr-1"
)
content = v.ListItemContent(children=[v.ListItemTitle(children=[i["name"]])])
dst_list = folder_list if type in ["FOLDER", "PROJECT"] else file_list
dst_list.append(v.ListItem(value=i["id"], children=[action, content]))
Expand All @@ -210,7 +212,9 @@ def get_items(self) -> List[v.ListItem]:
name = parent.parts[1] if parent.is_project() else parent.name
name = name or "." # special case for the root

action = v.ListItemAction(children=[v.Icon(color=color, children=[icon])], class_="mr-1")
action = v.ListItemAction(
children=[v.Icon(color=color, small=True, children=[icon])], class_="mr-1"
)
content = v.ListItemContent(children=[v.ListItemTitle(children=[name])])
item = v.ListItem(value=str(parent), children=[action, content])

Expand Down Expand Up @@ -241,7 +245,10 @@ def on_item_select(self, change: dict):

def on_reload(self, *args):
"""Reload the current folder."""
self.on_item_select(change={"new": self.folder})
try:
self.on_item_select(change={"new": self.folder})
except ValueError:
self.on_item_select(change={"new": ee.Asset(self.folder).parent.as_posix()})

def on_copy(self, *args):
"""Copy the selected item to clipboard."""
Expand Down
4 changes: 2 additions & 2 deletions ipygee/map.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""All the map related widgets and functions are here."""
from __future__ import annotations

import geemap
from geemap import core

from .sidecar import HasSideCar


class Map(geemap.Map, HasSideCar):
class Map(core.Map, HasSideCar):
"""A subclass of geemap.Map with a sidecar method."""

sidecar_title = "Map"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies = [
"ipyvuetify",
"natsort",
"sidecar",
"geemap",
"geemap[core]",
]

[[project.authors]]
Expand Down

0 comments on commit afd3d93

Please sign in to comment.