From 04d818e00f228c8d8b40815ac46b2898407d9b5a Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 15 May 2022 14:51:16 +0200 Subject: [PATCH] console/frontend: add a selector for dimensions --- common/helpers/bimap.go | 18 ++ common/helpers/bimap_test.go | 26 +++ console/frontend/package.json | 2 +- .../src/components/InputDimensions.vue | 196 ++++++++++++++++++ .../src/components/InputTimeRange.vue | 5 +- .../src/components/VisualizeOptions.vue | 27 ++- console/frontend/src/components/WidgetTop.vue | 2 +- console/frontend/yarn.lock | 8 +- console/graph.go | 4 + console/graph_test.go | 69 ++++++ console/root.go | 1 + 11 files changed, 348 insertions(+), 10 deletions(-) create mode 100644 console/frontend/src/components/InputDimensions.vue diff --git a/common/helpers/bimap.go b/common/helpers/bimap.go index 98ac2a40..f3b7577e 100644 --- a/common/helpers/bimap.go +++ b/common/helpers/bimap.go @@ -33,6 +33,24 @@ func (bi *Bimap[K, V]) LoadKey(v V) (K, bool) { return k, ok } +// Keys returns a slice of the keys in the bimap. +func (bi *Bimap[K, V]) Keys() []K { + var keys []K + for k := range bi.forward { + keys = append(keys, k) + } + return keys +} + +// Values returns a slice of the values in the bimap. +func (bi *Bimap[K, V]) Values() []V { + var values []V + for v := range bi.inverse { + values = append(values, v) + } + return values +} + // String returns a string representation of the bimap. func (bi *Bimap[K, V]) String() string { return fmt.Sprintf("Bi%v", bi.forward) diff --git a/common/helpers/bimap_test.go b/common/helpers/bimap_test.go index 357c5a83..1654423c 100644 --- a/common/helpers/bimap_test.go +++ b/common/helpers/bimap_test.go @@ -59,3 +59,29 @@ func TestBimapLoadKey(t *testing.T) { } } } + +func TestBimapKeys(t *testing.T) { + input := helpers.NewBimap(map[int]string{ + 1: "hello", + 2: "world", + 3: "happy", + }) + got := input.Keys() + expected := []int{1, 2, 3} + if diff := helpers.Diff(got, expected); diff != "" { + t.Errorf("Keys() (-want, +got):\n%s", diff) + } +} + +func TestBimapValues(t *testing.T) { + input := helpers.NewBimap(map[int]string{ + 1: "hello", + 2: "world", + 3: "happy", + }) + got := input.Values() + expected := []string{"hello", "world", "happy"} + if diff := helpers.Diff(got, expected); diff != "" { + t.Errorf("Values() (-want, +got):\n%s", diff) + } +} diff --git a/console/frontend/package.json b/console/frontend/package.json index f5548d7c..da4bc31b 100644 --- a/console/frontend/package.json +++ b/console/frontend/package.json @@ -10,7 +10,7 @@ "format": "prettier --loglevel warn --write {src/**/,}*.{js,vue,html}" }, "dependencies": { - "@headlessui/vue": "^1.5.0", + "@headlessui/vue": "1.6.1", "@heroicons/vue": "^1.0.6", "echarts": "^5.3.2", "lz-string": "^1.4.4", diff --git a/console/frontend/src/components/InputDimensions.vue b/console/frontend/src/components/InputDimensions.vue new file mode 100644 index 00000000..dbbbcd07 --- /dev/null +++ b/console/frontend/src/components/InputDimensions.vue @@ -0,0 +1,196 @@ + + + diff --git a/console/frontend/src/components/InputTimeRange.vue b/console/frontend/src/components/InputTimeRange.vue index 860d84e7..d69ad929 100644 --- a/console/frontend/src/components/InputTimeRange.vue +++ b/console/frontend/src/components/InputTimeRange.vue @@ -32,7 +32,7 @@ @@ -85,6 +85,9 @@ import InputFloatingLabel from "./InputFloatingLabel.vue"; const props = defineProps({ modelValue: { + // start: start time + // end: end time + // errors: is there an input error? type: Object, required: true, }, diff --git a/console/frontend/src/components/VisualizeOptions.vue b/console/frontend/src/components/VisualizeOptions.vue index de34eb59..1b783798 100644 --- a/console/frontend/src/components/VisualizeOptions.vue +++ b/console/frontend/src/components/VisualizeOptions.vue @@ -23,6 +23,13 @@ Time range

+ +