diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index 60acc1edf3..5382ef855c 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -530,9 +530,12 @@ class EditRequestHandler(BaseHandler): @authenticated @bind_config def get(self, configuration=None): - # pylint: disable=no-value-for-parameter - with open(settings.rel_path(configuration), 'r') as f: - content = f.read() + filename = settings.rel_path(configuration) + content = '' + if os.path.isfile(filename): + # pylint: disable=no-value-for-parameter + with open(filename, 'r') as f: + content = f.read() self.write(content) @authenticated diff --git a/esphome/dashboard/static/esphome.js b/esphome/dashboard/static/esphome.js index 2fb61be9cc..e56521c945 100644 --- a/esphome/dashboard/static/esphome.js +++ b/esphome/dashboard/static/esphome.js @@ -574,6 +574,7 @@ const editModalElem = document.getElementById("modal-editor"); const editorElem = editModalElem.querySelector("#editor"); const editor = ace.edit(editorElem); let activeEditorConfig = null; +let activeEditorSecrets = false; let aceWs = null; let aceValidationScheduled = false; let aceValidationRunning = false; @@ -685,7 +686,7 @@ editor.commands.addCommand({ }); editor.session.on('change', debounce(() => { - aceValidationScheduled = true; + aceValidationScheduled = !activeEditorSecrets; }, 250)); setInterval(() => { @@ -708,9 +709,13 @@ editorUploadButton.addEventListener('click', saveEditor); document.querySelectorAll(".action-edit").forEach((btn) => { btn.addEventListener('click', (e) => { activeEditorConfig = e.target.getAttribute('data-node'); + activeEditorSecrets = activeEditorConfig === 'secrets.yaml'; const modalInstance = M.Modal.getInstance(editModalElem); const filenameField = editModalElem.querySelector('.filename'); editorUploadButton.setAttribute('data-node', activeEditorConfig); + if (activeEditorSecrets) { + editorUploadButton.classList.add('disabled'); + } filenameField.innerHTML = activeEditorConfig; editor.setValue("Loading configuration yaml..."); diff --git a/esphome/dashboard/templates/index.html b/esphome/dashboard/templates/index.html index fe80392fe6..077cc7a3ba 100644 --- a/esphome/dashboard/templates/index.html +++ b/esphome/dashboard/templates/index.html @@ -38,8 +38,8 @@