From def5fd9718681a108bcfcfb84ae84953b38a0f7d Mon Sep 17 00:00:00 2001 From: vargburz Date: Mon, 25 Apr 2022 18:03:57 +0300 Subject: [PATCH] enable options catagories && add prettierr dep --- .prettierrc.js | 2 +- package.json | 3 ++- src/module.ts | 42 +++++++++++------------------------------- src/types.ts | 4 ++++ yarn.lock | 5 +++++ 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index 263dbd3..b035698 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,3 +1,3 @@ module.exports = { - ...require("./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json"), + ...require('./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json'), }; diff --git a/package.json b/package.json index b63ea51..726b09f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "@grafana/data": "latest", "@grafana/toolkit": "latest", "@grafana/ui": "latest", - "emotion": "10.0.27" + "emotion": "10.0.27", + "prettier": "^2.6.2" }, "engines": { "node": ">=14" diff --git a/src/module.ts b/src/module.ts index 7e928c0..c2c26ae 100644 --- a/src/module.ts +++ b/src/module.ts @@ -6,7 +6,8 @@ export const plugin = new PanelPlugin(Panel).setPanelOptions((buil return builder .addRadio({ path: 'visualizationType', - name: 'Visualization type', + name: 'Pod', + category: ['Visualization'], defaultValue: Pod.GAUGE, settings: { options: [ @@ -28,37 +29,16 @@ export const plugin = new PanelPlugin(Panel).setPanelOptions((buil ], }, }) - .addTextInput({ - path: 'text', - name: 'Simple text option', - description: 'Description of panel option', - defaultValue: 'Default value of text input option', - }) - .addBooleanSwitch({ - path: 'showSeriesCount', - name: 'Show series counter', - defaultValue: false, + .addNumberInput({ + path: 'gauge.min', + name: 'Min', + category: ['Gauge'], + showIf: (config) => config.visualizationType === Pod.GAUGE, }) - .addRadio({ - path: 'seriesCountSize', - defaultValue: 'sm', - name: 'Series counter size', - settings: { - options: [ - { - value: 'sm', - label: 'Small', - }, - { - value: 'md', - label: 'Medium', - }, - { - value: 'lg', - label: 'Large', - }, - ], - }, + .addNumberInput({ + path: 'gauge.max', + name: 'Max', + category: ['Gauge'], showIf: (config) => config.visualizationType === Pod.GAUGE, }); }); diff --git a/src/types.ts b/src/types.ts index 2db8ef4..4473524 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,9 @@ export interface PanelOptions { visualizationType: Pod; + gauge: { + min: number | null; + max: number | null; + }; } export enum Pod { diff --git a/yarn.lock b/yarn.lock index da21b27..54c8c4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9731,6 +9731,11 @@ prettier@2.6.0: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4" 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: version "2.1.2" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.2.tgz#be89f82d81b1c86ec8fdfbc385045882727f93b6"