Skip to content

Commit

Permalink
Merge pull request #1877 from chaveiro/master
Browse files Browse the repository at this point in the history
Add support for feed.getvalue asyncronously
  • Loading branch information
TrystanLea committed Apr 13, 2024
2 parents 29c1f05 + 3f10959 commit b9d044e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
41 changes: 34 additions & 7 deletions Modules/feed/feed.js
Expand Up @@ -118,21 +118,48 @@ var feed = {
return response;
},

getvalue: function(feedid,time) {
getvalue: function(feedid,time,callback=false,context=false) {
let data = {
id: feedid,
time: time
}
if (feed.apikey) data.apikey = feed.apikey;
let response = false;
$.ajax({ url: path+"feed/value.json", data: data, async: false, success: function(data){ response = data} });
return response;

var async = false;
if ( typeof callback === "function" ) {
async = true;
}

var non_async_result = false;
var ajaxAsyncXdr = $.ajax({
url: path+"feed/value.json",
data: data,
async: async,
success: function(result) {
if (result===null || result==="") {
console.log("ERROR","feed.getvalue invalid response: "+result);
result = false;
} else {
non_async_result = result;
}

if (async) {
if (!context) {
callback(result);
} else {
callback(context,result);
}
}
}
});
if (async) {
return ajaxAsyncXdr;
} else {
return non_async_result;
}
},

getdata: function(feedid,start,end,interval,average=0,delta=0,skipmissing=0,limitinterval=0,callback=false,context=false,timeformat='unixms'){



let data = {
id: feedid,
start: start,
Expand Down
2 changes: 1 addition & 1 deletion version.json
@@ -1,6 +1,6 @@
{
"name" : "Emoncms Core",
"version" : "11.4.12",
"version" : "11.5.0",
"location" : "/var/www",
"branches_available": ["stable","master"]
}

0 comments on commit b9d044e

Please sign in to comment.