Commit fd1af499 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

first version to display a connected graph

parent 82248bc5
......@@ -183,7 +183,7 @@ if __name__ == '__main__':
elif args["cmd_object"] == "rerun":
wfmanager.rerun_workflow(args["workflow_id"])
elif args["cmd_object"] == "execution_graph":
wfmanager.get_workflow_execution_graph(args["workflow_id"])
print wfmanager.get_workflow_execution_graph(args["workflow_id"])
elif args["cmd_object"] == "status":
if args["workflow_id"]:
workflow = wfmanager.get_workflow(args["workflow_id"])
......
......@@ -286,13 +286,17 @@ class JFlowServer (object):
currentFile.file.name,
os.path.join(formFields.get_tmp_directory(), formFields.getvalue("prefix") + "_" + currentFile.filename.encode('ascii','ignore'))
)
@cherrypy.expose
@jsonify
def get_workflows_status(self, **kwargs):
if kwargs.has_key("workflow_id"):
workflow = self.wfmanager.get_workflow(kwargs["workflow_id"])
return self.jsonify_workflow_status(workflow)
if kwargs["display"] == "list":
workflow = self.wfmanager.get_workflow(kwargs["workflow_id"])
return self.jsonify_workflow_status(workflow)
elif kwargs["display"] == "graph":
g = self.wfmanager.get_workflow_execution_graph(kwargs["workflow_id"])
return {"edges": g.edges(), "vertices": g.vertices()}
else:
status = []
workflows = self.wfmanager.get_workflows()
......
......@@ -146,6 +146,7 @@
<script src="../src/js/jquery.fileupload.js"></script>
<script src="../src/js/jquery.fileupload-process.js"></script>
<script src="../src/js/jquery.fileupload-validate.js"></script>
<script src='../src/js/cytoscape.min.js' type='text/javascript'></script>
<script src='../src/js/jflow-activewf.js' type='text/javascript'></script>
<script src='../src/js/jflow-availablewf.js' type='text/javascript'></script>
......
......@@ -118,6 +118,8 @@
<script src="../src/js/jquery.fileupload.js"></script>
<script src="../src/js/jquery.fileupload-process.js"></script>
<script src="../src/js/jquery.fileupload-validate.js"></script>
<script src='../src/js/cytoscape.min.js' type='text/javascript'></script>
<script src='../src/js/jflow-activewf.js' type='text/javascript'></script>
<script src='../src/js/jflow-availablewf.js' type='text/javascript'></script>
<script src='../src/js/jflow-wfform.js' type='text/javascript'></script>
......
......@@ -27,7 +27,10 @@ class Graph(object):
def edges(self):
""" returns the edges of a graph """
return self.__generate_edges()
edges = []
for edge in self.__generate_edges():
edges.append(list(edge))
return edges
def add_vertex(self, vertex):
""" If the vertex "vertex" is not in
......
......@@ -324,9 +324,8 @@ class Workflow(threading.Thread):
for ioparameter in cpt.__dict__.values():
if ( issubclass( ioparameter.__class__, InputFile ) or issubclass( ioparameter.__class__, OutputFile)
or issubclass( ioparameter.__class__, InputFileList) or issubclass( ioparameter.__class__, OutputFileList) ):
print ioparameter.name, ioparameter.component_nameid, ioparameter.parent_component_nameid
graph.add_edge({ioparameter.component_nameid, ioparameter.parent_component_nameid})
print graph
return graph
def set_stderr(self):
if hasattr(self, "stderr") and self.stderr is not None:
......
......@@ -115,7 +115,7 @@ class WorkflowsManager(object):
def get_workflow_execution_graph(self, workflow_id):
workflow = self.get_workflow(workflow_id)
workflow.get_execution_graph()
return workflow.get_execution_graph()
def get_workflows(self):
workflows = []
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -85,12 +85,12 @@
}
});
}
WFStatus.prototype.reload = function() {
WFStatus.prototype._listview = function() {
if (this.options.forceUsingWorkflow) {
var workflow = this.reformatWorkflowJSON(this.options.forceUsingWorkflow);
this.$element.html("");
$.tmpl(this.options.template, {workflow: workflow}).appendTo(this.$element);
$.tmpl(this.options.listTemplate, {workflow: workflow}).appendTo(this.$element);
// force for first display, then reload an update
this.options.forceUsingWorkflow = null;
} else if (this.options.workflowID) {
......@@ -108,6 +108,7 @@
'</div></div> <div class="span6">Please wait until modul is being loaded!</div></div>'].join('\n');
$this.$element.html(waiting_animation);
if (this.options.workflowID) { params = "workflow_id=" + this.options.workflowID + "&"; }
params += "display=" + this.options.display + "&";
$.ajax({
url: this.options.serverURL + '/get_workflows_status?'+params+'callback=?',
dataType: "json",
......@@ -122,11 +123,128 @@
success: function(data) {
var workflow = $this.reformatWorkflowJSON(data);
$this.$element.html("");
$.tmpl($this.options.template, {workflow: workflow}).appendTo($this.$element);
$.tmpl($this.options.listTemplate, {workflow: workflow}).appendTo($this.$element);
$this.errorMessage();
}
});
}
}
}
WFStatus.prototype._graphview = function() {
var $this = this,
params = "",
waiting_animation = ['<div class="row-fluid"><div class="span1 offset3"><div class="inline floatingBarsG">',
'<div class="blockG" id="rotateG_01"></div>',
'<div class="blockG" id="rotateG_02"></div>',
'<div class="blockG" id="rotateG_03"></div>',
'<div class="blockG" id="rotateG_04"></div>',
'<div class="blockG" id="rotateG_05"></div>',
'<div class="blockG" id="rotateG_06"></div>',
'<div class="blockG" id="rotateG_07"></div>',
'<div class="blockG" id="rotateG_08"></div>',
'</div></div> <div class="span6">Please wait until modul is being loaded!</div></div>'].join('\n');
$this.$element.html(waiting_animation);
if (this.options.workflowID) { params = "workflow_id=" + this.options.workflowID + "&"; }
params += "display=" + this.options.display + "&";
$.ajax({
url: this.options.serverURL + '/get_workflows_status?'+params+'callback=?',
dataType: "json",
timeout: 20000,
error: function (xhr, ajaxOptions, thrownError) {
var alert_message = ['<div class="alert alert-error">',
'<strong>Error!</strong>',
'Jflow failed to connect to the specified server <strong>' + $this.options.serverURL + '</strong>',
'</div>'].join('\n');
$this.$element.html(alert_message);
},
success: function(data) {
// prepare the container
$this.$element.html("");
$this.$element.height(500);
//$this.$element.width(200);
// prepare the data
var nodes = new Array(),
edges = new Array();
for (var i in data.vertices) {
if (data.vertices[i] != null) {
nodes.push({ data: { id: data.vertices[i], name: data.vertices[i] } });
}
}
for (var i in data.edges) {
if (data.edges[i][0] != null && data.edges[i][1] != null) {
edges.push({ data: { source: data.edges[i][0], target: data.edges[i][1] } });
}
}
$this.$element.cytoscape({
style: cytoscape.stylesheet()
.selector('node')
.css({
'content': 'data(name)',
'text-valign': 'center',
'color': 'white',
'text-outline-width': 2,
'text-outline-color': '#888'
})
.selector('edge')
.css({
'target-arrow-shape': 'triangle'
})
.selector(':selected')
.css({
'background-color': 'black',
'line-color': 'black',
'target-arrow-color': 'black',
'source-arrow-color': 'black'
})
.selector('.faded')
.css({
'opacity': 0.25,
'text-opacity': 0
}),
elements: {
nodes: nodes,
edges: edges
},
layout: {
name: 'grid',
padding: 10
},
ready: function(){
window.cy = this;
cy.elements().unselectify();
cy.on('tap', 'node', function(e){
var node = e.cyTarget;
var neighborhood = node.neighborhood().add(node);
cy.elements().addClass('faded');
neighborhood.removeClass('faded');
});
cy.on('tap', function(e){
if( e.cyTarget === cy ){
cy.elements().removeClass('faded');
}
});
}
});
$this.errorMessage();
}
});
}
WFStatus.prototype.reload = function() {
if (this.options.display == "list") {
this._listview();
} else if (this.options.display == "graph") {
this._graphview();
}
}
/* WFStatus PLUGIN DEFINITION
......@@ -152,7 +270,7 @@
$.fn.wfstatus.defaults = {
serverURL: "http://localhost:8080",
template: ['<dl class="dl-horizontal">',
listTemplate: ['<dl class="dl-horizontal">',
'<dt>Start</dt>',
'<dd>${workflow.start_time}</dd>',
'<dt>End</dt>',
......@@ -180,7 +298,8 @@
'{{/each}}',
'</dl>'].join('\n'),
workflowID: null,
forceUsingWorkflow: null
forceUsingWorkflow: null,
display: "graph"
}
$.fn.wfstatus.Constructor = WFStatus
......
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