Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: few design updates for the AssetManager #36

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ repos:
- id: ruff
stages: [commit]

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

# crash on ipyvuetify
#- repo: https://github.com/FHPythonUtils/LicenseCheck
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
Loading