Removed all curves at given day
This commit is contained in:
@ -57,6 +57,6 @@
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.jump-button-all, .jump-button-time{
|
||||
.jump-button{
|
||||
width: 200px;
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
class DatesPopup extends HTMLElement{
|
||||
|
||||
static TIME = 0;
|
||||
static ALL = 1;
|
||||
static DAY = new Date(24*60*60*1000);
|
||||
|
||||
constructor(goToNowCallback, jumpCallback){
|
||||
@ -23,16 +21,11 @@ class DatesPopup extends HTMLElement{
|
||||
return [dateInputValue.getTime(), timeMs];
|
||||
}
|
||||
|
||||
doJumpAllCallback(){
|
||||
let dateTimeInput = this.getDateTimeInput();
|
||||
this.hide();
|
||||
this.jumpCallback(dateTimeInput[0], dateTimeInput[1], DatesPopup.ALL);
|
||||
}
|
||||
|
||||
doJumpTimeCallback(){
|
||||
doJumpCallback(){
|
||||
let dateTimeInput = this.getDateTimeInput();
|
||||
this.hide();
|
||||
this.jumpCallback(dateTimeInput[0], dateTimeInput[1], DatesPopup.TIME);
|
||||
this.jumpCallback(dateTimeInput[0], dateTimeInput[1]);
|
||||
}
|
||||
|
||||
convertTimeStringToTimestamp(formattedTime){
|
||||
@ -68,8 +61,7 @@ class DatesPopup extends HTMLElement{
|
||||
this.getElementsByTagName("img")[0].onclick = () => {this.hide();};
|
||||
this.getElementsByClassName("go-to-now-button")[0].onclick = () => {this.doGoToNowCallback();};
|
||||
this.getElementsByClassName("input-date")[0].max = new Date().toISOString().split("T")[0]; // sets the max to today (set only at app start)
|
||||
this.getElementsByClassName("jump-button-time")[0].onclick = () => {this.doJumpTimeCallback();};
|
||||
this.getElementsByClassName("jump-button-all")[0].onclick = () => {this.doJumpAllCallback();};
|
||||
this.getElementsByClassName("jump-button")[0].onclick = () => {this.doJumpCallback();};
|
||||
}
|
||||
|
||||
render(){
|
||||
@ -95,11 +87,7 @@ class DatesPopup extends HTMLElement{
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button class="jump-button-time">Curves at the given time</button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button class="jump-button-all">All curves of the given day</button>
|
||||
<button class="jump-button">Jump</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -350,7 +350,7 @@ function successHandler(s, message) {
|
||||
begin = timeRange[0] - timeRange[1];
|
||||
select.value = begin;
|
||||
// Server-request for variable-list.*/
|
||||
reqJSON(0, "http://" + hostPort + "/getvars?time=" + timeRange + "&all=False&id="
|
||||
reqJSON(0, "http://" + hostPort + "/getvars?time=" + timeRange + "&id="
|
||||
+ clientID, successHandler, errorHandler);
|
||||
break;
|
||||
// Response to a "getvars"-server-request.
|
||||
|
@ -748,7 +748,7 @@ let graphs = (function (){
|
||||
resolution = Math.ceil((timeDelta / container.getBoundingClientRect().width))
|
||||
}
|
||||
|
||||
function jumpToDate(dateTimestampMs, timeValueMs, mode){
|
||||
function jumpToDate(dateTimestampMs, timeValueMs){
|
||||
|
||||
cursorLine(null);
|
||||
|
||||
@ -756,17 +756,11 @@ let graphs = (function (){
|
||||
|
||||
msLeftTimestampGetVars = dateTimestampMs;
|
||||
msLeftTimestampGetGraph = dateTimestampMs;
|
||||
|
||||
if(mode == DatesPopup.TIME){
|
||||
msRightTimestampGetVars = dateTimestampMs + timeValueMs;
|
||||
}
|
||||
else if(mode == DatesPopup.ALL){ // we ignore time
|
||||
msRightTimestampGetVars = dateTimestampMs + 24*60*60*1000 - 1000; // we exclude the very beginning of the next day
|
||||
}
|
||||
|
||||
msRightTimestampGetVars = dateTimestampMs + timeValueMs;
|
||||
msRightTimestampGetGraph = dateTimestampMs + 24*60*60*1000 - 1000;
|
||||
|
||||
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestampGetVars/1000 + "," + msRightTimestampGetVars/1000 + "&all=" +allQueryParameterRepresentation(mode) + "&id="+ clientID).getJSON().then(function(data){
|
||||
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestampGetVars/1000 + "," + msRightTimestampGetVars/1000 + "&id="+ clientID).getJSON().then(function(data){
|
||||
blocks = data.blocks;
|
||||
document.getElementById("device").innerHTML = data.device
|
||||
maxTime = msRightTimestampGetGraph;
|
||||
@ -785,15 +779,6 @@ let graphs = (function (){
|
||||
|
||||
}
|
||||
|
||||
function allQueryParameterRepresentation(mode){
|
||||
if(mode == DatesPopup.ALL){
|
||||
return "True";
|
||||
}
|
||||
else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The function called when the viewing window is moved by the mouse.
|
||||
*
|
||||
@ -845,7 +830,7 @@ let graphs = (function (){
|
||||
let msLeftTimestamp = msRightTimestamp - 30*60*1000;
|
||||
cursorLine(null);
|
||||
|
||||
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestamp/1000 + "," + msRightTimestamp/1000 + "&all=False&id="+ clientID).getJSON().then(function(data){
|
||||
AJAX("http://" + hostPort + "/getvars?time=" + msLeftTimestamp/1000 + "," + msRightTimestamp/1000 + "&id="+ clientID).getJSON().then(function(data){
|
||||
currentMaxTime = msRightTimestamp + 60000;
|
||||
currentMinTime = msLeftTimestamp;
|
||||
|
||||
|
28
influxdb.py
28
influxdb.py
@ -53,7 +53,7 @@ class InfluxDataGetter:
|
||||
|
||||
# ----- PUBLIC METHODS
|
||||
|
||||
def get_available_variables_at_time(self, times, all=False):
|
||||
def get_available_variables_at_time(self, times):
|
||||
"""
|
||||
Gets the available variables (those that we can have a value for since the device has been installed on the instrument) at the given point in time.
|
||||
We can get the last available variables at the given point in time or all the known variables for the day corresponding to the timestamp.
|
||||
@ -67,7 +67,7 @@ class InfluxDataGetter:
|
||||
a block of curves with their name, their label and their color to display, grouped by their tag (which can be the unit augmented with an index) and their unit.
|
||||
"""
|
||||
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times, all)
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times)
|
||||
available_variables = self._extract_variables(all_setup_info)
|
||||
available_variables = self._remove_variables_without_value_float(available_variables, times)
|
||||
available_variables = self._set_variables_with_target(available_variables, times)
|
||||
@ -75,7 +75,7 @@ class InfluxDataGetter:
|
||||
|
||||
return res
|
||||
|
||||
def get_available_variables_at_time2(self, times, all=False):
|
||||
def get_available_variables_at_time2(self, times):
|
||||
"""
|
||||
Gets the available variables (those that we can have a value for since the device has been installed on the instrument) at the given point in time.
|
||||
We can get the last available variables at the given point in time or all the known variables for the day corresponding to the timestamp.
|
||||
@ -89,7 +89,7 @@ class InfluxDataGetter:
|
||||
a block of curves with their name, their label and their color to display, grouped by their tag (which can be the unit augmented with an index) and their unit.
|
||||
"""
|
||||
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times, all)
|
||||
all_setup_info = self._get_all_setup_info_as_dict(times)
|
||||
|
||||
available_variables = self._extract_variables2(all_setup_info)
|
||||
available_variables = self._filter_params_with_config(available_variables)
|
||||
@ -214,14 +214,13 @@ class InfluxDataGetter:
|
||||
|
||||
# ----- PRIVATE METHODS
|
||||
|
||||
def _get_all_setup_info_as_dict(self, times, all=False):
|
||||
def _get_all_setup_info_as_dict(self, times):
|
||||
"""
|
||||
Gets the value of the field setup_info in the measurements nicos/se_main, nicos/se_stick, nicos/se_addons as an array of Python dicts.
|
||||
Takes the last setup_info dict (for each measurement) known at times[1], or all the dicts for this day + the previous known (also for each)
|
||||
|
||||
Parameters
|
||||
times ([int]) : the unix timestamps in seconds of the range. The first value can be unused. The last can represent the point in time.
|
||||
all (bool) : indicates if we want all the variables for the given times[1] timestamp (all the day)
|
||||
|
||||
Returns :
|
||||
[{(str):((str), {...})}]: an array of the parsed "setup_info dict" of each measurements. The key is the secop_module prefixed with "se_", and the value is a tuple with its first value
|
||||
@ -234,10 +233,10 @@ class InfluxDataGetter:
|
||||
to_add = []
|
||||
query = f"""
|
||||
from(bucket: "{self._bucket}")
|
||||
|> range(start: {times[0] if all=="True" else 0}, stop: {times[1] + 1})
|
||||
|> range(start: 0, stop: {times[1] + 1})
|
||||
|> filter(fn: (r) => r._measurement == "{measurement}")
|
||||
|> filter(fn: (r) => r._field == "setup_info")
|
||||
{"" if all=="True" else "|> last()"}
|
||||
|> last()
|
||||
|> yield(name: "res")
|
||||
"""
|
||||
tables = self._db.query(query)
|
||||
@ -245,19 +244,6 @@ class InfluxDataGetter:
|
||||
for record in table.records:
|
||||
to_add.append(ast.literal_eval(record.get_value()))
|
||||
|
||||
if all == "True":
|
||||
query = f"""
|
||||
from(bucket: "{self._bucket}")
|
||||
|> range(start: 0, stop: {times[0]+1})
|
||||
|> filter(fn: (r) => r._measurement == "{measurement}")
|
||||
|> filter(fn: (r) => r._field == "setup_info")
|
||||
|> last()
|
||||
|> yield(name: "res")
|
||||
"""
|
||||
tables = self._db.query(query)
|
||||
for table in tables:
|
||||
for record in table.records:
|
||||
to_add.append(ast.literal_eval(record.get_value()))
|
||||
res.extend(to_add)
|
||||
return res
|
||||
|
||||
|
@ -119,7 +119,7 @@ class InfluxGraph:
|
||||
time = [float(t) for t in time.split(',')]
|
||||
return dict(type='time', time= self.get_abs_time(time))
|
||||
|
||||
def w_getvars(self, time, all=False):
|
||||
def w_getvars(self, time):
|
||||
"""
|
||||
Gets the curve names available at a given point in time.
|
||||
Called when the route /getvars is reached.
|
||||
@ -137,7 +137,7 @@ class InfluxGraph:
|
||||
start_time = int(self.get_abs_time(time)[0])
|
||||
end_time = int(self.get_abs_time(time)[-1])
|
||||
|
||||
blocks = self.influx_data_getter.get_available_variables_at_time2([start_time, end_time], all)
|
||||
blocks = self.influx_data_getter.get_available_variables_at_time2([start_time, end_time])
|
||||
device_name = self.influx_data_getter.get_device_name(end_time)
|
||||
# updates the self.variables attribute to keep track of the available variables
|
||||
self.variables = [variable["name"] for block in blocks for variable in block["curves"]]
|
||||
|
Reference in New Issue
Block a user