From 3ac5bc1591b31b6b9d2dfce21153d9c8d63f60c6 Mon Sep 17 00:00:00 2001 From: jakeymac Date: Thu, 19 Dec 2024 15:44:22 -0700 Subject: [PATCH 1/2] added optional resource name for workflows --- .../workflows/map_workflows/spatial_condor_job_mwv.py | 7 ++++++- .../workflows/controllers/workflows/workflow_view.py | 8 +++++++- tethysext/workflows/models/workflow.py | 1 + .../workflows/templates/gizmos/new_workflow_modal.html | 4 ++++ tethysext/workflows/views/layouts/workflow_layout.py | 2 ++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tethysext/workflows/controllers/workflows/map_workflows/spatial_condor_job_mwv.py b/tethysext/workflows/controllers/workflows/map_workflows/spatial_condor_job_mwv.py index 6f6cf0b..6288895 100644 --- a/tethysext/workflows/controllers/workflows/map_workflows/spatial_condor_job_mwv.py +++ b/tethysext/workflows/controllers/workflows/map_workflows/spatial_condor_job_mwv.py @@ -118,6 +118,11 @@ def render_condor_jobs_table(self, request, session, workflow, current_step, pre # Get the current app step_url_name = self.get_step_url_name(request, workflow) + if workflow.resource_name: + nav_title = f'{workflow.resource_name}: {workflow.name}' + else: + nav_title = workflow.name + context = { 'workflow': workflow, 'steps': steps, @@ -129,7 +134,7 @@ def render_condor_jobs_table(self, request, session, workflow, current_step, pre 'finish_title': self.finish_title, 'previous_title': self.previous_title, 'back_url': self.back_url, - 'nav_title': workflow.name, + 'nav_title': nav_title, 'nav_subtitle': workflow.DISPLAY_TYPE_SINGULAR, 'jobs_table': jobs_table, 'base_template': self.base_template diff --git a/tethysext/workflows/controllers/workflows/workflow_view.py b/tethysext/workflows/controllers/workflows/workflow_view.py index 5501e67..d8fc393 100644 --- a/tethysext/workflows/controllers/workflows/workflow_view.py +++ b/tethysext/workflows/controllers/workflows/workflow_view.py @@ -88,6 +88,12 @@ def get_context(self, request, session, context, workflow_id, step_id, *args, ** # Get the current app step_url_name = self.get_step_url_name(request, workflow) + + if workflow.resource_name: + nav_title = f'{workflow.resource_name}: {workflow.name}' + else: + nav_title = workflow.name + context.update({ 'workflow': workflow, 'steps': steps, @@ -95,7 +101,7 @@ def get_context(self, request, session, context, workflow_id, step_id, *args, ** 'previous_step': previous_step, 'next_step': next_step, 'step_url_name': step_url_name, - 'nav_title': 'Replacement Resource Name: replacement workflow name', + 'nav_title': nav_title, 'nav_subtitle': workflow.DISPLAY_TYPE_SINGULAR, 'previous_title': self.previous_title, 'next_title': self.next_title, diff --git a/tethysext/workflows/models/workflow.py b/tethysext/workflows/models/workflow.py index aad7b58..1b3e816 100644 --- a/tethysext/workflows/models/workflow.py +++ b/tethysext/workflows/models/workflow.py @@ -77,6 +77,7 @@ class TethysWorkflow(WorkflowsBase, AttributesMixin, ResultsMixin): name = Column(String) date_created = Column(DateTime, default=dt.datetime.utcnow) _attributes = Column(String) + resource_name = Column(String, nullable=True) steps = relationship('Step', order_by='Step.order', backref='workflow', cascade='all,delete') diff --git a/tethysext/workflows/templates/gizmos/new_workflow_modal.html b/tethysext/workflows/templates/gizmos/new_workflow_modal.html index 08fec1a..75fc39e 100644 --- a/tethysext/workflows/templates/gizmos/new_workflow_modal.html +++ b/tethysext/workflows/templates/gizmos/new_workflow_modal.html @@ -25,6 +25,10 @@ {% endfor %} +
+ + +
- - + +
diff --git a/tethysext/workflows/templates/workflows/components/nav_header.html b/tethysext/workflows/templates/workflows/components/nav_header.html index 1c77c9e..97b1e8b 100644 --- a/tethysext/workflows/templates/workflows/components/nav_header.html +++ b/tethysext/workflows/templates/workflows/components/nav_header.html @@ -8,6 +8,9 @@ nav_title(str): Title to show at the top of the nav. nav_subtitle(str, optional): Sub-title to show below the title. +Optional Context Variables: + description(str): Description to show below the subtitle. + Required CSS: Optional CSS: @@ -32,6 +35,9 @@ {% if nav_subtitle %}

{{ nav_subtitle }}

{% endif %} + {% if description %} +

{{ description }}

+ {% endif %} {% endblock %} diff --git a/tethysext/workflows/views/layouts/workflow_layout.py b/tethysext/workflows/views/layouts/workflow_layout.py index c2a3300..957abda 100644 --- a/tethysext/workflows/views/layouts/workflow_layout.py +++ b/tethysext/workflows/views/layouts/workflow_layout.py @@ -159,7 +159,7 @@ def post(self, request, *args, **kwargs): if 'new-workflow' in params: workflow_name = params.get('workflow-name') workflow_type = params.get('workflow-type') - resource_name = params.get('resource-name', None) + description = params.get('description', None) if not workflow_name: messages.error(request, 'Unable to create new workflow: no name given.') @@ -174,7 +174,7 @@ def post(self, request, *args, **kwargs): workflow = workflow_model.new( app=self.app, name=workflow_name, - resource_name=resource_name, + description=description, creator_id = request.user.id, creator_name = request.user.username, geoserver_name = self.app.GEOSERVER_NAME,