Browse Source

enable options catagories && add prettierr dep

merge-requests/1/merge
vargburz 3 years ago
parent
commit
def5fd9718
  1. 2
      .prettierrc.js
  2. 3
      package.json
  3. 42
      src/module.ts
  4. 4
      src/types.ts
  5. 5
      yarn.lock

2
.prettierrc.js

@ -1,3 +1,3 @@
module.exports = { module.exports = {
...require("./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json"), ...require('./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json'),
}; };

3
package.json

@ -16,7 +16,8 @@
"@grafana/data": "latest", "@grafana/data": "latest",
"@grafana/toolkit": "latest", "@grafana/toolkit": "latest",
"@grafana/ui": "latest", "@grafana/ui": "latest",
"emotion": "10.0.27" "emotion": "10.0.27",
"prettier": "^2.6.2"
}, },
"engines": { "engines": {
"node": ">=14" "node": ">=14"

42
src/module.ts

@ -6,7 +6,8 @@ export const plugin = new PanelPlugin<PanelOptions>(Panel).setPanelOptions((buil
return builder return builder
.addRadio({ .addRadio({
path: 'visualizationType', path: 'visualizationType',
name: 'Visualization type', name: 'Pod',
category: ['Visualization'],
defaultValue: Pod.GAUGE, defaultValue: Pod.GAUGE,
settings: { settings: {
options: [ options: [
@ -28,37 +29,16 @@ export const plugin = new PanelPlugin<PanelOptions>(Panel).setPanelOptions((buil
], ],
}, },
}) })
.addTextInput({ .addNumberInput({
path: 'text', path: 'gauge.min',
name: 'Simple text option', name: 'Min',
description: 'Description of panel option', category: ['Gauge'],
defaultValue: 'Default value of text input option', showIf: (config) => config.visualizationType === Pod.GAUGE,
})
.addBooleanSwitch({
path: 'showSeriesCount',
name: 'Show series counter',
defaultValue: false,
}) })
.addRadio({ .addNumberInput({
path: 'seriesCountSize', path: 'gauge.max',
defaultValue: 'sm', name: 'Max',
name: 'Series counter size', category: ['Gauge'],
settings: {
options: [
{
value: 'sm',
label: 'Small',
},
{
value: 'md',
label: 'Medium',
},
{
value: 'lg',
label: 'Large',
},
],
},
showIf: (config) => config.visualizationType === Pod.GAUGE, showIf: (config) => config.visualizationType === Pod.GAUGE,
}); });
}); });

4
src/types.ts

@ -1,5 +1,9 @@
export interface PanelOptions { export interface PanelOptions {
visualizationType: Pod; visualizationType: Pod;
gauge: {
min: number | null;
max: number | null;
};
} }
export enum Pod { export enum Pod {

5
yarn.lock

@ -9731,6 +9731,11 @@ prettier@2.6.0:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4"
integrity sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A== integrity sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==
prettier@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==
pretty-error@^2.0.2: pretty-error@^2.0.2:
version "2.1.2" version "2.1.2"
resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.2.tgz#be89f82d81b1c86ec8fdfbc385045882727f93b6" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.2.tgz#be89f82d81b1c86ec8fdfbc385045882727f93b6"

Loading…
Cancel
Save