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

Display loading indicator on View #435

Merged
merged 2 commits into from
Jan 24, 2023
Merged
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
10 changes: 10 additions & 0 deletions lumen/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class View(MultiTypeComponent, Viewer):
The download objects determines whether and how the source tables
can be downloaded.""")

loading_indicator = param.Boolean(default=True, constant=True, doc="""
Whether to display a loading indicator on the View when the
Pipeline is refreshing the data.""")

pipeline = param.ClassSelector(class_=Pipeline, doc="""
The data pipeline that drives the View.""")

Expand Down Expand Up @@ -178,6 +182,8 @@ def __init__(self, **params):
if isinstance(self.param[fp], param.Selector):
self.param[fp].objects = fields
pipeline.param.watch(self.update, 'data')
if self.loading_indicator:
pipeline._update_widget.param.watch(self._update_loading, 'loading')
super().__init__(pipeline=pipeline, refs=refs, **params)
self.param.watch(self.update, [p for p in self.param if p not in ('rerender', 'selection_expr', 'name')])
self.download.view = self
Expand All @@ -190,6 +196,10 @@ def __panel__(self) -> Viewable:
self.update()
return pn.panel(pn.bind(lambda e: self.panel, self.param.rerender))

def _update_loading(self, event):
if self._panel is not None:
self._panel.loading = event.new

def _update_ref(self, pname: str, ref: str, *events: param.parameterized.Event) -> None:
# Note: Do not trigger update in View if Pipeline references
# the same variable and is not set up to auto-update
Expand Down