@perses-dev/dashboards 0.27.0 → 0.29.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/dist/cjs/components/GridLayout/GridItemContent.js +22 -4
- package/dist/cjs/components/GridLayout/GridLayout.js +31 -2
- package/dist/cjs/components/Panel/Panel.js +2 -2
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +41 -34
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +32 -18
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +87 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +4 -4
- package/dist/cjs/context/DashboardProvider/common.js +26 -6
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +8 -32
- package/dist/cjs/stories/decorators/WithDataQueriesProvider.js +39 -0
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +2 -47
- package/dist/cjs/stories/decorators/WithPluginRegistry.js +3 -0
- package/dist/cjs/stories/decorators/index.js +1 -0
- package/dist/cjs/test/datasource-provider.js +70 -0
- package/dist/cjs/test/index.js +1 -0
- package/dist/cjs/test/plugin-registry.js +11 -5
- package/dist/cjs/test/testDashboard.js +79 -79
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/time.js +27 -0
- package/dist/components/GridLayout/GridItemContent.d.ts +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +22 -4
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +31 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +3 -3
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +42 -35
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +32 -18
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.d.ts +15 -0
- package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -0
- package/dist/components/PanelDrawer/usePanelEditor.js +84 -0
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +4 -4
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +2 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +17 -2
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +3 -6
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +9 -33
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/stories/decorators/WithDataQueriesProvider.js +33 -0
- package/dist/stories/decorators/WithDataQueriesProvider.js.map +1 -0
- package/dist/stories/decorators/WithDatasourceStore.js +1 -46
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithPluginRegistry.js +3 -0
- package/dist/stories/decorators/WithPluginRegistry.js.map +1 -1
- package/dist/stories/decorators/index.js +1 -0
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/test/datasource-provider.d.ts +6 -0
- package/dist/test/datasource-provider.d.ts.map +1 -0
- package/dist/test/datasource-provider.js +60 -0
- package/dist/test/datasource-provider.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +11 -5
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/testDashboard.js +79 -79
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/time.d.ts +5 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +23 -0
- package/dist/utils/time.js.map +1 -0
- package/package.json +6 -6
|
@@ -20,62 +20,17 @@ Object.defineProperty(exports, "WithDatasourceStore", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _dashboards = require("@perses-dev/dashboards");
|
|
23
|
-
const
|
|
23
|
+
const _test = require("../../test");
|
|
24
24
|
// Type guard because storybook types parameters as `any`
|
|
25
25
|
function isWithDatasourceStoreParameter(parameter) {
|
|
26
26
|
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
27
27
|
}
|
|
28
|
-
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
29
|
-
const prometheusDemo = {
|
|
30
|
-
kind: 'GlobalDatasource',
|
|
31
|
-
metadata: {
|
|
32
|
-
name: 'PrometheusDemo',
|
|
33
|
-
created_at: '0001-01-01T00:00:00Z',
|
|
34
|
-
updated_at: '0001-01-01T00:00:00Z',
|
|
35
|
-
version: 0
|
|
36
|
-
},
|
|
37
|
-
spec: {
|
|
38
|
-
default: true,
|
|
39
|
-
plugin: {
|
|
40
|
-
kind: 'PrometheusDatasource',
|
|
41
|
-
spec: {
|
|
42
|
-
direct_url: prometheusDemoUrl
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
28
|
const WithDatasourceStore = (Story, context)=>{
|
|
48
29
|
const initParameter = context.parameters.withDatasourceStore;
|
|
49
30
|
const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;
|
|
50
31
|
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
51
|
-
// This default currently defines the bare minimum to get a story working in
|
|
52
|
-
// the `Dashboard` storybook with the Prometheus demo api. We'll likely want
|
|
53
|
-
// to expand it to do more in the future.
|
|
54
|
-
const defaultDatasourceProps = {
|
|
55
|
-
dashboardResource: _constants.EMPTY_DASHBOARD_RESOURCE,
|
|
56
|
-
datasourceApi: {
|
|
57
|
-
getDatasource: ()=>{
|
|
58
|
-
return Promise.resolve(undefined);
|
|
59
|
-
},
|
|
60
|
-
getGlobalDatasource: (selector)=>{
|
|
61
|
-
if (selector.kind === 'PrometheusDatasource') {
|
|
62
|
-
return Promise.resolve({
|
|
63
|
-
resource: prometheusDemo,
|
|
64
|
-
proxyUrl: prometheusDemoUrl
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return Promise.resolve(undefined);
|
|
68
|
-
},
|
|
69
|
-
listDatasources: ()=>{
|
|
70
|
-
return Promise.resolve([]);
|
|
71
|
-
},
|
|
72
|
-
listGlobalDatasources: ()=>{
|
|
73
|
-
return Promise.resolve([]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
32
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboards.DatasourceStoreProvider, {
|
|
78
|
-
...defaultDatasourceProps,
|
|
33
|
+
..._test.defaultDatasourceProps,
|
|
79
34
|
...props,
|
|
80
35
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
81
36
|
});
|
|
@@ -86,6 +86,9 @@ const bundledPluginLoader = (0, _pluginSystem.dynamicImportPluginLoader)([
|
|
|
86
86
|
const WithPluginRegistry = (Story)=>{
|
|
87
87
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
88
88
|
pluginLoader: bundledPluginLoader,
|
|
89
|
+
defaultPluginKinds: {
|
|
90
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
91
|
+
},
|
|
89
92
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
90
93
|
});
|
|
91
94
|
};
|
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./constants"), exports);
|
|
18
18
|
_exportStar(require("./WithDashboard"), exports);
|
|
19
|
+
_exportStar(require("./WithDataQueriesProvider"), exports);
|
|
19
20
|
_exportStar(require("./WithDatasourceStore"), exports);
|
|
20
21
|
_exportStar(require("./WithPluginRegistry"), exports);
|
|
21
22
|
_exportStar(require("./WithQueryClient"), exports);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
prometheusDemoUrl: ()=>prometheusDemoUrl,
|
|
25
|
+
prometheusDemo: ()=>prometheusDemo,
|
|
26
|
+
defaultDatasourceProps: ()=>defaultDatasourceProps
|
|
27
|
+
});
|
|
28
|
+
const _dashboardProvider = require("./dashboard-provider");
|
|
29
|
+
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
30
|
+
const prometheusDemo = {
|
|
31
|
+
kind: 'GlobalDatasource',
|
|
32
|
+
metadata: {
|
|
33
|
+
name: 'PrometheusDemo',
|
|
34
|
+
created_at: '0001-01-01T00:00:00Z',
|
|
35
|
+
updated_at: '0001-01-01T00:00:00Z',
|
|
36
|
+
version: 0
|
|
37
|
+
},
|
|
38
|
+
spec: {
|
|
39
|
+
default: true,
|
|
40
|
+
plugin: {
|
|
41
|
+
kind: 'PrometheusDatasource',
|
|
42
|
+
spec: {
|
|
43
|
+
direct_url: prometheusDemoUrl
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const defaultDatasourceProps = {
|
|
49
|
+
dashboardResource: (0, _dashboardProvider.getTestDashboard)(),
|
|
50
|
+
datasourceApi: {
|
|
51
|
+
getDatasource: ()=>{
|
|
52
|
+
return Promise.resolve(undefined);
|
|
53
|
+
},
|
|
54
|
+
getGlobalDatasource: (selector)=>{
|
|
55
|
+
if (selector.kind === 'PrometheusDatasource') {
|
|
56
|
+
return Promise.resolve({
|
|
57
|
+
resource: prometheusDemo,
|
|
58
|
+
proxyUrl: prometheusDemoUrl
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return Promise.resolve(undefined);
|
|
62
|
+
},
|
|
63
|
+
listDatasources: ()=>{
|
|
64
|
+
return Promise.resolve([]);
|
|
65
|
+
},
|
|
66
|
+
listGlobalDatasources: ()=>{
|
|
67
|
+
return Promise.resolve([]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
package/dist/cjs/test/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./dashboard-provider"), exports);
|
|
18
|
+
_exportStar(require("./datasource-provider"), exports);
|
|
18
19
|
_exportStar(require("./plugin-registry"), exports);
|
|
19
20
|
_exportStar(require("./render"), exports);
|
|
20
21
|
function _exportStar(from, to) {
|
|
@@ -19,17 +19,23 @@ Object.defineProperty(exports, "MOCK_PLUGINS", {
|
|
|
19
19
|
get: ()=>MOCK_PLUGINS
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const FakeTimeSeriesChartOptionEditor = ()=>{
|
|
23
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
24
|
+
children: "TimeSeriesChart options"
|
|
25
|
+
});
|
|
26
|
+
};
|
|
22
27
|
const FakeTimeSeriesPlugin = {
|
|
23
28
|
PanelComponent: ()=>{
|
|
24
29
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
25
30
|
children: "TimeSeriesChart panel"
|
|
26
31
|
});
|
|
27
32
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
panelOptionsEditorComponents: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Settings',
|
|
36
|
+
content: FakeTimeSeriesChartOptionEditor
|
|
37
|
+
}
|
|
38
|
+
],
|
|
33
39
|
createInitialOptions: ()=>({})
|
|
34
40
|
};
|
|
35
41
|
const MOCK_TIME_SERIES_PANEL = {
|
|
@@ -62,24 +62,24 @@ const testDashboard = {
|
|
|
62
62
|
plugin: {
|
|
63
63
|
kind: 'TimeSeriesChart',
|
|
64
64
|
spec: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
unit: {
|
|
66
|
+
kind: '%'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
queries: [
|
|
71
|
+
{
|
|
72
|
+
kind: 'TimeSeriesQuery',
|
|
73
|
+
spec: {
|
|
74
|
+
plugin: {
|
|
75
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
68
76
|
spec: {
|
|
69
|
-
|
|
70
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
71
|
-
spec: {
|
|
72
|
-
query: 'avg without (cpu)(rate(node_cpu_seconds_total{job="node",instance="$instance",mode!="idle"}[$interval]))'
|
|
73
|
-
}
|
|
74
|
-
}
|
|
77
|
+
query: 'avg without (cpu)(rate(node_cpu_seconds_total{job="node",instance="$instance",mode!="idle"}[$interval]))'
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
],
|
|
78
|
-
unit: {
|
|
79
|
-
kind: '%'
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
]
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
memory: {
|
|
@@ -91,57 +91,57 @@ const testDashboard = {
|
|
|
91
91
|
plugin: {
|
|
92
92
|
kind: 'TimeSeriesChart',
|
|
93
93
|
spec: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
unit: {
|
|
95
|
+
kind: 'Bytes'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
queries: [
|
|
100
|
+
{
|
|
101
|
+
kind: 'TimeSeriesQuery',
|
|
102
|
+
spec: {
|
|
103
|
+
plugin: {
|
|
104
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
97
105
|
spec: {
|
|
98
|
-
|
|
99
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
100
|
-
spec: {
|
|
101
|
-
query: 'node_memory_MemTotal_bytes{job="node",instance="$instance"} - node_memory_MemFree_bytes{job="node",instance="$instance"} - node_memory_Buffers_bytes{job="node",instance="$instance"} - node_memory_Cached_bytes{job="node",instance="$instance"}'
|
|
102
|
-
}
|
|
103
|
-
}
|
|
106
|
+
query: 'node_memory_MemTotal_bytes{job="node",instance="$instance"} - node_memory_MemFree_bytes{job="node",instance="$instance"} - node_memory_Buffers_bytes{job="node",instance="$instance"} - node_memory_Cached_bytes{job="node",instance="$instance"}'
|
|
104
107
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
kind: 'TimeSeriesQuery',
|
|
113
|
+
spec: {
|
|
114
|
+
plugin: {
|
|
115
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
108
116
|
spec: {
|
|
109
|
-
|
|
110
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
111
|
-
spec: {
|
|
112
|
-
query: 'node_memory_Buffers_bytes{job="node",instance="$instance"}'
|
|
113
|
-
}
|
|
114
|
-
}
|
|
117
|
+
query: 'node_memory_Buffers_bytes{job="node",instance="$instance"}'
|
|
115
118
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
kind: 'TimeSeriesQuery',
|
|
124
|
+
spec: {
|
|
125
|
+
plugin: {
|
|
126
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
119
127
|
spec: {
|
|
120
|
-
|
|
121
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
122
|
-
spec: {
|
|
123
|
-
query: 'node_memory_Cached_bytes{job="node",instance="$instance"}'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
128
|
+
query: 'node_memory_Cached_bytes{job="node",instance="$instance"}'
|
|
126
129
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
kind: 'TimeSeriesQuery',
|
|
135
|
+
spec: {
|
|
136
|
+
plugin: {
|
|
137
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
130
138
|
spec: {
|
|
131
|
-
|
|
132
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
133
|
-
spec: {
|
|
134
|
-
query: 'node_memory_MemFree_bytes{job="node",instance="$instance"}'
|
|
135
|
-
}
|
|
136
|
-
}
|
|
139
|
+
query: 'node_memory_MemFree_bytes{job="node",instance="$instance"}'
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
],
|
|
140
|
-
unit: {
|
|
141
|
-
kind: 'Bytes'
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
]
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
// This panel is referenced in more than one layout below
|
|
@@ -154,24 +154,24 @@ const testDashboard = {
|
|
|
154
154
|
plugin: {
|
|
155
155
|
kind: 'TimeSeriesChart',
|
|
156
156
|
spec: {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
unit: {
|
|
158
|
+
kind: 'Percent'
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
queries: [
|
|
163
|
+
{
|
|
164
|
+
kind: 'TimeSeriesQuery',
|
|
165
|
+
spec: {
|
|
166
|
+
plugin: {
|
|
167
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
160
168
|
spec: {
|
|
161
|
-
|
|
162
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
163
|
-
spec: {
|
|
164
|
-
query: 'rate(node_disk_io_time_seconds_total{job="node",instance="$instance",device!~"^(md\\\\d+$|dm-)"}[$interval])'
|
|
165
|
-
}
|
|
166
|
-
}
|
|
169
|
+
query: 'rate(node_disk_io_time_seconds_total{job="node",instance="$instance",device!~"^(md\\\\d+$|dm-)"}[$interval])'
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
|
-
],
|
|
170
|
-
unit: {
|
|
171
|
-
kind: 'Percent'
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
|
|
174
|
+
]
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
177
|
filesystemFullness: {
|
|
@@ -183,24 +183,24 @@ const testDashboard = {
|
|
|
183
183
|
plugin: {
|
|
184
184
|
kind: 'TimeSeriesChart',
|
|
185
185
|
spec: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
unit: {
|
|
187
|
+
kind: 'Percent'
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
queries: [
|
|
192
|
+
{
|
|
193
|
+
kind: 'TimeSeriesQuery',
|
|
194
|
+
spec: {
|
|
195
|
+
plugin: {
|
|
196
|
+
kind: 'PrometheusTimeSeriesQuery',
|
|
189
197
|
spec: {
|
|
190
|
-
|
|
191
|
-
kind: 'PrometheusTimeSeriesQuery',
|
|
192
|
-
spec: {
|
|
193
|
-
query: '1 - node_filesystem_free_bytes{job="node",instance="$instance",fstype!="rootfs",mountpoint!~"/(run|var).*",mountpoint!=""} / node_filesystem_size_bytes{job="node",instance="$instance"}'
|
|
194
|
-
}
|
|
195
|
-
}
|
|
198
|
+
query: '1 - node_filesystem_free_bytes{job="node",instance="$instance",fstype!="rootfs",mountpoint!~"/(run|var).*",mountpoint!=""} / node_filesystem_size_bytes{job="node",instance="$instance"}'
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
|
-
],
|
|
199
|
-
unit: {
|
|
200
|
-
kind: 'Percent'
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
]
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
},
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./panelUtils"), exports);
|
|
18
|
+
_exportStar(require("./time"), exports);
|
|
18
19
|
function _exportStar(from, to) {
|
|
19
20
|
Object.keys(from).forEach(function(k) {
|
|
20
21
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useSuggestedStepMs", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useSuggestedStepMs
|
|
20
|
+
});
|
|
21
|
+
const _core = require("@perses-dev/core");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
function useSuggestedStepMs(width) {
|
|
24
|
+
const { absoluteTimeRange } = (0, _pluginSystem.useTimeRange)();
|
|
25
|
+
if (width === undefined) return 0;
|
|
26
|
+
return (0, _core.getSuggestedStepMs)(absoluteTimeRange, width);
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,gBAAgB,EAA0C,MAAM,eAAe,CAAC;AAIzF,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAkC1D"}
|
|
@@ -11,13 +11,16 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { DataQueriesProvider } from '@perses-dev/plugin-system';
|
|
14
15
|
import { useEditMode, usePanel, usePanelActions } from '../../context';
|
|
16
|
+
import { useSuggestedStepMs } from '../../utils';
|
|
15
17
|
import { Panel } from '../Panel/Panel';
|
|
16
18
|
/**
|
|
17
19
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
18
20
|
*/ export function GridItemContent(props) {
|
|
19
|
-
const { panelGroupItemId } = props;
|
|
21
|
+
const { panelGroupItemId , width } = props;
|
|
20
22
|
const panelDefinition = usePanel(panelGroupItemId);
|
|
23
|
+
const { spec: { queries } , } = panelDefinition;
|
|
21
24
|
const { isEditMode } = useEditMode();
|
|
22
25
|
const { openEditPanel , openDeletePanelDialog , duplicatePanel } = usePanelActions(panelGroupItemId);
|
|
23
26
|
// Provide actions to the panel when in edit mode
|
|
@@ -29,9 +32,24 @@ import { Panel } from '../Panel/Panel';
|
|
|
29
32
|
onDeletePanelClick: openDeletePanelDialog
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
// map TimeSeriesQueryDefinition to Definition<UnknownSpec>
|
|
36
|
+
const suggestedStepMs = useSuggestedStepMs(width);
|
|
37
|
+
const queryDefinitions = queries !== null && queries !== void 0 ? queries : [];
|
|
38
|
+
const definitions = queryDefinitions.map((query)=>{
|
|
39
|
+
return {
|
|
40
|
+
kind: query.spec.plugin.kind,
|
|
41
|
+
spec: query.spec.plugin.spec
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
return /*#__PURE__*/ _jsx(DataQueriesProvider, {
|
|
45
|
+
definitions: definitions,
|
|
46
|
+
options: {
|
|
47
|
+
suggestedStepMs
|
|
48
|
+
},
|
|
49
|
+
children: /*#__PURE__*/ _jsx(Panel, {
|
|
50
|
+
definition: panelDefinition,
|
|
51
|
+
editHandlers: editHandlers
|
|
52
|
+
})
|
|
35
53
|
});
|
|
36
54
|
}
|
|
37
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelGroupItemId, useEditMode, usePanel, usePanelActions } from '../../context';\nimport { Panel, PanelProps } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel } = usePanelActions(panelGroupItemId);\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n return <Panel definition={panelDefinition} editHandlers={editHandlers}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition } from '@perses-dev/core';\nimport { DataQueriesProvider } from '@perses-dev/plugin-system';\nimport { PanelGroupItemId, useEditMode, usePanel, usePanelActions } from '../../context';\nimport { useSuggestedStepMs } from '../../utils';\nimport { Panel, PanelProps } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n const {\n spec: { queries },\n } = panelDefinition;\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel } = usePanelActions(panelGroupItemId);\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query: QueryDefinition) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n return (\n <DataQueriesProvider definitions={definitions} options={{ suggestedStepMs }}>\n <Panel definition={panelDefinition} editHandlers={editHandlers} />\n </DataQueriesProvider>\n );\n}\n"],"names":["DataQueriesProvider","useEditMode","usePanel","usePanelActions","useSuggestedStepMs","Panel","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","editHandlers","undefined","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","queryDefinitions","definitions","map","query","kind","plugin","options","definition"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,mBAAmB,QAAQ,2BAA2B,CAAC;AAChE,SAA2BC,WAAW,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,eAAe,CAAC;AACzF,SAASC,kBAAkB,QAAQ,aAAa,CAAC;AACjD,SAASC,KAAK,QAAoB,gBAAgB,CAAC;AAOnD;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGF,KAAK,AAAC;IAC1C,MAAMG,eAAe,GAAGR,QAAQ,CAACM,gBAAgB,CAAC,AAAC;IACnD,MAAM,EACJG,IAAI,EAAE,EAAEC,OAAO,CAAA,EAAE,CAAA,IAClB,GAAGF,eAAe,AAAC;IACpB,MAAM,EAAEG,UAAU,CAAA,EAAE,GAAGZ,WAAW,EAAE,AAAC;IACrC,MAAM,EAAEa,aAAa,CAAA,EAAEC,qBAAqB,CAAA,EAAEC,cAAc,CAAA,EAAE,GAAGb,eAAe,CAACK,gBAAgB,CAAC,AAAC;IAEnG,iDAAiD;IACjD,IAAIS,YAAY,GAA+BC,SAAS,AAAC;IACzD,IAAIL,UAAU,EAAE;QACdI,YAAY,GAAG;YACbE,gBAAgB,EAAEL,aAAa;YAC/BM,qBAAqB,EAAEJ,cAAc;YACrCK,kBAAkB,EAAEN,qBAAqB;SAC1C,CAAC;IACJ,CAAC;IAED,2DAA2D;IAC3D,MAAMO,eAAe,GAAGlB,kBAAkB,CAACK,KAAK,CAAC,AAAC;IAClD,MAAMc,gBAAgB,GAAGX,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI,EAAE,AAAC;IACvC,MAAMY,WAAW,GAAGD,gBAAgB,CAACE,GAAG,CAAC,CAACC,KAAsB,GAAK;QACnE,OAAO;YACLC,IAAI,EAAED,KAAK,CAACf,IAAI,CAACiB,MAAM,CAACD,IAAI;YAC5BhB,IAAI,EAAEe,KAAK,CAACf,IAAI,CAACiB,MAAM,CAACjB,IAAI;SAC7B,CAAC;IACJ,CAAC,CAAC,AAAC;IAEH,qBACE,KAACX,mBAAmB;QAACwB,WAAW,EAAEA,WAAW;QAAEK,OAAO,EAAE;YAAEP,eAAe;SAAE;kBACzE,cAAA,KAACjB,KAAK;YAACyB,UAAU,EAAEpB,eAAe;YAAEO,YAAY,EAAEA,YAAY;UAAI;MAC9C,CACtB;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAoD,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAoD,YAAY,EAAE,MAAM,eAAe,CAAC;AAS/F,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkFhD"}
|
|
@@ -20,6 +20,7 @@ import { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants'
|
|
|
20
20
|
import { GridTitle } from './GridTitle';
|
|
21
21
|
import { GridItemContent } from './GridItemContent';
|
|
22
22
|
import { GridContainer } from './GridContainer';
|
|
23
|
+
const DEFAULT_MARGIN = 10;
|
|
23
24
|
const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
24
25
|
/**
|
|
25
26
|
* Layout component that arranges children in a Grid based on the definition.
|
|
@@ -31,6 +32,7 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
31
32
|
var ref;
|
|
32
33
|
const [isOpen, setIsOpen] = useState((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
33
34
|
const { isEditMode } = useEditMode();
|
|
35
|
+
const [gridColWidth, setGridColWidth] = useState(0);
|
|
34
36
|
const handleLayoutChange = (currentLayout, allLayouts)=>{
|
|
35
37
|
// Using the value from `allLayouts` instead of `currentLayout` because of
|
|
36
38
|
// a bug in react-layout-grid where `currentLayout` does not adjust properly
|
|
@@ -41,6 +43,16 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
41
43
|
updatePanelGroupLayouts(smallLayout);
|
|
42
44
|
}
|
|
43
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Calculate the column width so we can determine the width of each panel for suggested step ms
|
|
48
|
+
* https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35
|
|
49
|
+
*/ const handleWidthChange = (containerWidth, margin, cols, containerPadding)=>{
|
|
50
|
+
const marginX = margin[0];
|
|
51
|
+
const marginWidth = marginX * (cols - 1);
|
|
52
|
+
const containerPaddingWidth = containerPadding[0] * 2;
|
|
53
|
+
// exclude margin and padding from total width
|
|
54
|
+
setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);
|
|
55
|
+
};
|
|
44
56
|
return /*#__PURE__*/ _jsxs(GridContainer, {
|
|
45
57
|
children: [
|
|
46
58
|
groupDefinition.title !== undefined && /*#__PURE__*/ _jsx(GridTitle, {
|
|
@@ -70,6 +82,10 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
70
82
|
],
|
|
71
83
|
isDraggable: isEditMode,
|
|
72
84
|
isResizable: isEditMode,
|
|
85
|
+
margin: [
|
|
86
|
+
DEFAULT_MARGIN,
|
|
87
|
+
DEFAULT_MARGIN
|
|
88
|
+
],
|
|
73
89
|
containerPadding: [
|
|
74
90
|
0,
|
|
75
91
|
10
|
|
@@ -78,14 +94,16 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
78
94
|
[GRID_LAYOUT_SMALL_BREAKPOINT]: groupDefinition.itemLayouts
|
|
79
95
|
},
|
|
80
96
|
onLayoutChange: handleLayoutChange,
|
|
81
|
-
|
|
97
|
+
onWidthChange: handleWidthChange,
|
|
98
|
+
children: groupDefinition.itemLayouts.map(({ i , w })=>/*#__PURE__*/ _jsx("div", {
|
|
82
99
|
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
83
100
|
FallbackComponent: ErrorAlert,
|
|
84
101
|
children: /*#__PURE__*/ _jsx(GridItemContent, {
|
|
85
102
|
panelGroupItemId: {
|
|
86
103
|
panelGroupId,
|
|
87
104
|
panelGroupItemLayoutId: i
|
|
88
|
-
}
|
|
105
|
+
},
|
|
106
|
+
width: calculateGridItemWidth(w, gridColWidth)
|
|
89
107
|
})
|
|
90
108
|
})
|
|
91
109
|
}, i))
|
|
@@ -94,5 +112,16 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
|
|
|
94
112
|
]
|
|
95
113
|
});
|
|
96
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Calculates grid item width
|
|
117
|
+
* @param w number of columns the grid item spans
|
|
118
|
+
* @param colWidth the width of each column in px
|
|
119
|
+
* @returns grid item's width in px
|
|
120
|
+
* https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35
|
|
121
|
+
*/ const calculateGridItemWidth = (w, colWidth)=>{
|
|
122
|
+
// 0 * Infinity === NaN, which causes problems with resize contraints
|
|
123
|
+
if (!Number.isFinite(w)) return w;
|
|
124
|
+
return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);
|
|
125
|
+
};
|
|
97
126
|
|
|
98
127
|
//# sourceMappingURL=GridLayout.js.map
|