@grafana/create-plugin 0.0.1
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/.eslintrc +6 -0
- package/.github/workflows/create-release.yml +49 -0
- package/.github/workflows/npm-bump-version.yml +51 -0
- package/.github/workflows/test.yml +31 -0
- package/.prettierrc +10 -0
- package/CONTRIBUTING.md +42 -0
- package/README.md +143 -0
- package/dist/bin/run.js +17 -0
- package/dist/commands/generate.command.js +56 -0
- package/dist/commands/generate.plopfile.js +119 -0
- package/dist/commands/index.js +19 -0
- package/dist/commands/migrate.command.js +133 -0
- package/dist/commands/update.command.js +101 -0
- package/dist/constants.js +74 -0
- package/dist/utils/tests/utils.files.test.js +30 -0
- package/dist/utils/tests/utils.handlebars.test.js +26 -0
- package/dist/utils/tests/utils.npm.test.js +138 -0
- package/dist/utils/tests/utils.plugin.test.js +20 -0
- package/dist/utils/tests/utils.templates.test.js +32 -0
- package/dist/utils/utils.console.js +41 -0
- package/dist/utils/utils.files.js +61 -0
- package/dist/utils/utils.handlebars.js +73 -0
- package/dist/utils/utils.npm.js +162 -0
- package/dist/utils/utils.plugin.js +14 -0
- package/dist/utils/utils.templates.js +77 -0
- package/docs/example.mp4 +0 -0
- package/jest.config.js +20 -0
- package/package.json +69 -0
- package/src/bin/run.ts +15 -0
- package/src/commands/generate.command.ts +15 -0
- package/src/commands/generate.plopfile.ts +151 -0
- package/src/commands/index.ts +3 -0
- package/src/commands/migrate.command.ts +99 -0
- package/src/commands/update.command.ts +66 -0
- package/src/constants.ts +99 -0
- package/src/utils/tests/utils.files.test.ts +41 -0
- package/src/utils/tests/utils.handlebars.test.ts +35 -0
- package/src/utils/tests/utils.npm.test.ts +193 -0
- package/src/utils/tests/utils.plugin.test.ts +22 -0
- package/src/utils/tests/utils.templates.test.ts +44 -0
- package/src/utils/utils.console.ts +41 -0
- package/src/utils/utils.files.ts +65 -0
- package/src/utils/utils.handlebars.ts +47 -0
- package/src/utils/utils.npm.ts +189 -0
- package/src/utils/utils.plugin.ts +9 -0
- package/src/utils/utils.templates.ts +76 -0
- package/templates/_partials/backend-getting-started.md +20 -0
- package/templates/_partials/frontend-getting-started.md +59 -0
- package/templates/app/README.md +20 -0
- package/templates/app/src/components/App/App.test.tsx +32 -0
- package/templates/app/src/components/App/App.tsx +8 -0
- package/templates/app/src/components/App/index.tsx +1 -0
- package/templates/app/src/components/AppConfig/AppConfig.test.tsx +51 -0
- package/templates/app/src/components/AppConfig/AppConfig.tsx +92 -0
- package/templates/app/src/components/AppConfig/index.tsx +1 -0
- package/templates/app/src/module.ts +12 -0
- package/templates/app/src/plugin.json +33 -0
- package/templates/backend/Magefile.go +12 -0
- package/templates/backend/go.mod +5 -0
- package/templates/backend/go.sum +568 -0
- package/templates/backend/pkg/main.go +24 -0
- package/templates/backend/pkg/plugin/datasource.go +111 -0
- package/templates/backend/pkg/plugin/datasource_test.go +28 -0
- package/templates/common/.config/.eslintrc +12 -0
- package/templates/common/.config/.prettierrc.js +16 -0
- package/templates/common/.config/Dockerfile +15 -0
- package/templates/common/.config/README.md +115 -0
- package/templates/common/.config/jest-setup.js +24 -0
- package/templates/common/.config/jest.config.js +31 -0
- package/templates/common/.config/tsconfig.json +17 -0
- package/templates/common/.config/types/custom.d.ts +37 -0
- package/templates/common/.config/webpack/constants.ts +3 -0
- package/templates/common/.config/webpack/tsconfig.webpack.json +9 -0
- package/templates/common/.config/webpack/utils.ts +17 -0
- package/templates/common/.config/webpack/webpack.config.ts +187 -0
- package/templates/common/.eslintrc +3 -0
- package/templates/common/.nvmrc +1 -0
- package/templates/common/.prettierrc.js +4 -0
- package/templates/common/CHANGELOG.md +5 -0
- package/templates/common/LICENSE +201 -0
- package/templates/common/cypress/integration/01-smoke.spec.ts +10 -0
- package/templates/common/docker-compose.yaml +14 -0
- package/templates/common/jest-setup.js +2 -0
- package/templates/common/jest.config.js +4 -0
- package/templates/common/package.json +67 -0
- package/templates/common/src/README.md +5 -0
- package/templates/common/src/img/logo.svg +1 -0
- package/templates/common/tsconfig.json +3 -0
- package/templates/datasource/README.md +20 -0
- package/templates/datasource/src/components/ConfigEditor.tsx +83 -0
- package/templates/datasource/src/components/QueryEditor.tsx +50 -0
- package/templates/datasource/src/datasource.ts +46 -0
- package/templates/datasource/src/module.ts +9 -0
- package/templates/datasource/src/plugin.json +37 -0
- package/templates/datasource/src/types.ts +24 -0
- package/templates/github/ci/.github/workflows/ci.yml +76 -0
- package/templates/github/ci/.github/workflows/release.yml +165 -0
- package/templates/github/is-compatible/.github/workflows/is-compatible.yml +17 -0
- package/templates/panel/README.md +22 -0
- package/templates/panel/src/components/SimplePanel.tsx +62 -0
- package/templates/panel/src/module.test.ts +6 -0
- package/templates/panel/src/module.ts +40 -0
- package/templates/panel/src/plugin.json +33 -0
- package/templates/panel/src/types.ts +7 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{{!-- /* 🚨 The `${{ }}` Github workflow expressions need to be escaped so they are not being interpreted by Handlebars. (this comment is going to be removed after scaffolding) 🚨 */ --}}
|
|
2
|
+
name: CI
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- master
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- master
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v2
|
|
16
|
+
|
|
17
|
+
- name: Setup Node.js environment
|
|
18
|
+
uses: actions/setup-node@v2.1.2
|
|
19
|
+
with:
|
|
20
|
+
node-version: '14.x'
|
|
21
|
+
|
|
22
|
+
- name: Get yarn cache directory path
|
|
23
|
+
id: yarn-cache-dir-path
|
|
24
|
+
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
25
|
+
|
|
26
|
+
- name: Cache yarn cache
|
|
27
|
+
uses: actions/cache@v2
|
|
28
|
+
id: cache-yarn-cache
|
|
29
|
+
with:
|
|
30
|
+
path: $\{{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
31
|
+
key: $\{{ runner.os }}-yarn-$\{{ hashFiles('**/yarn.lock') }}
|
|
32
|
+
restore-keys: |
|
|
33
|
+
$\{{ runner.os }}-yarn-
|
|
34
|
+
|
|
35
|
+
- name: Cache node_modules
|
|
36
|
+
id: cache-node-modules
|
|
37
|
+
uses: actions/cache@v2
|
|
38
|
+
with:
|
|
39
|
+
path: node_modules
|
|
40
|
+
key: $\{{ runner.os }}-$\{{ matrix.node-version }}-nodemodules-$\{{ hashFiles('**/yarn.lock') }}
|
|
41
|
+
restore-keys: |
|
|
42
|
+
$\{{ runner.os }}-$\{{ matrix.node-version }}-nodemodules-
|
|
43
|
+
|
|
44
|
+
- name: Install dependencies
|
|
45
|
+
run: yarn install --frozen-lockfile
|
|
46
|
+
|
|
47
|
+
- name: Build and test frontend
|
|
48
|
+
run: yarn build
|
|
49
|
+
|
|
50
|
+
- name: Check for backend
|
|
51
|
+
id: check-for-backend
|
|
52
|
+
run: |
|
|
53
|
+
if [ -f "Magefile.go" ]
|
|
54
|
+
then
|
|
55
|
+
echo "::set-output name=has-backend::true"
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
- name: Setup Go environment
|
|
59
|
+
if: steps.check-for-backend.outputs.has-backend == 'true'
|
|
60
|
+
uses: actions/setup-go@v2
|
|
61
|
+
with:
|
|
62
|
+
go-version: '1.15'
|
|
63
|
+
|
|
64
|
+
- name: Test backend
|
|
65
|
+
if: steps.check-for-backend.outputs.has-backend == 'true'
|
|
66
|
+
uses: magefile/mage-action@v1
|
|
67
|
+
with:
|
|
68
|
+
version: latest
|
|
69
|
+
args: coverage
|
|
70
|
+
|
|
71
|
+
- name: Build backend
|
|
72
|
+
if: steps.check-for-backend.outputs.has-backend == 'true'
|
|
73
|
+
uses: magefile/mage-action@v1
|
|
74
|
+
with:
|
|
75
|
+
version: latest
|
|
76
|
+
args: buildAll
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
{{!-- /* 🚨 The `$\{{ }}` Github workflow expressions need to be escaped so they are not being interpreted by Handlebars. (this comment is going to be removed after scaffolding) 🚨 */ --}}
|
|
2
|
+
name: Release
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- 'v*.*.*' # Run workflow on version tags, e.g. v1.0.0.
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
release:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
|
|
16
|
+
- name: Setup Node.js environment
|
|
17
|
+
uses: actions/setup-node@v2.1.2
|
|
18
|
+
with:
|
|
19
|
+
node-version: '14.x'
|
|
20
|
+
|
|
21
|
+
- name: Setup Go environment
|
|
22
|
+
uses: actions/setup-go@v2
|
|
23
|
+
with:
|
|
24
|
+
go-version: '1.15'
|
|
25
|
+
|
|
26
|
+
- name: Get yarn cache directory path
|
|
27
|
+
id: yarn-cache-dir-path
|
|
28
|
+
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
29
|
+
|
|
30
|
+
- name: Cache yarn cache
|
|
31
|
+
uses: actions/cache@v2
|
|
32
|
+
id: cache-yarn-cache
|
|
33
|
+
with:
|
|
34
|
+
path: $\{{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
35
|
+
key: $\{{ runner.os }}-yarn-$\{{ hashFiles('**/yarn.lock') }}
|
|
36
|
+
restore-keys: |
|
|
37
|
+
$\{{ runner.os }}-yarn-
|
|
38
|
+
|
|
39
|
+
- name: Cache node_modules
|
|
40
|
+
id: cache-node-modules
|
|
41
|
+
uses: actions/cache@v2
|
|
42
|
+
with:
|
|
43
|
+
path: node_modules
|
|
44
|
+
key: $\{{ runner.os }}-$\{{ matrix.node-version }}-nodemodules-$\{{ hashFiles('**/yarn.lock') }}
|
|
45
|
+
restore-keys: |
|
|
46
|
+
$\{{ runner.os }}-$\{{ matrix.node-version }}-nodemodules-
|
|
47
|
+
|
|
48
|
+
- name: Install dependencies
|
|
49
|
+
run: yarn install --frozen-lockfile;
|
|
50
|
+
if: |
|
|
51
|
+
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
|
|
52
|
+
steps.cache-node-modules.outputs.cache-hit != 'true'
|
|
53
|
+
|
|
54
|
+
- name: Build and test frontend
|
|
55
|
+
run: yarn build
|
|
56
|
+
|
|
57
|
+
- name: Check for backend
|
|
58
|
+
id: check-for-backend
|
|
59
|
+
run: |
|
|
60
|
+
if [ -f "Magefile.go" ]
|
|
61
|
+
then
|
|
62
|
+
echo "::set-output name=has-backend::true"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
- name: Test backend
|
|
66
|
+
if: steps.check-for-backend.outputs.has-backend == 'true'
|
|
67
|
+
uses: magefile/mage-action@v1
|
|
68
|
+
with:
|
|
69
|
+
version: latest
|
|
70
|
+
args: coverage
|
|
71
|
+
|
|
72
|
+
- name: Build backend
|
|
73
|
+
if: steps.check-for-backend.outputs.has-backend == 'true'
|
|
74
|
+
uses: magefile/mage-action@v1
|
|
75
|
+
with:
|
|
76
|
+
version: latest
|
|
77
|
+
args: buildAll
|
|
78
|
+
|
|
79
|
+
- name: Sign plugin
|
|
80
|
+
run: yarn sign
|
|
81
|
+
env:
|
|
82
|
+
GRAFANA_API_KEY: $\{{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
|
|
83
|
+
|
|
84
|
+
- name: Get plugin metadata
|
|
85
|
+
id: metadata
|
|
86
|
+
run: |
|
|
87
|
+
sudo apt-get install jq
|
|
88
|
+
|
|
89
|
+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
|
|
90
|
+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
|
|
91
|
+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
|
|
92
|
+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
|
|
93
|
+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
|
|
94
|
+
|
|
95
|
+
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
|
|
96
|
+
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
|
|
97
|
+
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
|
|
98
|
+
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
|
|
99
|
+
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
|
|
100
|
+
|
|
101
|
+
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
|
|
102
|
+
|
|
103
|
+
- name: Read changelog
|
|
104
|
+
id: changelog
|
|
105
|
+
run: |
|
|
106
|
+
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
|
|
107
|
+
echo "::set-output name=path::release_notes.md"
|
|
108
|
+
|
|
109
|
+
- name: Check package version
|
|
110
|
+
run: if [ "v$\{{ steps.metadata.outputs.plugin-version }}" != "$\{{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
|
|
111
|
+
|
|
112
|
+
- name: Package plugin
|
|
113
|
+
id: package-plugin
|
|
114
|
+
run: |
|
|
115
|
+
mv dist $\{{ steps.metadata.outputs.plugin-id }}
|
|
116
|
+
zip $\{{ steps.metadata.outputs.archive }} $\{{ steps.metadata.outputs.plugin-id }} -r
|
|
117
|
+
md5sum $\{{ steps.metadata.outputs.archive }} > $\{{ steps.metadata.outputs.archive-checksum }}
|
|
118
|
+
echo "::set-output name=checksum::$(cat ./$\{{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
|
|
119
|
+
|
|
120
|
+
- name: Lint plugin
|
|
121
|
+
run: |
|
|
122
|
+
git clone https://github.com/grafana/plugin-validator
|
|
123
|
+
pushd ./plugin-validator/cmd/plugincheck
|
|
124
|
+
go install
|
|
125
|
+
popd
|
|
126
|
+
plugincheck $\{{ steps.metadata.outputs.archive }}
|
|
127
|
+
|
|
128
|
+
- name: Create release
|
|
129
|
+
id: create_release
|
|
130
|
+
uses: actions/create-release@v1
|
|
131
|
+
env:
|
|
132
|
+
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
133
|
+
with:
|
|
134
|
+
tag_name: $\{{ github.ref }}
|
|
135
|
+
release_name: Release $\{{ github.ref }}
|
|
136
|
+
body_path: $\{{ steps.changelog.outputs.path }}
|
|
137
|
+
draft: true
|
|
138
|
+
|
|
139
|
+
- name: Add plugin to release
|
|
140
|
+
id: upload-plugin-asset
|
|
141
|
+
uses: actions/upload-release-asset@v1
|
|
142
|
+
env:
|
|
143
|
+
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
144
|
+
with:
|
|
145
|
+
upload_url: $\{{ steps.create_release.outputs.upload_url }}
|
|
146
|
+
asset_path: ./$\{{ steps.metadata.outputs.archive }}
|
|
147
|
+
asset_name: $\{{ steps.metadata.outputs.archive }}
|
|
148
|
+
asset_content_type: application/zip
|
|
149
|
+
|
|
150
|
+
- name: Add checksum to release
|
|
151
|
+
id: upload-checksum-asset
|
|
152
|
+
uses: actions/upload-release-asset@v1
|
|
153
|
+
env:
|
|
154
|
+
GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
|
|
155
|
+
with:
|
|
156
|
+
upload_url: $\{{ steps.create_release.outputs.upload_url }}
|
|
157
|
+
asset_path: ./$\{{ steps.metadata.outputs.archive-checksum }}
|
|
158
|
+
asset_name: $\{{ steps.metadata.outputs.archive-checksum }}
|
|
159
|
+
asset_content_type: text/plain
|
|
160
|
+
|
|
161
|
+
- name: Publish to Grafana.com
|
|
162
|
+
run: |
|
|
163
|
+
echo A draft release has been created for your plugin. Please review and publish it. Then submit your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
|
|
164
|
+
echo
|
|
165
|
+
echo '{ "id": "$\{{ steps.metadata.outputs.plugin-id }}", "type": "$\{{ steps.metadata.outputs.plugin-type }}", "url": "https://github.com/$\{{ github.repository }}", "versions": [ { "version": "$\{{ steps.metadata.outputs.plugin-version }}", "commit": "$\{{ github.sha }}", "url": "https://github.com/$\{{ github.repository }}", "download": { "any": { "url": "https://github.com/$\{{ github.repository }}/releases/download/v$\{{ steps.metadata.outputs.plugin-version }}/$\{{ steps.metadata.outputs.archive }}", "md5": "$\{{ steps.package-plugin.outputs.checksum }}" } } } ] }' | jq .
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: Latest Grafana API compatibility check
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
compatibilitycheck:
|
|
6
|
+
runs-on: ubuntu-latest
|
|
7
|
+
steps:
|
|
8
|
+
- uses: actions/checkout@v3
|
|
9
|
+
- uses: actions/setup-node@v3
|
|
10
|
+
with:
|
|
11
|
+
node-version: '16'
|
|
12
|
+
- name: Install dependencies
|
|
13
|
+
run: yarn install
|
|
14
|
+
- name: Build plugin
|
|
15
|
+
run: yarn build
|
|
16
|
+
- name: Compatibility check
|
|
17
|
+
run: npx @grafana/levitate@latest is-compatible --path src/module.ts --target @grafana/data,@grafana/ui,@grafana/runtime
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Grafana panel plugin template
|
|
2
|
+
|
|
3
|
+
This template is a starting point for building a panel plugin for Grafana.
|
|
4
|
+
|
|
5
|
+
## What are Grafana panel plugins?
|
|
6
|
+
|
|
7
|
+
Panel plugins allow you to add new types of visualizations to your dashboard, such as maps, clocks, pie charts, lists, and more.
|
|
8
|
+
|
|
9
|
+
Use panel plugins when you want to do things like visualize data returned by data source queries, navigate between dashboards, or control external systems (such as smart home devices).
|
|
10
|
+
|
|
11
|
+
## Getting started
|
|
12
|
+
|
|
13
|
+
-- INSERT FRONTEND GETTING STARTED --
|
|
14
|
+
{{#if hasBackend}}-- INSERT BACKEND GETTING STARTED --{{/if}}
|
|
15
|
+
|
|
16
|
+
## Learn more
|
|
17
|
+
|
|
18
|
+
Below you can find source code for existing app plugins and other related documentation.
|
|
19
|
+
|
|
20
|
+
- [Basic panel plugin example](https://github.com/grafana/grafana-plugin-examples/tree/master/examples/panel-basic#readme)
|
|
21
|
+
- [Plugin.json documentation](https://grafana.com/docs/grafana/latest/developers/plugins/metadata/)
|
|
22
|
+
- [How to sign a plugin?](https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PanelProps } from '@grafana/data';
|
|
3
|
+
import { SimpleOptions } from 'types';
|
|
4
|
+
import { css, cx } from '@emotion/css';
|
|
5
|
+
import { useStyles2, useTheme2 } from '@grafana/ui';
|
|
6
|
+
|
|
7
|
+
interface Props extends PanelProps<SimpleOptions> {}
|
|
8
|
+
|
|
9
|
+
const getStyles = () => {
|
|
10
|
+
return {
|
|
11
|
+
wrapper: css`
|
|
12
|
+
font-family: Open Sans;
|
|
13
|
+
position: relative;
|
|
14
|
+
`,
|
|
15
|
+
svg: css`
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
`,
|
|
20
|
+
textBox: css`
|
|
21
|
+
position: absolute;
|
|
22
|
+
bottom: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
padding: 10px;
|
|
25
|
+
`,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const SimplePanel: React.FC<Props> = ({ options, data, width, height }) => {
|
|
30
|
+
const theme = useTheme2();
|
|
31
|
+
const styles = useStyles2(getStyles);
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
className={cx(
|
|
35
|
+
styles.wrapper,
|
|
36
|
+
css`
|
|
37
|
+
width: ${width}px;
|
|
38
|
+
height: ${height}px;
|
|
39
|
+
`
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
<svg
|
|
43
|
+
className={styles.svg}
|
|
44
|
+
width={width}
|
|
45
|
+
height={height}
|
|
46
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
47
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
48
|
+
viewBox={`-${width / 2} -${height / 2} ${width} ${height}`}
|
|
49
|
+
>
|
|
50
|
+
<g>
|
|
51
|
+
{{!-- /* 🚨 Escaping the following line because of Handlebars. (this comment is going to be removed after scaffolding) 🚨 */ --}}
|
|
52
|
+
<circle style=\{{ fill: theme.colors.primary.main }} r={100} />
|
|
53
|
+
</g>
|
|
54
|
+
</svg>
|
|
55
|
+
|
|
56
|
+
<div className={styles.textBox}>
|
|
57
|
+
{options.showSeriesCount && <div>Number of series: {data.series.length}</div>}
|
|
58
|
+
<div>Text option value: {options.text}</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PanelPlugin } from '@grafana/data';
|
|
2
|
+
import { SimpleOptions } from './types';
|
|
3
|
+
import { SimplePanel } from './components/SimplePanel';
|
|
4
|
+
|
|
5
|
+
export const plugin = new PanelPlugin<SimpleOptions>(SimplePanel).setPanelOptions((builder) => {
|
|
6
|
+
return builder
|
|
7
|
+
.addTextInput({
|
|
8
|
+
path: 'text',
|
|
9
|
+
name: 'Simple text option',
|
|
10
|
+
description: 'Description of panel option',
|
|
11
|
+
defaultValue: 'Default value of text input option',
|
|
12
|
+
})
|
|
13
|
+
.addBooleanSwitch({
|
|
14
|
+
path: 'showSeriesCount',
|
|
15
|
+
name: 'Show series counter',
|
|
16
|
+
defaultValue: false,
|
|
17
|
+
})
|
|
18
|
+
.addRadio({
|
|
19
|
+
path: 'seriesCountSize',
|
|
20
|
+
defaultValue: 'sm',
|
|
21
|
+
name: 'Series counter size',
|
|
22
|
+
settings: {
|
|
23
|
+
options: [
|
|
24
|
+
{
|
|
25
|
+
value: 'sm',
|
|
26
|
+
label: 'Small',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: 'md',
|
|
30
|
+
label: 'Medium',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: 'lg',
|
|
34
|
+
label: 'Large',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
showIf: (config) => config.showSeriesCount,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
|
+
"type": "panel",
|
|
4
|
+
"name": "{{ titleCase pluginName }}",
|
|
5
|
+
"id": "{{ normalize_id pluginName orgName 'panel' }}",
|
|
6
|
+
"info": {
|
|
7
|
+
"description": "{{ sentenceCase pluginDescription }}",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "{{ sentenceCase orgName }}"
|
|
10
|
+
},
|
|
11
|
+
"logos": {
|
|
12
|
+
"small": "img/logo.svg",
|
|
13
|
+
"large": "img/logo.svg"
|
|
14
|
+
},
|
|
15
|
+
"links": [
|
|
16
|
+
{
|
|
17
|
+
"name": "Website",
|
|
18
|
+
"url": "https://github.com/grafana/grafana-starter-panel"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "License",
|
|
22
|
+
"url": "https://github.com/grafana/grafana-starter-panel/blob/master/LICENSE"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"screenshots": [],
|
|
26
|
+
"version": "%VERSION%",
|
|
27
|
+
"updated": "%TODAY%"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"grafanaDependency": ">={{ grafanaVersion }}",
|
|
31
|
+
"plugins": []
|
|
32
|
+
}
|
|
33
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"removeComments": true,
|
|
5
|
+
"preserveConstEnums": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"noImplicitReturns": true,
|
|
9
|
+
"noImplicitThis": true,
|
|
10
|
+
"noUnusedLocals": true,
|
|
11
|
+
"pretty": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"allowSyntheticDefaultImports": true,
|
|
14
|
+
},
|
|
15
|
+
"include": ["src"],
|
|
16
|
+
"exclude": ["node_modules", "templates"],
|
|
17
|
+
}
|