@kong-ui-public/dashboard-renderer 10.5.0 → 10.5.1-pr.4084.22032af76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -0
- package/dist/{GeoMapRenderer-sfj8cOX0.js → GeoMapRenderer-BJ5o73Ow.js} +28 -26
- package/dist/dashboard-renderer.es.js +1 -1
- package/dist/dashboard-renderer.umd.js +14 -14
- package/dist/{index-C9j3O5jK.js → index-DOltdHAw.js} +2985 -2877
- package/dist/style.css +1 -1
- package/dist/types/components/BarChartRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/BaseAnalyticsChartRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/DashboardTile.vue.d.ts +6 -1
- package/dist/types/components/DashboardTile.vue.d.ts.map +1 -1
- package/dist/types/components/DashboardTilePreview.vue.d.ts +6 -1
- package/dist/types/components/DashboardTilePreview.vue.d.ts.map +1 -1
- package/dist/types/components/DonutChartRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/GeoMapRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/HeatmapRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/QueryDataProvider.vue.d.ts +5 -3
- package/dist/types/components/QueryDataProvider.vue.d.ts.map +1 -1
- package/dist/types/components/ScatterChartRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/SimpleChartRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/TableDataGridRenderer.vue.d.ts +2 -0
- package/dist/types/components/TableDataGridRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/TimeseriesChartRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/TopNTableRenderer.vue.d.ts.map +1 -1
- package/dist/types/components/TreemapRenderer.vue.d.ts.map +1 -1
- package/dist/types/composables/index.d.ts +2 -0
- package/dist/types/composables/index.d.ts.map +1 -1
- package/dist/types/composables/useIsPropPassed.d.ts +12 -0
- package/dist/types/composables/useIsPropPassed.d.ts.map +1 -0
- package/dist/types/types/renderer-types.d.ts +19 -1
- package/dist/types/types/renderer-types.d.ts.map +1 -1
- package/dist/types/utils/supplied-tile-data.d.ts +32 -0
- package/dist/types/utils/supplied-tile-data.d.ts.map +1 -0
- package/dist/types/utils/table-data-grid-renderer.d.ts +9 -1
- package/dist/types/utils/table-data-grid-renderer.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Render Analytics charts on a page from a JSON definition.
|
|
4
4
|
|
|
5
5
|
- [Consumer entry points](#consumer-entry-points)
|
|
6
|
+
- [Render a tile from supplied data](#render-a-tile-from-supplied-data)
|
|
6
7
|
- [Requirements](#requirements)
|
|
7
8
|
- [Usage](#usage)
|
|
8
9
|
- [Props](#props)
|
|
@@ -77,6 +78,92 @@ For a metric selector, set the tile query's `metrics` to the selected metric.
|
|
|
77
78
|
series; ungrouped results keep all queried metrics. Do not combine requests,
|
|
78
79
|
tokens, latency, and cost on a single axis and rely on that prop to select one.
|
|
79
80
|
|
|
81
|
+
### Render a tile from supplied data
|
|
82
|
+
|
|
83
|
+
Pass the `data` prop to `DashboardTilePreview` to render data the host already
|
|
84
|
+
has. When `data` is passed, the tile doesn't run a query. The definition still
|
|
85
|
+
sets the chart type and options.
|
|
86
|
+
|
|
87
|
+
The tile type sets the data shape. All three types are exported from
|
|
88
|
+
`@kong-ui-public/analytics-utilities`, and the union is exported as `TileData`.
|
|
89
|
+
|
|
90
|
+
| Tile | Data |
|
|
91
|
+
|------|------|
|
|
92
|
+
| `table` | `PlatformTabularResponse` |
|
|
93
|
+
| `scatter` with the `requests` datasource | `ApiRequestsResult` |
|
|
94
|
+
| Other chart tiles | `ExploreResultV4` |
|
|
95
|
+
|
|
96
|
+
The value sets the state:
|
|
97
|
+
|
|
98
|
+
| Value | State |
|
|
99
|
+
|-------|-------|
|
|
100
|
+
| `undefined` | Loading skeleton |
|
|
101
|
+
| `null` | Empty state |
|
|
102
|
+
| An `Error` | Error state with the error message |
|
|
103
|
+
| Data | The chart. Data that doesn't match the tile type shows the error state. |
|
|
104
|
+
|
|
105
|
+
Pass `undefined` while the host loads, not an omitted prop. Without `data`,
|
|
106
|
+
the tile queries through the `AnalyticsBridge`.
|
|
107
|
+
|
|
108
|
+
With `data`:
|
|
109
|
+
|
|
110
|
+
- The refresh action and the "Jump to Explore" and "Jump to Requests" links
|
|
111
|
+
are hidden.
|
|
112
|
+
- Zoom emits `tile-time-range-zoom`. Fetch data for the new time range and
|
|
113
|
+
pass it to `data`.
|
|
114
|
+
- `chart-data` emits the supplied data, and CSV export uses it.
|
|
115
|
+
- The renderer checks only the top-level shape of the data, such as its
|
|
116
|
+
`data` and `meta` fields.
|
|
117
|
+
- `golden_signals` and `top_talkers` tiles don't support `data`. They run
|
|
118
|
+
their queries.
|
|
119
|
+
|
|
120
|
+
```vue
|
|
121
|
+
<template>
|
|
122
|
+
<DashboardTilePreview
|
|
123
|
+
:context="context"
|
|
124
|
+
:data="data"
|
|
125
|
+
:definition="definition"
|
|
126
|
+
@tile-time-range-zoom="onZoom"
|
|
127
|
+
/>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<script setup lang="ts">
|
|
131
|
+
import { ref } from 'vue'
|
|
132
|
+
import { DashboardTilePreview } from '@kong-ui-public/dashboard-renderer'
|
|
133
|
+
import type { DashboardRendererContext, TileData, TileZoomEvent } from '@kong-ui-public/dashboard-renderer'
|
|
134
|
+
import type { ChartTileDefinition, TimeRangeV4 } from '@kong-ui-public/analytics-utilities'
|
|
135
|
+
|
|
136
|
+
const context: DashboardRendererContext = {
|
|
137
|
+
filters: [],
|
|
138
|
+
timeSpec: { type: 'relative', time_range: '7d' },
|
|
139
|
+
}
|
|
140
|
+
const definition: ChartTileDefinition = {
|
|
141
|
+
chart: { type: 'timeseries_line' },
|
|
142
|
+
query: {
|
|
143
|
+
datasource: 'api_usage',
|
|
144
|
+
metrics: ['request_count'],
|
|
145
|
+
dimensions: ['time'],
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// `undefined` shows the loading skeleton until the host's request settles.
|
|
150
|
+
const data = ref<TileData | null | Error>()
|
|
151
|
+
|
|
152
|
+
const load = async (timeRange: TimeRangeV4) => {
|
|
153
|
+
data.value = undefined
|
|
154
|
+
try {
|
|
155
|
+
data.value = await fetchRequestCounts(timeRange) // The host's own request, which returns ExploreResultV4.
|
|
156
|
+
} catch (error) {
|
|
157
|
+
data.value = error instanceof Error ? error : new Error(String(error))
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const onZoom = ({ timeRange }: TileZoomEvent) => load(timeRange)
|
|
162
|
+
|
|
163
|
+
load(context.timeSpec!)
|
|
164
|
+
</script>
|
|
165
|
+
```
|
|
166
|
+
|
|
80
167
|
## Requirements
|
|
81
168
|
|
|
82
169
|
- `vue` must be initialized in the host application
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { _ as
|
|
3
|
-
import { exploreResultToCountryMetrics as
|
|
4
|
-
import { COUNTRIES as
|
|
5
|
-
const U = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as p, ref as v, computed as o, openBlock as q, createBlock as C, withCtx as g, createVNode as x, unref as M } from "vue";
|
|
2
|
+
import { _ as E } from "./index-DOltdHAw.js";
|
|
3
|
+
import { exploreResultToCountryMetrics as O, AnalyticsGeoMap as R } from "@kong-ui-public/analytics-geo-map";
|
|
4
|
+
import { COUNTRIES as _ } from "@kong-ui-public/analytics-utilities";
|
|
5
|
+
const U = /* @__PURE__ */ p({
|
|
6
6
|
__name: "GeoMapRenderer",
|
|
7
7
|
props: {
|
|
8
8
|
query: {},
|
|
@@ -15,11 +15,12 @@ const U = /* @__PURE__ */ v({
|
|
|
15
15
|
headerDescription: {},
|
|
16
16
|
requestsLink: {},
|
|
17
17
|
exploreLink: {},
|
|
18
|
-
zoomConfiguration: {}
|
|
18
|
+
zoomConfiguration: {},
|
|
19
|
+
suppliedData: {}
|
|
19
20
|
},
|
|
20
21
|
emits: ["bounds-change"],
|
|
21
|
-
setup(
|
|
22
|
-
const n =
|
|
22
|
+
setup(t, { emit: c }) {
|
|
23
|
+
const n = t, e = v(void 0), a = o(() => e.value ? O(e.value) : {}), s = o(() => e.value ? e.value?.meta.metric_names && e.value.meta.metric_names[0] : ""), m = o(() => n.query.limit !== void 0 && n.query.limit > 0 ? n.query.limit : _.length), l = o(() => {
|
|
23
24
|
if (!n.query.filters?.find(({ field: i, operator: u }) => i === "country_code" && (u === "not_empty" || u === "empty" || u === "in"))) {
|
|
24
25
|
const i = {
|
|
25
26
|
field: "country_code",
|
|
@@ -37,34 +38,35 @@ const U = /* @__PURE__ */ v({
|
|
|
37
38
|
}), y = o(() => {
|
|
38
39
|
if (!e.value)
|
|
39
40
|
return "";
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
-
}),
|
|
43
|
-
e.value =
|
|
44
|
-
},
|
|
45
|
-
|
|
41
|
+
const r = e?.value?.meta.metric_units, i = e?.value?.meta?.metric_names;
|
|
42
|
+
return r && i && r[i[0]];
|
|
43
|
+
}), d = (r) => {
|
|
44
|
+
e.value = r;
|
|
45
|
+
}, f = c, h = (r) => {
|
|
46
|
+
f("bounds-change", r);
|
|
46
47
|
};
|
|
47
|
-
return (
|
|
48
|
-
context:
|
|
48
|
+
return (r, i) => (q(), C(E, {
|
|
49
|
+
context: t.context,
|
|
49
50
|
"limit-override": m.value,
|
|
50
51
|
query: l.value,
|
|
51
|
-
"query-ready":
|
|
52
|
-
"refresh-counter":
|
|
53
|
-
|
|
52
|
+
"query-ready": t.queryReady,
|
|
53
|
+
"refresh-counter": t.refreshCounter,
|
|
54
|
+
"supplied-data": t.suppliedData,
|
|
55
|
+
onChartData: d
|
|
54
56
|
}, {
|
|
55
57
|
default: g(() => [
|
|
56
|
-
x(
|
|
57
|
-
bounds:
|
|
58
|
-
"country-metrics":
|
|
59
|
-
"fit-to-country":
|
|
60
|
-
metric:
|
|
58
|
+
x(M(R), {
|
|
59
|
+
bounds: t.chartOptions.bounds,
|
|
60
|
+
"country-metrics": a.value,
|
|
61
|
+
"fit-to-country": t.chartOptions.fit_to_country,
|
|
62
|
+
metric: s.value,
|
|
61
63
|
"metric-unit": y.value,
|
|
62
|
-
"with-legend":
|
|
64
|
+
"with-legend": t.chartOptions.legend || !1,
|
|
63
65
|
onBoundsChange: h
|
|
64
66
|
}, null, 8, ["bounds", "country-metrics", "fit-to-country", "metric", "metric-unit", "with-legend"])
|
|
65
67
|
]),
|
|
66
68
|
_: 1
|
|
67
|
-
}, 8, ["context", "limit-override", "query", "query-ready", "refresh-counter"]));
|
|
69
|
+
}, 8, ["context", "limit-override", "query", "query-ready", "refresh-counter", "supplied-data"]));
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as s, a as R, b as _, D as T, c as e, d as i, e as D, f as I, E as L, F as N, g as O, I as S, h as o, T as r, i as A, j as C, k as n, l as F, m } from "./index-
|
|
1
|
+
import { C as s, a as R, b as _, D as T, c as e, d as i, e as D, f as I, E as L, F as N, g as O, I as S, h as o, T as r, i as A, j as C, k as n, l as F, m } from "./index-DOltdHAw.js";
|
|
2
2
|
export {
|
|
3
3
|
s as CELLS_PER_ROW,
|
|
4
4
|
R as CP_ID_TOKEN,
|