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

reset ok from gui

parent c9c10480
......@@ -229,6 +229,12 @@ class JFlowServer (object):
workflow = self.wfmanager.rerun_workflow(kwargs["workflow_id"])
return self.jsonify_workflow_status(workflow)
@cherrypy.expose
@jsonify
def reset_workflow_component(self, **kwargs):
workflow = self.wfmanager.reset_workflow_component(kwargs["workflow_id"], kwargs["component_name"])
return self.jsonify_workflow_status(workflow)
@cherrypy.expose
def upload_light(self, **kwargs):
prefix = ""
......
......@@ -108,6 +108,7 @@
<div class="modal-footer">
<div class="btn-group">
<button id="refresh_workflow" class="btn status-panel"><i class="icon-refresh"></i> Refresh</button>
<button id="reset_component" class="btn status-panel"><i class="icon-remove"></i> Reset</button>
<button id="rerun_workflow" class="btn status-panel"><i class="icon-cog"></i> ReRun</button>
</div>
<button id="output_workflow" class="btn btn-success status-panel"><i class="icon-chevron-right icon-white"></i> Output</button>
......@@ -192,6 +193,7 @@
$("#refresh_workflow").click(function(){ $('#statusModalBody').wfstatus('reload'); });
$("#rerun_workflow").click(function(){ $('#statusModalBody').wfstatus('rerun'); });
$("#reset_component").click(function(){ $('#statusModalBody').wfstatus('reset'); });
$("#reset_workflow").click(function(){ $('#setAndRunModalBody').wfform('reset'); });
$("#back_workflow").click(function(){
$('#statusModalBody').wfstatus('reload');
......
......@@ -62,11 +62,10 @@ class Workflow(threading.Thread):
STATUS_COMPLETED = "completed"
STATUS_FAILED = "failed"
STATUS_ABORTED = "aborted"
STATUS_RESETED = "reseted"
def __init__(self, args={}, id=None, function= "process"):
"""
"""
# define as a thread
threading.Thread.__init__(self)
self.jflow_config_reader = JFlowConfigReader()
......@@ -509,6 +508,7 @@ class Workflow(threading.Thread):
if self.step == 1:
try:
self.reseted_components = []
self.status = self.STATUS_STARTED
self.wf_execution_wrapper()
except SystemExit, e:
self.status = self.STATUS_FAILED
......@@ -526,6 +526,7 @@ class Workflow(threading.Thread):
if self.step == 2:
try:
self.reseted_components = []
self.status = self.STATUS_STARTED
self.wf_execution_wrapper()
except SystemExit, e:
self.status = self.STATUS_FAILED
......@@ -557,7 +558,9 @@ class Workflow(threading.Thread):
log = MakeflowLog(log_path)
log.parse()
make_states.append(log.state)
if self.STATUS_ABORTED in make_states:
if len(self.reseted_components) > 0:
self.status = self.STATUS_RESETED
elif self.STATUS_ABORTED in make_states:
self.status = self.STATUS_ABORTED
elif self.STATUS_FAILED in make_states:
self.status = self.STATUS_FAILED
......@@ -619,6 +622,7 @@ class Workflow(threading.Thread):
sys.stderr.write("Impossible to reset component '" + component_name + "'! This one is not part of the workflow\n")
sys.exit(1)
self.reseted_components.append(component_name)
self.status = self.STATUS_RESETED
self._serialize()
def makeflow_pretty_print_node(self, dag, node):
......
......@@ -94,6 +94,7 @@ class WorkflowsManager(object):
def reset_workflow_component(self, workflow_id, component_name):
workflow = self.get_workflow(workflow_id)
workflow.reset_component(component_name)
return workflow
def run_workflow(self, workflow_class, args, function="process"):
# Load all modules within the workflow module
......
......@@ -122,6 +122,8 @@
'<td> <span class="label label-important">${workflow.status}</span></td>',
'{{else workflow.status == "started"}}',
'<td> <span class="label label-info">${workflow.status}</span></td>',
'{{else workflow.status == "reseted"}}',
'<td> <span class="label">${workflow.status}</span></td>',
'{{else}}',
'<td>${workflow.status}</td>',
'{{/if}}',
......
......@@ -125,6 +125,18 @@
$this.$element.html("");
$.tmpl($this.options.listTemplate, {workflow: workflow}).appendTo($this.$element);
$this.errorMessage();
$("[id^=component_]").hover(function(){
$(this).addClass("component-hover");
});
$("[id^=component_]").mouseout(function(){
$(this).removeClass("component-hover");
});
$("[id^=component_]").click(function(){
$("[id^=component_]").each(function(){
$(this).removeClass("component-select");
});
$(this).addClass("component-select");
});
}
});
}
......@@ -267,6 +279,37 @@
});
}
WFStatus.prototype.reset = function() {
var $this = this,
params = "" ,
one_is_selected = false;
if (this.options.workflowID) { params = "workflow_id=" + this.options.workflowID + "&"; }
$("[id^=component_]").each(function(){
if ($(this).hasClass("component-select")) {
params += 'component_name='+$(this).attr("id").split("component_")[1],+'&';
one_is_selected = true;
}
});
if (one_is_selected) {
$.ajax({
url: this.options.serverURL + '/reset_workflow_component?'+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) {
$this.reload();
}
});
}
}
/* WFStatus PLUGIN DEFINITION
* ========================== */
......@@ -306,7 +349,7 @@
'</div>',
'<br/>',
'{{each(index, component) workflow.components}}',
'<dt>${component.name}</dt>',
'<div id="component_${component.name}"><p><dt>${component.name}</dt>',
'<dd>',
'<div class="progress">',
'<div class="bar bar-success" style="width: ${component.completed}%;"></div>',
......@@ -314,7 +357,7 @@
'<div class="bar" style="width: ${component.running}%;"></div>',
'<div class="bar bar-warning" style="width: ${component.waiting}%;"></div>',
'</div>',
'</dd>',
'</dd></p></div>',
'{{/each}}',
'</dl>'].join('\n'),
workflowID: null,
......
......@@ -24,6 +24,58 @@ position:relative;
width:16px;
height:20px}
.component-select, .component-hover {
background-color: #efefef;
border-bottom-color: #efefef;
border-left-color-ltr-source: physical;
border-left-color-rtl-source: physical;
border-left-color-value: #efefef;
border-right-color-ltr-source: physical;
border-right-color-rtl-source: physical;
border-right-color-value: #efefef;
border-top-color: #efefef;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-style: solid;
border-bottom-width: 1px;
border-image-outset: 0 0 0 0;
border-image-repeat: stretch stretch;
border-image-slice: 100% 100% 100% 100%;
border-image-source: none;
border-image-width: 1 1 1 1;
border-left-color-ltr-source: physical;
border-left-color-rtl-source: physical;
border-left-style-ltr-source: physical;
border-left-style-rtl-source: physical;
border-left-style-value: solid;
border-left-width-ltr-source: physical;
border-left-width-rtl-source: physical;
border-left-width-value: 1px;
border-right-color-ltr-source: physical;
border-right-color-rtl-source: physical;
border-right-style-ltr-source: physical;
border-right-style-rtl-source: physical;
border-right-style-value: solid;
border-right-width-ltr-source: physical;
border-right-width-rtl-source: physical;
border-right-width-value: 1px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-top-style: solid;
border-top-width: 1px;
margin-bottom: 20px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.blockG{
position:absolute;
background-color:#FFFFFF;
......
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