Skip to content

Commit

Permalink
Avoid leaking panel config settings (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Oct 6, 2022
1 parent 9423eab commit 99f6647
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
10 changes: 7 additions & 3 deletions lumen/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import param
import yaml

from panel.io.resources import CSS_URLS
from panel.template.base import BasicTemplate

from .auth import AuthPlugin
Expand All @@ -29,9 +30,6 @@
from .variables import Variable, Variables
from .views import View # noqa

pn.config.css_files.append(
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css'
)

def load_yaml(yaml_spec, **kwargs):
expanded = expand_spec(yaml_spec, config.template_vars, **kwargs)
Expand Down Expand Up @@ -325,6 +323,7 @@ def __init__(self, specification=None, **params):
self._edited = False
self._debug = params.pop('debug', False)
super().__init__(**params)
self._init_config()

# Initialize from spec
config.load_local_modules()
Expand Down Expand Up @@ -353,6 +352,11 @@ def __init__(self, specification=None, **params):
state._apps[pn.state.curdoc] = self
pn.state.onload(self._render_dashboard)

def _init_config(self):
pn.config.notifications = True
if CSS_URLS['font-awesome'] not in pn.config.css_files:
pn.config.css_files.append(CSS_URLS['font-awesome'])

##################################################################
# Load specification
##################################################################
Expand Down
24 changes: 0 additions & 24 deletions lumen/ui/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,6 @@
from .variables import VariablesEditor
from .views import ViewEditor, ViewGallery, ViewGalleryItem

CSS_RAW = """
i.fa.fa-plus:hover {
color: var(--neutral-fill-color) !important;
}
.gallery-item:hover {
box-shadow: 0 1px 5px;
}
.gallery-item {
cursor: pointer;
}
.card-margin {
height: calc(100% - 40px);
}
.bk-root {
height: 100% !important;
}
"""

pn.extension('ace', 'perspective', 'tabulator', raw_css=[CSS_RAW])


class Builder(param.Parameterized):

Expand Down
27 changes: 27 additions & 0 deletions lumen/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,38 @@

import panel as pn

from panel.io.resources import CSS_URLS
from panel.template import FastListTemplate

from lumen.ui.builder import Builder
from lumen.ui.state import state

CSS_RAW = """
i.fa.fa-plus:hover {
color: var(--neutral-fill-color) !important;
}
.gallery-item:hover {
box-shadow: 0 1px 5px;
}
.gallery-item {
cursor: pointer;
}
.card-margin {
height: calc(100% - 40px);
}
.bk-root {
height: 100% !important;
}
"""

pn.extension(
'ace', 'perspective', 'tabulator', raw_css=[CSS_RAW],
css_files=[CSS_URLS['font-awesome']]
)

def main():
path = Path(state.components)
Expand Down
2 changes: 0 additions & 2 deletions lumen/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ def catch_and_notify(message=None):
exception message.
"""
pn.config.notifications = True

# This is to be able to call the decorator
# like this @catch_and_notify
function = None
Expand Down

0 comments on commit 99f6647

Please sign in to comment.