Skip to content

Commit

Permalink
Update tool-upgrade.cgi
Browse files Browse the repository at this point in the history
Updated If statements and drop down menu
  • Loading branch information
Pretend-Maintenance authored Dec 12, 2024
1 parent 7aaf17f commit 1d7ed88
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions package/thingino-webui/files/var/www/x/tool-upgrade.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ upgrade_file_or_url=""
<div class="row g-4 mb-4">
<div class="col col-md-4">
<form>
<% field_select "tools_upgrade_option" "Upgrade Option" "Full Upgrade, Partial Upgrade, Upgrade Bootloader" %>
<% field_select "tools_upgrade_option" "Upgrade Option" "FullUpgrade,PartialUpgrade,UpgradeBootloader" %>
<% field_text "upgrade_file_or_url" "File/URL (Optional)" "Local file path or URL" %>
<% button_submit "Run Upgrade" %>
</form>
Expand All @@ -22,7 +22,17 @@ upgrade_file_or_url=""

<script>
$('form').onsubmit = (ev) => {
const upgradeOption = $('#tools_upgrade_option').value;
let upgradeOption;
const option = $('#tools_upgrade_option').value;
if (option === 'FullUpgrade') {
upgradeOption = '-f';
} else if (option === 'PartialUpgrade') {
upgradeOption = '-p';
} else if (option === 'UpgradeBootloader') {
upgradeOption = '-b';
}


const fileOrUrl = $('#upgrade_file_or_url').value;

ev.preventDefault();
Expand Down Expand Up @@ -80,14 +90,23 @@ $('form').onsubmit = (ev) => {
}

async function run() {
let lineCount = 0;
const maxLines = 40;
for await (let line of makeTextFileLineIterator('/x/run.cgi?cmd=' + btoa(el.dataset.cmd))) {
const re1 = /\u001b\[1;(\d+)m/;
const re2 = /\u001b\[0m/;
line = line.replace(re1, '<span class="ansi-$1">').replace(re2, '</span>');
el.innerHTML += line + '\n';

lineCount++;
if (lineCount > maxLines) {
const lines = el.innerHTML.split('\n');
el.innerHTML = lines.slice(lines.length - maxLines).join('\n');
}
}
}
run();
}
</script>
<%in _footer.cgi %>

0 comments on commit 1d7ed88

Please sign in to comment.