Commit 156c6fd4 authored by Penom Nom's avatar Penom Nom
Browse files

update download archive

parent 41b6aa6d
...@@ -66,7 +66,7 @@ tmp_directory = <path>/tmp ...@@ -66,7 +66,7 @@ tmp_directory = <path>/tmp
[local] [local]
# This is a space separated list of workflows Class names that will not be available # This is a space separated list of workflows Class names that will not be available
# for adding a run # for adding a run
runwf_filter = AddAnalysis AddProject AddFiles RADseq DownloadArchive DownloadSymlink runwf_filter = AddAnalysis AddProject AddFiles RADseq DownloadArchive DownloadSymlink DownloadURL
# This must be an absolute path of a directory mounted and accessible by the server # This must be an absolute path of a directory mounted and accessible by the server
server_directory = /work/ server_directory = /work/
......
...@@ -217,6 +217,33 @@ class tx_nG6_eid { ...@@ -217,6 +217,33 @@ class tx_nG6_eid {
} }
print tx_nG6_utils::get_octet_string_representation($full_size); print tx_nG6_utils::get_octet_string_representation($full_size);
// data size
}else if ($type = 'get_data_size'){
$run_ids = trim(t3lib_div::_GP('run_ids'));
$data_ids = trim(t3lib_div::_GP('data_ids'));
$analysis_ids = trim(t3lib_div::_GP('analysis_ids'));
$full_size = 0;
if ($run_ids){
$data = explode(',', $run_ids);
foreach($data as $id => $value) {
$full_size += tx_nG6_db::get_run_size($value, true);
}
}
if ($data_ids){
$data = explode(',', $data_ids);
foreach($data as $id => $value) {
$full_size += tx_nG6_db::get_run_size($value, false);
}
}
if ($analysis_ids){
$data = explode(',', $analysis_ids);
foreach($data as $id => $value) {
$full_size += tx_nG6_db::get_analysis_size($value);
}
}
print $full_size . ":::" . tx_nG6_utils::get_octet_string_representation($full_size);
// If update a field // If update a field
} else if ($type == 'update_db_field') { } else if ($type == 'update_db_field') {
......
...@@ -54,7 +54,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -54,7 +54,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div> </div>
</form> </form>
<h4>Downloaded files : </h4> <h4>Downloaded files <span id="total_data_size"></span>: </h4>
<div id="warning_message" class="alert alert-danger" style="display:none"></div>
<div id="download_list"> <div id="download_list">
<p> <p>
No run neither any analyze selected. <br/> No run neither any analyze selected. <br/>
......
...@@ -64,88 +64,6 @@ ...@@ -64,88 +64,6 @@
$(function () { $(function () {
$("#download_tree").jstree({
"themes" : {
"theme" : "default",
"icons" : false
},
"html_data" : {
"data" : $("#html_tree").attr("value"),
"ajax" : {
"url" : "index.php?eID=tx_nG6",
"data" : function (n) {
return {
raw_data_description : "Raw data",
run_short_description : "Run ###SPAN_NAME### (###SPAN_DATE###)",
run_description : "Run ###SPAN_NAME### (###SPAN_SPECIES###) - (###SPAN_DATE###) produced ###SPAN_NB_SEQ### reads",
analyse_description : "Analyse ###SPAN_NAME###",
user_id : $("#user_id").val(),
id : n.attr("id").split("_")[1],
type : n.attr("id").split("_")[0]
};
}
}
},
"plugins" : [ "themes", "html_data", "ui", "checkbox" ]
}).bind("change_state.jstree", function(event, data) {
var nb_selected = 0;
var runs_list = new Array();
var download_list = new Array();
$("#download_list").html("");
$(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
nb_selected += 1;
var tmp = $(this).attr("id").split("_");
if (tmp[0] == "run") {
runs_list.push($(this).attr("id"));
download_list[$(this).attr("id")] = $(this).attr("name") + " : <br /> Raw data + all analyses";
} else if (tmp[0] == "analyse") {
var tmp2 = $(this).attr("name").split("_");
if (tmp2.length > 1) {
var is_in = false;
for (var i = 0; i < runs_list.length; i++){
if (tmp2[0]+"_"+tmp2[1] == runs_list[i]) {
is_in = true;
}
}
if (!is_in) {
if (tmp2[0]+"_"+tmp2[1] in download_list) {
download_list[tmp2[0]+"_"+tmp2[1]] += ", " + tmp2[2];
} else {
download_list[tmp2[0]+"_"+tmp2[1]] = $("#"+tmp2[0]+"_"+tmp2[1]).attr("name") + " : <br /> " + tmp2[2];
}
}
} else {
download_list[$(this).attr("id")] = $(this).attr("name");
}
} else if (tmp[0] == "data") {
var tmp2 = $(this).attr("name").split("_");
var is_in = false;
for (var i = 0; i < runs_list.length; i++){
if (tmp2[0]+"_"+tmp2[1] == runs_list[i]) {
is_in = true;
}
}
if (!is_in) {
if (tmp2[0]+"_"+tmp2[1] in download_list) {
download_list[tmp2[0]+"_"+tmp2[1]] += ", " + tmp2[2];
} else {
download_list[tmp2[0]+"_"+tmp2[1]] = $("#"+tmp2[0]+"_"+tmp2[1]).attr("name") + " : <br /> " + tmp2[2];
}
}
}
});
for (var key in download_list) {
$("#download_list").append("<p class='bullet'>" + download_list[key] + "</p>");
}
if (nb_selected == 0) {
$("#download_btn").addClass("disabled");
$("#download_list").html("<p>No run neither any analyze selected. <br/>Please select below the data you want to download...</p>");
} else {
$("#download_btn").removeClass("disabled");
}
});
/** /**
* Retrieve workflow status * Retrieve workflow status
*/ */
...@@ -199,11 +117,11 @@ $(function () { ...@@ -199,11 +117,11 @@ $(function () {
} }
// List of available downloads // List of available downloads
var download_options = [ var download_options = {
// archive on server // archive on server
{ "download_archive" : {
label : "archive", label : "archive",
id : "download_archive", id : "download_archive",
wfName : "DownloadArchive", wfName : "DownloadArchive",
...@@ -278,7 +196,7 @@ $(function () { ...@@ -278,7 +196,7 @@ $(function () {
} }
}, },
// symlink // symlink
{ "download_symlink" : {
label : "symbolic link", label : "symbolic link",
id : "download_symlink", id : "download_symlink",
wfName : "DownloadSymlink", wfName : "DownloadSymlink",
...@@ -347,7 +265,7 @@ $(function () { ...@@ -347,7 +265,7 @@ $(function () {
} }
}, },
// urls // urls
{ "download_url" : {
label : "url", label : "url",
id : "download_url", id : "download_url",
wfName : "DownloadURL", wfName : "DownloadURL",
...@@ -421,23 +339,165 @@ $(function () { ...@@ -421,23 +339,165 @@ $(function () {
get_workflow_status($("#server_url").val() , running_wf.id, cb, errcb) get_workflow_status($("#server_url").val() , running_wf.id, cb, errcb)
} }
} }
]; };
// Add download options to the dropdown list
$.each(download_options, function(id, val){
$("#available-download-types").append($('<option id="' + val.id + '" >' + val.label + '</option>'));
});
var get_selected_ids = function (){
var run_ids = [],
data_ids = [],
analysis_ids = [];
for (var i = 0; i < download_options.length; i++) { $(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
$("#available-download-types").append($('<option id="' + download_options[i].id + '" > ' + download_options[i].label + '</option>')); var parts = $(this).attr("id").split('_');
if (parts[0] == 'analyse') {
analysis_ids.push(parts[1]);
}
else if (parts [0] == 'data'){
data_ids.push(parts[1]);
} }
else if (parts[0] == 'run'){
run_ids.push(parts[1]);
}
});
return [run_ids, data_ids, analysis_ids];
};
$("#download_btn").click(function(){
var selected_option = $("#available-download-types option:selected" ),
download_option;
var arrayLength = download_options.length; var check_data_size = function(){
for (var i = 0; i < download_options.length; i++) { var selected_ids = get_selected_ids(),
if ( download_options[i].id === selected_option.attr('id') ) { run_ids = selected_ids[0],
download_option = download_options[i]; data_ids = selected_ids[1],
break; analysis_ids = selected_ids[2];
$.ajax({
url: "index.php?eID=tx_nG6&type=get_data_size&run_ids=" + run_ids.join(',') + '&data_ids=' + data_ids.join(',') +'&analysis_ids=' + analysis_ids.join(',') ,
success: function (data) {
var sp = data.split(':::'),
octets = sp [0],
string_representation = sp[1];
if ( parseInt(octets) > 0 ){
$('#total_data_size').html('<small>(' + string_representation + ')</small>');
if ( $("#available-download-types option:selected" ).attr('id') == 'download_archive' ){
if (parseInt(octets) > 104857600){
$('#warning_message').html("The total size of selected data cannot exceed 100 Mo for archive downloading").show();
$("#download_btn").addClass("disabled");
}
else{
$('#warning_message').hide();
$("#download_btn").removeClass("disabled");
} }
} }
else {
$('#warning_message').fadeOut(500);
$("#download_btn").removeClass("disabled");
}
}
else {
$("#download_btn").addClass("disabled");
$('#total_data_size').html('');
$('#warning_message').fadeOut(500);
}
}
});
};
$("#download_tree").jstree({
"themes" : {
"theme" : "default",
"icons" : false
},
"html_data" : {
"data" : $("#html_tree").attr("value"),
"ajax" : {
"url" : "index.php?eID=tx_nG6",
"data" : function (n) {
return {
raw_data_description : "Raw data",
run_short_description : "Run ###SPAN_NAME### (###SPAN_DATE###)",
run_description : "Run ###SPAN_NAME### (###SPAN_SPECIES###) - (###SPAN_DATE###) produced ###SPAN_NB_SEQ### reads",
analyse_description : "Analyse ###SPAN_NAME###",
user_id : $("#user_id").val(),
id : n.attr("id").split("_")[1],
type : n.attr("id").split("_")[0]
};
}
}
},
"plugins" : [ "themes", "html_data", "ui", "checkbox" ]
}).bind("change_state.jstree", function(event, data) {
var nb_selected = 0;
var runs_list = new Array();
var download_list = new Array();
$("#download_list").html("");
$(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
nb_selected += 1;
var tmp = $(this).attr("id").split("_");
if (tmp[0] == "run") {
runs_list.push($(this).attr("id"));
download_list[$(this).attr("id")] = $(this).attr("name") + " : <br /> Raw data + all analyses";
} else if (tmp[0] == "analyse") {
var tmp2 = $(this).attr("name").split("_");
if (tmp2.length > 1) {
var is_in = false;
for (var i = 0; i < runs_list.length; i++){
if (tmp2[0]+"_"+tmp2[1] == runs_list[i]) {
is_in = true;
}
}
if (!is_in) {
if (tmp2[0]+"_"+tmp2[1] in download_list) {
download_list[tmp2[0]+"_"+tmp2[1]] += ", " + tmp2[2];
} else {
download_list[tmp2[0]+"_"+tmp2[1]] = $("#"+tmp2[0]+"_"+tmp2[1]).attr("name") + " : <br /> " + tmp2[2];
}
}
} else {
download_list[$(this).attr("id")] = $(this).attr("name");
}
} else if (tmp[0] == "data") {
var tmp2 = $(this).attr("name").split("_");
var is_in = false;
for (var i = 0; i < runs_list.length; i++){
if (tmp2[0]+"_"+tmp2[1] == runs_list[i]) {
is_in = true;
}
}
if (!is_in) {
if (tmp2[0]+"_"+tmp2[1] in download_list) {
download_list[tmp2[0]+"_"+tmp2[1]] += ", " + tmp2[2];
} else {
download_list[tmp2[0]+"_"+tmp2[1]] = $("#"+tmp2[0]+"_"+tmp2[1]).attr("name") + " : <br /> " + tmp2[2];
}
}
}
});
for (var key in download_list) {
$("#download_list").append("<p class='bullet'>" + download_list[key] + "</p>");
}
if (nb_selected == 0) {
$("#download_list").html("<p>No run neither any analyze selected. <br/>Please select below the data you want to download...</p>");
check_data_size();
} else {
check_data_size();
}
});
$('#available-download-types').change(function(){
check_data_size();
});
$("#download_btn").click(function(){
var download_option = download_options[$("#available-download-types option:selected" ).attr('id')];
$('#myModalLabel').html("Loading"); $('#myModalLabel').html("Loading");
$('#myModalFooter').html([ $('#myModalFooter').html([
...@@ -474,22 +534,10 @@ $(function () { ...@@ -474,22 +534,10 @@ $(function () {
} }
}); });
var run_ids = [], var sel = get_selected_ids(),
data_ids = [], run_ids = sel[0],
analysis_ids = []; data_ids = sel[1],
analysis_ids = sel[2];
$(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
var parts = $(this).attr("id").split('_');
if (parts[0] == 'analyse') {
analysis_ids.push(parts[1]);
}
else if (parts [0] == 'data'){
data_ids.push(parts[1]);
}
else if (parts[0] == 'run'){
run_ids.push(parts[1]);
}
});
var wfform_options = { var wfform_options = {
workflowClass: download_option.wfName, workflowClass: download_option.wfName,
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
# #
from ng6.ng6workflow import DownloadWorkflow from ng6.ng6workflow import DownloadWorkflow
from ng6.config_reader import NG6ConfigReader
class DownloadArchive (DownloadWorkflow): class DownloadArchive (DownloadWorkflow):
...@@ -25,10 +23,8 @@ class DownloadArchive (DownloadWorkflow): ...@@ -25,10 +23,8 @@ class DownloadArchive (DownloadWorkflow):
return """This workflow allows you to create a downloadable archive of the selected data. The link to the archive will be sent to the user via the provided email""" return """This workflow allows you to create a downloadable archive of the selected data. The link to the archive will be sent to the user via the provided email"""
def define_parameters(self, function="process"): def define_parameters(self, function="process"):
config = NG6ConfigReader()
self.save_directory = config.get_save_directory()
self.add_parameter('archive_mail', 'Provide a valid email address to be warned when the archive is created', display_name = "User mail", type="email", required = True) self.add_parameter('archive_mail', 'Provide a valid email address to be warned when the archive is created', display_name = "User mail", type="email", required = True)
def process(self): def process(self):
self.add_component('CreateArchive', [self.admin_login, self.save_directory, self.archive_mail, self.data_id, self.run_id, self.analysis_id]) self.add_component('CreateArchive', [self.admin_login, self.archive_mail, self.data_id, self.run_id, self.analysis_id])
...@@ -22,7 +22,7 @@ from jflow.component import Component ...@@ -22,7 +22,7 @@ from jflow.component import Component
from weaver.function import PythonFunction from weaver.function import PythonFunction
def create_archive( ng6_username, email, data_folder, output_folder, ids_dump_path, web_archive, archive_file ): def create_archive( ng6_username, email, output_folder, ids_dump_path, web_archive, archive_file ):
import os import os
import pickle import pickle
import shutil import shutil
...@@ -30,7 +30,12 @@ def create_archive( ng6_username, email, data_folder, output_folder, ids_dump_pa ...@@ -30,7 +30,12 @@ def create_archive( ng6_username, email, data_folder, output_folder, ids_dump_pa
import tarfile import tarfile
from jflow.utils import robust_rmtree from jflow.utils import robust_rmtree
from ng6.utils import Utils from ng6.utils import Utils
from ng6.config_reader import NG6ConfigReader
config = NG6ConfigReader()
data_folder = config.get_save_directory()
fh = open(ids_dump_path, "rb") fh = open(ids_dump_path, "rb")
prefixed_ids = pickle.load(fh) prefixed_ids = pickle.load(fh)
...@@ -68,9 +73,8 @@ def create_archive( ng6_username, email, data_folder, output_folder, ids_dump_pa ...@@ -68,9 +73,8 @@ def create_archive( ng6_username, email, data_folder, output_folder, ids_dump_pa
class CreateArchive (Component): class CreateArchive (Component):
def define_parameters(self, login, data_directory, email, data_ids = [], run_ids = [], analysis_ids = []): def define_parameters(self, login, email, data_ids = [], run_ids = [], analysis_ids = []):
self.add_parameter('login', 'The login of the user in ng6', type = 'ng6userlogin', default = login) self.add_parameter('login', 'The login of the user in ng6', type = 'ng6userlogin', default = login)
self.add_parameter('data_directory', 'Where are stored all the datas', default = data_directory, required = True)
self.add_parameter('email', 'The email where the url to the archive will be sent', default = email, required = True) self.add_parameter('email', 'The email where the url to the archive will be sent', default = email, required = True)
self.add_parameter_list('data_ids', 'Ids of a run from which rawdata will be retrieved', default = data_ids) self.add_parameter_list('data_ids', 'Ids of a run from which rawdata will be retrieved', default = data_ids)
self.add_parameter_list('run_ids', 'Ids of run from which all data will be retrieved', default = run_ids) self.add_parameter_list('run_ids', 'Ids of run from which all data will be retrieved', default = run_ids)
...@@ -91,7 +95,7 @@ class CreateArchive (Component): ...@@ -91,7 +95,7 @@ class CreateArchive (Component):
web_archive = self._webify_outputs(self.archive) web_archive = self._webify_outputs(self.archive)
archive = PythonFunction(create_archive, cmd_format = "{EXE} {ARG} {IN} {OUT} ") archive = PythonFunction(create_archive, cmd_format = "{EXE} {ARG} {IN} {OUT} ")
archive(arguments = [ self.login, self.email, self.data_directory, output_folder, ids_dump_path, web_archive], outputs = self.archive) archive(arguments = [ self.login, self.email, output_folder, ids_dump_path, web_archive], outputs = self.archive)
def _webify_outputs(self, path): def _webify_outputs(self, path):
......
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