|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
import typing as t
|
|
|
from datetime import datetime
|
|
|
+from threading import Lock
|
|
|
|
|
|
from dateutil import parser
|
|
|
|
|
@@ -26,44 +27,34 @@ from taipy.gui.utils import _TaipyBase
|
|
|
from ..version import _get_version
|
|
|
|
|
|
|
|
|
-class GuiCoreScenarioAdapter(_TaipyBase):
|
|
|
+class _GuiCoreScenarioAdapter(_TaipyBase):
|
|
|
__INNER_PROPS = ["name"]
|
|
|
|
|
|
def get(self):
|
|
|
data = super().get()
|
|
|
if isinstance(data, Scenario):
|
|
|
- return [
|
|
|
- data.id,
|
|
|
- data.is_primary,
|
|
|
- data.config_id,
|
|
|
- data.creation_date,
|
|
|
- data.get_simple_label(),
|
|
|
- list(data.tags),
|
|
|
- [(k, v) for k, v in data.properties.items() if k not in GuiCoreScenarioAdapter.__INNER_PROPS],
|
|
|
- [(p.id, p.get_simple_label()) for p in data.pipelines.values()],
|
|
|
- list(data.properties.get("authorized_tags", set())),
|
|
|
- not data.is_primary, # deletable
|
|
|
- ]
|
|
|
- return data
|
|
|
+ scenario = tp.get(data.id)
|
|
|
+ if scenario:
|
|
|
+ return [
|
|
|
+ scenario.id,
|
|
|
+ scenario.is_primary,
|
|
|
+ scenario.config_id,
|
|
|
+ scenario.creation_date,
|
|
|
+ scenario.get_simple_label(),
|
|
|
+ list(scenario.tags),
|
|
|
+ [(k, v) for k, v in scenario.properties.items() if k not in _GuiCoreScenarioAdapter.__INNER_PROPS],
|
|
|
+ [(p.id, p.get_simple_label()) for p in scenario.pipelines.values()],
|
|
|
+ list(scenario.properties.get("authorized_tags", set())),
|
|
|
+ tp.is_deletable(scenario), # deletable
|
|
|
+ ]
|
|
|
+ return None
|
|
|
|
|
|
@staticmethod
|
|
|
def get_hash():
|
|
|
return _TaipyBase._HOLDER_PREFIX + "Sc"
|
|
|
|
|
|
|
|
|
-class GuiCoreScenarioIdAdapter(_TaipyBase):
|
|
|
- def get(self):
|
|
|
- data = super().get()
|
|
|
- if isinstance(data, Scenario):
|
|
|
- return data.id
|
|
|
- return data
|
|
|
-
|
|
|
- @staticmethod
|
|
|
- def get_hash():
|
|
|
- return _TaipyBase._HOLDER_PREFIX + "ScI"
|
|
|
-
|
|
|
-
|
|
|
-class GuiCoreScenarioDagAdapter(_TaipyBase):
|
|
|
+class _GuiCoreScenarioDagAdapter(_TaipyBase):
|
|
|
@staticmethod
|
|
|
def get_entity_type(node: t.Any):
|
|
|
return DataNode.__name__ if isinstance(node.entity, DataNode) else node.type
|
|
@@ -71,31 +62,33 @@ class GuiCoreScenarioDagAdapter(_TaipyBase):
|
|
|
def get(self):
|
|
|
data = super().get()
|
|
|
if isinstance(data, Scenario):
|
|
|
- dag = data._get_dag()
|
|
|
- nodes = dict()
|
|
|
- for id, node in dag.nodes.items():
|
|
|
- entityType = GuiCoreScenarioDagAdapter.get_entity_type(node)
|
|
|
- cat = nodes.get(entityType)
|
|
|
- if cat is None:
|
|
|
- cat = dict()
|
|
|
- nodes[entityType] = cat
|
|
|
- cat[id] = {
|
|
|
- "name": node.entity.get_simple_label(),
|
|
|
- "type": node.entity.storage_type() if hasattr(node.entity, "storage_type") else None,
|
|
|
- }
|
|
|
- return [
|
|
|
- data.get_label(),
|
|
|
- nodes,
|
|
|
- [
|
|
|
- (
|
|
|
- GuiCoreScenarioDagAdapter.get_entity_type(e.src),
|
|
|
- e.src.entity.id,
|
|
|
- GuiCoreScenarioDagAdapter.get_entity_type(e.dest),
|
|
|
- e.dest.entity.id,
|
|
|
- )
|
|
|
- for e in dag.edges
|
|
|
- ],
|
|
|
- ]
|
|
|
+ scenario = tp.get(data.id)
|
|
|
+ if scenario:
|
|
|
+ dag = data._get_dag()
|
|
|
+ nodes = dict()
|
|
|
+ for id, node in dag.nodes.items():
|
|
|
+ entityType = _GuiCoreScenarioDagAdapter.get_entity_type(node)
|
|
|
+ cat = nodes.get(entityType)
|
|
|
+ if cat is None:
|
|
|
+ cat = dict()
|
|
|
+ nodes[entityType] = cat
|
|
|
+ cat[id] = {
|
|
|
+ "name": node.entity.get_simple_label(),
|
|
|
+ "type": node.entity.storage_type() if hasattr(node.entity, "storage_type") else None,
|
|
|
+ }
|
|
|
+ return [
|
|
|
+ data.get_label(),
|
|
|
+ nodes,
|
|
|
+ [
|
|
|
+ (
|
|
|
+ _GuiCoreScenarioDagAdapter.get_entity_type(e.src),
|
|
|
+ e.src.entity.id,
|
|
|
+ _GuiCoreScenarioDagAdapter.get_entity_type(e.dest),
|
|
|
+ e.dest.entity.id,
|
|
|
+ )
|
|
|
+ for e in dag.edges
|
|
|
+ ],
|
|
|
+ ]
|
|
|
return None
|
|
|
|
|
|
@staticmethod
|
|
@@ -103,7 +96,7 @@ class GuiCoreScenarioDagAdapter(_TaipyBase):
|
|
|
return _TaipyBase._HOLDER_PREFIX + "ScG"
|
|
|
|
|
|
|
|
|
-class GuiCoreContext(CoreEventConsumerBase):
|
|
|
+class _GuiCoreContext(CoreEventConsumerBase):
|
|
|
__PROP_ENTITY_ID = "id"
|
|
|
__PROP_SCENARIO_CONFIG_ID = "config"
|
|
|
__PROP_SCENARIO_DATE = "date"
|
|
@@ -118,47 +111,57 @@ class GuiCoreContext(CoreEventConsumerBase):
|
|
|
|
|
|
def __init__(self, gui: Gui) -> None:
|
|
|
self.gui = gui
|
|
|
- self.cycles_scenarios: t.Optional[t.List[t.Union[Cycle, Scenario]]] = None
|
|
|
+ self.scenarios_base_level: t.Optional[t.List[t.Union[Cycle, Scenario]]] = None
|
|
|
+ self.data_nodes_base_level: t.Optional[t.List[t.Union[Cycle, Scenario, Pipeline, DataNode]]] = None
|
|
|
self.scenario_configs: t.Optional[t.List[t.Tuple[str, str]]] = None
|
|
|
# register to taipy core notification
|
|
|
reg_id, reg_queue = Notifier.register()
|
|
|
+ self.lock = Lock()
|
|
|
super().__init__(reg_id, reg_queue)
|
|
|
self.start()
|
|
|
|
|
|
def process_event(self, event: Event):
|
|
|
- if event.entity_type == EventEntityType.SCENARIO or event.entity_type == EventEntityType.CYCLE:
|
|
|
- self.cycles_scenarios = None
|
|
|
+ if event.entity_type == EventEntityType.SCENARIO:
|
|
|
+ self.scenarios_base_level = None
|
|
|
+ scenario = tp.get(event.entity_id) if event.operation.value != 3 else None
|
|
|
self.gui.broadcast(
|
|
|
- GuiCoreContext._CORE_CHANGED_NAME,
|
|
|
- {"scenario": (event.entity_id if event.entity_type == EventEntityType.SCENARIO else True) or True},
|
|
|
+ _GuiCoreContext._CORE_CHANGED_NAME,
|
|
|
+ {"scenario": event.entity_id if scenario else True},
|
|
|
)
|
|
|
- elif event.entity_type == EventEntityType.PIPELINE and event.entity_id:
|
|
|
- pipeline = tp.get(event.entity_id)
|
|
|
- self.gui.broadcast(GuiCoreContext._CORE_CHANGED_NAME, {"scenario": [x for x in pipeline.parent_ids]})
|
|
|
+ self.data_nodes_base_level = None
|
|
|
+ elif event.entity_type == EventEntityType.PIPELINE and event.entity_id: # TODO import EventOperation
|
|
|
+ pipeline = tp.get(event.entity_id) if event.operation.value != 3 else None
|
|
|
+ if pipeline:
|
|
|
+ if hasattr(pipeline, "parent_ids") and pipeline.parent_ids:
|
|
|
+ self.gui.broadcast(
|
|
|
+ _GuiCoreContext._CORE_CHANGED_NAME, {"scenario": [x for x in pipeline.parent_ids]}
|
|
|
+ )
|
|
|
|
|
|
@staticmethod
|
|
|
def scenario_adapter(data):
|
|
|
- if isinstance(data, Cycle):
|
|
|
- return (data.id, data.name, tp.get_scenarios(data), 0, False)
|
|
|
- elif isinstance(data, Scenario):
|
|
|
- return (data.id, data.name, None, 1, data.is_primary)
|
|
|
- return data
|
|
|
+ if hasattr(data, "id") and tp.get(data.id) is not None:
|
|
|
+ if isinstance(data, Cycle):
|
|
|
+ return (data.id, data.name, tp.get_scenarios(data), 0, False)
|
|
|
+ elif isinstance(data, Scenario):
|
|
|
+ return (data.id, data.name, None, 1, data.is_primary)
|
|
|
+ return None
|
|
|
|
|
|
def get_scenarios(self):
|
|
|
- if self.cycles_scenarios is None:
|
|
|
- self.cycles_scenarios = []
|
|
|
- for cycle, scenarios in tp.get_cycles_scenarios().items():
|
|
|
- if cycle is None:
|
|
|
- self.cycles_scenarios.extend(scenarios)
|
|
|
- else:
|
|
|
- self.cycles_scenarios.append(cycle)
|
|
|
- return self.cycles_scenarios
|
|
|
+ with self.lock:
|
|
|
+ if self.scenarios_base_level is None:
|
|
|
+ self.scenarios_base_level = []
|
|
|
+ for cycle, scenarios in tp.get_cycles_scenarios().items():
|
|
|
+ if cycle is None:
|
|
|
+ self.scenarios_base_level.extend(scenarios)
|
|
|
+ else:
|
|
|
+ self.scenarios_base_level.append(cycle)
|
|
|
+ return self.scenarios_base_level
|
|
|
|
|
|
def select_scenario(self, state: State, id: str, action: str, payload: t.Dict[str, str]):
|
|
|
args = payload.get("args")
|
|
|
if args is None or not isinstance(args, list) or len(args) == 0:
|
|
|
return
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ID_VAR, args[0])
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ID_VAR, args[0])
|
|
|
|
|
|
def get_scenario_by_id(self, id: str) -> t.Optional[Scenario]:
|
|
|
if not id:
|
|
@@ -169,11 +172,12 @@ class GuiCoreContext(CoreEventConsumerBase):
|
|
|
return None
|
|
|
|
|
|
def get_scenario_configs(self):
|
|
|
- if self.scenario_configs is None:
|
|
|
- configs = tp.Config.scenarios
|
|
|
- if isinstance(configs, dict):
|
|
|
- self.scenario_configs = [(id, f"{c.id}") for id, c in configs.items()]
|
|
|
- return self.scenario_configs
|
|
|
+ with self.lock:
|
|
|
+ if self.scenario_configs is None:
|
|
|
+ configs = tp.Config.scenarios
|
|
|
+ if isinstance(configs, dict):
|
|
|
+ self.scenario_configs = [(id, f"{c.id}") for id, c in configs.items()]
|
|
|
+ return self.scenario_configs
|
|
|
|
|
|
def crud_scenario(self, state: State, id: str, action: str, payload: t.Dict[str, str]):
|
|
|
args = payload.get("args")
|
|
@@ -190,97 +194,142 @@ class GuiCoreContext(CoreEventConsumerBase):
|
|
|
delete = args[1]
|
|
|
data = args[2]
|
|
|
scenario = None
|
|
|
- name = data.get(GuiCoreContext.__PROP_ENTITY_NAME)
|
|
|
+ name = data.get(_GuiCoreContext.__PROP_ENTITY_NAME)
|
|
|
if update:
|
|
|
- scenario_id = data.get(GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
+ scenario_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
if delete:
|
|
|
try:
|
|
|
tp.delete(scenario_id)
|
|
|
except Exception as e:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Error deleting Scenario. {e}")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Error deleting Scenario. {e}")
|
|
|
else:
|
|
|
scenario = tp.get(scenario_id)
|
|
|
else:
|
|
|
- config_id = data.get(GuiCoreContext.__PROP_SCENARIO_CONFIG_ID)
|
|
|
+ config_id = data.get(_GuiCoreContext.__PROP_SCENARIO_CONFIG_ID)
|
|
|
scenario_config = tp.Config.scenarios.get(config_id)
|
|
|
if scenario_config is None:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Invalid configuration id ({config_id})")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Invalid configuration id ({config_id})")
|
|
|
return
|
|
|
- date_str = data.get(GuiCoreContext.__PROP_SCENARIO_DATE)
|
|
|
+ date_str = data.get(_GuiCoreContext.__PROP_SCENARIO_DATE)
|
|
|
try:
|
|
|
date = parser.parse(date_str) if isinstance(date_str, str) else None
|
|
|
except Exception as e:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Invalid date ({date_str}).{e}")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Invalid date ({date_str}).{e}")
|
|
|
return
|
|
|
try:
|
|
|
scenario = tp.create_scenario(scenario_config, date, name)
|
|
|
except Exception as e:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Error creating Scenario. {e}")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Error creating Scenario. {e}")
|
|
|
if scenario:
|
|
|
with scenario as sc:
|
|
|
- sc._properties[GuiCoreContext.__PROP_ENTITY_NAME] = name
|
|
|
+ sc._properties[_GuiCoreContext.__PROP_ENTITY_NAME] = name
|
|
|
if props := data.get("properties"):
|
|
|
try:
|
|
|
for prop in props:
|
|
|
key = prop.get("key")
|
|
|
- if key and key not in GuiCoreContext.__SCENARIO_PROPS:
|
|
|
+ if key and key not in _GuiCoreContext.__SCENARIO_PROPS:
|
|
|
sc._properties[key] = prop.get("value")
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, "")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, "")
|
|
|
except Exception as e:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Error creating Scenario. {e}")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR, f"Error creating Scenario. {e}")
|
|
|
|
|
|
def edit_entity(self, state: State, id: str, action: str, payload: t.Dict[str, str]):
|
|
|
args = payload.get("args")
|
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
|
return
|
|
|
data = args[0]
|
|
|
- entity_id = data.get(GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
+ entity_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
entity: t.Union[Scenario, Pipeline] = tp.get(entity_id)
|
|
|
if entity:
|
|
|
with entity as ent:
|
|
|
try:
|
|
|
if isinstance(entity, Scenario):
|
|
|
- primary = data.get(GuiCoreContext.__PROP_SCENARIO_PRIMARY)
|
|
|
+ primary = data.get(_GuiCoreContext.__PROP_SCENARIO_PRIMARY)
|
|
|
if primary is True:
|
|
|
tp.set_primary(ent)
|
|
|
- tags = data.get(GuiCoreContext.__PROP_SCENARIO_TAGS)
|
|
|
+ tags = data.get(_GuiCoreContext.__PROP_SCENARIO_TAGS)
|
|
|
if isinstance(tags, (list, tuple)):
|
|
|
ent.tags = {t for t in tags}
|
|
|
- name = data.get(GuiCoreContext.__PROP_ENTITY_NAME)
|
|
|
+ name = data.get(_GuiCoreContext.__PROP_ENTITY_NAME)
|
|
|
if isinstance(name, str):
|
|
|
- ent.properties[GuiCoreContext.__PROP_ENTITY_NAME] = name
|
|
|
+ ent.properties[_GuiCoreContext.__PROP_ENTITY_NAME] = name
|
|
|
props = data.get("properties")
|
|
|
if isinstance(props, (list, tuple)):
|
|
|
for prop in props:
|
|
|
key = prop.get("key")
|
|
|
- if key and key not in GuiCoreContext.__SCENARIO_PROPS:
|
|
|
+ if key and key not in _GuiCoreContext.__SCENARIO_PROPS:
|
|
|
ent.properties[key] = prop.get("value")
|
|
|
deleted_props = data.get("deleted_properties")
|
|
|
if isinstance(deleted_props, (list, tuple)):
|
|
|
for prop in deleted_props:
|
|
|
key = prop.get("key")
|
|
|
- if key and key not in GuiCoreContext.__SCENARIO_PROPS:
|
|
|
+ if key and key not in _GuiCoreContext.__SCENARIO_PROPS:
|
|
|
ent.properties.pop(key, None)
|
|
|
- state.assign(GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, "")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, "")
|
|
|
except Exception as e:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, f"Error updating Scenario. {e}")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, f"Error updating Scenario. {e}")
|
|
|
|
|
|
def submit_entity(self, state: State, id: str, action: str, payload: t.Dict[str, str]):
|
|
|
args = payload.get("args")
|
|
|
if args is None or not isinstance(args, list) or len(args) < 1 or not isinstance(args[0], dict):
|
|
|
return
|
|
|
data = args[0]
|
|
|
- entity_id = data.get(GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
+ entity_id = data.get(_GuiCoreContext.__PROP_ENTITY_ID)
|
|
|
entity = tp.get(entity_id)
|
|
|
if entity:
|
|
|
try:
|
|
|
tp.submit(entity)
|
|
|
- state.assign(GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, "")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, "")
|
|
|
except Exception as e:
|
|
|
- state.assign(GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, f"Error submitting entity. {e}")
|
|
|
+ state.assign(_GuiCoreContext._SCENARIO_VIZ_ERROR_VAR, f"Error submitting entity. {e}")
|
|
|
+
|
|
|
+ def get_datanodes_tree(self):
|
|
|
+ with self.lock:
|
|
|
+ if self.data_nodes_base_level is None:
|
|
|
+ self.data_nodes_base_level = _GuiCoreContext.__get_data_nodes()
|
|
|
+ for cycle, scenarios in tp.get_cycles_scenarios().items():
|
|
|
+ if cycle is None:
|
|
|
+ self.data_nodes_base_level.extend(scenarios)
|
|
|
+ else:
|
|
|
+ self.data_nodes_base_level.append(cycle)
|
|
|
+ return self.data_nodes_base_level
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def __get_data_nodes(id: t.Optional[str] = None):
|
|
|
+ def from_parent(dn: DataNode):
|
|
|
+ if id is None and dn.owner_id is None:
|
|
|
+ return True
|
|
|
+ return False if id is None or dn.owner_id is None else dn.owner_id == id
|
|
|
+
|
|
|
+ return [x for x in tp.get_data_nodes() if from_parent(x)]
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def data_node_adapter(data):
|
|
|
+ if hasattr(data, "id") and tp.get(data.id) is not None:
|
|
|
+ if isinstance(data, Cycle):
|
|
|
+ return (
|
|
|
+ data.id,
|
|
|
+ data.get_simple_label(),
|
|
|
+ _GuiCoreContext.__get_data_nodes(data.id) + tp.get_scenarios(data),
|
|
|
+ 0,
|
|
|
+ False,
|
|
|
+ )
|
|
|
+ elif isinstance(data, Scenario):
|
|
|
+ return (
|
|
|
+ data.id,
|
|
|
+ data.get_simple_label(),
|
|
|
+ _GuiCoreContext.__get_data_nodes(data.id) + [tp.get(p) for p in data._pipelines],
|
|
|
+ 1,
|
|
|
+ data.is_primary,
|
|
|
+ )
|
|
|
+ elif isinstance(data, Pipeline):
|
|
|
+ return (data.id, data.get_simple_label(), _GuiCoreContext.__get_data_nodes(data.id), 2, False)
|
|
|
+ elif isinstance(data, DataNode):
|
|
|
+ return (data.id, data.get_simple_label(), None, 3, False)
|
|
|
+ return None
|
|
|
|
|
|
def broadcast_core_changed(self):
|
|
|
- self.gui.broadcast(GuiCoreContext._CORE_CHANGED_NAME, "")
|
|
|
+ self.gui.broadcast(_GuiCoreContext._CORE_CHANGED_NAME, "")
|
|
|
|
|
|
|
|
|
class GuiCore(ElementLibrary):
|
|
@@ -296,18 +345,19 @@ class GuiCore(ElementLibrary):
|
|
|
"show_primary_flag": ElementProperty(PropertyType.dynamic_boolean, True),
|
|
|
"value": ElementProperty(PropertyType.lov_value),
|
|
|
"on_change": ElementProperty(PropertyType.function),
|
|
|
+ "height": ElementProperty(PropertyType.string, "50vh"),
|
|
|
},
|
|
|
inner_properties={
|
|
|
"scenarios": ElementProperty(PropertyType.lov, f"{{{__CTX_VAR_NAME}.get_scenarios()}}"),
|
|
|
"on_scenario_crud": ElementProperty(PropertyType.function, f"{{{__CTX_VAR_NAME}.crud_scenario}}"),
|
|
|
"configs": ElementProperty(PropertyType.react, f"{{{__CTX_VAR_NAME}.get_scenario_configs()}}"),
|
|
|
- "core_changed": ElementProperty(PropertyType.broadcast, GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
- "error": ElementProperty(PropertyType.react, f"{{{GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR}}}"),
|
|
|
+ "core_changed": ElementProperty(PropertyType.broadcast, _GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
+ "error": ElementProperty(PropertyType.react, f"{{{_GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR}}}"),
|
|
|
"type": ElementProperty(PropertyType.inner, Scenario),
|
|
|
- "adapter": ElementProperty(PropertyType.inner, GuiCoreContext.scenario_adapter),
|
|
|
+ "adapter": ElementProperty(PropertyType.inner, _GuiCoreContext.scenario_adapter),
|
|
|
"scenario_edit": ElementProperty(
|
|
|
- GuiCoreScenarioAdapter,
|
|
|
- f"{{{__CTX_VAR_NAME}.get_scenario_by_id({GuiCoreContext._SCENARIO_SELECTOR_ID_VAR})}}",
|
|
|
+ _GuiCoreScenarioAdapter,
|
|
|
+ f"{{{__CTX_VAR_NAME}.get_scenario_by_id({_GuiCoreContext._SCENARIO_SELECTOR_ID_VAR})}}",
|
|
|
),
|
|
|
"on_scenario_select": ElementProperty(PropertyType.function, f"{{{__CTX_VAR_NAME}.select_scenario}}"),
|
|
|
},
|
|
@@ -316,7 +366,7 @@ class GuiCore(ElementLibrary):
|
|
|
"scenario",
|
|
|
{
|
|
|
"id": ElementProperty(PropertyType.string),
|
|
|
- "scenario": ElementProperty(GuiCoreScenarioAdapter),
|
|
|
+ "scenario": ElementProperty(_GuiCoreScenarioAdapter),
|
|
|
"active": ElementProperty(PropertyType.dynamic_boolean, True),
|
|
|
"expandable": ElementProperty(PropertyType.boolean, True),
|
|
|
"expanded": ElementProperty(PropertyType.dynamic_boolean, False),
|
|
@@ -333,15 +383,15 @@ class GuiCore(ElementLibrary):
|
|
|
"on_edit": ElementProperty(PropertyType.function, f"{{{__CTX_VAR_NAME}.edit_entity}}"),
|
|
|
"on_submit": ElementProperty(PropertyType.function, f"{{{__CTX_VAR_NAME}.submit_entity}}"),
|
|
|
"on_delete": ElementProperty(PropertyType.function, f"{{{__CTX_VAR_NAME}.crud_scenario}}"),
|
|
|
- "core_changed": ElementProperty(PropertyType.broadcast, GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
- "error": ElementProperty(PropertyType.react, f"{{{GuiCoreContext._SCENARIO_VIZ_ERROR_VAR}}}"),
|
|
|
+ "core_changed": ElementProperty(PropertyType.broadcast, _GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
+ "error": ElementProperty(PropertyType.react, f"{{{_GuiCoreContext._SCENARIO_VIZ_ERROR_VAR}}}"),
|
|
|
},
|
|
|
),
|
|
|
"dag": Element(
|
|
|
"scenario",
|
|
|
{
|
|
|
"id": ElementProperty(PropertyType.string),
|
|
|
- "scenario": ElementProperty(GuiCoreScenarioDagAdapter),
|
|
|
+ "scenario": ElementProperty(_GuiCoreScenarioDagAdapter),
|
|
|
"button_label": ElementProperty(PropertyType.dynamic_string),
|
|
|
"show": ElementProperty(PropertyType.dynamic_boolean, True),
|
|
|
"with_button": ElementProperty(PropertyType.boolean, True),
|
|
@@ -349,17 +399,23 @@ class GuiCore(ElementLibrary):
|
|
|
"height": ElementProperty(PropertyType.string),
|
|
|
},
|
|
|
inner_properties={
|
|
|
- "core_changed": ElementProperty(PropertyType.broadcast, GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
+ "core_changed": ElementProperty(PropertyType.broadcast, _GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
},
|
|
|
),
|
|
|
"data_node_selector": Element(
|
|
|
- "val",
|
|
|
+ "value",
|
|
|
{
|
|
|
- "val": ElementProperty(GuiCoreScenarioDagAdapter),
|
|
|
+ "display_cycles": ElementProperty(PropertyType.dynamic_boolean, True),
|
|
|
+ "show_primary_flag": ElementProperty(PropertyType.dynamic_boolean, True),
|
|
|
+ "value": ElementProperty(PropertyType.lov_value),
|
|
|
+ "on_change": ElementProperty(PropertyType.function),
|
|
|
+ "height": ElementProperty(PropertyType.string, "50vh"),
|
|
|
},
|
|
|
inner_properties={
|
|
|
- "scenarios": ElementProperty(PropertyType.lov, f"{{{__CTX_VAR_NAME}.get_scenarios()}}"),
|
|
|
- "core_changed": ElementProperty(PropertyType.broadcast, GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
+ "datanodes": ElementProperty(PropertyType.lov, f"{{{__CTX_VAR_NAME}.get_datanodes_tree()}}"),
|
|
|
+ "core_changed": ElementProperty(PropertyType.broadcast, _GuiCoreContext._CORE_CHANGED_NAME),
|
|
|
+ "type": ElementProperty(PropertyType.inner, DataNode),
|
|
|
+ "adapter": ElementProperty(PropertyType.inner, _GuiCoreContext.data_node_adapter),
|
|
|
},
|
|
|
),
|
|
|
}
|
|
@@ -374,13 +430,13 @@ class GuiCore(ElementLibrary):
|
|
|
return ["lib/taipy-gui-core.js"]
|
|
|
|
|
|
def on_init(self, gui: Gui) -> t.Optional[t.Tuple[str, t.Any]]:
|
|
|
- return GuiCore.__CTX_VAR_NAME, GuiCoreContext(gui)
|
|
|
+ return GuiCore.__CTX_VAR_NAME, _GuiCoreContext(gui)
|
|
|
|
|
|
def on_user_init(self, state: State):
|
|
|
for var in [
|
|
|
- GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR,
|
|
|
- GuiCoreContext._SCENARIO_SELECTOR_ID_VAR,
|
|
|
- GuiCoreContext._SCENARIO_VIZ_ERROR_VAR,
|
|
|
+ _GuiCoreContext._SCENARIO_SELECTOR_ERROR_VAR,
|
|
|
+ _GuiCoreContext._SCENARIO_SELECTOR_ID_VAR,
|
|
|
+ _GuiCoreContext._SCENARIO_VIZ_ERROR_VAR,
|
|
|
]:
|
|
|
state._add_attribute(var, "")
|
|
|
|