Providing fileName string directly to DataViewer as suggested

This commit is contained in:
jstnlowe 2024-06-04 20:41:18 -04:00 committed by psychedelicious
parent 37b1f21bcf
commit 9cba0dfac9
4 changed files with 5 additions and 6 deletions

View File

@ -32,9 +32,8 @@ const DataViewer = (props: Props) => {
const handleDownload = useCallback(() => {
const blob = new Blob([dataString]);
const a = document.createElement('a');
const imageName = fileName ? fileName.replace('.png', '') : null;
a.href = URL.createObjectURL(blob);
a.download = imageName ? `${ imageName }_${ label }.json` : `${ label }.json`;
a.download = `${ fileName || label }.json`;
document.body.appendChild(a);
a.click();
a.remove();

View File

@ -28,7 +28,7 @@ const ImageMetadataGraphTabContent = ({ image }: Props) => {
return <IAINoContentFallback label={t('nodes.noGraph')} />;
}
return <DataViewer fileName={image.image_name} data={graph} label={t('nodes.graph')} />;
return <DataViewer fileName={`${image.image_name.replace('.png','')}_${t('nodes.graph')}`} data={graph} label={t('nodes.graph')} />;
};
export default memo(ImageMetadataGraphTabContent);

View File

@ -68,14 +68,14 @@ const ImageMetadataViewer = ({ image }: ImageMetadataViewerProps) => {
</TabPanel>
<TabPanel>
{metadata ? (
<DataViewer fileName={image.image_name} data={metadata} label={t('metadata.metadata')} />
<DataViewer fileName={`${image.image_name.replace('.png','')}_${t('metadata.metadata')}`} data={metadata} label={t('metadata.metadata')} />
) : (
<IAINoContentFallback label={t('metadata.noMetaData')} />
)}
</TabPanel>
<TabPanel>
{image ? (
<DataViewer fileName={image.image_name} data={image} label={t('metadata.imageDetails')} />
<DataViewer fileName={`${image.image_name.replace('.png','')}_${t('metadata.imageDetails')}`} data={image} label={t('metadata.imageDetails')} />
) : (
<IAINoContentFallback label={t('metadata.noImageDetails')} />
)}

View File

@ -28,7 +28,7 @@ const ImageMetadataWorkflowTabContent = ({ image }: Props) => {
return <IAINoContentFallback label={t('nodes.noWorkflow')} />;
}
return <DataViewer fileName={image.image_name} data={workflow} label={t('metadata.workflow')} />;
return <DataViewer fileName={`${image.image_name.replace('.png','')}_${t('metadata.workflow')}`} data={workflow} label={t('metadata.workflow')} />;
};
export default memo(ImageMetadataWorkflowTabContent);