MCPcopy
hub / github.com/zenml-io/zenml / syncJsonToForm

Function syncJsonToForm

src/zenml/deployers/server/dashboard/assets/dashboard.js:616–647  ·  view source on GitHub ↗

* Sync JSON editor back to form fields

()

Source from the content-addressed store, hash-verified

614 * Sync JSON editor back to form fields
615 */
616function syncJsonToForm() {
617 try {
618 const jsonInput = document.getElementById('json-input');
619 const data = JSON.parse(jsonInput.value || '{}');
620
621 // Update form fields with JSON data
622 Object.entries(data).forEach(([key, value]) => {
623 const input = document.querySelector(`input[name="${key}"], select[name="${key}"]`);
624 if (input) {
625 input.value = value;
626 if (input.classList.contains('text-input')) {
627 input.classList.toggle('filled', !!value);
628 }
629 }
630
631 const toggle = document.querySelector(`.toggle-switch[data-name="${key}"]`);
632 if (toggle) {
633 if (value) {
634 toggle.classList.add('on');
635 toggle.classList.remove('off');
636 } else {
637 toggle.classList.add('off');
638 toggle.classList.remove('on');
639 }
640 const label = toggle.parentElement.querySelector('.toggle-label');
641 if (label) label.textContent = value ? 'True' : 'False';
642 }
643 });
644 } catch (e) {
645 console.error('Failed to sync JSON to form:', e);
646 }
647}
648
649/* ============================================================================
650 Pipeline Execution

Callers

nothing calls this directly

Calls 4

parseMethod · 0.80
addMethod · 0.80
errorMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected