Commit e3d356e9 authored by matjaz's avatar matjaz
Browse files

New functionality for widget configuration.

Widget configuration access link was added to the parameter dialog window (at the bottom).
User can configure his widget by:
- manually reordering inputs, outputs and parameters
- moving inputs to parameters and vice versa
Implementation required two new fields to be added in the database Input.order and Output.order
parent 72d403fe
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Input.order'
db.add_column('workflows_input', 'order',
self.gf('django.db.models.fields.PositiveIntegerField')(default=1),
keep_default=False)
# Adding field 'Output.order'
db.add_column('workflows_output', 'order',
self.gf('django.db.models.fields.PositiveIntegerField')(default=1),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Input.order'
db.delete_column('workflows_input', 'order')
# Deleting field 'Output.order'
db.delete_column('workflows_output', 'order')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'workflows.abstractinput': {
'Meta': {'ordering': "('order',)", 'object_name': 'AbstractInput'},
'default': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'multi': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'parameter': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'parameter_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'widget': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'inputs'", 'to': "orm['workflows.AbstractWidget']"})
},
'workflows.abstractoption': {
'Meta': {'ordering': "['name']", 'object_name': 'AbstractOption'},
'abstract_input': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'options'", 'to': "orm['workflows.AbstractInput']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'value': ('django.db.models.fields.TextField', [], {'blank': 'True'})
},
'workflows.abstractoutput': {
'Meta': {'ordering': "('order',)", 'object_name': 'AbstractOutput'},
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'widget': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'outputs'", 'to': "orm['workflows.AbstractWidget']"})
},
'workflows.abstractwidget': {
'Meta': {'ordering': "('order', 'name')", 'object_name': 'AbstractWidget'},
'action': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'category': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'widgets'", 'to': "orm['workflows.Category']"}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'has_progress_bar': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('workflows.thumbs.ThumbnailField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'interaction_view': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
'interactive': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'post_interact_action': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
'treeview_image': ('workflows.thumbs.ThumbnailField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'widgets'", 'null': 'True', 'to': "orm['auth.User']"}),
'visualization_view': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
'wsdl': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'wsdl_method': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'})
},
'workflows.category': {
'Meta': {'ordering': "('order', 'name')", 'object_name': 'Category'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['workflows.Category']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'categories'", 'null': 'True', 'to': "orm['auth.User']"}),
'workflow': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'categories'", 'null': 'True', 'to': "orm['workflows.Workflow']"})
},
'workflows.connection': {
'Meta': {'object_name': 'Connection'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'input': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'connections'", 'to': "orm['workflows.Input']"}),
'output': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'connections'", 'to': "orm['workflows.Output']"}),
'workflow': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'connections'", 'to': "orm['workflows.Workflow']"})
},
'workflows.input': {
'Meta': {'ordering': "('order',)", 'object_name': 'Input'},
'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'inner_output': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'outer_input_rel'", 'null': 'True', 'to': "orm['workflows.Output']"}),
'multi_id': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'outer_output': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'inner_input_rel'", 'null': 'True', 'to': "orm['workflows.Output']"}),
'parameter': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'parameter_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
'value': ('picklefield.fields.PickledObjectField', [], {'null': 'True'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'widget': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'inputs'", 'to': "orm['workflows.Widget']"})
},
'workflows.option': {
'Meta': {'ordering': "['name']", 'object_name': 'Option'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'input': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'options'", 'to': "orm['workflows.Input']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'})
},
'workflows.output': {
'Meta': {'ordering': "('order',)", 'object_name': 'Output'},
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'inner_input': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'outer_output_rel'", 'null': 'True', 'to': "orm['workflows.Input']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {'default': '1'}),
'outer_input': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'inner_output_rel'", 'null': 'True', 'to': "orm['workflows.Input']"}),
'short_name': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
'value': ('picklefield.fields.PickledObjectField', [], {'null': 'True'}),
'variable': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'widget': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'outputs'", 'to': "orm['workflows.Widget']"})
},
'workflows.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'active_workflow': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'users'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['workflows.Workflow']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'userprofile'", 'unique': 'True', 'to': "orm['auth.User']"})
},
'workflows.widget': {
'Meta': {'object_name': 'Widget'},
'abstract_widget': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'instances'", 'null': 'True', 'to': "orm['workflows.AbstractWidget']"}),
'error': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'finished': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'interaction_waiting': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
'progress': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'running': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'type': ('django.db.models.fields.CharField', [], {'default': "'regular'", 'max_length': '50'}),
'workflow': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'widgets'", 'to': "orm['workflows.Workflow']"}),
'x': ('django.db.models.fields.IntegerField', [], {}),
'y': ('django.db.models.fields.IntegerField', [], {})
},
'workflows.workflow': {
'Meta': {'ordering': "['name']", 'object_name': 'Workflow'},
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'default': "'Untitled workflow'", 'max_length': '200'}),
'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'template_parent': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['workflows.Workflow']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'workflows'", 'to': "orm['auth.User']"}),
'widget': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'workflow_link'", 'unique': 'True', 'null': 'True', 'to': "orm['workflows.Widget']"})
}
}
complete_apps = ['workflows']
\ No newline at end of file
...@@ -579,6 +579,10 @@ class Input(models.Model): ...@@ -579,6 +579,10 @@ class Input(models.Model):
('select', 'Select box'), ('select', 'Select box'),
) )
parameter_type = models.CharField(max_length=50,choices=PARAMETER_CHOICES,blank=True,null=True) parameter_type = models.CharField(max_length=50,choices=PARAMETER_CHOICES,blank=True,null=True)
order = models.PositiveIntegerField(default=1)
class Meta:
ordering = ('order',)
def __unicode__(self): def __unicode__(self):
return unicode(self.name) return unicode(self.name)
...@@ -600,6 +604,10 @@ class Output(models.Model): ...@@ -600,6 +604,10 @@ class Output(models.Model):
value = PickledObjectField(null=True) value = PickledObjectField(null=True)
inner_input = models.ForeignKey(Input,related_name="outer_output_rel",blank=True,null=True) #za subprocess inner_input = models.ForeignKey(Input,related_name="outer_output_rel",blank=True,null=True) #za subprocess
outer_input = models.ForeignKey(Input,related_name="inner_output_rel",blank=True,null=True) #za subprocess outer_input = models.ForeignKey(Input,related_name="inner_output_rel",blank=True,null=True) #za subprocess
order = models.PositiveIntegerField(default=1)
class Meta:
ordering = ('order',)
def __unicode__(self): def __unicode__(self):
return unicode(self.name) return unicode(self.name)
......
...@@ -163,4 +163,7 @@ td{ ...@@ -163,4 +163,7 @@ td{
padding: 5px 10px; text-align: right; padding: 5px 10px; text-align: right;
} }
.sortable { list-style-type: none; margin: 0; padding: 0; }
.sortable li { margin: 0 2px 2px 2px; padding: 0.4em; padding-left: 1.5em; }
.sortable li span { position: absolute; margin-left: -1.3em; }
...@@ -544,10 +544,69 @@ function updateWidgetListeners() { ...@@ -544,10 +544,69 @@ function updateWidgetListeners() {
unfinish(widgetId); unfinish(widgetId);
} }
$(this).dialog("close"); $(this).dialog("close");
$(this).remove();
} }
, ,
"Close": function() { "Close": function() {
$(this).dialog("close"); $(this).dialog("close");
$(this).remove();
}
}
});
$("#dialogs div.widgetconfdialog").dialog({
autoOpen: false,
modal: false,
resizable: true,
width: 600,
buttons: {
"Apply": function() {
var inputs = new Array();
$(this).find("#inputs").children().each(function() {
var id = $(this).attr('id').replace("input-","");
inputs.push(parseInt(id));
});
var params = new Array();
$(this).find("#params").children().each(function() {
var id = $(this).attr('id').replace("input-","");
params.push(parseInt(id));
});
var outputs = new Array();
$(this).find("#outputs").children().each(function() {
var id = $(this).attr('id').replace("output-","");
outputs.push(parseInt(id));
});
var widgetId = $(this).attr('id').replace("widgetconfiguration-","");
$.ajax({
url: url['save-configuration'],
type: "POST",
data: { 'widgetId':widgetId, 'inputs':inputs, 'params':params, 'outputs':outputs },
dataType: "json",
traditional: true,
success: function(data) {
if (data.changed || data.reordered) {
unfinish(widgetId);
refreshWidget(widgetId, activeCanvasId);
$('#widgetpreferences-'+widgetId).remove();
$('#widgetconfiguration-'+widgetId).remove();
reportStatus("Successfully saved widget configuration.");
}
else {
$('#widgetconfiguration-'+widgetId).remove();
}
},
error: function(e,f) {
$('#widgetpreferences-'+widgetId).remove();
$('#widgetconfiguration-'+widgetId).remove();
reportError("Error saving widget configuration!");
}
});
}
,
"Close": function() {
$(this).dialog("close");
$(this).remove();
} }
} }
}); });
...@@ -968,6 +1027,23 @@ function updateWidgetListeners() { ...@@ -968,6 +1027,23 @@ function updateWidgetListeners() {
} }
function openConfiguration(thisWidgetId) {
var dialog = $("#widgetconfiguration-"+thisWidgetId);
if (dialog.size()==0) {
$.post(url['get-configuration'], {'widget_id':thisWidgetId}, function(data) {
$("#dialogs").append(data);
updateWidgetListeners();
fileListeners();
dialog = $("#widgetconfiguration-"+thisWidgetId);
$( "#inputs, #params" ).sortable({connectWith:".inputsParams"}).disableSelection();
$( "#outputs" ).sortable().disableSelection();
dialog.dialog('open');
},'html');
} else {
dialog.dialog('open');
}
}
function addConnection(output,input) { function addConnection(output,input) {
$.post(url['add-connection'], { "output_id": output, "input_id": input }, function(data) { $.post(url['add-connection'], { "output_id": output, "input_id": input }, function(data) {
......
{% load url from future %}
<div id="widgetconfiguration-{{widget.pk}}" rel="{{widget.pk}}" class="widgetconfdialog" title="{{widget.name}} input / output configuration" style="width:1000px;">
Drag and drop to change the order of the widget's inputs.
You can also pick an input and move it to the parameters or vice-versa.
Reorganize widgets inputs and parameters to best suit your workflow needs.
<br/><br/>
<div>
<div style="width:49%; float: left;">
<div style="text-align: center; width:100%;">Inputs</div>
<div style="border: solid 1px #a9a9a9; background-color: white ; padding: 2px; padding-top:3px; margin-top:2px">
<ul id="inputs" class="inputsParams sortable" style="min-height:2em;">
{% for p in inputs %}
<li id="input-{{p.pk}}" class="wid-input ui-state-default">
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
({{p.short_name}}) {{p.name}}
</li>
{% endfor %}
</ul>
</div>
</div>
<div style="width:2%; float: left;">
<span class="ui-icon ui-icon-arrowthick-2-e-w">&nbsp</span>
</div>
<div style="width:49%; float: left;">
<div style="text-align: center; width:100%;">Parameters</div>
<div style="border: solid 1px #a9a9a9; background-color: white ; padding: 2px; padding-top:3px; margin-top:2px">
<ul id="params" class="inputsParams sortable" style="min-height:2em;">
{% for p in parameters %}
<li id="input-{{p.pk}}" class="wid-param ui-state-default">
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
({{p.short_name}}) {{p.name}}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
<div class="clear"><!----></div>
<div style="font-size: 3px;"><hr style="border:0px; height:1px; margin-top: 10px;margin-bottom: 10px; color:lightgray;background-color:lightgray;"/></div>
Drag and drop to change the order of the widget's outputs. Mainly used for resolving entangled connections on a workflow.
<br/><br/>
<div>
<div>
<div style="width:15%; float: left;">&nbsp</div>
<div style="width:70%; float: left;">
<div style="text-align: center; width:100%;">Outputs</div>
<div style="border: solid 1px #a9a9a9; background-color: white ; padding: 2px; padding-top:3px; margin-top:2px">
<ul id="outputs" class="sortable" style="min-height:2em;">
{% for p in outputs %}
<li id="output-{{p.pk}}" class="wid-output ui-state-default">
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
({{p.short_name}}) {{p.name}}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -73,6 +73,8 @@ url['get-designate-dialogs'] = "{% url 'get designate dialogs' %}"; ...@@ -73,6 +73,8 @@ url['get-designate-dialogs'] = "{% url 'get designate dialogs' %}";
url['save-designation'] = "{% url 'save designation' %}"; url['save-designation'] = "{% url 'save designation' %}";
url['workflow-url'] = "{% url 'workflow url' %}"; url['workflow-url'] = "{% url 'workflow url' %}";
url['unfinish-vizualizations'] = "{% url 'unfinish visualizations' %}"; url['unfinish-vizualizations'] = "{% url 'unfinish visualizations' %}";
url['get-configuration'] = "{% url 'get configuration' %}";
url['save-configuration'] = "{% url 'save configuration' %}";
static_url = "{{STATIC_URL}}"; static_url = "{{STATIC_URL}}";
......
...@@ -31,4 +31,6 @@ ...@@ -31,4 +31,6 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</fieldset> </fieldset>
<br/>
<a href="#" onclick="openConfiguration({{widget.pk}})" style="color:#a9a9a9;">Advanced widget's input/output configuration</a>
</div> </div>
\ No newline at end of file
...@@ -19,6 +19,8 @@ urlpatterns = patterns('', ...@@ -19,6 +19,8 @@ urlpatterns = patterns('',
url(r'^get-widget/', 'workflows.views.get_widget', name='get widget'), url(r'^get-widget/', 'workflows.views.get_widget', name='get widget'),
url(r'^get-parameters/', 'workflows.views.get_parameters', name='get parameters'), url(r'^get-parameters/', 'workflows.views.get_parameters', name='get parameters'),
url(r'^save-parameter/', 'workflows.views.save_parameter', name='save parameter'), url(r'^save-parameter/', 'workflows.views.save_parameter', name='save parameter'),
url(r'^get-configuration/', 'workflows.views.get_configuration', name='get configuration'),
url(r'^save-configuration/', 'workflows.views.save_configuration', name='save configuration'),
url(r'^get-rename/', 'workflows.views.get_rename_dialog', name='rename widget dialog'), url(r'^get-rename/', 'workflows.views.get_rename_dialog', name='rename widget dialog'),
url(r'^rename-widget/', 'workflows.views.rename_widget', name='rename widget'), url(r'^rename-widget/', 'workflows.views.rename_widget', name='rename widget'),
url(r'^rename-workflow/', 'workflows.views.rename_workflow', name='rename workflow'), url(r'^rename-workflow/', 'workflows.views.rename_workflow', name='rename workflow'),
......
...@@ -97,6 +97,8 @@ def add_widget(request): ...@@ -97,6 +97,8 @@ def add_widget(request):
w.abstract_widget = aw w.abstract_widget = aw
w.type = 'regular' w.type = 'regular'
w.save() w.save()
inputOrder = 0
paramOrder = 0
for i in aw.inputs.all(): for i in aw.inputs.all():
j = Input() j = Input()
j.name = i.name j.name = i.name
...@@ -107,6 +109,12 @@ def add_widget(request): ...@@ -107,6 +109,12 @@ def add_widget(request):
j.required = i.required j.required = i.required
j.parameter = i.parameter j.parameter = i.parameter
j.value = None j.value = None
if (i.parameter):
paramOrder += 1
j.order = paramOrder
else:
inputOrder += 1
j.order = inputOrder
if not i.multi: if not i.multi:
j.value = i.default j.value = i.default
j.parameter_type = i.parameter_type j.parameter_type = i.parameter_type
...@@ -119,6 +127,7 @@ def add_widget(request): ...@@ -119,6 +127,7 @@ def add_widget(request):
o.value = k.value o.value = k.value
o.input = j o.input = j
o.save() o.save()
outputOrder = 0
for i in aw.outputs.all(): for i in aw.outputs.all():
j = Output() j = Output()
j.name = i.name j.name = i.name
...@@ -126,6 +135,8 @@ def add_widget(request): ...@@ -126,6 +135,8 @@ def add_widget(request):
j.description = i.description j.description = i.description
j.variable = i.variable j.variable = i.variable
j.widget = w j.widget = w
outputOrder += 1
j.order = outputOrder
j.save() j.save()
return render(request, 'widgets.html', {'widgets':[w,]}) return render(request, 'widgets.html', {'widgets':[w,]})
else: else:
...@@ -612,7 +623,80 @@ def save_parameter(request): ...@@ -612,7 +623,80 @@ def save_parameter(request):
return HttpResponse(status=400) return HttpResponse(status=400)
else: else:
return HttpResponse(status=400) return HttpResponse(status=400)
@login_required
def get_configuration(request):
if request.is_ajax() or DEBUG:
w = get_object_or_404(Widget, pk=request.POST['widget_id'])
if (w.workflow.user==request.user):
inputs = w.inputs.filter(parameter=False);
parameters = w.inputs.filter(parameter=True);
outputs = w.outputs.all();
return render(request, 'configuration.html', {'widget':w,'inputs': inputs, 'parameters':parameters, 'outputs':outputs})
else:
return HttpResponse(status=400)
else:
return HttpResponse(status=400)
@login_required
def save_configuration(request):
if request.is_ajax() or DEBUG:
widget = get_object_or_404(Widget, pk=request.POST['widgetId'])
if (widget.workflow.user==request.user):
inputs = request.POST.getlist('inputs')
params = request.POST.getlist('params')
outputs = request.POST.getlist('outputs')
changed = False
reordered = False
for (id, input) in enumerate(inputs):
inp = get_object_or_404(Input, pk=input)
id += 1
if (inp.widget.workflow.user!=request.user):
return HttpResponse(status=400)
if (inp.parameter):
inp.parameter = False
changed = True
inp.save()
if (inp.order != id):
inp.order = id
reordered = True
inp.save()
for (id, input) in enumerate(params):
inp = get_object_or_404(Input, pk=input)
id += 1
if (inp.widget.workflow.user!=request.user):
return HttpResponse(status=400)
if (not inp.parameter):
#need to be careful if connections are set up to this input and need to be removed