Commit 6a18d962 authored by Marc Duez's avatar Marc Duez
Browse files

model.js : improve loading of remote files

parent c47ceae9
......@@ -140,6 +140,11 @@ List.prototype = {
},
update_data_list: function () {
if (Object.keys(this.index_data).length != Object.keys(this.m.data_info).length){
this.build_data_list()
this.resize();
return
}
for (var key in this.index_data){
var val = this.m.data[key][this.m.t]
if (this.m.norm && this.m.normalization.type=="data") val = this.m.normalize(val,this.m.t)
......
......@@ -91,22 +91,33 @@ if (typeof config != 'undefined' && location.search != ''){
var tmp = location.search.substring(1).split('&')
var patient = -1
var config = -1
var dataURL = ""
var analysisURL = ""
for (var i=0; i<tmp.length; i++){
var tmp2 = tmp[i].split('=')
if (tmp2[0] == 'data'){
m.loadDataUrl(tmp2[1])
myConsole.flash("load data from url : " + tmp2[1])
}
if (tmp2[0] == 'analysis'){
m.loadAnalysisUrl(tmp2[1])
}
if (tmp2[0] == 'data') dataURL = tmp2[1]
if (tmp2[0] == 'analysis') analysisURL = tmp2[1]
if (tmp2[0] == 'patient') patient = tmp2[1]
if (tmp2[0] == 'config') config = tmp2[1]
if (patient != "-1" && config != "-1"){
//wait 1sec to check ssl
setTimeout(function () { db.load_data( {"patient" : patient , "config" : config } , "") }, 1000);
}
if (dataURL != "") {
if (analysisURL != ""){
var callback = function() {m.loadAnalysisUrl(analysisURL)}
m.loadDataUrl(dataURL, callback)
}else{
m.loadDataUrl(dataURL)
}
}
if (patient != "-1" && config != "-1"){
//wait 1sec to check ssl
setTimeout(function () { db.load_data( {"patient" : patient , "config" : config } , "") }, 1000);
}
}else if (typeof config != 'undefined' && config.use_database){
//wait 1sec to check ssl
setTimeout(function () { db.call("patient/index.html")}, 1000);
......
......@@ -51,6 +51,8 @@ Model.prototype = {
this.clusters = [];
this.clones = [];
this.data = {};
this.data_info = {};
this.t = 0;
this.focus = -1;
......@@ -177,8 +179,9 @@ Model.prototype = {
/* load the selected vidjil/analysis file from an url
* */
loadDataUrl: function (url) {
loadDataUrl: function (url, callback) {
var self = this;
callback = typeof callback !== 'undefined' ? callback : function(){self.loadAnalysisUrl(url)}
var url_split = url.split('/')
......@@ -192,7 +195,7 @@ Model.prototype = {
self.loadGermline();
self.initClones()
self.dataFileName = url_split[url_split.length-1]
self.loadAnalysisUrl(url)
callback()
},
error: function (request, status, error) {
myConsole.flash("error : can't reach " + url + "file");
......@@ -217,6 +220,7 @@ Model.prototype = {
url: url2,
success: function (result) {
self.parseJsonAnalysis(result)
self.initClones()
self.analysisFileName = url_split[url_split.length-1]
},
error: function () {
......@@ -480,6 +484,7 @@ Model.prototype = {
i++
}
}
this.update()
},
/* complete some clones with analysis (tag / name / expected value)
......
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