Export : added API call + fixed route issues
This commit is contained in:
@ -285,7 +285,14 @@ function loadExportPopup(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, binning=null){
|
function exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, binning=null){
|
||||||
console.log(selectedVariables, startDateTimeMs, endDateTimeMs, binning);
|
|
||||||
|
let binningParam = "None";
|
||||||
|
if (binning !== null)
|
||||||
|
binningParam = binning
|
||||||
|
let exportURL = "http://" + hostPort + "/export?time=" + startDateTimeMs/1000 + "," + endDateTimeMs/1000 + "&variables=" + selectedVariables + "&interval=" + binningParam + "&id=" + clientID
|
||||||
|
let a = document.createElement('a');
|
||||||
|
a.href = exportURL
|
||||||
|
a.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
let graphs = (function (){
|
let graphs = (function (){
|
||||||
|
@ -197,7 +197,10 @@ class InfluxDataGetter:
|
|||||||
data_frame_last_known = self._db.query_data_frame(query_last_known)
|
data_frame_last_known = self._db.query_data_frame(query_last_known)
|
||||||
row_to_insert = None
|
row_to_insert = None
|
||||||
for index, row in data_frame_last_known.iterrows():
|
for index, row in data_frame_last_known.iterrows():
|
||||||
if row_to_insert == None or row["timestamp"] > row_to_insert["timestamp"]:
|
try: #needed because row_to_insert == None is not possible
|
||||||
|
if row_to_insert.empty or row["timestamp"] > row_to_insert["timestamp"]:
|
||||||
|
row_to_insert = row
|
||||||
|
except:
|
||||||
row_to_insert = row
|
row_to_insert = row
|
||||||
try:
|
try:
|
||||||
if not row_to_insert.empty :
|
if not row_to_insert.empty :
|
||||||
|
@ -176,12 +176,19 @@ class InfluxGraph:
|
|||||||
Returns :
|
Returns :
|
||||||
io.BytesIO : an BytesIO object containing the dataframe to retrieve
|
io.BytesIO : an BytesIO object containing the dataframe to retrieve
|
||||||
"""
|
"""
|
||||||
df = self.influx_data_getter.get_curves_data_frame(variables, time, interval)
|
|
||||||
|
time = [float(t) for t in time.split(',')]
|
||||||
|
start, end = self.get_abs_time(time)
|
||||||
|
start, end = int(start), int(end)
|
||||||
|
|
||||||
|
queried_variables = variables.split(',')
|
||||||
|
if interval != "None" : interval = self.milliseconds_to_nano(int(interval))
|
||||||
|
|
||||||
|
df = self.influx_data_getter.get_curves_data_frame(queried_variables, [start, end], interval)
|
||||||
|
|
||||||
mem = io.BytesIO()
|
mem = io.BytesIO()
|
||||||
mem.write(bytes(df.to_csv(sep="\t", index=False), "utf-8"))
|
df.to_csv(mem, sep="\t", index=False)
|
||||||
mem.seek(0)
|
mem.seek(0)
|
||||||
|
|
||||||
return mem
|
return mem
|
||||||
|
|
||||||
def graphpoll(self):
|
def graphpoll(self):
|
||||||
|
Reference in New Issue
Block a user