Commit f6ff4bed authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-sc/4703_display_single_sample_with_analysys' into 'dev'

Feature sc/4703 display single sample with analysis

Closes #2442 and #4703

See merge request !942
parents 173eeff1 1c79b600
Pipeline #239575 failed with stages
in 9 minutes and 43 seconds
......@@ -503,6 +503,7 @@ Builder.prototype = {
var save_analysis = document.createElement("a");
save_analysis.className = "buttonSelector"
if (typeof this.m.custom != 'undefined') save_analysis.className = "buttonSelector devel-mode"
save_analysis.appendChild(document.createTextNode("save"));
save_analysis.onclick = function() {
db.save_analysis();
......
......@@ -942,20 +942,19 @@ Database.prototype = {
return
}
if (typeof args == 'undefined'){
args={}
args.custom = this.getListInput("custom_result[]")
}
if (typeof args == 'undefined') args={};
if (typeof args.custom == 'undefined') args.custom = this.getListInput("custom_result[]");
console.log("db : custom data "+list)
var arg = this.argsToStr(args)
this.m.custom = arg;
var id_vars = ["sample_set_id", "patient_id", "run_id", "config"];
var id_vars = ["sample_set_id", "patient_id", "run_id", "config", "custom"];
for (var j = 0; j < id_vars.length; j++) {
this.m[id_vars[j]] = undefined;
this.m[id_vars[j]] = args[id_vars[j]];
}
var arg = this.argsToStr(args)
this.m.custom = arg;
this.m.wait("Comparing samples...")
$.ajax({
......@@ -1008,6 +1007,12 @@ Database.prototype = {
save_analysis: function () {
var self = this;
if (typeof this.m.custom != 'undefined' &&
getComputedStyle(document.querySelector('.devel-mode')).display != "block"){
console.log({ msg: "'save' has been disabled for custom file. <br/> Use the complete related sample set (patient/run) if you wish to keep your modification.", type: "flash", priority: 2 });
return
}
if (self.last_file == self.m.db_key){
......@@ -1018,8 +1023,11 @@ Database.prototype = {
var fd = new FormData();
fd.append("fileToUpload", blob);
fd.append("info", self.m.info);
fd.append("samples_info", self.m.samples.info);
fd.append("samples_id", self.m.samples.id);
if (self.m.sample != undefined && self.m.samples.info != undefined && self.m.samples.id != undefined){
fd.append("samples_info", self.m.samples.info);
fd.append("samples_id", self.m.samples.id);
}
$.ajax({
type: "POST",
......
......@@ -58,6 +58,17 @@ Model_loader.prototype = {
}
}
else if (typeof params.custom !== "undefined" && params.custom.length>0){
//wait 1sec to check ssl
if (typeof params.sample_set_id !== "undefined" && typeof params.config !== "undefined"){
//wait 1sec to check ssl
setTimeout(function () { self.db.load_custom_data( {"custom" : params.custom, "sample_set_id" : params.sample_set_id, "config": params.config }) }, 1000);
return
}
setTimeout(function () { self.db.load_custom_data( {"custom" : params.custom }) }, 1000);
return
}
else if (typeof params.sample_set_id !== "undefined" && typeof params.config !== "undefined"){
//wait 1sec to check ssl
setTimeout(function () { self.db.load_data( {"sample_set_id" : params.sample_set_id , "config" : params.config } , "") }, 1000);
......@@ -72,11 +83,6 @@ Model_loader.prototype = {
//wait 1sec to check ssl
setTimeout(function () { self.db.load_data( {"run" : params.run_id , "config" : params.config } , "") }, 1000);
}
else if (typeof params.custom !== "undefined" && params.custom.length>0){
//wait 1sec to check ssl
setTimeout(function () { self.db.load_custom_data( {"custom" : params.custom }) }, 1000);
}
else if (typeof config != 'undefined' && config.use_database){
//wait 1sec to check ssl
......
......@@ -51,7 +51,8 @@ Url.prototype= {
var custom_split = this.m.custom.split('&');
for (var j = 0; j < custom_split.length; j++) {
if (custom_split[j] !== "") {
custom_ids.push(custom_split[j].split('=')[1]);
if (custom_split[j].split('=')[0] == "custom")
custom_ids.push(custom_split[j].split('=')[1]);
}
}
......@@ -208,10 +209,10 @@ Url.prototype= {
db.load_data(args, filename);
},
loadCustomUrl: function(db) {
loadCustomUrl: function(db, args) {
this.url_dict = {};
this.pushUrl("");
db.load_custom_data();
db.load_custom_data(args);
},
clean: function(){
......
......@@ -435,7 +435,7 @@ def get_custom_data():
config_id = db.results_file[id].config_id
name = vidjil_utils.anon_ids([patient_run.id])[0] if sample_set.sample_type == defs.SET_TYPE_PATIENT else patient_run.name
filename = db.sequence_file[sequence_file_id].filename
data["samples"]["original_names"].append(name + "_" + filename)
data["samples"]["original_names"].append(name + "_" + filename+ " ("+id+")")
data["samples"]["timestamp"].append(str(db.sequence_file[sequence_file_id].sampling_date))
data["samples"]["info"].append(db.sequence_file[sequence_file_id].info)
data["samples"]["commandline"].append(db.config[config_id].command)
......@@ -457,7 +457,7 @@ def get_custom_data():
def get_analysis():
error = ""
if "custom" in request.vars :
if "custom" in request.vars and "sample_set_id" not in request.vars :
res = {"success" : "true"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -475,9 +475,6 @@ def get_analysis():
error += "id sample_set file needed, "
if not auth.can_view_sample_set(request.vars["sample_set_id"]):
error += "you do not have permission to consult this sample_set ("+str(request.vars["sample_set_id"])+")"
if "custom" in request.vars :
return gluon.contrib.simplejson.dumps(get_default_analysis(), separators=(',',':'))
if error == "" :
......@@ -513,9 +510,7 @@ def save_analysis():
if "run" in request.vars :
request.vars["sample_set_id"] = db.run[request.vars["run"]].sample_set_id
if not "sample_set_id" in request.vars :
error += "It is currently not possible to save an analysis on a comparison of samples, "
elif not auth.can_save_sample_set(request.vars['sample_set_id']) :
if not auth.can_save_sample_set(request.vars['sample_set_id']) :
error += "you do not have permission to save changes on this sample set"
if error == "" :
......
......@@ -108,7 +108,7 @@
<div class="db_block_right">
<span class="devel-mode button2" onclick="db.call('sample_set/multi_sample_stats', {'custom_result': db.getListInput('custom_result[]') })" >preview / quality control</span>
<span class="button2" onclick="myUrl.loadCustomUrl(db)" > see results </span>
<span class="button2" onclick="myUrl.loadCustomUrl(db, { 'sample_set_id':{{=request.vars["id"]}} })" > see results </span>
</div>
</div>
......
......@@ -67,6 +67,7 @@
<td class="column5"></td>
<td class="column5"></td>
<td class="column5"></td>
<td class="column5"></td>
</tr>
</thead>
......@@ -160,6 +161,19 @@
{{pass}}
{{pass}}
</td>
{{if row.results_file.id and row.results_file.data_file:}}
<td><a class="button" href="{{=http_origin}}?custom={{=row.results_file.id}}&sample_set_id={{=request.vars["id"]}}&config={{=config_id}}" type="text/html"
onclick= "event.preventDefault();
if( event.which == 2 ) { window.open(this.href); }
else { myUrl.loadCustomUrl(db, {'custom': '{{=row.results_file.id}}', 'sample_set_id' : {{=request.vars["id"]}}, 'config' : {{=config_id}} } ); } " >
<i class="icon-forward" title="open this sample results in client"></i>
</a></td>
{{else:}}
<td></td>
{{pass}}
</tr>
{{pass}}
......
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