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

add loading page and load config2 on load event, format console.log, kill timeout and xhr on unload #89

Merged
merged 5 commits into from
Nov 9, 2023
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
63 changes: 48 additions & 15 deletions pyscada/hmi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def _get_objects_for_html(
exclude_model_names=exclude_model_names,
)

def add_custom_fields_list(self, opts):
return opts

def add_exclude_fields_list(self, opts):
return opts

def create_widget_content_entry(self):
def fullname(o):
return o.__module__ + "." + o.__class__.__name__
Expand Down Expand Up @@ -543,8 +549,8 @@ def gen_html(self, **kwargs):
opts["show_daterangepicker"] = True
opts["show_timeline"] = True
opts["flot"] = True
opts["object_config_list"] = set()
opts["object_config_list"].update(self._get_objects_for_html())
# opts["object_config_list"] = set()
# opts["object_config_list"].update(self._get_objects_for_html())
return main_content, sidebar_content, opts

def _get_objects_for_html(
Expand Down Expand Up @@ -763,19 +769,24 @@ def gen_html(self, **kwargs):
and item.display_value_options.type == 3
):
opts["flot"] = True
opts["object_config_list"] = set()
opts["object_config_list"].update(self._get_objects_for_html())
opts["custom_fields_list"] = {
"variable": [
# opts["object_config_list"] = set()
# opts["object_config_list"].update(self._get_objects_for_html())
# opts = self.add_custom_fields_list(opts)
return main_content, sidebar_content, opts

def add_custom_fields_list(self, opts):
if type(opts) == dict:
if "custom_fields_list" not in opts:
opts["custom_fields_list"] = dict()
opts["custom_fields_list"]["variable"] = [
{"name": "refresh-requested-timestamp", "value": ""},
{"name": "value-timestamp", "value": ""},
],
"variableproperty": [
]
opts["custom_fields_list"]["variableproperty"] = [
{"name": "refresh-requested-timestamp", "value": ""},
{"name": "value-timestamp", "value": ""},
],
}
return main_content, sidebar_content, opts
]
return opts


class CustomHTMLPanel(WidgetContentModel):
Expand Down Expand Up @@ -813,8 +824,8 @@ def gen_html(self, **kwargs):
)
sidebar_content = None
opts = dict()
opts["object_config_list"] = set()
opts["object_config_list"].update(self._get_objects_for_html())
# opts["object_config_list"] = set()
# opts["object_config_list"].update(self._get_objects_for_html())
return main_content, sidebar_content, opts


Expand Down Expand Up @@ -906,8 +917,8 @@ def gen_html(self, **kwargs):
)
sidebar_content = None
opts = dict()
opts["object_config_list"] = set()
opts["object_config_list"].update(self._get_objects_for_html())
# opts["object_config_list"] = set()
# opts["object_config_list"].update(self._get_objects_for_html())

return main_content, sidebar_content, opts

Expand Down Expand Up @@ -949,6 +960,28 @@ def create_panel_html(self, **kwargs):
# todo del self
return "", "", ""

def get_hidden_config2(self, **kwargs):
"""
return main_content, sidebar_content, optional list
"""
content_model = self._import_content_model()
opts = dict()
opts["object_config_list"] = set()
try:
if content_model is not None:
opts["object_config_list"].update(content_model._get_objects_for_html())
opts = content_model.add_custom_fields_list(opts)
opts = content_model.add_exclude_fields_list(opts)
else:
logger.info(
f"WidgetContent content_model of {self.content_str} is None"
)
except:
logger.error(f"{content_model} unhandled exception", exc_info=True)
# todo del self

return opts

def _import_content_model(self):
content_class_str = self.content_model
class_name = content_class_str.split(".")[-1]
Expand Down
Loading