mirror of
https://github.com/esphome/esphome.git
synced 2025-03-16 15:48:16 +00:00
added download, edit and retry buttons to upload modal
This commit is contained in:
parent
df50b95e5a
commit
c101bd75fc
@ -406,16 +406,27 @@ const logsModal = new LogModalElem({
|
|||||||
});
|
});
|
||||||
logsModal.setup();
|
logsModal.setup();
|
||||||
|
|
||||||
|
const retryUploadButton = document.querySelector('.retry-upload');
|
||||||
|
const editAfterUploadButton = document.querySelector('.edit-after-upload');
|
||||||
|
const downloadAfterUploadButton = document.querySelector('.download-after-upload');
|
||||||
const uploadModal = new LogModalElem({
|
const uploadModal = new LogModalElem({
|
||||||
name: 'upload',
|
name: 'upload',
|
||||||
onPrepare: (modalElem, config) => {
|
onPrepare: (modalElem, config) => {
|
||||||
|
retryUploadButton.setAttribute('data-node', uploadModal.activeConfig);
|
||||||
|
retryUploadButton.classList.add('hide');
|
||||||
|
editAfterUploadButton.setAttribute('data-node', uploadModal.activeConfig);
|
||||||
|
downloadAfterUploadButton.classList.remove('hide');
|
||||||
|
downloadAfterUploadButton.classList.add('disabled');
|
||||||
modalElem.querySelector(".stop-logs").innerHTML = "Stop";
|
modalElem.querySelector(".stop-logs").innerHTML = "Stop";
|
||||||
},
|
},
|
||||||
onProcessExit: (modalElem, code) => {
|
onProcessExit: (modalElem, code) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
M.toast({html: "Program exited successfully."});
|
M.toast({html: "Program exited successfully."});
|
||||||
|
downloadAfterUploadButton.classList.remove('disabled');
|
||||||
} else {
|
} else {
|
||||||
M.toast({html: `Program failed with code ${code}`});
|
M.toast({html: `Program failed with code ${code}`});
|
||||||
|
downloadAfterUploadButton.classList.add('hide');
|
||||||
|
retryUploadButton.classList.remove('hide');
|
||||||
}
|
}
|
||||||
modalElem.querySelector(".stop-logs").innerHTML = "Close";
|
modalElem.querySelector(".stop-logs").innerHTML = "Close";
|
||||||
},
|
},
|
||||||
@ -425,6 +436,14 @@ const uploadModal = new LogModalElem({
|
|||||||
dismissible: false,
|
dismissible: false,
|
||||||
});
|
});
|
||||||
uploadModal.setup();
|
uploadModal.setup();
|
||||||
|
downloadAfterUploadButton.addEventListener('click', () => {
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.download = name;
|
||||||
|
link.href = `./download.bin?configuration=${encodeURIComponent(uploadModal.activeConfig)}`;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
});
|
||||||
|
|
||||||
const validateModal = new LogModalElem({
|
const validateModal = new LogModalElem({
|
||||||
name: 'validate',
|
name: 'validate',
|
||||||
|
@ -121,6 +121,9 @@
|
|||||||
class="tooltipped" data-position="left" data-tooltip="Flash using esphomeflasher" rel="noreferrer">
|
class="tooltipped" data-position="left" data-tooltip="Flash using esphomeflasher" rel="noreferrer">
|
||||||
<i class="material-icons flash-using-esphomeflasher">help_outline</i>
|
<i class="material-icons flash-using-esphomeflasher">help_outline</i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="modal-close waves-effect waves-green btn-flat disabled download-after-upload">Download Binary</a>
|
||||||
|
<a class="modal-close waves-effect waves-green btn-flat action-edit edit-after-upload">Edit</a>
|
||||||
|
<a class="waves-effect waves-green btn-flat hide action-upload retry-upload">Retry</a>
|
||||||
<a class="modal-close waves-effect waves-green btn-flat stop-logs">Stop</a>
|
<a class="modal-close waves-effect waves-green btn-flat stop-logs">Stop</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user