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

allow to add analysis from the ui

parent bdc332d8
......@@ -634,6 +634,41 @@ class tx_nG6_eid {
$smarty->assign('is_at_least_admin_of_1_project', $is_at_least_admin_of_1_project);
$smarty->assign('login_user', $login_user);
print $smarty->fetch('project_table.tpl');
} elseif($type == 'analyses_table') {
$smarty = new Smarty();
$smarty->setTemplateDir(t3lib_extMgm::extPath('nG6').'/pi1');
$smarty->setCompileDir(t3lib_extMgm::extPath('nG6').'/res/smarty/templates_c');
$smarty->setCacheDir(t3lib_extMgm::extPath('nG6').'/res/smarty/cache');
$smarty->setConfigDir(t3lib_extMgm::extPath('nG6').'/res/smarty/configs');
$smarty->security = true;
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$user_id = trim(t3lib_div::_GP('user_id'));
$login_user = intVal(trim(t3lib_div::_GP('login_user')));
$page_id = intVal(trim(t3lib_div::_GP('page_id')));
$project_id = intVal(trim(t3lib_div::_GP('project_id')));
$run_id = intVal(trim(t3lib_div::_GP('run_id')));
if ($run_id != "") {
$analysis = tx_nG6_db::get_run_analysis($run_id);
} else {
$analysis = tx_nG6_db::get_project_analysis($project_id);
}
// Add some information to the table
foreach($analysis as $analysis_id => $analysis_values) {
if (tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id'])) { $is_admin = true; }
$analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id']);
if ($run_id != "") {
$href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_id.'&tx_nG6_pi1[run_id]='.$run_id.'&tx_nG6_pi1[analyze_id]='.$analysis_values['id'].'">'.$analysis_values['name'].'</a>';
} else {
$href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_id.'&tx_nG6_pi1[analyze_id]='.$analysis_values['id'].'">'.$analysis_values['name'].'</a>';
}
$analysis[$analysis_id]['href'] = $href;
}
$smarty->assign('display_analysis_result', $is_admin);
$smarty->assign('is_admin', $is_admin);
$smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($analysis));
$smarty->assign('login_user', $login_user);
print $smarty->fetch('analysis_table.tpl');
}
}
......
{*
Copyright (C) 2009 INRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*}
<table class="table table-striped table-bordered dataTable" id="analysis_data_table">
<thead>
<tr>
{if $is_admin && $login_user && $display_analysis_result}
<th><center><input type="checkbox" id="chk_all_analysis"></center></th>
{/if}
<th nowrap>Name</th>
<th>Description</th>
<th>Sofware</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{include file="recursive_list_analysis_display.tpl" element=$h_analysis prof=0}
</tbody>
{if $is_admin && $login_user && $display_analysis_result}
<tfoot>
<tr>
<th align="left" colspan="5">
With selection :
<div class="btn-group">
<button id="hide_analysis" type="button" class="btn btn-small"><i class=" icon-eye-close"></i> hide</button>
<button id="unhide_analysis" type="button" class="btn btn-small"><i class="icon-eye-open"></i> unhide</button>
</div>
<div class="btn-group">
<button id="add_analysis" type="button" class="btn btn-small"><i class="icon-plus"></i> add</button>
<button id="delete_analysis" type="button" class="btn btn-small"><i class="icon-minus"></i> delete</button>
</div>
</th>
</tr>
</tfoot>
{/if}
</table>
\ No newline at end of file
......@@ -211,7 +211,7 @@ class tx_nG6_pi1 extends tslib_pibase {
$project_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']);
$project_analysis[$analysis_id]['href'] = $this->pi_list_linkSingle($analysis_values['name'],$analysis_values['id'],1, array('analyze_id'=>$analysis_values['id'], 'project_id'=>$this->piVars['project_id']));
}
$smarty->assign('h_project_analysis', tx_nG6_utils::trace_hierarchy($project_analysis));
$smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($project_analysis));
$smarty->assign('project_analysis', $project_analysis);
}
return $smarty->fetch('project_view.tpl');
......@@ -282,7 +282,7 @@ class tx_nG6_pi1 extends tslib_pibase {
$run_analysis[$analysis_id]['href'] = $this->pi_list_linkSingle($analysis_values['name'],$analysis_values['id'],1, array('analyze_id'=>$analysis_values['id'], 'run_id'=>$this->piVars['run_id']));
}
}
$smarty->assign('h_run_analysis', tx_nG6_utils::trace_hierarchy($run_analysis));
$smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($run_analysis));
$smarty->assign('run_analysis', $run_analysis);
}
return $smarty->fetch('run_view.tpl');
......
......@@ -80,43 +80,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="tab-pane fade" id="analyses">
{* Find out if an analysis table should be displayed *}
{assign var="display_analysis_result" value=false}
{foreach from=$h_project_analysis key=analysis_id item=analysis_values}
{foreach from=$h_analysis key=analysis_id item=analysis_values}
{if $analysis_values.is_admin && $analysis_values.hidden == 1}
{assign var="display_analysis_result" value=true}
{elseif $analysis_values.hidden == 0}
{assign var="display_analysis_result" value=true}
{/if}
{/foreach}
<table class="table table-striped table-bordered dataTable" id="analysis_data_table">
<thead>
<tr>
{if $projects[key($projects)].is_admin && $login_user && $display_analysis_result}
<th><center><input type="checkbox" id="chk_all_analysis"></center></th>
{/if}
<th nowrap>Name</th>
<th>Description</th>
<th>Sofware</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{include file="recursive_list_analysis_display.tpl" element=$h_project_analysis prof=0}
</tbody>
{if $projects[key($projects)].is_admin && $login_user && $display_analysis_result}
<tfoot>
<tr>
<th align="left" colspan="5">
With selection :
<div class="btn-group">
<button id="hide_analysis" type="button" class="btn btn-small"><i class=" icon-eye-close"></i> hide</button>
<button id="unhide_analysis" type="button" class="btn btn-small"><i class="icon-eye-open"></i> unhide</button>
</div>
<button id="delete_analysis" type="button" class="btn btn-small"><i class="icon-remove"></i> delete</button>
</th>
</tr>
</tfoot>
{/if}
</table>
{assign var="is_admin" value=$projects[key($projects)].is_admin}
{include file='analysis_table.tpl'}
</div>
{if $login_user}
......
......@@ -72,43 +72,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="tab-pane fade in active" id="analyses">
{* Find out if an analysis table should be displayed *}
{assign var="display_analysis_result" value=false}
{foreach from=$h_run_analysis key=analysis_id item=analysis_values}
{foreach from=$h_analysis key=analysis_id item=analysis_values}
{if $analysis_values.is_admin && $analysis_values.hidden == 1}
{assign var="display_analysis_result" value=true}
{elseif $analysis_values.hidden == 0}
{assign var="display_analysis_result" value=true}
{/if}
{/foreach}
<table class="table table-striped table-bordered dataTable" id="analysis_data_table">
<thead>
<tr>
{if $runs[key($runs)].is_admin && $login_user && $display_analysis_result}
<th><center><input type="checkbox" id="chk_all_analysis"></center></th>
{/if}
<th nowrap>Name</th>
<th>Description</th>
<th>Software</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{include file="recursive_list_analysis_display.tpl" element=$h_run_analysis prof=0}
</tbody>
{if $runs[key($runs)].is_admin && $login_user && $display_analysis_result}
<tfoot>
<tr>
<th align="left" colspan="5">
With selection :
<div class="btn-group">
<button id="hide_analysis" type="button" class="btn btn-small"><i class=" icon-eye-close"></i> hide</button>
<button id="unhide_analysis" type="button" class="btn btn-small"><i class="icon-eye-open"></i> unhide</button>
</div>
<button id="delete_analysis" type="button" class="btn btn-small"><i class="icon-trash"></i> delete</button>
</th>
</tr>
</tfoot>
{/if}
</table>
{assign var="is_admin" value=$runs[key($runs)].is_admin}
{include file='analysis_table.tpl'}
</div>
<div class="tab-pane fade" id="downloads">
......
......@@ -165,6 +165,9 @@ $(function () {
/* add a brand new run option */
$(":button[id=add_run]").on('click', addRunHandler);
/* add a brand new analysis option */
$(":button[id=add_analysis]").on('click', addAnalysisHandler);
/* delete user from project option */
$(":button[id=del_user]").click(function(){
......@@ -1072,9 +1075,116 @@ function addProjectHandler(){
});
});
$('#setAndRunModal').modal();
$("#refresh_workflow").click(function(){ $('#statusModalBody').wfstatus('reload'); });
$("#reset_workflow").click(function(){ $('#setAndRunModalBody').wfform('reset'); });
$("#run_workflow").click(function(){ $('#setAndRunModalBody').wfform('run'); });
}
function refreshAnalysisTable() {
var params = simpleQueryParams(location.href),
page_id = params["id"],
run_id = params["tx_nG6_pi1[run_id]"],
project_id = params["tx_nG6_pi1[project_id]"],
parameters = {};
// define default parameters so the user do not have to fill them
if (run_id) {
parameters["run_id"] = run_id;
parameters["project_id"] = '';
} else if (project_id) {
parameters["project_id"] = project_id;
parameters["run_id"] = '';
}
$.ajax({
url: 'index.php?eID=tx_nG6&type=analyses_table&user_id='+$("#user_id").val()+'&login_user='+$("#login_user").val()+'&page_id='+page_id+"&project_id="+parameters["project_id"]+"&run_id="+parameters["run_id"],
dataType: "html",
error: function (xhr, ajaxOptions, thrownError) {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to reload the analysis table.</div>';
$("#analyses").html(html);
},
success: function(data) {
if (data) {
$("#analyses").html(data);
initEditableFields();
initCheckboxes();
var analysisTable = initAnalysisTable();
$('#delete_analysis').on('click', deletePRAHandler);
$("#hide_analysis").on('click', hideHandler);
$("#unhide_analysis").on('click', unhideHandler);
$("#add_analysis").on('click', addAnalysisHandler);
} else {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to reload the analysis table.</div>';
$("#analyses").html(html);
}
}
});
}
function addAnalysisHandler(){
$('#setAndRunModalLabel').html("Loading");
$("#reset_workflow").hide();
$("#run_workflow").hide();
var carousel = '<div id="myCarousel" class="carousel slide">';
carousel += '<div class="carousel-inner">';
carousel += '<div id="wfForm" class="active item"></div>';
carousel += '<div id="monitoringWorkflow" class="item"></div>';
carousel += '</div>';
carousel += '</div>';
$('#setAndRunModalBody').html(carousel);
var params = simpleQueryParams(location.href),
page_id = params["id"],
run_id = params["tx_nG6_pi1[run_id]"],
project_id = params["tx_nG6_pi1[project_id]"],
parameters = {};
// define default parameters so the user do not have to fill them
if (run_id) {
parameters["run_id"] = run_id;
parameters["project_id"] = '';
} else if (project_id) {
parameters["project_id"] = project_id;
parameters["run_id"] = '';
}
if ($("#close").size() == 0) {
$('<button id="close" class="btn" data-dismiss="modal"><i class="icon-remove"></i> Close</button>').insertBefore("#reset_workflow");
}
if ($("#refresh_workflow_status").size() == 0) {
$('<button id="refresh_workflow_status" class="btn"><i class="icon-refresh"></i> Refresh</button>').insertBefore("#reset_workflow");
}
$("#refresh_workflow_status").hide();
$("#close").show();
$('#wfForm').on("loaded", function(event, workflow) {
$('#setAndRunModalLabel').html(workflow["name"] + " <small>" + workflow["help"] + "</small>");
$("#reset_workflow").show();
$("#run_workflow").show();
$("#close").hide();
});
$('#wfForm').wfform({
workflowClass: "AddAnalysis",
displayRunButton: false,
displayResetButton: false,
parameters: parameters
});
$('#wfForm').on('run', function(event, running_wf) {
$("#reset_workflow").hide();
$("#run_workflow").hide();
$("#refresh_workflow_status").show();
$("#myCarousel").carousel('next');
$("#myCarousel").carousel('pause');
$('#setAndRunModalLabel').html(running_wf["name"] + " <small>" + running_wf["id"] + "</small>");
$('#monitoringWorkflow').wfstatus({
workflowID: running_wf.id,
forceUsingWorkflow: running_wf
});
refreshAnalysisTable();
});
$('#setAndRunModal').modal();
$("#reset_workflow").click(function(){ $('#wfForm').wfform('reset'); });
$("#run_workflow").click(function(){ $('#wfForm').wfform('run'); });
$("#refresh_workflow_status").click(function(){
$('#monitoringWorkflow').wfstatus('reload');
refreshAnalysisTable();
});
}
\ No newline at end of file
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