draft 1.2.7 (need test)

# Test Managers.ControlPanel HTML and add option to rerender (for debug purpose)
dev-linux
Ivan Maslov 3 years ago
parent 34396b13dd
commit b7ca9ad446

@ -7,18 +7,26 @@ from ..Web import Basic
class ControlPanel():
"""
Manage your control panel on the orchestrator
.. code-block:: python
# Usage example:
lCPManager = Orchestrator.Managers.ControlPanel(inControlPanelNameStr="TestControlPanel",
inJinja2TemplatePathStr="ControlPanel\\test.html", inJinja2TemplateRefreshBool = True)
"""
mControlPanelNameStr = None
mJinja2TemplatePathStr = None
mJinja2TemplateFileNameStr = None
mJinja2Loader = None
mJinja2Env = None
mJinja2Template = None
mJinja2TemplateRefreshBool = None
mBackwardCompatibilityHTMLDef = None
mBackwardCompatibilityJSDef = None
mBackwardCompatibilityJSONDef = None
def __init__(self, inControlPanelNameStr, inJinja2TemplatePathStr = None):
def __init__(self, inControlPanelNameStr, inJinja2TemplatePathStr = None, inJinja2TemplateRefreshBool = False):
"""
Constructor of the control panel manager
@ -30,6 +38,7 @@ class ControlPanel():
raise Exception(f"Another control panel with name {inControlPanelNameStr} is already exists. Please resolve the error and restart")
Orchestrator.GSettingsGet()["ServerDict"]["ControlPanelDict"][inControlPanelNameStr] = self
self.Jinja2TemplatePathSet(inJinja2TemplatePathStr = inJinja2TemplatePathStr)
self.mJinja2TemplateRefreshBool = inJinja2TemplateRefreshBool
self.mControlPanelNameStr = inControlPanelNameStr # Set the name of the control panel
def Jinja2TemplatePathSet(self, inJinja2TemplatePathStr):
@ -42,6 +51,7 @@ class ControlPanel():
if inJinja2TemplatePathStr is not None:
lSystemLoaderPathStr = "/".join(inJinja2TemplatePathStr.split("\\")[0:-1])
lTemplateFileNameStr = inJinja2TemplatePathStr.split("\\")[-1]
self.mJinja2TemplateFileNameStr = lTemplateFileNameStr
self.mJinja2Loader = jinja2.FileSystemLoader(lSystemLoaderPathStr)
self.mJinja2Env = jinja2.Environment(loader=self.mJinja2Loader, trim_blocks=True)
self.mJinja2Template = self.mJinja2Env.get_template(lTemplateFileNameStr)
@ -52,6 +62,8 @@ class ControlPanel():
:param inDataDict:
:return:
"""
if self.mJinja2TemplateRefreshBool == True:
self.mJinja2Template = self.mJinja2Env.get_template(self.mJinja2TemplateFileNameStr)
lHTMLStr = self.mJinja2Template.render(**inDataDict) # Render the template into str
return lHTMLStr

Loading…
Cancel
Save