nova-trame 0.21.0__py3-none-any.whl → 0.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nova/trame/model/data_selector.py +31 -32
- nova/trame/view/components/data_selector.py +2 -0
- nova/trame/view/theme/assets/core_style.scss +8 -0
- nova/trame/view_model/data_selector.py +30 -1
- {nova_trame-0.21.0.dist-info → nova_trame-0.22.0.dist-info}/METADATA +1 -1
- {nova_trame-0.21.0.dist-info → nova_trame-0.22.0.dist-info}/RECORD +9 -9
- {nova_trame-0.21.0.dist-info → nova_trame-0.22.0.dist-info}/LICENSE +0 -0
- {nova_trame-0.21.0.dist-info → nova_trame-0.22.0.dist-info}/WHEEL +0 -0
- {nova_trame-0.21.0.dist-info → nova_trame-0.22.0.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
import os
|
4
4
|
from pathlib import Path
|
5
|
-
from typing import Any, List, Optional
|
5
|
+
from typing import Any, Dict, List, Optional
|
6
6
|
from warnings import warn
|
7
7
|
|
8
8
|
from natsort import natsorted
|
@@ -140,7 +140,7 @@ class DataSelectorModel:
|
|
140
140
|
|
141
141
|
return natsorted(experiments)
|
142
142
|
|
143
|
-
def sort_directories(self, directories: List[Any]) -> List[Any]:
|
143
|
+
def sort_directories(self, directories: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
144
144
|
# Sort the current level of dictionaries
|
145
145
|
sorted_dirs = natsorted(directories, key=lambda x: x["title"])
|
146
146
|
|
@@ -164,9 +164,11 @@ class DataSelectorModel:
|
|
164
164
|
|
165
165
|
return Path(self.state.custom_directory)
|
166
166
|
|
167
|
-
def get_directories(self) -> List[str]:
|
167
|
+
def get_directories(self, base_path: Optional[Path] = None) -> List[Dict[str, Any]]:
|
168
168
|
using_custom_directory = self.state.facility == CUSTOM_DIRECTORIES_LABEL
|
169
|
-
if
|
169
|
+
if base_path:
|
170
|
+
pass
|
171
|
+
elif using_custom_directory:
|
170
172
|
base_path = self.get_custom_directory_path()
|
171
173
|
else:
|
172
174
|
base_path = self.get_experiment_directory_path()
|
@@ -176,34 +178,31 @@ class DataSelectorModel:
|
|
176
178
|
|
177
179
|
directories = []
|
178
180
|
try:
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
# Add the last part (current directory) as a child
|
206
|
-
current_level.append({"path": dirpath, "title": path_parts[-1]})
|
181
|
+
for dirpath, dirs, _ in os.walk(base_path):
|
182
|
+
# Get the relative path from the start path
|
183
|
+
path_parts = os.path.relpath(dirpath, base_path).split(os.sep)
|
184
|
+
|
185
|
+
if len(path_parts) > 1:
|
186
|
+
dirs.clear()
|
187
|
+
|
188
|
+
# Only create a new entry for top-level directories
|
189
|
+
if len(path_parts) == 1 and path_parts[0] != ".": # This indicates a top-level directory
|
190
|
+
current_dir = {"path": dirpath, "title": path_parts[0]}
|
191
|
+
directories.append(current_dir)
|
192
|
+
|
193
|
+
# Add subdirectories to the corresponding parent directory
|
194
|
+
elif len(path_parts) > 1:
|
195
|
+
current_level: Any = directories
|
196
|
+
for part in path_parts[:-1]: # Parent directories
|
197
|
+
for item in current_level:
|
198
|
+
if item["title"] == part:
|
199
|
+
if "children" not in item:
|
200
|
+
item["children"] = []
|
201
|
+
current_level = item["children"]
|
202
|
+
break
|
203
|
+
|
204
|
+
# Add the last part (current directory) as a child
|
205
|
+
current_level.append({"path": dirpath, "title": path_parts[-1]})
|
207
206
|
except OSError:
|
208
207
|
pass
|
209
208
|
|
@@ -133,8 +133,10 @@ class DataSelector(datagrid.VGrid):
|
|
133
133
|
activatable=True,
|
134
134
|
active_strategy="single-independent",
|
135
135
|
classes="flex-1-0 h-0 overflow-y-auto",
|
136
|
+
fluid=True,
|
136
137
|
item_value="path",
|
137
138
|
items=(self._directories_name,),
|
139
|
+
click_open=(self._vm.expand_directory, "[$event.path]"),
|
138
140
|
update_activated=(self._vm.set_directory, "$event"),
|
139
141
|
)
|
140
142
|
vuetify.VListItem("No directories found", classes="flex-0-1 text-center", v_else=True)
|
@@ -20,6 +20,14 @@ html {
|
|
20
20
|
white-space: pre-wrap;
|
21
21
|
}
|
22
22
|
|
23
|
+
.nova-data-selector {
|
24
|
+
.v-list-group {
|
25
|
+
.v-treeview-item {
|
26
|
+
--indent-padding: 1em !important;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
23
31
|
.nova-data-selector revo-grid {
|
24
32
|
font-family: 'Roboto', sans-serif;
|
25
33
|
font-size: 0.75rem !important;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"""View model implementation for the DataSelector widget."""
|
2
2
|
|
3
3
|
import os
|
4
|
+
from pathlib import Path
|
4
5
|
from typing import Any, Dict, List, Optional
|
5
6
|
|
6
7
|
from nova.mvvm.interface import BindingInterface
|
@@ -14,6 +15,8 @@ class DataSelectorViewModel:
|
|
14
15
|
self.model = model
|
15
16
|
|
16
17
|
self.datafiles: List[Dict[str, Any]] = []
|
18
|
+
self.directories: List[Dict[str, Any]] = []
|
19
|
+
self.expanded: List[str] = []
|
17
20
|
|
18
21
|
self.state_bind = binding.new_bind(self.model.state, callback_after_update=self.on_state_updated)
|
19
22
|
self.facilities_bind = binding.new_bind()
|
@@ -23,6 +26,30 @@ class DataSelectorViewModel:
|
|
23
26
|
self.datafiles_bind = binding.new_bind()
|
24
27
|
self.reset_bind = binding.new_bind()
|
25
28
|
|
29
|
+
def expand_directory(self, paths: List[str]) -> None:
|
30
|
+
if paths[-1] in self.expanded:
|
31
|
+
return
|
32
|
+
|
33
|
+
# Query for the new subdirectories to display in the view
|
34
|
+
new_directories = self.model.get_directories(Path(paths[-1]))
|
35
|
+
|
36
|
+
# Find the entry in the existing directories that corresponds to the directory to expand
|
37
|
+
current_level: Dict[str, Any] = {}
|
38
|
+
children: List[Dict[str, Any]] = self.directories
|
39
|
+
for current_path in paths:
|
40
|
+
if current_level:
|
41
|
+
children = current_level["children"]
|
42
|
+
|
43
|
+
for entry in children:
|
44
|
+
if current_path == entry["path"]:
|
45
|
+
current_level = entry
|
46
|
+
break
|
47
|
+
current_level["children"] = new_directories
|
48
|
+
|
49
|
+
# Mark this directory as expanded and display the new content
|
50
|
+
self.expanded.append(paths[-1])
|
51
|
+
self.directories_bind.update_in_view(self.directories)
|
52
|
+
|
26
53
|
def set_directory(self, directory_path: str = "") -> None:
|
27
54
|
self.model.set_directory(directory_path)
|
28
55
|
self.update_view()
|
@@ -33,6 +60,8 @@ class DataSelectorViewModel:
|
|
33
60
|
|
34
61
|
def reset(self) -> None:
|
35
62
|
self.model.set_directory("")
|
63
|
+
self.directories = self.model.get_directories()
|
64
|
+
self.expanded = []
|
36
65
|
self.reset_bind.update_in_view(None)
|
37
66
|
|
38
67
|
def on_state_updated(self, results: Dict[str, Any]) -> None:
|
@@ -55,7 +84,7 @@ class DataSelectorViewModel:
|
|
55
84
|
self.facilities_bind.update_in_view(self.model.get_facilities())
|
56
85
|
self.instruments_bind.update_in_view(self.model.get_instruments())
|
57
86
|
self.experiments_bind.update_in_view(self.model.get_experiments())
|
58
|
-
self.directories_bind.update_in_view(self.
|
87
|
+
self.directories_bind.update_in_view(self.directories)
|
59
88
|
|
60
89
|
self.datafiles = [
|
61
90
|
{"path": datafile, "title": os.path.basename(datafile)} for datafile in self.model.get_datafiles()
|
@@ -1,9 +1,9 @@
|
|
1
1
|
nova/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
|
2
2
|
nova/trame/__init__.py,sha256=gFrAg1qva5PIqR5TjvPzAxLx103IKipJLqp3XXvrQL8,59
|
3
|
-
nova/trame/model/data_selector.py,sha256=
|
3
|
+
nova/trame/model/data_selector.py,sha256=UnLBCp_jJ523QxTR3R8iun2Ogq4D0G0lxmtW9e_zwOM,8938
|
4
4
|
nova/trame/model/remote_file_input.py,sha256=9KAf31ZHzpsh_aXUrNcF81Q5jvUZDWCzW1QATKls-Jk,3675
|
5
5
|
nova/trame/view/components/__init__.py,sha256=60BeS69aOrFnkptjuD17rfPE1f4Z35iBH56TRmW5MW8,451
|
6
|
-
nova/trame/view/components/data_selector.py,sha256=
|
6
|
+
nova/trame/view/components/data_selector.py,sha256=lgZjyT_jc3eE19HNgz_Hdog5bWvXZJ3IfxxiSBkZ7hE,11222
|
7
7
|
nova/trame/view/components/execution_buttons.py,sha256=fIkrWKI3jFZqk3GHhtmYh3nK2c-HOXpD3D3zd_TUpi0,4049
|
8
8
|
nova/trame/view/components/file_upload.py,sha256=7VcpfA6zmiqMDLkwVPlb35Tf0IUTBN1xsHpoUFnSr1w,3111
|
9
9
|
nova/trame/view/components/input_field.py,sha256=q6WQ_N-BOlimUL9zgazDlsDfK28FrrKjH4he8e_HzRA,16088
|
@@ -19,7 +19,7 @@ nova/trame/view/layouts/hbox.py,sha256=qlOMp_iOropIkC9Jxa6D89b7OPv0pNvJ73tUEzddy
|
|
19
19
|
nova/trame/view/layouts/utils.py,sha256=Hg34VQWTG3yHBsgNvmfatR4J-uL3cko7UxSJpT-h3JI,376
|
20
20
|
nova/trame/view/layouts/vbox.py,sha256=hzhzPu99R2fAclMe-FwHZseJWk7iailZ31bKdGhi1hk,3514
|
21
21
|
nova/trame/view/theme/__init__.py,sha256=70_marDlTigIcPEOGiJb2JTs-8b2sGM5SlY7XBPtBDM,54
|
22
|
-
nova/trame/view/theme/assets/core_style.scss,sha256=
|
22
|
+
nova/trame/view/theme/assets/core_style.scss,sha256=lK86Fp55oAMDh1eUHA-DTeGGZi0uUYOseIyJUTj-0A0,4081
|
23
23
|
nova/trame/view/theme/assets/favicon.png,sha256=Xbp1nUmhcBDeObjsebEbEAraPDZ_M163M_ZLtm5AbQc,1927
|
24
24
|
nova/trame/view/theme/assets/js/delay_manager.js,sha256=mRV6KoO8-Bxq3tG5Bh9CQYy-CRVbkj3IYlqNb-Og7cI,526
|
25
25
|
nova/trame/view/theme/assets/js/lodash.min.js,sha256=KCyAYJ-fsqtp_HMwbjhy6IKjlA5lrVrtWt1JdMsC57k,73016
|
@@ -27,13 +27,13 @@ nova/trame/view/theme/assets/js/revo_grid.js,sha256=WBsmoslu9qI5DHZkHkJam2AVgdiB
|
|
27
27
|
nova/trame/view/theme/assets/vuetify_config.json,sha256=a0FSgpLYWGFlRGSMhMq61MyDFBEBwvz55G4qjkM08cs,5627
|
28
28
|
nova/trame/view/theme/theme.py,sha256=0KzBJgAZRwlnwzCIf7gUjDY-gbhON7b2h3CMh2_9HY4,11746
|
29
29
|
nova/trame/view/utilities/local_storage.py,sha256=vD8f2VZIpxhIKjZwEaD7siiPCTZO4cw9AfhwdawwYLY,3218
|
30
|
-
nova/trame/view_model/data_selector.py,sha256=
|
30
|
+
nova/trame/view_model/data_selector.py,sha256=RyMHml1K_pupH4JtXnGxAaYTYYwNoEVus7Abdpqwueo,3698
|
31
31
|
nova/trame/view_model/execution_buttons.py,sha256=MfKSp95D92EqpD48C15cBo6dLO0Yld4FeRZMJNxJf7Y,3551
|
32
32
|
nova/trame/view_model/progress_bar.py,sha256=6AUKHF3hfzbdsHqNEnmHRgDcBKY5TT8ywDx9S6ovnsc,2854
|
33
33
|
nova/trame/view_model/remote_file_input.py,sha256=ojEOJ8ZPkajpbAaZi9VLj7g-uBjhb8BMrTdMmwf_J6A,3367
|
34
34
|
nova/trame/view_model/tool_outputs.py,sha256=ev6LY7fJ0H2xAJn9f5ww28c8Kpom2SYc2FbvFcoN4zg,829
|
35
|
-
nova_trame-0.
|
36
|
-
nova_trame-0.
|
37
|
-
nova_trame-0.
|
38
|
-
nova_trame-0.
|
39
|
-
nova_trame-0.
|
35
|
+
nova_trame-0.22.0.dist-info/LICENSE,sha256=Iu5QiDbwNbREg75iYaxIJ_V-zppuv4QFuBhAW-qiAlM,1061
|
36
|
+
nova_trame-0.22.0.dist-info/METADATA,sha256=7ySWYYUkEE99UeZnMvMMwskNWHHhHjrrNv0_5dYRU0s,1603
|
37
|
+
nova_trame-0.22.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
38
|
+
nova_trame-0.22.0.dist-info/entry_points.txt,sha256=J2AmeSwiTYZ4ZqHHp9HO6v4MaYQTTBPbNh6WtoqOT58,42
|
39
|
+
nova_trame-0.22.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|