addet training info
This commit is contained in:
@@ -640,4 +640,69 @@ document.getElementById('parameters-form').addEventListener('submit', async func
|
||||
</div>
|
||||
|
||||
<script src="js/settings.js"></script>
|
||||
<script>
|
||||
// Handle readonly mode and load training data
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const trainingId = urlParams.get('training_id');
|
||||
const isReadonly = urlParams.get('readonly') === 'true';
|
||||
|
||||
if (isReadonly) {
|
||||
// Update page title
|
||||
const titleLabel = document.querySelector('#project-title-label');
|
||||
if (titleLabel) {
|
||||
titleLabel.textContent = 'View Training Details (Read-Only)';
|
||||
}
|
||||
|
||||
// Disable all form inputs
|
||||
document.querySelectorAll('input, select, textarea, button[type="submit"]').forEach(el => {
|
||||
el.disabled = true;
|
||||
el.style.opacity = '0.6';
|
||||
el.style.cursor = 'not-allowed';
|
||||
});
|
||||
|
||||
// Hide submit buttons
|
||||
document.querySelectorAll('button[type="submit"]').forEach(btn => {
|
||||
btn.style.display = 'none';
|
||||
});
|
||||
|
||||
// Re-enable navigation buttons (back, etc.)
|
||||
document.querySelectorAll('button:not([type="submit"])').forEach(btn => {
|
||||
if (btn.textContent.includes('Back') || btn.onclick) {
|
||||
btn.disabled = false;
|
||||
btn.style.opacity = '1';
|
||||
btn.style.cursor = 'pointer';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Load training data if training_id is present
|
||||
if (trainingId) {
|
||||
fetch(`/api/trainings/${trainingId}`)
|
||||
.then(res => res.json())
|
||||
.then(training => {
|
||||
// Populate form fields with training data
|
||||
Object.keys(training).forEach(key => {
|
||||
const input = document.querySelector(`[name="${key}"]`);
|
||||
if (input) {
|
||||
if (input.type === 'checkbox') {
|
||||
input.checked = training[key];
|
||||
} else {
|
||||
input.value = training[key] || '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle special fields
|
||||
if (training.train) document.getElementById('train-slider').value = training.train;
|
||||
if (training.valid) document.getElementById('valid-slider').value = training.valid;
|
||||
if (training.test) document.getElementById('test-slider').value = training.test;
|
||||
syncSplitSliders('train');
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to load training data:', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body></html>
|
||||
Reference in New Issue
Block a user