add error message in homepage of dataset visualizer if could not load dataset

This commit is contained in:
Adle Ben Salem 2025-02-20 17:21:21 +01:00
parent fe483b1d0d
commit c97d3c36e4
1 changed files with 15 additions and 3 deletions

View File

@ -9,10 +9,21 @@
</head>
<body class="h-screen overflow-hidden font-mono text-white" x-data="{
inputValue: '',
errorMessage: '',
navigateToDataset() {
const trimmedValue = this.inputValue.trim();
if (trimmedValue) {
fetch(`/${trimmedValue}`, { method: 'HEAD' })
.then(response => {
if (response.ok) {
window.location.href = `/${trimmedValue}`;
} else {
this.errorMessage = `Error when trying to visualize the dataset. Please make sure you uploaded the dataset ${trimmedValue}`;
}
})
.catch(error => {
this.errorMessage = `Error when trying to visualize the dataset. Please make sure you uploaded the dataset ${trimmedValue}`;
});
}
}
}">
@ -54,7 +65,8 @@
Go
</button>
</div>
<!-- Display error message if dataset not found -->
<div x-show="errorMessage" class="text-red-500 mt-2" x-text="errorMessage"></div>
<details class="mt-4 max-w-full px-4">
<summary>More example datasets</summary>
<ul class="list-disc list-inside max-h-28 overflow-y-auto break-all">