Commit c97cfc77 authored by Celine Noirot's avatar Celine Noirot
Browse files

recode extend

parent 65dd4c2e
...@@ -857,17 +857,14 @@ class tx_nG6_eid { ...@@ -857,17 +857,14 @@ class tx_nG6_eid {
//Change date format //Change date format
print json_encode(tx_nG6_db::filter_list_retention_data_info($filter_size,$max_retention_date,$create_users, $without_laboratories_id,$with_laboratories_id)); print json_encode(tx_nG6_db::filter_list_retention_data_info($filter_size,$max_retention_date,$create_users, $without_laboratories_id,$with_laboratories_id));
} elseif ($type == 'delete_data') { } elseif ($type == 'delete_purge_data') {
//TODO check if user is still logged //TODO check if user is still logged
if ($user_id == ""){ if ($user_id == ""){
print json_encode("Error: reconnect"); print json_encode("Error: reconnect");
} else { } else {
//Delete data link to the list of purge demand //Delete data link to the list of purge demand
$purge_ids = trim(t3lib_div::_GP('purge_demand')); $purge_ids = trim(t3lib_div::_GP('purge_demand'));
$data_folder = trim(t3lib_div::_GP('data_folder')); print json_encode(tx_nG6_pi6::delete_purge_demand(explode(',',$purge_ids)));
$user = trim(t3lib_div::_GP('username'));
$password = trim(t3lib_div::_GP('password'));
print json_encode(tx_nG6_pi6::set_purge_demand_processed(explode(',',$purge_ids),"delete",$data_folder,$user,$password));
} }
} elseif ($type == 'extend_rentention_date') { } elseif ($type == 'extend_rentention_date') {
//Extend the retention date for the //Extend the retention date for the
...@@ -880,7 +877,7 @@ class tx_nG6_eid { ...@@ -880,7 +877,7 @@ class tx_nG6_eid {
//Change date format //Change date format
$date = explode('/', $value); $date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]); $timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_pi6::set_purge_demand_processed(explode(',',$purge_ids),"extend",$timestamp)); print json_encode(tx_nG6_pi6::extend_rentention_date(explode(',',$purge_ids),$timestamp));
} }
} }
......
...@@ -198,7 +198,8 @@ Files impacted of: ...@@ -198,7 +198,8 @@ Files impacted of:
return implode("\r\n", $headers).$mail; return implode("\r\n", $headers).$mail;
} }
function set_purge_demand_processed($demand_ids,$process, $value,$user,$pwd){ function extend_rentention_date($demand_ids, $date){
//extend
$all_demands=tx_nG6_db::get_purge_demand_from_id($demand_ids); $all_demands=tx_nG6_db::get_purge_demand_from_id($demand_ids);
$all_runs=array(); $all_runs=array();
$all_analyses=array(); $all_analyses=array();
...@@ -209,9 +210,6 @@ Files impacted of: ...@@ -209,9 +210,6 @@ Files impacted of:
$all_runs=array_merge($all_runs,explode(',',$res["run_ids"])); $all_runs=array_merge($all_runs,explode(',',$res["run_ids"]));
} }
} }
//extend
if ($process == "extend"){
$date=$value;
tx_nG6_db::update_field('tx_nG6_run', $all_runs, tx_nG6_db::update_field('tx_nG6_run', $all_runs,
array("retention_date","data_state", "mail_sent_date","purge_demand_id"), array("retention_date","data_state", "mail_sent_date","purge_demand_id"),
array($date,"extended","","NULL"), array($date,"extended","","NULL"),
...@@ -224,13 +222,13 @@ Files impacted of: ...@@ -224,13 +222,13 @@ Files impacted of:
array("processed_date","demand_state"), array("processed_date","demand_state"),
array($date,"extended")); array($date,"extended"));
return("Done extend"); return("Done extend");
}else{ //delete
}
function delete_purge_demand($demand_ids){
$data_folder=$value; $data_folder=$value;
$date= time(); $date= time();
$all_runs_purged=array(); $all_runs_purged=array();
$all_analyses_purged=array(); $all_analyses_purged=array();
if ( $connexion )
{
//purged_size = storage_size !!! //purged_size = storage_size !!!
tx_nG6_db::update_field('tx_nG6_run', $all_runs_purged, array("purged_size","data_state", "purged_date", "storage_size"), tx_nG6_db::update_field('tx_nG6_run', $all_runs_purged, array("purged_size","data_state", "purged_date", "storage_size"),
array("storage_size","purged",$date, 0), array("storage_size","purged",$date, 0),
...@@ -248,12 +246,9 @@ Files impacted of: ...@@ -248,12 +246,9 @@ Files impacted of:
}else{ }else{
return("Error: not all runs or analyses were purged , please check unix permission (see apache logs)."); return("Error: not all runs or analyses were purged , please check unix permission (see apache logs).");
} }
}else{
return("Error while ssh login.");
}
} }
}
} }
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi6/class.tx_nG6_pi6.php']) { if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi6/class.tx_nG6_pi6.php']) {
......
...@@ -394,6 +394,22 @@ $(function () { ...@@ -394,6 +394,22 @@ $(function () {
// Delete data after selecting list of ids demand // Delete data after selecting list of ids demand
$("#delete_data_from_list").click(function(){ $("#delete_data_from_list").click(function(){
console.log("IIIIIIIIIIICCCCCCCCCCCCCCCCCCCC");
$("#modal-label-tmpl").html("Delete");
$("#modal-body-tmpl").html("Are you sure you want to delete those data?");
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">No</button>' +
'<button id="modal-btn-yes" class="btn btn-primary">Yes</button>');
$("#ng6modal").modal();
$("#modal-btn-yes").click( function() {
$(':checked[id^=chk_demand').each(function(){
demand_id=$(this).val();
demands.push(demand_id);
console.log(demands);
});
delete_data(demands,purge_table["demand"]);
});
var demands=[]; var demands=[];
$(':checked[id^=chk_demand').each(function(){ $(':checked[id^=chk_demand').each(function(){
demand_id=$(this).val(); demand_id=$(this).val();
...@@ -421,188 +437,13 @@ $(function () { ...@@ -421,188 +437,13 @@ $(function () {
}); });
}); });
function delete_data(list_ids,purge_demand_datatable){ function delete_data(list_ids,purge_demand_datatable){
var _get_workflow_status = function(workflow_id, callback, error_callback){
$.ajax({ $.ajax({
url : $("#server_url").val() + '/get_workflow_status?display=list&workflow_id=' + workflow_id ,
dataType : 'jsonp',
timeout: 20000 ,
success : function(data){
if (callback){
callback(data);
}
},
error : function(jqXHR, textStatus, errorThrown){
if (error_callback){
error_callback(jqXHR, textStatus, errorThrown);
}
}
});
};
var _retrieve_data = function(workflow_id, callback, error_callback){ url: "index.php?eID=tx_nG6&type=delete_purge_data&purge_demand=" + list_ids.join(',') + "&user_id="+$('input[id=user_id]').val(),
$.ajax({ success: function (data) {
url : $("#server_url").val() + '/get_workflow_outputs?workflow_id=' + workflow_id, console.log ("DONE");
dataType : 'jsonp',
success : function(data){
if (callback) {
callback(data);
}
},
error : function(jqXHR, textStatus, errorThrown){
if (error_callback){
error_callback(jqXHR, textStatus, errorThrown);
} }
}
});
};
var _display_file_content = function(filepath, $elmt){
$.get(filepath, function(data){
$elmt.html([
'<div class="alert">',
' <p>',
' <strong>Success !</strong> You will find bellow the list of deteted paths.',
' </p>',
'</div>',
].join(''));
var client = new ZeroClipboard($("#copy_urls"));
});
};
$('#setAndRunModalLabel').html("Loading");
$('#setAndRunModalFooter').html([
' <div class="btn-group">',
' <button id="close" class="btn btn-default" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i> Close</button>',
' </div>',
' <div class="btn-group">',
' <button id="reset_workflow" class="btn btn-default"><i class="glyphicon glyphicon-refresh"></i> Reset</button>',
' <button id="run_workflow" class="btn btn-primary"><i class="glyphicon glyphicon-floppy-save"></i> Start</button>',
' </div>'
].join(''));
$("#reset_workflow, #run_workflow").hide();
$("#close").show();
$('#setAndRunModalBody').html([
'<div >',
' <p id="wf-help" class="text-justify"></p><br/><br/>',
' <div id="wfform"><div class="tx-nG6-wait">Please wait</div></div>',
'</div>',
].join(''));
var modal = {
'$label' : $('#setAndRunModalLabel'),
'$body' : $('#setAndRunModalBody'),
'$footer' : $('#setAndRunModalFooter'),
'$modal' : $('#setAndRunModal')
};
var wfform_options = {
workflowClass: "PurgeDemand",
serverURL: $("#server_url").val(),
displayRunButton: false,
displayResetButton: false,
parameters : {
"admin_login" : $("#user_name").val(),
"demand_id" : list_ids
}
};
$('#wfform').on("loaded.wfform", function(event, workflow) {
$("#reset_workflow, #run_workflow").show();
$("#close").hide();
if(workflow){
modal.$label.html(workflow["name"]) ;
$('#wf-help').html(workflow["help"]);
}
else{
modal.$body.html('<div class="alert alert-warning"> <strong>Warning !</strong> The workflow "PurgeDemand" is not available</div>');
}
});
$("#reset_workflow").click(function(){
$('#wfform').wfform('reset');
});
$("#run_workflow").click(function(){
$('#wfform').wfform('run');
});
// remove plugin data
$('#wfform').removeData();
modal.$modal.modal();
modal.$modal.find('#wfform').wfform(wfform_options);
modal.$modal.find('#wfform').on('run.wfform', function(event, running_wf) {
modal.$body.html([
'<div>',
' <div class="alert alert-info">',
' <p>',
' <strong>The data</strong> are being deleted. Use the refresh button to get the status and retrieve list of deleted directories.',
' </p>',
' </div>',
' <div id="wfstatus">',
' </div>',
'</div>'
].join(''));
modal.$footer.html([
' <div class="btn-group">',
' <button id="refresh_workflow" class="btn btn-default"><i class="glyphicon glyphicon-refresh"></i> Refresh</button>',
' </div>',
' <div class="btn-group">',
' <button id="close" class="btn btn-default" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i> Close</button>',
' </div>',
].join(''));
modal.$modal.find('#wfstatus').wfstatus({
workflowID : running_wf.id,
display : 'list',
serverURL: $("#server_url").val(),
});
$("#refresh_workflow").click(function(){
modal.$body.find('#wfstatus').html("<div class='tx-nG6-wait'> <strong>Please</strong> wait...</div>");
button = this;
button.disabled = true;
_get_workflow_status(running_wf.id ,
// successcb
function(statusdata){
if (statusdata.status == "completed"){
_retrieve_data(running_wf.id, function(data){
$(button).hide();
$.each(data, function(i, component) {
$.each(component, function(filename, file) {
if (filename == "remove_list.txt"){
_display_file_content(file.url, modal.$body);
}
});
});
},
//errorcb
function(jqXHR, textStatus, errorThrown){
modal.$body.html([
'<div class="alert alert-danger">',
' <p><strong>Failed !</strong> to get outputs from ' + $("#server_url").val() + ' </p>',
'</div>',
].join(''));
}
);
}
else {
modal.$modal.find('#wfstatus').wfstatus('reload');
button.disabled = false;
}
},
// errorcb
function(){
modal.$modal.find('#wfstatus').wfstatus('reload');
button.disabled = false;
}
);
});
}); });
} }
...@@ -633,12 +474,12 @@ function extend_date(list_ids, purge_demand_datatable, obsolete_project_datatabl ...@@ -633,12 +474,12 @@ function extend_date(list_ids, purge_demand_datatable, obsolete_project_datatabl
success: function(val, status, xhr) { success: function(val, status, xhr) {
$("#ng6modal").modal('hide'); $("#ng6modal").modal('hide');
refresh_purge_demand(purge_demand_datatable); refresh_purge_demand(purge_demand_datatable);
refresh_project_obsolete(obsolete_project_datatable) refresh_project_obsolete(obsolete_project_datatable);
}, },
error: function(val) { error: function(val) {
$("#ng6modal").modal('hide'); $("#ng6modal").modal('hide');
refresh_purge_demand(purge_demand_datatable); refresh_purge_demand(purge_demand_datatable);
refresh_project_obsolete(obsolete_project_datatable) refresh_project_obsolete(obsolete_project_datatable);
} }
}); });
......
Supports Markdown
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