mirror of
https://github.com/esphome/esphome.git
synced 2024-11-29 18:24:13 +01:00
parent
57bee74225
commit
7c31592850
3 changed files with 14 additions and 6 deletions
|
@ -530,8 +530,11 @@ class EditRequestHandler(BaseHandler):
|
||||||
@authenticated
|
@authenticated
|
||||||
@bind_config
|
@bind_config
|
||||||
def get(self, configuration=None):
|
def get(self, configuration=None):
|
||||||
|
filename = settings.rel_path(configuration)
|
||||||
|
content = ''
|
||||||
|
if os.path.isfile(filename):
|
||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
with open(settings.rel_path(configuration), 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.write(content)
|
self.write(content)
|
||||||
|
|
||||||
|
|
|
@ -574,6 +574,7 @@ const editModalElem = document.getElementById("modal-editor");
|
||||||
const editorElem = editModalElem.querySelector("#editor");
|
const editorElem = editModalElem.querySelector("#editor");
|
||||||
const editor = ace.edit(editorElem);
|
const editor = ace.edit(editorElem);
|
||||||
let activeEditorConfig = null;
|
let activeEditorConfig = null;
|
||||||
|
let activeEditorSecrets = false;
|
||||||
let aceWs = null;
|
let aceWs = null;
|
||||||
let aceValidationScheduled = false;
|
let aceValidationScheduled = false;
|
||||||
let aceValidationRunning = false;
|
let aceValidationRunning = false;
|
||||||
|
@ -685,7 +686,7 @@ editor.commands.addCommand({
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.session.on('change', debounce(() => {
|
editor.session.on('change', debounce(() => {
|
||||||
aceValidationScheduled = true;
|
aceValidationScheduled = !activeEditorSecrets;
|
||||||
}, 250));
|
}, 250));
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
@ -708,9 +709,13 @@ editorUploadButton.addEventListener('click', saveEditor);
|
||||||
document.querySelectorAll(".action-edit").forEach((btn) => {
|
document.querySelectorAll(".action-edit").forEach((btn) => {
|
||||||
btn.addEventListener('click', (e) => {
|
btn.addEventListener('click', (e) => {
|
||||||
activeEditorConfig = e.target.getAttribute('data-node');
|
activeEditorConfig = e.target.getAttribute('data-node');
|
||||||
|
activeEditorSecrets = activeEditorConfig === 'secrets.yaml';
|
||||||
const modalInstance = M.Modal.getInstance(editModalElem);
|
const modalInstance = M.Modal.getInstance(editModalElem);
|
||||||
const filenameField = editModalElem.querySelector('.filename');
|
const filenameField = editModalElem.querySelector('.filename');
|
||||||
editorUploadButton.setAttribute('data-node', activeEditorConfig);
|
editorUploadButton.setAttribute('data-node', activeEditorConfig);
|
||||||
|
if (activeEditorSecrets) {
|
||||||
|
editorUploadButton.classList.add('disabled');
|
||||||
|
}
|
||||||
filenameField.innerHTML = activeEditorConfig;
|
filenameField.innerHTML = activeEditorConfig;
|
||||||
|
|
||||||
editor.setValue("Loading configuration yaml...");
|
editor.setValue("Loading configuration yaml...");
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul id="dropdown-nav-actions" class="select-action dropdown-content card-dropdown-action">
|
<ul id="dropdown-nav-actions" class="select-action dropdown-content card-dropdown-action">
|
||||||
<li><a id="update-all-button" class="modal-close waves-effect waves-green btn-flat"
|
<li><a id="update-all-button" data-node="{{ escape(config_dir) }}">Update All</a></li>
|
||||||
data-node="{{ escape(config_dir) }}">Update All</a></li>
|
<li><a id="secrets-button" class="action-edit" data-node="secrets.yaml">Secrets</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue