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

Avoid leaking panel config settings #349

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
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: 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