Browse Source

fetching data

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
b8c4b81a62
  1. 37
      client/src/components/hastic_pod/index.ts
  2. 1
      server/src/services/data_service.rs

37
client/src/components/hastic_pod/index.ts

@ -49,10 +49,24 @@ export class HasticPod extends LinePod {
this._udc = udc; this._udc = udc;
// TODO: move to params this.fetchData();
const to = Math.floor(Date.now() / 1000); }
const from = to - 5000; // -5000 seconds
renderMetrics() {
super.renderMetrics();
console.log('render my metrics');
}
protected fetchData() {
let to = Math.floor(Date.now() / 1000);
let from = to - 5000; // -5000 seconds
if(this.state?.xValueRange !== undefined) {
[from, to] = this.state?.xValueRange;
console.log('took from range');
}
console.log(from + " ---- " + to);
this._udc({ from, to }) this._udc({ from, to })
.then(resp => { .then(resp => {
this.updateData(resp.timeserie); this.updateData(resp.timeserie);
@ -61,11 +75,6 @@ export class HasticPod extends LinePod {
.catch(() => { /* set "error" message */ }) .catch(() => { /* set "error" message */ })
} }
renderMetrics() {
super.renderMetrics();
console.log('render my metrics');
}
protected addEvents(): void { protected addEvents(): void {
this.initBrush(); this.initBrush();
this.initPan(); this.initPan();
@ -125,11 +134,13 @@ export class HasticPod extends LinePod {
} }
const segment = new Segment(id, from, to); const segment = new Segment(id, from, to);
const storedId = await this._csc(segment); //const storedId =
segment.id = storedId; await this._csc(segment);
this.fetchData();
// segment.id = storedId;
this._segmentSet.addSegment(segment); // this._segmentSet.addSegment(segment);
this.renderSegment(segment); // this.renderSegment(segment);
} }
protected renderSegments() { protected renderSegments() {
@ -183,4 +194,4 @@ export class HasticPod extends LinePod {
this._tempIdCounted--; this._tempIdCounted--;
return this._tempIdCounted.toString(); return this._tempIdCounted.toString();
} }
} }

1
server/src/services/data_service.rs

@ -2,7 +2,6 @@ use rusqlite::{params, Connection, ToSql};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::rc::Rc;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::iter::repeat_with; use std::iter::repeat_with;

Loading…
Cancel
Save