Commit 4381e4a7 authored by matjaz's avatar matjaz
Browse files

Added context menu on treeview widget repository for categories and widgets to...

Added context menu on treeview widget repository for categories and widgets to directly access admin console.
Reorganised context menu
Run widget with hieraricaly running all predeccessos
Reset widget
Reset workflow
parent 01bd5979
......@@ -507,6 +507,19 @@ class Widget(models.Model):
self.save()
return None
def reset(self,offline):
for i in self.inputs.all():
if not i.parameter:
i.value = None
i.save()
for i in self.outputs.all():
i.value = None
i.save()
self.finished = False
self.error = False
self.running = False
self.save()
def run_post(self,request):
if not self.ready_to_run():
raise Exception("The prerequisites for running this widget have not been met.")
......
......@@ -62,3 +62,9 @@
.contextMenu LI.quit A { background-image: url(images/door.png); }
.contextMenu LI.runwidget A { background-image: url(images/control_play.png); }
.contextMenu LI.widgetproperties A { background-image: url(images/control_play.png); }
.contextMenu LI.runtree A { background-image: url(images/control_play_all.png); }
.contextMenu LI.resetwidget A { background-image: url(images/reset_widget.png); }
.contextMenu LI.resetworkflow A { background-image: url(images/reset_workflow.png); }
.contextMenu LI.rename A { background-image: url(images/rename.png); }
.contextMenu LI.view A { background-image: url(images/results.png); }
.contextMenu LI.help A { background-image: url(images/help.png); }
......@@ -360,6 +360,12 @@ function unfinish(widgetId) {
}
}
function unfinishOne(widgetId) {
$(".statusimage"+widgetId).hide();
$(".widget"+widgetId+"progressbar").css('width','0px');
$(".widget"+widgetId+"progress").hide();
executed[widgetId]=false;
}
function unfinishDescendants(widgetId) {
for (c in connections) {
if (connections[c].outputWidget==widgetId) {
......@@ -399,9 +405,61 @@ function runWidget(widgetId) {
$(".statusimage"+data.widget_id).hide();
$(".done"+data.widget_id).show();
}
executed[widgetId] = true;
},'json');
}
function waitPredecessorAndRunWidget(widgetId) {
allRun = true;
for (c in connections) {
if (connections[c].inputWidget==widgetId) {
if(!executed[connections[c].outputWidget]) {
allRun = false;
}
}
}
if (allRun)
runWidget(widgetId);
else
setTimeout(function(){waitPredecessorAndRunWidget(widgetId);},100);
}
function runTree(widgetId) {
$.post(url['get-executed-status'], { 'workflow_id':activeCanvasId }, function(data) {
executed = data.executedStatus;
runTreeRec(widgetId);
},'json');
}
function runTreeRec(widgetId) {
if(executed[widgetId]) return;
for (c in connections) {
if (connections[c].inputWidget==widgetId) {
runTreeRec(connections[c].outputWidget);
}
}
waitPredecessorAndRunWidget(widgetId);
}
function resetWidget(widgetId) {
$.post(url['reset-widget'], { 'widget_id':widgetId }, function(data) {
unfinishOne(widgetId)
for (c in connections) {
if (connections[c].outputWidget==widgetId) {
resetWidget(connections[c].inputWidget);
}
}
},'json');
}
function resetWorkflow() {
$.post(url['reset-workflow'], { 'workflow_id':activeCanvasId }, function(data) {
for (i in data.resetWidget) {
unfinishOne(data.resetWidget[i]);
}
},'json');
}
function updateProgressBar(widgetId) {
......@@ -860,7 +918,20 @@ function updateWidgetListeners() {
if (action=='properties') {
$("#widget"+thisWidgetId).dblclick();
}
if (action=='runtree') {
runTree(thisWidgetId);
}
if (action=='resetwidget') {
resetWidget(thisWidgetId);
}
if (action=='resetworkflow') {
resetWorkflow();
}
if (action=='results') {
showResults(thisWidgetId);
}
......@@ -1503,6 +1574,30 @@ $(function(){
setTimeout("resizeSvg()",1000);
//MatjazJ: Make links for admin editing widgets and categories directly from treeview
//doesnt matter if user manually tammpers this setting as he will not have permission to enter admin mode due to the provided django security
if(typeof userIsStaff === 'undefined') userIsStaff=false;
if(userIsStaff){
$(".wid, .folder").each(function () {
var thisWidgetType = $(this).attr('relType');
var thisWidgetId = $(this).attr('rel');
if ($(this).data('contextMenu') != true) {
$(this).contextMenu({
menu:'widMenu'
},
function (action, el, pos) {
if (action == 'edit') {
window.open('/admin/workflows/'+thisWidgetType+'/'+thisWidgetId, '', '');
}
});
$(this).data('contextMenu', true);
}
});
}
});
function refreshProgressBars() {
......
......@@ -57,6 +57,8 @@ url['synchronize-connections'] = "{% url 'synchronize connections' %}";
url['get-widget'] = "{% url 'get widget' %}";
url['get-parameters'] = "{% url 'get parameters' %}";
url['save-parameter'] = "{% url 'save parameter' %}";
url['get-configuration'] = "{% url 'get configuration' %}";
url['save-configuration'] = "{% url 'save configuration' %}";
url['get-rename'] = "{% url 'rename widget dialog' %}";
url['rename-widget'] = "{% url 'rename widget' %}";
url['rename-workflow'] = "{% url 'rename workflow' %}";
......@@ -75,12 +77,14 @@ url['get-designate-dialogs'] = "{% url 'get designate dialogs' %}";
url['save-designation'] = "{% url 'save designation' %}";
url['workflow-url'] = "{% url 'workflow url' %}";
url['unfinish-vizualizations'] = "{% url 'unfinish visualizations' %}";
url['get-configuration'] = "{% url 'get configuration' %}";
url['save-configuration'] = "{% url 'save configuration' %}";
url['reset-widget'] = "{% url 'reset widget' %}";
url['reset-workflow'] = "{% url 'reset workflow' %}";
url['get-executed-status'] = "{% url 'get executed status' %}";
static_url = "{{STATIC_URL}}";
activeCanvasId = {{ user.userprofile.active_workflow.id }}
activeCanvasId = {{ user.userprofile.active_workflow.id }};
userIsStaff = '{{ user.is_staff }}'=='True';
</script>
<script type="text/javascript">
......@@ -124,16 +128,23 @@ activeCanvasId = {{ user.userprofile.active_workflow.id }}
{% for category in categories %}
{% if not category.parent %}
{% if not category.user %}
<li class="closed"><span class="folder">{{ category.name }}</span><ul>
<li class="closed"><span class="folder" rel="{{ category.id }}" relType="category">{{ category.name }}</span><ul>
{% for c in category.children.all %}
<li class="closed"><span class="folder">{{ c.name }}</span><ul>
{% for widget in c.widgets.all %}
<li><a class="widget wid" rel="{{ widget.id }}"><span class="image" style="background-image:url('{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}');">{{ widget.name }}</span></a></li>
{% endfor %}
<li class="closed"><span class="folder" rel="{{ c.id }}" relType="category">{{ c.name }}</span><ul>
{% for d in c.children.all %}
<li class="closed"><span class="folder" rel="{{ d.id }}" relType="category">{{ d.name }}</span><ul>
{% for widget in d.widgets.all %}
<li><a class="widget wid" rel="{{ widget.id }}" relType="abstractwidget"><span class="image" style="background-size:16px;background-image:url('{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}');">{{ widget.name }}</span></a></li>
{% endfor %}
</ul></li>
{% endfor %}
{% for widget in c.widgets.all %}
<li><a class="widget wid" rel="{{ widget.id }}" relType="abstractwidget"><span class="image" style="background-size:16px;background-image:url('{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}');">{{ widget.name }}</span></a></li>
{% endfor %}
</ul></li>
{% endfor %}
{% for widget in category.widgets.all %}
<li><a class="widget wid" rel="{{ widget.id }}"><span class="image" style="background-image:url('{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}');">{{ widget.name }}</span></a></li>
<li><a class="widget wid" rel="{{ widget.id }}" relType="abstractwidget"><span class="image" style="background-size:16px;background-image:url('{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}');">{{ widget.name }}</span></a></li>
{% endfor %}
</ul></li>
{% endif %}
......@@ -236,15 +247,26 @@ Preconditions for running this widget have not yet been met. Do you want to run
<ul id="widgetMenu" class="contextMenu">
<li class="runwidget"><a href="#run">Run</a></li>
<li class="runtree"><a href="#runtree">Run</a></li>
<li class="runwidget"><a href="#run">Run only this</a></li>
<li style="font-size: 3px;"><hr style="border:0px; height:1px; color:lightgray;background-color:lightgray;"/></li>
<li class="edit"><a href="#properties">Properties</a></li>
<li class="delete"><a href="#delete">Delete</a></li>
<li style="font-size: 3px;"><hr style="border:0px; height:1px; color:lightgray;background-color:lightgray;"/></li>
<li class="view"><a href="#results">Results</a></li>
<li class="resetwidget"><a href="#resetwidget">Reset Widget</a></li>
<li class="resetworkflow"><a href="#resetworkflow">Reset Workflow</a></li>
<li style="font-size: 3px;"><hr style="border:0px; height:1px; color:lightgray;background-color:lightgray;"/></li>
<li class="rename"><a href="#rename">Rename</a></li>
<li class="copy"><a href="#copy">Copy Widget</a></li>
<li class="delete"><a href="#delete">Delete</a></li>
<li style="font-size: 3px;"><hr style="border:0px; height:1px; color:lightgray;background-color:lightgray;"/></li>
<li class="help"><a href="#help">Help</a></li>
</ul>
<ul id="widMenu" class="contextMenu">
<li class="edit"><a href="#edit">Edit Definition</a></li>
</ul>
<div style="position:absolute;top:50%;left:50%;display:none;z-index:1003;" class="ajax-loader">
<img src="{{STATIC_URL}}images/ajax-loader-big.gif">
</div>
......
......@@ -8,7 +8,7 @@
{% endfor %}
</div>
<div class="ui-widget-content {% ifequal widget.type 'for_input' %}ui-state-green{% endifequal %} {% ifequal widget.type 'for_output' %}ui-state-green{% endifequal %} ui-corner-all widgetcenter" style="padding-left:10px;padding-right:10px;">
<div style="width:34px;height:34px;background-repeat:no-repeat;background-position:center center;background-image:url('{% if widget.abstract_widget.image %}{{MEDIA_URL}}{{widget.abstract_widget.image}}{% else %}{% if widget.abstract_widget.wsdl %}{{STATIC_URL}}widget-icons/ws.png{% else %}{% if widget.workflow_link %}{{MEDIA_URL}}images/120px-Gears_icon.png{% else %}{% ifequal widget.type 'input' %}{{MEDIA_URL}}images/forward-arrow.png{% else %}{% ifequal widget.type 'output' %}{{MEDIA_URL}}images/forward-arrow.png{% else %}{% ifequal widget.type 'for_output' %}{{MEDIA_URL}}images/Toolbar_-_Loop.png{% else %}{% ifequal widget.type 'for_input' %}{{MEDIA_URL}}images/Toolbar_-_Loop.png{% else %}{{STATIC_URL}}widget-icons/question-mark.gif{% endifequal %}{% endifequal %}{% endifequal %}{% endifequal %}{% endif %}{% endif %}{% endif %}')">
<div style="width:34px;height:34px;background-size:100%;background-repeat:no-repeat;background-position:center center;background-image:url('{% if widget.abstract_widget.image %}{{MEDIA_URL}}{{widget.abstract_widget.image}}{% else %}{% if widget.abstract_widget.wsdl %}{{STATIC_URL}}widget-icons/ws.png{% else %}{% if widget.workflow_link %}{{MEDIA_URL}}images/120px-Gears_icon.png{% else %}{% ifequal widget.type 'input' %}{{MEDIA_URL}}images/forward-arrow.png{% else %}{% ifequal widget.type 'output' %}{{MEDIA_URL}}images/forward-arrow.png{% else %}{% ifequal widget.type 'for_output' %}{{MEDIA_URL}}images/Toolbar_-_Loop.png{% else %}{% ifequal widget.type 'for_input' %}{{MEDIA_URL}}images/Toolbar_-_Loop.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endifequal %}{% endifequal %}{% endifequal %}{% endifequal %}{% endif %}{% endif %}{% endif %}')">
</div></div>
<div class="outputs">
{% for output in widget.outputs.all %}
......
......@@ -52,4 +52,9 @@ urlpatterns = patterns('',
url(r'^(?P<workflow_id>[0-9]+)/$', 'workflows.views.open_workflow', name='open workflow'),
url(r'^sensitivity_analysis/', 'workflows.visualization_views.sensitivity_analysis_viewer', name='sensitivity analysis'),
url(r'^reset-widget/', 'workflows.views.reset_widget', name='reset widget'),
url(r'^get-executed-status/', 'workflows.views.get_executed_status', name='get executed status'),
url(r'^reset-workflow/', 'workflows.views.reset_workflow', name='reset workflow'),
)
\ No newline at end of file
......@@ -824,6 +824,101 @@ def run_widget(request):
else:
return HttpResponse(status=400)
@login_required
def run_tree(request):
if request.is_ajax() or DEBUG:
w = get_object_or_404(Widget, pk=request.POST['widget_id'])
if (w.workflow.user==request.user):
try:
if w.type == 'for_input' or w.type == 'for_output':
raise Exception("You can't run for loops like this. Please run the containing widget.")
output_dict = w.run(False)
mimetype = 'application/javascript'
if not w.abstract_widget is None:
if w.abstract_widget.interactive:
w.interaction_waiting = True
w.save()
data = simplejson.dumps({'status':'interactive','message':'Widget '+w.name+' needs your attention.','widget_id':w.id})
elif w.abstract_widget.visualization_view!='':
data = simplejson.dumps({'status':'visualize','message':'Visualizing widget '+w.name+'.','widget_id':w.id})
else:
data = simplejson.dumps({'status':'ok','message':'Widget '+w.name+' executed successfully.'})
else:
data = simplejson.dumps({'status':'ok','message':'Widget '+w.name+' executed successfully.'})
except Exception, e:
mimetype = 'application/javascript'
w.error = True
w.running = False
w.finished = False
w.save()
raise
for o in w.outputs.all():
o.value=None
o.save()
data = simplejson.dumps({'status':'error','message':'Error occured when trying to execute widget '+w.name+':<pre>'+str(sys.exc_info())+'</pre>'})
return HttpResponse(data,mimetype)
else:
return HttpResponse(status=400)
else:
return HttpResponse(status=400)
@login_required
def reset_widget(request):
if request.is_ajax() or DEBUG:
w = get_object_or_404(Widget, pk=request.POST['widget_id'])
if (w.workflow.user==request.user):
try:
w.reset(False)
data = simplejson.dumps({'status':'ok','message':'Widget '+w.name+' reset successfully.'})
mimetype = 'application/javascript'
except Exception, e:
mimetype = 'application/javascript'
w.error = True
w.running = False
w.finished = False
w.save()
raise
for o in w.outputs.all():
o.value=None
o.save()
data = simplejson.dumps({'status':'error','message':'Error occurred when trying to reset widget '+w.name+':<pre>'+str(sys.exc_info())+'</pre>'})
return HttpResponse(data,mimetype)
else:
return HttpResponse(status=400)
else:
return HttpResponse(status=400)
@login_required
def reset_workflow(request):
if request.is_ajax() or DEBUG:
workflow = get_object_or_404(Workflow, pk=request.POST['workflow_id'])
resetWidget = []
for w in workflow.widgets.all():
w.reset(False)
resetWidget.append(w.pk)
mimetype = 'application/javascript'
data = simplejson.dumps({'resetWidget':resetWidget})
return HttpResponse(data,mimetype)
else:
return HttpResponse(status=400)
@login_required
def get_executed_status(request):
if request.is_ajax() or DEBUG:
workflow = get_object_or_404(Workflow, pk=request.POST['workflow_id'])
executedStatus = {}
for w in workflow.widgets.all():
if w.error or w.running or not w.finished:
executedStatus[w.pk] = False
else:
executedStatus[w.pk] = True
mimetype = 'application/javascript'
data = simplejson.dumps({'executedStatus':executedStatus})
return HttpResponse(data,mimetype)
else:
return HttpResponse(status=400)
@login_required
def visualize_widget(request):
if request.is_ajax() or DEBUG:
......
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