Commit b1b725b0 authored by Matija Obreza's avatar Matija Obreza
Browse files

webapi JS bugfix

parent 8b1032c5
...@@ -17,49 +17,50 @@ var GenesysPGR = function(baseUrl, clientId) { ...@@ -17,49 +17,50 @@ var GenesysPGR = function(baseUrl, clientId) {
clientId: clientId, clientId: clientId,
baseUrl: baseUrl, baseUrl: baseUrl,
clientSecret: null, clientSecret: null,
defaultOptions: defaultOptions defaultOptions: defaultOptions,
};
}; getUrl : function(apiCall) {
return this.baseUrl + '/webapi' + apiCall + '?client_id=' + this.clientId + (this.clientSecret!==null ? '&client_secret=' + this.clientSecret : '');
},
listAccessions : function (filter, opts) {
var o = $.extend({}, GenesysPGR.defaultOptions, opts);
var json={filter: JSON.stringify(filter), startAt: Math.max(1, o.startAt), maxRecords: o.maxRecords };
GenesysPGR.prototype.getUrl = function(apiCall) { $.ajax(this.getUrl('/v0/acn/filter'), {
return this.baseUrl + '/webapi' + apiCall + '?client_id=' + this.clientId + (this.clientSecret!==null ? '&client_secret=' + this.clientSecret : ''); dataType: 'json',
}; type: 'POST',
contentType: 'application/json; charset=utf-8',
GenesysPGR.prototype.listAccessions = function (filter, opts) { data: JSON.stringify(json),
var o = $.extend({}, GenesysPGR.defaultOptions, opts);
var json={filter: JSON.stringify(filter), startAt: Math.max(1, o.startAt), maxRecords: o.maxRecords };
$.ajax(this.getUrl('/v0/acn/filter'), { success: function (accessions) {
dataType: 'json', o.success(accessions);
type: 'POST', },
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(json),
success: function (accessions) { error: function (errorAsync) {
o.success(accessions); o.error(errorAsync);
}, }
});
},
overview : function (filter, opts) {
var o = $.extend({}, GenesysPGR.defaultOptions, opts);
error: function (errorAsync) { $.ajax(this.getUrl('/v0/acn/overview'), {
o.error(errorAsync); dataType: 'json',
} type: 'POST',
}); contentType: 'application/json; charset=utf-8',
}; data: JSON.stringify(filter),
GenesysPGR.prototype.overview = function (filter, opts) { success: function (accessions) {
var o = $.extend({}, GenesysPGR.defaultOptions, opts); o.success(accessions);
},
$.ajax(this.getUrl('/v0/acn/overview'), { error: function (errorAsync) {
dataType: 'json', o.error(errorAsync);
type: 'POST', }
contentType: 'application/json; charset=utf-8', });
data: JSON.stringify(filter), }
};
success: function (accessions) {
o.success(accessions);
},
error: function (errorAsync) {
o.error(errorAsync);
}
});
}; };
\ 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