Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for feed.getvalue asyncronously #1877

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 34 additions & 7 deletions Modules/feed/feed.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "Emoncms Core",
"version" : "11.4.12",
"version" : "11.5.0",
"location" : "/var/www",
"branches_available": ["stable","master"]
}