Browse Source

HasticPod begin

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
dc6782e899
  1. 6
      client/src/components/Graph.vue
  2. 8
      client/src/components/hastic_pod.ts
  3. 10
      client/src/services/data.service.ts
  4. 9
      client/src/services/metrics.service.ts

6
client/src/components/Graph.vue

@ -4,16 +4,14 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ChartwerkLineChart } from "@chartwerk/line-pod";
import { HasticPod } from "./hastic_pod";
// TODO: place chartwerk
// TODO: fetch data from API
// TODO: set height
export default defineComponent({
name: 'Graph',
props: {},
mounted() {
console.log(this.$el);
const startTime = 1590590148;
const arrayLength = 20;
const data1: [number, number][] = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 40), startTime + idx * 10000]);
@ -28,7 +26,7 @@ export default defineComponent({
// },
// eventsCallbacks: { zoomIn: zoomIn, zoomOut }
}
var pod = new ChartwerkLineChart(
var pod = new HasticPod(
document.getElementById('chart'),
[
{ target: 'test1', datapoints: data1, color: 'green' },

8
client/src/components/hastic_pod.ts

@ -0,0 +1,8 @@
import { ChartwerkLineChart, LineOptions, LineTimeSerie } from "@chartwerk/line-pod";
export class HasticPod extends ChartwerkLineChart {
constructor(el: HTMLElement, series?: LineTimeSerie[], options?: LineOptions) {
super(el, series, options)
}
}

10
client/src/services/data.service.ts

@ -1,10 +0,0 @@
export default function authHeader() {
let user = JSON.parse(localStorage.getItem('user')!);
if (user && user.accessToken) {
return { Authorization: 'Bearer ' + user.accessToken };
} else {
return {};
}
}

9
client/src/services/metrics.service.ts

@ -0,0 +1,9 @@
import { API_URL } from "@/config";
import axios from 'axios';
const METRICS_API_URL = API_URL + "metrics";
export default async function getMetrics(from: number, to: number, step: number) {
let uri = METRICS_API_URL + `?from=${from}`;
let res = axios.get(METRICS_API_URL);
}
Loading…
Cancel
Save