mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SharePanelInternally: Number inputs fix (#98270)
This commit is contained in:
parent
e0e4e1cdff
commit
833f5d5d22
@ -50,8 +50,13 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme }
|
|||||||
buildUrl({ width: watch('width'), height: watch('height'), scale: watch('scaleFactor') });
|
buildUrl({ width: watch('width'), height: watch('height'), scale: watch('scaleFactor') });
|
||||||
}, [buildUrl, watch]);
|
}, [buildUrl, watch]);
|
||||||
|
|
||||||
const [{ loading, value: image, error }, renderImage] = useAsyncFn(async () => {
|
const [{ loading, value: image, error }, renderImage] = useAsyncFn(async (imageUrl) => {
|
||||||
const { width, height, scaleFactor } = watch();
|
const response = await lastValueFrom(getBackendSrv().fetch<BlobPart>({ url: imageUrl, responseType: 'blob' }));
|
||||||
|
return new Blob([response.data], { type: 'image/png' });
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onRenderImageClick = async (data: ImageSettingsForm) => {
|
||||||
|
const { width, height, scaleFactor } = data;
|
||||||
DashboardInteractions.generatePanelImageClicked({
|
DashboardInteractions.generatePanelImageClicked({
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@ -59,9 +64,9 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme }
|
|||||||
theme,
|
theme,
|
||||||
shareResource: 'panel',
|
shareResource: 'panel',
|
||||||
});
|
});
|
||||||
const response = await lastValueFrom(getBackendSrv().fetch<BlobPart>({ url: imageUrl, responseType: 'blob' }));
|
|
||||||
return new Blob([response.data], { type: 'image/png' });
|
await renderImage(imageUrl);
|
||||||
}, [imageUrl, watch('width'), watch('height'), watch('scaleFactor'), theme]);
|
};
|
||||||
|
|
||||||
const onDownloadImageClick = () => {
|
const onDownloadImageClick = () => {
|
||||||
DashboardInteractions.downloadPanelImageClicked({ shareResource: 'panel' });
|
DashboardInteractions.downloadPanelImageClicked({ shareResource: 'panel' });
|
||||||
@ -78,7 +83,7 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme }
|
|||||||
<Text element="h4">
|
<Text element="h4">
|
||||||
<Trans i18nKey="share-panel-image.preview.title">Panel preview</Trans>
|
<Trans i18nKey="share-panel-image.preview.title">Panel preview</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
<form onSubmit={handleSubmit(renderImage)}>
|
<form onSubmit={handleSubmit(onRenderImageClick)}>
|
||||||
<FieldSet
|
<FieldSet
|
||||||
disabled={!config.rendererAvailable}
|
disabled={!config.rendererAvailable}
|
||||||
label={
|
label={
|
||||||
@ -112,6 +117,7 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme }
|
|||||||
value: 1,
|
value: 1,
|
||||||
message: t('share-panel-image.settings.width-min', 'Width must be equal or greater than 1'),
|
message: t('share-panel-image.settings.width-min', 'Width must be equal or greater than 1'),
|
||||||
},
|
},
|
||||||
|
valueAsNumber: true,
|
||||||
onChange: onChange,
|
onChange: onChange,
|
||||||
})}
|
})}
|
||||||
placeholder={t('share-panel-image.settings.width-placeholder', '1000')}
|
placeholder={t('share-panel-image.settings.width-placeholder', '1000')}
|
||||||
@ -134,6 +140,7 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme }
|
|||||||
value: 1,
|
value: 1,
|
||||||
message: t('share-panel-image.settings.height-min', 'Height must be equal or greater than 1'),
|
message: t('share-panel-image.settings.height-min', 'Height must be equal or greater than 1'),
|
||||||
},
|
},
|
||||||
|
valueAsNumber: true,
|
||||||
onChange: onChange,
|
onChange: onChange,
|
||||||
})}
|
})}
|
||||||
placeholder={t('share-panel-image.settings.height-placeholder', '500')}
|
placeholder={t('share-panel-image.settings.height-placeholder', '500')}
|
||||||
@ -159,6 +166,7 @@ export function SharePanelPreview({ title, imageUrl, buildUrl, disabled, theme }
|
|||||||
'Scale factor must be equal or greater than 1'
|
'Scale factor must be equal or greater than 1'
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
valueAsNumber: true,
|
||||||
onChange: onChange,
|
onChange: onChange,
|
||||||
})}
|
})}
|
||||||
placeholder={t('share-panel-image.settings.scale-factor-placeholder', '1')}
|
placeholder={t('share-panel-image.settings.scale-factor-placeholder', '1')}
|
||||||
|
Loading…
Reference in New Issue
Block a user