@kong-ui-public/dashboard-renderer 0.14.2 → 0.14.3
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 +125 -25
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,19 +4,20 @@ Render Analytics charts on a page from a JSON definition.
|
|
|
4
4
|
|
|
5
5
|
- [Requirements](#requirements)
|
|
6
6
|
- [Usage](#usage)
|
|
7
|
-
- [Install](#install)
|
|
8
7
|
- [Props](#props)
|
|
8
|
+
- [Example](#example)
|
|
9
9
|
|
|
10
10
|
## Requirements
|
|
11
11
|
|
|
12
12
|
- `vue` must be initialized in the host application
|
|
13
13
|
- A plugin providing an `AnalyticsBridge` must be installed in the root of the application.
|
|
14
|
-
- This plugin must `provide` the necessary methods to adhere to the
|
|
14
|
+
- This plugin must `provide` the necessary methods to adhere to the [AnalyticsBridge](https://github.com/Kong/public-ui-components/blob/main/packages/analytics/analytics-utilities/src/types/query-bridge.ts) interface defined in `@kong-ui-public/analytics-utilities`.
|
|
15
15
|
- The plugin's query method is in charge of passing the query to the correct API for the host app's environment.
|
|
16
|
-
- See the sandbox plugin (
|
|
16
|
+
- See the sandbox plugin [sandbox-query-provider.ts](https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/sandbox/sandbox-query-provider.ts) for an example that simply returns static data rather than consuming an API.
|
|
17
17
|
- The host application must supply peer dependencies for:
|
|
18
18
|
- `@kong-ui-public/analytics-chart`
|
|
19
19
|
- `@kong-ui-public/analytics-utilities`
|
|
20
|
+
- `@kong-ui-public/analytics-metric-provider`
|
|
20
21
|
- `@kong-ui-public/i18n`
|
|
21
22
|
- `@kong/kongponents`
|
|
22
23
|
- `swrv`
|
|
@@ -31,9 +32,11 @@ This component only takes two properties:
|
|
|
31
32
|
- [context](https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/src/types/dashboard-renderer-types.ts) : The time range that the dashboard should query and any additional filters that should be applied.
|
|
32
33
|
- [config](https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/src/types/dashboard-renderer-types.ts) : The dashboard config and layout.
|
|
33
34
|
|
|
35
|
+
For context `filters` and `timeSpec` see [here](https://github.com/Kong/public-ui-components/blob/main/packages/analytics/analytics-utilities/src/types/explore-v4.ts)
|
|
36
|
+
|
|
34
37
|
### Example
|
|
35
38
|
|
|
36
|
-
```
|
|
39
|
+
```html
|
|
37
40
|
<DashboardRenderer
|
|
38
41
|
:context="context"
|
|
39
42
|
:config="config"
|
|
@@ -43,6 +46,10 @@ This component only takes two properties:
|
|
|
43
46
|
with the following data:
|
|
44
47
|
|
|
45
48
|
```typescript
|
|
49
|
+
|
|
50
|
+
import type { DashboardRendererContext, DashboardConfig } from '@kong-ui-public/dashboard-renderer'
|
|
51
|
+
import { DashboardRenderer, ChartTypes } from '@kong-ui-public/dashboard-renderer'
|
|
52
|
+
|
|
46
53
|
const context: DashboardRendererContext = {
|
|
47
54
|
filters: [],
|
|
48
55
|
timeSpec: {
|
|
@@ -52,10 +59,10 @@ const context: DashboardRendererContext = {
|
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
const config: DashboardConfig = {
|
|
55
|
-
//
|
|
62
|
+
// 4 x 1 grid
|
|
56
63
|
gridSize: {
|
|
57
|
-
cols:
|
|
58
|
-
rows:
|
|
64
|
+
cols: 4,
|
|
65
|
+
rows: 1,
|
|
59
66
|
}
|
|
60
67
|
tiles: [
|
|
61
68
|
{
|
|
@@ -63,41 +70,49 @@ const config: DashboardConfig = {
|
|
|
63
70
|
chart: {
|
|
64
71
|
type: ChartTypes.HorizontalBar,
|
|
65
72
|
},
|
|
66
|
-
|
|
73
|
+
// Request count by route
|
|
74
|
+
query: {
|
|
75
|
+
metrics: ['request_count'],
|
|
76
|
+
dimensions: ['route']
|
|
77
|
+
},
|
|
67
78
|
},
|
|
68
79
|
layout: {
|
|
69
80
|
// Position at column 0, row 0
|
|
70
81
|
position: {
|
|
71
|
-
col:
|
|
72
|
-
row:
|
|
82
|
+
col: 0,
|
|
83
|
+
row: 0,
|
|
73
84
|
},
|
|
74
|
-
// Spans
|
|
85
|
+
// Spans 2 columns and 1 rows
|
|
75
86
|
size: {
|
|
76
|
-
col:
|
|
77
|
-
row:
|
|
87
|
+
col: 2,
|
|
88
|
+
row: 1,
|
|
78
89
|
}
|
|
79
90
|
}
|
|
80
91
|
},
|
|
81
92
|
{
|
|
82
93
|
definition: {
|
|
83
94
|
chart: {
|
|
84
|
-
type: ChartTypes.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
type: ChartTypes.TopN,
|
|
96
|
+
chartTitle: 'Top N Table',
|
|
97
|
+
description: 'Table description',
|
|
98
|
+
},
|
|
99
|
+
// Top 5 routes by request_count
|
|
100
|
+
query: {
|
|
101
|
+
metrics: ['request_count'],
|
|
102
|
+
dimensions: ['route'],
|
|
103
|
+
limit: 5,
|
|
88
104
|
},
|
|
89
|
-
query: {},
|
|
90
105
|
},
|
|
91
106
|
layout: {
|
|
92
|
-
// Position at column
|
|
107
|
+
// Position at column 2, row 0
|
|
93
108
|
position: {
|
|
94
|
-
col:
|
|
95
|
-
row:
|
|
109
|
+
col: 2,
|
|
110
|
+
row: 0,
|
|
96
111
|
},
|
|
97
|
-
// Spans
|
|
112
|
+
// Spans 2 columns and 1 rows
|
|
98
113
|
size: {
|
|
99
|
-
col:
|
|
100
|
-
row:
|
|
114
|
+
col: 2,
|
|
115
|
+
row: 1,
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
118
|
},
|
|
@@ -105,4 +120,89 @@ const config: DashboardConfig = {
|
|
|
105
120
|
}
|
|
106
121
|
```
|
|
107
122
|
|
|
108
|
-
|
|
123
|
+
### Example with slotted content
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<DashboardRenderer
|
|
127
|
+
:context="context"
|
|
128
|
+
:config="config"
|
|
129
|
+
>
|
|
130
|
+
<!-- use the `id` set in the tile config for the slot name -->
|
|
131
|
+
<template #slot-1>
|
|
132
|
+
<div>
|
|
133
|
+
<h3>Custom Slot</h3>
|
|
134
|
+
<p>This is a slotted tile</p>
|
|
135
|
+
</div>
|
|
136
|
+
</template>
|
|
137
|
+
</DashboardRenderer>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import type { DashboardRendererContext, DashboardConfig } from '@kong-ui-public/dashboard-renderer'
|
|
142
|
+
import { DashboardRenderer, ChartTypes } from '@kong-ui-public/dashboard-renderer'
|
|
143
|
+
|
|
144
|
+
const context: DashboardRendererContext = {
|
|
145
|
+
filters: [],
|
|
146
|
+
timeSpec: {
|
|
147
|
+
type: 'relative',
|
|
148
|
+
time_range: '15M',
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const config: DashboardConfig = {
|
|
153
|
+
// 4 x 1 grid
|
|
154
|
+
gridSize: {
|
|
155
|
+
cols: 4,
|
|
156
|
+
rows: 1,
|
|
157
|
+
}
|
|
158
|
+
tiles: [
|
|
159
|
+
{
|
|
160
|
+
// Line chart
|
|
161
|
+
definition: {
|
|
162
|
+
chart: {
|
|
163
|
+
type: ChartTypes.TimeSeriesLine,
|
|
164
|
+
},
|
|
165
|
+
// requests by status code over time
|
|
166
|
+
query: {
|
|
167
|
+
metrics: ['request_count'],
|
|
168
|
+
dimensions: ['status_code', 'time']
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
layout: {
|
|
172
|
+
// Position at column 0, row 0
|
|
173
|
+
position: {
|
|
174
|
+
col: 0,
|
|
175
|
+
row: 0,
|
|
176
|
+
},
|
|
177
|
+
// Spans 2 columns and 1 rows
|
|
178
|
+
size: {
|
|
179
|
+
col: 2,
|
|
180
|
+
row: 1,
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
// Slottable tile
|
|
186
|
+
definition: {
|
|
187
|
+
chart: {
|
|
188
|
+
type: ChartTypes.Slottable,
|
|
189
|
+
id: 'slot-1' // slot name
|
|
190
|
+
},
|
|
191
|
+
query: {},
|
|
192
|
+
},
|
|
193
|
+
layout: {
|
|
194
|
+
// Position at column 2, row 0
|
|
195
|
+
position: {
|
|
196
|
+
col: 2,
|
|
197
|
+
row: 0,
|
|
198
|
+
},
|
|
199
|
+
// Spans 2 columns and 1 rows
|
|
200
|
+
size: {
|
|
201
|
+
col: 2,
|
|
202
|
+
row: 1,
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
}
|
|
208
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/dashboard-renderer",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/dashboard-renderer.umd.js",
|
|
6
6
|
"module": "./dist/dashboard-renderer.es.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@kong-ui-public/analytics-chart": "^2.5.2",
|
|
31
31
|
"@kong-ui-public/analytics-metric-provider": "^5.0.1",
|
|
32
32
|
"@kong-ui-public/analytics-utilities": "^2.0.0",
|
|
33
|
-
"@kong-ui-public/
|
|
34
|
-
"@kong-ui-public/
|
|
33
|
+
"@kong-ui-public/i18n": "^2.1.4",
|
|
34
|
+
"@kong-ui-public/sandbox-layout": "^2.0.43"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|