diff --git a/lumen/views/base.py b/lumen/views/base.py index e294759b2..863d91535 100644 --- a/lumen/views/base.py +++ b/lumen/views/base.py @@ -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.""") @@ -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 @@ -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