112 lines
3.7 KiB
Python
112 lines
3.7 KiB
Python
from components.BaseCommandManager import BaseCommandManager
|
|
from components.workflows.constants import Routes, ROUTE_ROOT
|
|
|
|
|
|
class WorkflowsCommandManager(BaseCommandManager):
|
|
def __init__(self, owner):
|
|
super().__init__(owner)
|
|
|
|
def request_add_workflow(self):
|
|
return {
|
|
"hx-get": f"{ROUTE_ROOT}{Routes.AddWorkflow}",
|
|
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'{{"_id": "{self._id}"}}',
|
|
}
|
|
|
|
def add_workflow(self, tab_id: str):
|
|
return {
|
|
"hx-post": f"{ROUTE_ROOT}{Routes.AddWorkflow}",
|
|
"hx-target": f"#w_{self._id}",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "tab_id": "{tab_id}", "tab_boundaries": getTabContentBoundaries("{self._owner.tabs_manager.get_id()}")}}',
|
|
}
|
|
|
|
def show_workflow(self, workflow_name):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.ShowWorkflow}",
|
|
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "name": "{workflow_name}", "tab_boundaries": getTabContentBoundaries("{self._owner.tabs_manager.get_id()}")}}',
|
|
}
|
|
|
|
|
|
class WorkflowDesignerCommandManager(BaseCommandManager):
|
|
def __init__(self, owner):
|
|
super().__init__(owner)
|
|
|
|
def on_save(self):
|
|
return {}
|
|
|
|
def on_cancel(self):
|
|
return {}
|
|
|
|
def select_processor(self, component_id: str):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.SelectProcessor}",
|
|
"hx-target": f"#ppc_{self._id}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-trigger": "change",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "component_id": "{component_id}"}}',
|
|
}
|
|
|
|
def save_properties(self, component_id: str):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.SaveProperties}",
|
|
"hx-target": f"#p_{self._id}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "component_id": "{component_id}"}}',
|
|
}
|
|
|
|
def cancel_properties(self, component_id: str):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.CancelProperties}",
|
|
"hx-target": f"#p_{self._id}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "component_id": "{component_id}"}}',
|
|
}
|
|
|
|
def on_processor_details_event(self, component_id: str, event_name: str):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.OnProcessorDetailsEvent}",
|
|
"hx-target": f"#p_{self._id}",
|
|
"hx-trigger": "change",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "component_id": "{component_id}", "event_name": "{event_name}"}}',
|
|
}
|
|
|
|
def play_workflow(self):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.PlayWorkflow}",
|
|
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}", "tab_boundaries": getTabContentBoundaries("{self._owner.tabs_manager.get_id()}")}}',
|
|
}
|
|
|
|
def pause_workflow(self):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.PauseWorkflow}",
|
|
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
|
}
|
|
|
|
def stop_workflow(self):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.StopWorkflow}",
|
|
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
|
"hx-swap": "outerHTML",
|
|
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
|
}
|
|
|
|
def refresh(self):
|
|
return {
|
|
"hx_post": f"{ROUTE_ROOT}{Routes.Refresh}",
|
|
"hx-swap": "none",
|
|
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
|
}
|
|
|
|
|
|
class WorkflowPlayerCommandManager(BaseCommandManager):
|
|
def __init__(self, owner):
|
|
super().__init__(owner)
|