From d9e7b87080f5f8f4da52a278c26040d8358e9166 Mon Sep 17 00:00:00 2001 From: vargburz Date: Wed, 11 May 2022 16:42:26 +0300 Subject: [PATCH] link click --- src/components/Panel.tsx | 13 +++++++++++++ src/module.ts | 6 ++++++ src/types.ts | 5 +++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx index 3cba27f..08d45cb 100644 --- a/src/components/Panel.tsx +++ b/src/components/Panel.tsx @@ -29,13 +29,26 @@ export function Panel({ options, data, width, height, timeZone, timeRange, onCha const pod = new ChartwerkGaugePod((chartContainer as any).current, series, chartwerkOptions); pod.render(); }); + + const isLinkActive = !_.isEmpty(options.gauge.link); + const chartClickHandler = (event: React.MouseEvent) => { + event.preventDefault(); + console.log('click', options); + if (!isLinkActive) { + return; + } + window.open(options.gauge.link, "_self"); + }; + return (
); } diff --git a/src/module.ts b/src/module.ts index f73279f..0ecec60 100644 --- a/src/module.ts +++ b/src/module.ts @@ -128,5 +128,11 @@ export const plugin = new PanelPlugin(Panel).setPanelOptions((buil }, showIf: (config) => config.visualizationType === Pod.GAUGE, editor: ThresholdsEditor as any, + }) + .addTextInput({ + path: 'gauge.link', + name: '', + category: ['Link'], + showIf: (config) => config.visualizationType === Pod.GAUGE, }); }); diff --git a/src/types.ts b/src/types.ts index a0a2e94..0957663 100644 --- a/src/types.ts +++ b/src/types.ts @@ -6,14 +6,15 @@ export interface PanelOptions { value: ExtremumOptions; valueSize: number; reversed: boolean; - decimals?: number; - unit?: string; thresholds: { arcBackground: string; defaultColor: string; thresholds: Threshold[]; }; icons: Icon[]; + decimals?: number; + unit?: string; + link?: string; }; }