From d68178b7a03d54615b874807cfcee074a804e421 Mon Sep 17 00:00:00 2001 From: Alexey Velikiy Date: Sun, 31 Oct 2021 19:46:13 +0300 Subject: [PATCH] analytic status ui --- client/src/components/AnlyticsStatus.vue | 29 ++++++++++++++++++++++++ client/src/components/Graph.vue | 10 -------- client/src/services/analytics.service.ts | 22 ++++++++++++++++++ client/src/utils.ts | 15 ++++++++++++ client/src/views/Home.vue | 20 +++++++++++++++- 5 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 client/src/components/AnlyticsStatus.vue create mode 100644 client/src/services/analytics.service.ts create mode 100644 client/src/utils.ts diff --git a/client/src/components/AnlyticsStatus.vue b/client/src/components/AnlyticsStatus.vue new file mode 100644 index 0000000..478e3ca --- /dev/null +++ b/client/src/components/AnlyticsStatus.vue @@ -0,0 +1,29 @@ + + + diff --git a/client/src/components/Graph.vue b/client/src/components/Graph.vue index 2fe2bdc..192f3b7 100644 --- a/client/src/components/Graph.vue +++ b/client/src/components/Graph.vue @@ -1,12 +1,6 @@ @@ -107,8 +101,4 @@ export default defineComponent({ width: 80%; height: 350px; } - -pre { - display: inline; -} diff --git a/client/src/services/analytics.service.ts b/client/src/services/analytics.service.ts new file mode 100644 index 0000000..1507591 --- /dev/null +++ b/client/src/services/analytics.service.ts @@ -0,0 +1,22 @@ +// TODO: https://github.com/hastic/hastic-grafana-app/blob/c67bd8af140105c36f24c875187929869e48e51e/src/panel/graph_panel/services/analytic_service.ts + +import { API_URL } from "@/config"; +import axios from 'axios'; + +import { getGenerator } from '@/utils'; + +import _ from 'lodash'; + +const ANALYTICS_API_URL = API_URL + "analytics/"; + +export async function getStatus(): Promise { + const uri = ANALYTICS_API_URL + `status`; + const res = await axios.get(uri); + const data = res['data'] as any; + console.log(data.status); + return data.status; +} + +export function getStatusGenerator(): AsyncIterableIterator { + return getGenerator(100, getStatus); +} diff --git a/client/src/utils.ts b/client/src/utils.ts new file mode 100644 index 0000000..72aa441 --- /dev/null +++ b/client/src/utils.ts @@ -0,0 +1,15 @@ +export async function *getGenerator( + duration: number, + func: (...args: any[]) => Promise, + ...args +): AsyncIterableIterator { + + let timeout = async () => new Promise( + resolve => setTimeout(resolve, duration) + ); + + while(true) { + yield await func(...args); + await timeout(); + } +} \ No newline at end of file diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue index e3d2836..6e92e46 100644 --- a/client/src/views/Home.vue +++ b/client/src/views/Home.vue @@ -2,17 +2,35 @@
Vue logo + +
+
+ Hold
ctrl
to label patterns
+ Holde key
D
to delete patterns +
+ +
+
+ +