Skip to content

Commit

Permalink
Fix re-render of layout
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 19, 2023
1 parent 6dad168 commit 3ec45bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions lumen/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,28 @@ def _navigate(self, event: param.parameterized.Event):
pn.state.location.pathname = f'/{app}'
pn.state.location.reload = True

def _set_loading(self, name: str = ''):
def _set_loading(self, name: str = '', reloading: bool = True):
state.loading_msg.object = f'<b>Reloading {name}...</b>'
if reloading:
self._main.loading = True
return
if isinstance(self._layout, pn.GridBox):
items = [pn.pane.HTML(width=self._layout[i].width) # type: ignore
for i in range(self._layout.ncols) if i < len(self._layout)]
index = int(min(self._layout.ncols, (len(self._layout)-1)) / 2)
if items:
items[index] = self._loading
else:
items = [self._loading]
elif isinstance(self._layout, pn.Tabs):
items = list(zip(self._layout._names, list(self._layout.objects))) # type: ignore
tab_name = items[self._layout.active][0]
if name and tab_name != name:
return
items[self._layout.active] = (tab_name, self._loading)
else:
items = [self._loading]
self._layout[:] = items
self._main.loading = True

def _open_modal(self, event: param.parameterized.Event):
Expand Down Expand Up @@ -875,7 +895,7 @@ def _render_filters(self):

def _render_layouts(self, event: param.parameterized.Event | None = None):
if event is not None:
self._set_loading(event.obj.title)
self._set_loading(event.obj.title, reloading=event.name == 'rerender')
items = []
for layout, spec in zip(self.layouts, state.spec.get('layouts', [])):
if layout is None or isinstance(layout, Future):
Expand Down
2 changes: 1 addition & 1 deletion lumen/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def _rerender(self, update_views: bool = True):
if update_views:
self._rerender_cards(cards)
rerender = True
if set(cards) != set(self._cards):
if cards != self._cards:
self._cards[:] = cards
rerender = True
if rerender:
Expand Down

0 comments on commit 3ec45bb

Please sign in to comment.