From 2c492af32f73df4503018d0ca5cdd48f1f073c5c Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Wed, 9 Oct 2013 17:46:33 +0400 Subject: [PATCH] Add job parameters and arguments configuration * Appearance config, params and/or args sections depending on job type: MR - only configs Pig - configs, params, args Hive - configs, params Fixes Bug #1228138 Change-Id: Ida66111bc9148adf7cb4a6667e214b12dc40aced --- savannadashboard/jobs/views.py | 12 + savannadashboard/jobs/workflows/launch.py | 18 +- .../templates/jobs/config_template.html | 215 +++++++++++------- 3 files changed, 165 insertions(+), 80 deletions(-) diff --git a/savannadashboard/jobs/views.py b/savannadashboard/jobs/views.py index 0e5efc87..8ff72570 100644 --- a/savannadashboard/jobs/views.py +++ b/savannadashboard/jobs/views.py @@ -14,7 +14,9 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +import json +from django.http import HttpResponse import logging from horizon import tables @@ -66,6 +68,16 @@ class LaunchJobView(workflows.WorkflowView): classes = ("ajax-modal") template_name = "jobs/launch.html" + def get(self, request, *args, **kwargs): + if request.is_ajax(): + if request.REQUEST.get("json", None): + job_id = request.REQUEST.get("job_id") + savanna = savannaclient(request) + job_type = savanna.jobs.get(job_id).type + return HttpResponse(json.dumps({"job_type": job_type}), + mimetype='application/json') + return super(LaunchJobView, self).get(request, args, kwargs) + def get_context_data(self, **kwargs): context = super(LaunchJobView, self).get_context_data(**kwargs) return context diff --git a/savannadashboard/jobs/workflows/launch.py b/savannadashboard/jobs/workflows/launch.py index fd398fca..5628f2bd 100644 --- a/savannadashboard/jobs/workflows/launch.py +++ b/savannadashboard/jobs/workflows/launch.py @@ -104,7 +104,15 @@ class JobConfigAction(workflows.Action): required=False, ) - conf_props = forms.CharField( + job_configs = forms.CharField( + required=False, + widget=forms.HiddenInput()) + + job_params = forms.CharField( + required=False, + widget=forms.HiddenInput()) + + job_args = forms.CharField( required=False, widget=forms.HiddenInput()) @@ -141,8 +149,12 @@ class JobConfig(workflows.Step): template_name = 'jobs/config_template.html' def contribute(self, data, context): - job_config = json.loads(data.get("conf_props", '{}')) - context["job_config"] = {"configs": job_config} + job_config = json.loads(data.get("job_configs", '{}')) + job_params = json.loads(data.get("job_params", '{}')) + job_args = json.loads(data.get("job_args", '{}')) + context["job_config"] = {"configs": job_config, + "params": job_params, + "args": job_args} return context diff --git a/savannadashboard/templates/jobs/config_template.html b/savannadashboard/templates/jobs/config_template.html index c38371c4..0f20acce 100644 --- a/savannadashboard/templates/jobs/config_template.html +++ b/savannadashboard/templates/jobs/config_template.html @@ -1,80 +1,28 @@ - - -{% include "horizon/common/_form_fields.html" %} - - - - - -
+ + + + +{% include "horizon/common/_form_fields.html" %} + + + + + + + +
+
+ +
+
+ +
+
+