Skip to content

Commit

Permalink
ENH: extensive rehaul of pagination and sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
jotelha committed Nov 7, 2024
1 parent e7dc3f2 commit b579d4e
Show file tree
Hide file tree
Showing 5 changed files with 423 additions and 233 deletions.
22 changes: 14 additions & 8 deletions dtool_lookup_gui/models/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
from dtool_info.inventory import _dataset_info
from dtool_lookup_api.core.LookupClient import ConfigurationBasedLookupClient



from ..utils.logging import _log_nested
from ..utils.multiprocessing import StatusReportingChildProcessBuilder, process_initializer
from ..utils.progressbar import ProgressBar
Expand Down Expand Up @@ -272,22 +270,30 @@ def __init__(self, uri=None, dataset_info=None):
raise ValueError('Please provide either `uri` or `dateset_info`.')

@classmethod
async def get_datasets(cls, keyword, page_number, page_size,sort_fields,sort_order, pagination={} ,sorting={}):
async def get_datasets(cls, free_text=None, page_number=None, page_size=None,
sort_fields=None, sort_order=None, pagination={} , sorting={}):
async with ConfigurationBasedLookupClient() as lookup:
datasets = await lookup.get_datasets(keyword, page_number=page_number, page_size=page_size,sort_fields=sort_fields,sort_order=sort_order, pagination=pagination,sorting=sorting)
datasets = await lookup.get_datasets(
free_text=free_text, page_number=page_number, page_size=page_size,
sort_fields=sort_fields, sort_order=sort_order,
pagination=pagination, sorting=sorting)
return [await cls.from_lookup(lookup_dict) for lookup_dict in datasets]

@classmethod
async def query(cls, query_text, *args, **kwargs):
async def get_datasets_by_mongo_query(cls, query, *args, **kwargs):
async with ConfigurationBasedLookupClient() as lookup:
datasets = await lookup.query(query_text, *args, **kwargs)
datasets = await lookup.get_datasets_by_mongo_query(query=query, *args, **kwargs)
return [await cls.from_lookup(lookup_dict) for lookup_dict in datasets]

@classmethod
async def query_all(cls,sort_fields,sort_order, page_number=1, page_size=10, pagination={},sorting={}):
async def query_all(cls, sort_fields=None, sort_order=None, page_number=None,
page_size=None, pagination={}, sorting={}):
"""Query all datasets from the lookup server."""
async with ConfigurationBasedLookupClient() as lookup:
datasets = await lookup.get_datasets(page_number=page_number, page_size=page_size,sort_fields=sort_fields,sort_order=sort_order, pagination=pagination,sorting=sorting)
datasets = await lookup.get_datasets(
page_number=page_number, page_size=page_size,
sort_fields=sort_fields, sort_order=sort_order,
pagination=pagination,sorting=sorting)
return [await cls.from_lookup(lookup_dict) for lookup_dict in datasets]

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion dtool_lookup_gui/views/login_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def on_skip_button_clicked(self, widget):
self.close()

@Gtk.Template.Callback()
def settings_button_clicked_cb(self, widget):
def on_settings_button_clicked_cb(self, widget):
logger.info("Settings button clicked. Opening settings dialog.")
self.settings_dialog.show()

Expand Down
2 changes: 1 addition & 1 deletion dtool_lookup_gui/views/login_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<signal name="clicked" handler="settings_button_clicked_cb" swapped="no"/>
<signal name="clicked" handler="on_settings_button_clicked_cb" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
Expand Down
Loading

0 comments on commit b579d4e

Please sign in to comment.