Skip to content

Commit afd3d93

Browse files
authored
fix: few design updates for the AssetManager (#36)
2 parents f6bd1b8 + 27e25bb commit afd3d93

File tree

5 files changed

+28
-40
lines changed

5 files changed

+28
-40
lines changed

.pre-commit-config.yaml

-13
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,6 @@ repos:
3232
- id: ruff
3333
stages: [pre-commit]
3434

35-
- repo: https://github.com/PyCQA/doc8
36-
rev: "v1.1.1"
37-
hooks:
38-
- id: doc8
39-
stages: [pre-commit]
40-
41-
# crash on ipyvuetify
42-
#- repo: https://github.com/FHPythonUtils/LicenseCheck
43-
# rev: "2023.5.1"
44-
# hooks:
45-
# - id: licensecheck
46-
# stages: [commit]
47-
4835
- repo: https://github.com/codespell-project/codespell
4936
rev: v2.2.4
5037
hooks:

example.ipynb

+5-11
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"metadata": {},
4848
"outputs": [],
4949
"source": [
50-
"tm = TaskManager()\n",
51-
"tm.to_sidecar()"
50+
"#tm = TaskManager()\n",
51+
"#tm.to_sidecar()"
5252
]
5353
},
5454
{
@@ -64,11 +64,7 @@
6464
{
6565
"cell_type": "code",
6666
"execution_count": null,
67-
"metadata": {
68-
"jupyter": {
69-
"source_hidden": true
70-
}
71-
},
67+
"metadata": {},
7268
"outputs": [],
7369
"source": [
7470
"dataset = (\n",
@@ -87,8 +83,6 @@
8783
" ]\n",
8884
"}\n",
8985
"\n",
90-
"m.setCenter(22.2, 21.2, 0)\n",
91-
"\n",
9286
"m.addLayer(dataset, visualization, 'Air temperature [K] at 2m height')"
9387
]
9488
},
@@ -109,7 +103,7 @@
109103
],
110104
"metadata": {
111105
"kernelspec": {
112-
"display_name": "Python 3",
106+
"display_name": "Python 3 (ipykernel)",
113107
"language": "python",
114108
"name": "python3"
115109
},
@@ -123,7 +117,7 @@
123117
"name": "python",
124118
"nbconvert_exporter": "python",
125119
"pygments_lexer": "ipython3",
126-
"version": "3.10.12"
120+
"version": "3.12.6"
127121
}
128122
},
129123
"nbformat": 4,

ipygee/asset.py

+20-13
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,18 @@ def __init__(self):
8080
# fmt: off
8181

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

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

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

108107
super().__init__(children=[
109108
self.w_delete_dialog, self.w_move_dialog, self.w_asset_dialog, self.w_create_dialog,
110-
w_main_line, w_selected_line, self.w_card
109+
w_main_line, w_btn_list, self.w_selected, self.w_card
111110
], v_model="", class_="ma-1")
112111
# fmt: on
113112

@@ -121,6 +120,7 @@ def __init__(self):
121120
t.link((self, "selected_item"), (self, "v_model"))
122121
self.w_list.children[0].observe(self.on_item_select, "v_model")
123122
self.w_reload.on_event("click", self.on_reload)
123+
self.w_delete_dialog.observe(self.on_reload, "value")
124124
self.w_copy.on_event("click", self.on_copy)
125125
self.w_delete.on_event("click", self.on_delete)
126126
self.w_selected.observe(self.activate_buttons, "v_model")
@@ -190,7 +190,9 @@ def get_items(self) -> List[v.ListItem]:
190190
icon = ICON_STYLE[type]["icon"]
191191
color = ICON_STYLE[type]["color"]
192192

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

213-
action = v.ListItemAction(children=[v.Icon(color=color, children=[icon])], class_="mr-1")
215+
action = v.ListItemAction(
216+
children=[v.Icon(color=color, small=True, children=[icon])], class_="mr-1"
217+
)
214218
content = v.ListItemContent(children=[v.ListItemTitle(children=[name])])
215219
item = v.ListItem(value=str(parent), children=[action, content])
216220

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

242246
def on_reload(self, *args):
243247
"""Reload the current folder."""
244-
self.on_item_select(change={"new": self.folder})
248+
try:
249+
self.on_item_select(change={"new": self.folder})
250+
except ValueError:
251+
self.on_item_select(change={"new": ee.Asset(self.folder).parent.as_posix()})
245252

246253
def on_copy(self, *args):
247254
"""Copy the selected item to clipboard."""

ipygee/map.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""All the map related widgets and functions are here."""
22
from __future__ import annotations
33

4-
import geemap
4+
from geemap import core
55

66
from .sidecar import HasSideCar
77

88

9-
class Map(geemap.Map, HasSideCar):
9+
class Map(core.Map, HasSideCar):
1010
"""A subclass of geemap.Map with a sidecar method."""
1111

1212
sidecar_title = "Map"

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies = [
2626
"ipyvuetify",
2727
"natsort",
2828
"sidecar",
29-
"geemap",
29+
"geemap[core]",
3030
]
3131

3232
[[project.authors]]

0 commit comments

Comments
 (0)