Skip to content

Commit be7f143

Browse files
committed
updated grafana version
1 parent 3d2bdf3 commit be7f143

File tree

6 files changed

+1328
-1852
lines changed

6 files changed

+1328
-1852
lines changed

.codeclimate.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
exclude_patterns:
2+
- "dist"
3+
- "**/node_modules/"
4+
- "**/*.d.ts"
5+
- "src/libs/"
6+
- "src/images/"
7+
- "src/img/"
8+
- "src/screenshots/"

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Grafana Button Control Panel
22

3+
[![CI](https://github.com/speakyourcode/grafana-button-panel/actions/workflows/ci.yml/badge.svg)](https://github.com/speakyourcode/grafana-button-panel/actions/workflows/ci.yml)
4+
[![Grafana Compatibility](https://github.com/speakyourcode/grafana-button-panel/actions/workflows/is-compatible.yml/badge.svg)](https://github.com/speakyourcode/grafana-button-panel/actions/workflows/is-compatible.yml)
5+
[![Maintainability](https://api.codeclimate.com/v1/badges/3d8db85bc1cc2b95d314/maintainability)](https://codeclimate.com/github/speakyourcode/grafana-button-panel/maintainability)
6+
[![Test Coverage](https://api.codeclimate.com/v1/badges/3d8db85bc1cc2b95d314/test_coverage)](https://codeclimate.com/github/speakyourcode/grafana-button-panel/test_coverage)
7+
38
This panel allows you to create buttons and define actions for them. It can be
49
used to add control functionality to your dashboards. Actions are defined as
510
queries to Datasources.

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
build:
77
context: ./.config
88
args:
9-
grafana_version: ${GRAFANA_VERSION:-9.1.2}
9+
grafana_version: ${GRAFANA_VERSION:-9.2.4}
1010
ports:
1111
- 3000:3000/tcp
1212
volumes:

package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,43 @@
1818
"license": "Apache-2.0",
1919
"devDependencies": {
2020
"@babel/core": "^7.16.7",
21-
"@grafana/e2e": "9.1.2",
22-
"@grafana/e2e-selectors": "9.1.2",
23-
"@grafana/eslint-config": "^2.5.0",
21+
"@grafana/e2e": "9.2.4",
22+
"@grafana/e2e-selectors": "9.2.4",
23+
"@grafana/eslint-config": "^5.1.0",
2424
"@grafana/tsconfig": "^1.2.0-rc1",
25-
"@swc/core": "^1.2.144",
26-
"@swc/helpers": "^0.3.6",
25+
"@swc/core": "^1.3.18",
26+
"@swc/helpers": "^0.4.13",
2727
"@swc/jest": "^0.2.20",
2828
"@testing-library/jest-dom": "^5.16.2",
29-
"@testing-library/react": "^12.1.3",
29+
"@testing-library/react": "^13.4.0",
3030
"@types/glob": "^8.0.0",
31-
"@types/jest": "^27.4.1",
31+
"@types/jest": "^29.2.3",
3232
"@types/lodash": "latest",
33-
"@types/node": "^17.0.19",
34-
"@typescript-eslint/eslint-plugin": "^4.33.0",
35-
"@typescript-eslint/parser": "^4.33.0",
36-
"copy-webpack-plugin": "^10.0.0",
37-
"css-loader": "6.7.1",
38-
"eslint": "^7.32.0",
33+
"@types/node": "^18.11.9",
34+
"@typescript-eslint/eslint-plugin": "^5.43.0",
35+
"@typescript-eslint/parser": "^5.43.0",
36+
"copy-webpack-plugin": "^11.0.0",
37+
"css-loader": "6.7.2",
38+
"eslint": "^8.27.0",
3939
"eslint-config-prettier": "^8.3.0",
40-
"eslint-plugin-jsdoc": "^36.1.0",
40+
"eslint-plugin-jsdoc": "^39.6.2",
4141
"eslint-plugin-prettier": "^4.0.0",
4242
"eslint-plugin-react": "^7.26.1",
4343
"eslint-plugin-react-hooks": "^4.2.0",
4444
"eslint-webpack-plugin": "^3.1.1",
4545
"fork-ts-checker-webpack-plugin": "^7.2.0",
4646
"glob": "^8.0.3",
4747
"identity-obj-proxy": "3.0.0",
48-
"jest": "27.5.0",
48+
"jest": "29.3.1",
4949
"prettier": "^2.5.0",
5050
"replace-in-file-webpack-plugin": "^1.0.6",
51-
"sass": "1.55.0",
52-
"sass-loader": "13.1.0",
51+
"sass": "1.56.1",
52+
"sass-loader": "13.2.0",
5353
"style-loader": "3.3.1",
54-
"swc-loader": "^0.1.15",
54+
"swc-loader": "^0.2.3",
5555
"ts-node": "^10.5.0",
56-
"tsconfig-paths": "^3.12.0",
57-
"typescript": "^4.4.0",
56+
"tsconfig-paths": "^4.1.0",
57+
"typescript": "^4.9.3",
5858
"webpack": "^5.69.1",
5959
"webpack-cli": "^4.9.2",
6060
"webpack-livereload-plugin": "^3.0.2"
@@ -64,11 +64,11 @@
6464
},
6565
"dependencies": {
6666
"@emotion/css": "^11.1.3",
67-
"@grafana/data": "9.1.2",
68-
"@grafana/runtime": "9.1.2",
69-
"@grafana/ui": "9.1.2",
67+
"@grafana/data": "9.2.4",
68+
"@grafana/runtime": "9.2.4",
69+
"@grafana/ui": "9.2.4",
7070
"@types/react": "^17",
71-
"react": "17.0.2",
72-
"react-dom": "17.0.2"
71+
"react": "18.2.0",
72+
"react-dom": "18.2.0"
7373
}
7474
}

src/buttonPanel.tsx

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,42 @@
1-
import { AppEvents, PanelProps } from '@grafana/data';
1+
import { AppEvents, InterpolateFunction, PanelProps } from '@grafana/data';
22
import { getBackendSrv, getDataSourceSrv, SystemJS } from '@grafana/runtime';
33
import { Button, HorizontalGroup, VerticalGroup } from '@grafana/ui';
44
import React from 'react';
55
import { ButtonOptions, Options } from 'types';
66

77
interface Props extends PanelProps<Options> {}
88

9+
async function postQuery(button: ButtonOptions, text: string, replaceVariables: InterpolateFunction) {
10+
const payload = JSON.parse(replaceVariables(button.query || '{}'));
11+
const ds = await getDataSourceSrv().get(button.datasource);
12+
try {
13+
const resp = await getBackendSrv().datasourceRequest({
14+
method: 'POST',
15+
url: 'api/ds/query',
16+
data: {
17+
queries: [
18+
{
19+
datasourceId: ds.id,
20+
refId: '1',
21+
...payload,
22+
},
23+
],
24+
},
25+
});
26+
const events = await SystemJS.load('app/core/app_events');
27+
events.emit(AppEvents.alertSuccess, [text + ': ' + resp.status + ' (' + resp.statusText + ')']);
28+
} catch (error: any) {
29+
const events = await SystemJS.load('app/core/app_events');
30+
events.emit(AppEvents.alertError, [text + ': ' + error.status + ' (' + error.statusText + ')', error.data.message]);
31+
}
32+
}
33+
934
export const ButtonPanel: React.FC<Props> = ({ options, replaceVariables }) => {
1035
const renderButtons = (buttons: ButtonOptions[]) => {
1136
return buttons.map((b: ButtonOptions, index: number) => {
1237
const text = b.text || 'Button';
1338
return (
14-
<Button
15-
key={index}
16-
variant={b.variant}
17-
onClick={async () => {
18-
const payload = JSON.parse(replaceVariables(b.query || '{}'));
19-
const ds = await getDataSourceSrv().get(b.datasource);
20-
try {
21-
const resp = await getBackendSrv().datasourceRequest({
22-
method: 'POST',
23-
url: 'api/tsdb/query',
24-
data: {
25-
queries: [
26-
{
27-
datasourceId: ds.id,
28-
refId: '1',
29-
...payload,
30-
},
31-
],
32-
},
33-
});
34-
const events = await SystemJS.load('app/core/app_events');
35-
events.emit(AppEvents.alertSuccess, [text + ': ' + resp.status + ' (' + resp.statusText + ')']);
36-
} catch (error: any) {
37-
const events = await SystemJS.load('app/core/app_events');
38-
events.emit(AppEvents.alertError, [
39-
text + ': ' + error.status + ' (' + error.statusText + ')',
40-
error.data.message,
41-
]);
42-
}
43-
}}
44-
>
39+
<Button key={index} variant={b.variant} onClick={async () => postQuery(b, text, replaceVariables)}>
4540
{text}
4641
</Button>
4742
);

0 commit comments

Comments
 (0)