From b8c4b81a6240a5cf527b335022919953ef40ba8b Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Fri, 29 Oct 2021 21:29:08 +0300 Subject: [PATCH] fetching data --- client/src/components/hastic_pod/index.ts | 37 +++++++++++++++-------- server/src/services/data_service.rs | 1 - 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/client/src/components/hastic_pod/index.ts b/client/src/components/hastic_pod/index.ts index 0bcbb9e..8ca369e 100644 --- a/client/src/components/hastic_pod/index.ts +++ b/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(); } -} \ No newline at end of file +} diff --git a/server/src/services/data_service.rs b/server/src/services/data_service.rs index 427f6b0..fc70560 100644 --- a/server/src/services/data_service.rs +++ b/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;