Commit 2fdab0b4 authored by Jerome Mariette's avatar Jerome Mariette

handle group from gui

parent 7c10905d
......@@ -111,20 +111,27 @@ class JFlowServer (object):
workflows = []
wf_instances = self.wfmanager.get_available_workflows()
for instance in wf_instances:
parameters = []
parameters, parameters_per_groups, groups = [], {}, ["default"]
for param in instance.parameters:
parameters.append({"help": param.help,
"required": param.required,
"default": param.default,
"choices": param.choices,
"action": param.action,
"type": param.get_type(),
"name": param.name,
"display_name": param.display_name})
hash_param = {"help": param.help,
"required": param.required,
"default": param.default,
"choices": param.choices,
"action": param.action,
"type": param.get_type(),
"name": param.name,
"display_name": param.display_name}
parameters.append(hash_param)
if parameters_per_groups.has_key(param.group):
parameters_per_groups[param.group].append(hash_param)
else: parameters_per_groups[param.group] = [hash_param]
groups.append(param.group)
workflows.append({"name": instance.name,
"help": instance.description,
"class": instance.__class__.__name__,
"parameters": parameters})
"parameters": parameters,
"parameters_per_groups": parameters_per_groups,
"groups": list(set(groups))})
return workflows
@cherrypy.expose
......
......@@ -216,49 +216,54 @@
serverURL: "http://localhost:8080",
template: ['<form id="workflow_form" class="form-horizontal">',
'<fieldset>',
' {{each(index, param) workflow.parameters}}',
' {{each(gindex, group) workflow.groups}}',
' {{each(index, param) workflow.parameters_per_groups[group]}}',
// it the parameter has not already been settled
' {{if Object.keys(parameters).indexOf(param.name) == -1 }}',
' <div class="control-group">',
' <label class="control-label">${param.display_name}</label>',
' <div class="controls">',
' {{if Object.keys(parameters).indexOf(param.name) == -1 }}',
' <div class="control-group">',
' {{if group != "default" && index == 0}}',
' <legend>${group}</legend>',
' {{/if}}',
' <label class="control-label">${param.display_name}</label>',
' <div class="controls">',
// if it's a multiple choice parameter, add a select
' {{if param.choices}}',
' <select id="${param.name}" name="${param.name}" class="input-xlarge">',
' {{each(j, choice) param.choices}}',
' {{if choice == param.default}}',
' <option selected>${choice}</option>',
' {{else}}',
' <option>${choice}</option>',
' {{/if}}',
' {{/each}}',
' </select>',
' {{if param.choices}}',
' <select id="${param.name}" name="${param.name}" class="input-xlarge">',
' {{each(j, choice) param.choices}}',
' {{if choice == param.default}}',
' <option selected>${choice}</option>',
' {{else}}',
' <option>${choice}</option>',
' {{/if}}',
' {{/each}}',
' </select>',
// if param is a date
' {{else param.type == "date"}}',
' <div class="input-append date" data-date="${param.default}" data-date-format="dd/mm/yyyy">',
' <input id="${param.name}" name="${param.name}" class="input-xlarge span2" type="text" value="${param.default}">',
' <button class="btn" type="button"><i class="icon-calendar"></i></button>',
' </div>',
' {{else param.type == "date"}}',
' <div class="input-append date" data-date="${param.default}" data-date-format="dd/mm/yyyy">',
' <input id="${param.name}" name="${param.name}" class="input-xlarge span2" type="text" value="${param.default}">',
' <button class="btn" type="button"><i class="icon-calendar"></i></button>',
' </div>',
// if param is a boolean
' {{else param.type == "bool"}}',
' <label class="checkbox">',
' {{if param.default == true}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" type="checkbox" checked>',
' {{else param.type == "bool"}}',
' <label class="checkbox">',
' {{if param.default == true}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" type="checkbox" checked>',
' {{else}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" type="checkbox">',
' {{/if}}',
' </label>',
// else a simple text input
' {{else}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" type="checkbox">',
' <input id="${param.name}" name="${param.name}" value="${param.default}" class="input-xlarge" type="text">',
' {{/if}}',
' </label>',
// else a simple text input
' <span class="help-block">${param.help}</span>',
' </div>',
' </div>',
' {{else}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" class="input-xlarge" type="text">',
' {{/if}}',
' <span class="help-block">${param.help}</span>',
' </div>',
' </div>',
' {{else}}',
// if the param is already settled, hide it
' <input id="${param.name}" name="${param.name}" value="${parameters[param.name]}" type="hidden">',
' {{/if}}',
' <input id="${param.name}" name="${param.name}" value="${parameters[param.name]}" type="hidden">',
' {{/if}}',
' {{/each}}',
' {{/each}}',
// for all workflow add the workflowClass
' <input name="workflow_class" value="${workflow.class}" type="hidden">',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment