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;
// TODO: move to params
const to = Math.floor(Date.now() / 1000);
const from = to - 5000; // -5000 seconds
this.fetchData();
}
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 })
.then(resp => {
this.updateData(resp.timeserie);
@ -61,11 +75,6 @@ export class HasticPod extends LinePod {
.catch(() => { /* set "error" message */ })
}
renderMetrics() {
super.renderMetrics();
console.log('render my metrics');
}
protected addEvents(): void {
this.initBrush();
this.initPan();
@ -125,11 +134,13 @@ export class HasticPod extends LinePod {
}
const segment = new Segment(id, from, to);
const storedId = await this._csc(segment);
segment.id = storedId;
//const storedId =
await this._csc(segment);
this.fetchData();
// segment.id = storedId;
this._segmentSet.addSegment(segment);
this.renderSegment(segment);
// this._segmentSet.addSegment(segment);
// this.renderSegment(segment);
}
protected renderSegments() {
@ -183,4 +194,4 @@ export class HasticPod extends LinePod {
this._tempIdCounted--;
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 std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::iter::repeat_with;

Loading…
Cancel
Save