Update templates/index.html
Browse files- templates/index.html +80 -20
templates/index.html
CHANGED
|
@@ -251,38 +251,98 @@
|
|
| 251 |
};
|
| 252 |
}
|
| 253 |
|
| 254 |
-
|
| 255 |
-
// (Same as previous version, just ensure they call getRecipe())
|
| 256 |
-
|
| 257 |
-
async function loadMetadata() { /* Same as before */
|
| 258 |
const btn = document.querySelector('button[onclick="loadMetadata()"]');
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
try {
|
| 261 |
const res = await fetch('/analyze_metadata', {
|
| 262 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 263 |
body: JSON.stringify({
|
| 264 |
-
token:
|
| 265 |
-
dataset_id:
|
| 266 |
})
|
| 267 |
});
|
|
|
|
| 268 |
const data = await res.json();
|
|
|
|
| 269 |
if(data.status === 'success') {
|
| 270 |
-
//
|
| 271 |
-
const
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
-
//
|
| 277 |
-
const
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
|
| 282 |
document.getElementById('inspect_btn').disabled = false;
|
| 283 |
-
} else {
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
}
|
| 287 |
|
| 288 |
async function startInspection() {
|
|
|
|
| 251 |
};
|
| 252 |
}
|
| 253 |
|
| 254 |
+
async function loadMetadata() {
|
|
|
|
|
|
|
|
|
|
| 255 |
const btn = document.querySelector('button[onclick="loadMetadata()"]');
|
| 256 |
+
const tokenVal = document.getElementById('token').value;
|
| 257 |
+
const datasetVal = document.getElementById('dataset_id').value;
|
| 258 |
+
|
| 259 |
+
if(!datasetVal) { alert("Please enter a Dataset ID"); return; }
|
| 260 |
+
|
| 261 |
+
btn.disabled = true; btn.innerText = "...";
|
| 262 |
+
|
| 263 |
try {
|
| 264 |
const res = await fetch('/analyze_metadata', {
|
| 265 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 266 |
body: JSON.stringify({
|
| 267 |
+
token: tokenVal,
|
| 268 |
+
dataset_id: datasetVal
|
| 269 |
})
|
| 270 |
});
|
| 271 |
+
|
| 272 |
const data = await res.json();
|
| 273 |
+
|
| 274 |
if(data.status === 'success') {
|
| 275 |
+
// Populate Configs
|
| 276 |
+
const confSel = document.getElementById('config_select');
|
| 277 |
+
confSel.innerHTML = '';
|
| 278 |
+
|
| 279 |
+
// Safe check: Ensure configs is an array
|
| 280 |
+
if (Array.isArray(data.configs) && data.configs.length > 0) {
|
| 281 |
+
data.configs.forEach(c => {
|
| 282 |
+
confSel.innerHTML += `<option value="${c}">${c}</option>`;
|
| 283 |
+
});
|
| 284 |
+
} else {
|
| 285 |
+
confSel.innerHTML = `<option value="default">default</option>`;
|
| 286 |
+
}
|
| 287 |
+
confSel.disabled = false;
|
| 288 |
+
|
| 289 |
+
// Populate Splits safely
|
| 290 |
+
populateSplits(data.splits);
|
| 291 |
|
| 292 |
+
// Set license if UI element exists and data returned it
|
| 293 |
+
const licInput = document.getElementById('license_input');
|
| 294 |
+
if(data.license_detected && licInput) {
|
| 295 |
+
licInput.value = data.license_detected;
|
| 296 |
+
}
|
| 297 |
|
| 298 |
document.getElementById('inspect_btn').disabled = false;
|
| 299 |
+
} else {
|
| 300 |
+
alert('Server Error: ' + data.message);
|
| 301 |
+
}
|
| 302 |
+
} catch(e) {
|
| 303 |
+
console.error(e);
|
| 304 |
+
alert("Network Error: " + e);
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
btn.disabled = false; btn.innerText = "Connect";
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
function populateSplits(splits) {
|
| 311 |
+
const sel = document.getElementById('split_select');
|
| 312 |
+
sel.innerHTML = '';
|
| 313 |
+
|
| 314 |
+
// Safe check: Ensure splits is an array
|
| 315 |
+
if (Array.isArray(splits) && splits.length > 0) {
|
| 316 |
+
splits.forEach(s => sel.innerHTML += `<option value="${s}">${s}</option>`);
|
| 317 |
+
} else {
|
| 318 |
+
// Fallback if array is empty or undefined
|
| 319 |
+
sel.innerHTML = `<option value="train">train (fallback)</option>`;
|
| 320 |
+
}
|
| 321 |
+
sel.disabled = false;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
async function updateSplits() {
|
| 325 |
+
const conf = document.getElementById('config_select').value;
|
| 326 |
+
const ds = document.getElementById('dataset_id').value;
|
| 327 |
+
const token = document.getElementById('token').value;
|
| 328 |
+
|
| 329 |
+
try {
|
| 330 |
+
const res = await fetch('/get_splits', {
|
| 331 |
+
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 332 |
+
body: JSON.stringify({dataset_id: ds, config: conf, token: token})
|
| 333 |
+
});
|
| 334 |
+
const data = await res.json();
|
| 335 |
+
|
| 336 |
+
if(data.status === 'success') {
|
| 337 |
+
populateSplits(data.splits);
|
| 338 |
+
} else {
|
| 339 |
+
console.warn("Could not fetch specific splits, using defaults.");
|
| 340 |
+
populateSplits(['train', 'test', 'validation']);
|
| 341 |
+
}
|
| 342 |
+
} catch(e) {
|
| 343 |
+
console.error(e);
|
| 344 |
+
populateSplits(['train', 'test', 'validation']);
|
| 345 |
+
}
|
| 346 |
}
|
| 347 |
|
| 348 |
async function startInspection() {
|