Browse Source

link click

merge-requests/7/head
vargburz 3 years ago
parent
commit
d9e7b87080
  1. 13
      src/components/Panel.tsx
  2. 6
      src/module.ts
  3. 5
      src/types.ts

13
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); const pod = new ChartwerkGaugePod((chartContainer as any).current, series, chartwerkOptions);
pod.render(); pod.render();
}); });
const isLinkActive = !_.isEmpty(options.gauge.link);
const chartClickHandler = (event: React.MouseEvent<HTMLDivElement>) => {
event.preventDefault();
console.log('click', options);
if (!isLinkActive) {
return;
}
window.open(options.gauge.link, "_self");
};
return ( return (
<div <div
ref={chartContainer} ref={chartContainer}
className={css` className={css`
width: ${width}px; width: ${width}px;
height: ${height}px; height: ${height}px;
cursor: ${isLinkActive ? 'pointer' : 'default'}
`} `}
onClick={chartClickHandler}
></div> ></div>
); );
} }

6
src/module.ts

@ -128,5 +128,11 @@ export const plugin = new PanelPlugin<PanelOptions>(Panel).setPanelOptions((buil
}, },
showIf: (config) => config.visualizationType === Pod.GAUGE, showIf: (config) => config.visualizationType === Pod.GAUGE,
editor: ThresholdsEditor as any, editor: ThresholdsEditor as any,
})
.addTextInput({
path: 'gauge.link',
name: '',
category: ['Link'],
showIf: (config) => config.visualizationType === Pod.GAUGE,
}); });
}); });

5
src/types.ts

@ -6,14 +6,15 @@ export interface PanelOptions {
value: ExtremumOptions; value: ExtremumOptions;
valueSize: number; valueSize: number;
reversed: boolean; reversed: boolean;
decimals?: number;
unit?: string;
thresholds: { thresholds: {
arcBackground: string; arcBackground: string;
defaultColor: string; defaultColor: string;
thresholds: Threshold[]; thresholds: Threshold[];
}; };
icons: Icon[]; icons: Icon[];
decimals?: number;
unit?: string;
link?: string;
}; };
} }

Loading…
Cancel
Save