Added Default Filter and Presenter Processors
This commit is contained in:
@@ -80,7 +80,8 @@ class WorkflowDesigner(BaseComponent):
|
||||
x=int(x),
|
||||
y=int(y),
|
||||
title=info["title"],
|
||||
description=info["description"]
|
||||
description=info["description"],
|
||||
properties={"processor_name": PROCESSOR_TYPES[component_type][0]}
|
||||
)
|
||||
|
||||
self._state.components[component_id] = component
|
||||
@@ -151,7 +152,10 @@ class WorkflowDesigner(BaseComponent):
|
||||
return self.refresh_properties()
|
||||
|
||||
def set_selected_processor(self, component_id: str, processor_name: str):
|
||||
self._state.selected_processor_name[component_id] = processor_name
|
||||
if component_id in self._state.components:
|
||||
component = self._state.components[component_id]
|
||||
component.properties = {"processor_name": processor_name}
|
||||
|
||||
self._db.save_state(self._key, self._state)
|
||||
return self.refresh_properties()
|
||||
|
||||
@@ -160,7 +164,8 @@ class WorkflowDesigner(BaseComponent):
|
||||
component = self._state.components[component_id]
|
||||
if event_name == "OnRepositoryChanged":
|
||||
component.properties["repository"] = details["repository"]
|
||||
component.properties["table"] = None
|
||||
tables = DbManagementHelper.list_tables(self._session, details["repository"])
|
||||
component.properties["table"] = tables[0] if len(tables) > 0 else None
|
||||
|
||||
return self.refresh_properties()
|
||||
|
||||
@@ -247,6 +252,10 @@ class WorkflowDesigner(BaseComponent):
|
||||
return self._mk_jira_processor_details(component)
|
||||
elif processor_name == "Repository":
|
||||
return self._mk_repository_processor_details(component)
|
||||
elif component.type == "filter" and processor_name == "Default":
|
||||
return self._mk_filter_processor_details(component)
|
||||
elif component.type == "presenter" and processor_name == "Default":
|
||||
return self._mk_presenter_processor_details(component)
|
||||
|
||||
return Div('Not defined yet !')
|
||||
|
||||
@@ -277,7 +286,7 @@ class WorkflowDesigner(BaseComponent):
|
||||
else:
|
||||
component_id = self._state.selected_component_id
|
||||
component = self._state.components[component_id]
|
||||
selected_processor_name = self._state.selected_processor_name.get(component_id, None)
|
||||
selected_processor_name = component.properties["processor_name"]
|
||||
icon = COMPONENT_TYPES[component.type]["icon"]
|
||||
color = COMPONENT_TYPES[component.type]["color"]
|
||||
return Form(
|
||||
@@ -317,21 +326,40 @@ class WorkflowDesigner(BaseComponent):
|
||||
selected_repo = component.properties.get("repository", None)
|
||||
selected_table = component.properties.get("table", None)
|
||||
|
||||
def _mk_repositories_options():
|
||||
repositories = DbManagementHelper.list_repositories(self._session)
|
||||
if len(repositories) == 0:
|
||||
return [Option("No repository available", disabled=True)]
|
||||
|
||||
return ([Option("Choose a repository", disabled=True, selected="selected" if selected_repo is None else None)] +
|
||||
[Option(repo.name, selected="selected" if repo.name == selected_repo else None)
|
||||
for repo in DbManagementHelper.list_repositories(self._session)])
|
||||
|
||||
def _mk_tables_options():
|
||||
if selected_repo is None:
|
||||
return [Option("No repository selected", disabled=True)]
|
||||
|
||||
tables = DbManagementHelper.list_tables(self._session, selected_repo)
|
||||
if len(tables) == 0:
|
||||
return [Option("No table available", disabled=True)]
|
||||
|
||||
return ([Option("Choose a table", disabled=True, selected="selected" if selected_table is None else None)] +
|
||||
[Option(table, selected="selected" if table == selected_table else None)
|
||||
for table in DbManagementHelper.list_tables(self._session, selected_repo)])
|
||||
|
||||
return Div(
|
||||
Fieldset(
|
||||
Legend("Repository", cls="fieldset-legend"),
|
||||
Div(
|
||||
Select(
|
||||
*[Option(repo.name, selected="selected" if repo.name == selected_repo else None)
|
||||
for repo in DbManagementHelper.list_repositories(self._session)],
|
||||
*_mk_repositories_options(),
|
||||
cls="select w-64",
|
||||
id=f"repository_{self._id}",
|
||||
name="repository",
|
||||
**self.commands.on_processor_details_event(component.id, "OnRepositoryChanged"),
|
||||
),
|
||||
Select(
|
||||
*[Option(table, selected="selected" if table == selected_table else None)
|
||||
for table in DbManagementHelper.list_tables(self._session, selected_repo)],
|
||||
*_mk_tables_options(),
|
||||
cls="select w-64 ml-4",
|
||||
id=f"table_{self._id}",
|
||||
name="table",
|
||||
@@ -344,6 +372,36 @@ class WorkflowDesigner(BaseComponent):
|
||||
)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _mk_filter_processor_details(component):
|
||||
return Div(
|
||||
Fieldset(
|
||||
Legend("Filter", cls="fieldset-legend"),
|
||||
Input(type="text",
|
||||
name="filter",
|
||||
value=component.properties.get("filter", ""),
|
||||
placeholder="Enter filter expression",
|
||||
cls="input w-full"),
|
||||
P("Write your filter expression (python syntax)"),
|
||||
cls="fieldset bg-base-200 border-base-300 rounded-box border p-4"
|
||||
)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _mk_presenter_processor_details(component):
|
||||
return Div(
|
||||
Fieldset(
|
||||
Legend("Filter", cls="fieldset-legend"),
|
||||
Input(type="text",
|
||||
name="filter",
|
||||
value=component.properties.get("filter", ""),
|
||||
placeholder="Enter filter expression",
|
||||
cls="input w-full"),
|
||||
P("Comma separated list of columns to display. Use * to display all columns, source=dest to rename columns."),
|
||||
cls="fieldset bg-base-200 border-base-300 rounded-box border p-4"
|
||||
)
|
||||
)
|
||||
|
||||
def _get_properties_height(self):
|
||||
print(f"height: {self._boundaries['height']}")
|
||||
return self._boundaries["height"] - self._state.designer_height - 86
|
||||
|
||||
@@ -17,7 +17,7 @@ class WorkflowComponent:
|
||||
y: int
|
||||
title: str
|
||||
description: str
|
||||
properties: dict = field(default_factory=dict)
|
||||
properties: dict
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -39,7 +39,6 @@ class WorkflowsDesignerState:
|
||||
component_counter = 0
|
||||
designer_height = 230
|
||||
selected_component_id = None
|
||||
selected_processor_name: dict = field(default_factory=dict) # selected processor for each component
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user