Web-If: Add Console-Cmd input

This commit is contained in:
feelfree69
2026-04-12 13:02:42 +02:00
parent c1a414833d
commit c91177d992
2 changed files with 26 additions and 0 deletions
+12
View File
@@ -16,6 +16,7 @@
<div class="tab-bar"> <div class="tab-bar">
<button class="tab-btn active" onclick="openTab(event, 'system-tab')">System</button> <button class="tab-btn active" onclick="openTab(event, 'system-tab')">System</button>
<button class="tab-btn" onclick="openTab(event, 'advanced-tab')">Advanced</button> <button class="tab-btn" onclick="openTab(event, 'advanced-tab')">Advanced</button>
<button class="tab-btn" onclick="openTab(event, 'console-tab')">Console</button>
</div> </div>
<nav id="sidebar"></nav> <nav id="sidebar"></nav>
<div style="margin-left:16%;padding:1px 16px;height:1000px;"> <div style="margin-left:16%;padding:1px 16px;height:1000px;">
@@ -56,6 +57,17 @@
<input style="width:40%;" class="action" id="switch_reset" onclick="resetSwitch();" type="button" value="Reset Switch"> <input style="width:40%;" class="action" id="switch_reset" onclick="resetSwitch();" type="button" value="Reset Switch">
</div> </div>
<div id="console-tab" class="tab-content">
<h1>Console Command</h1>
<label for="console_command">Enter command:</label>
<input type="text" id="console_cmd" name="console_cmd" style="width:40%;">
<input style="width:20%;" class="action" id="cmd_sub" onclick="cmdSub();" type="button" value="Send Command"><br/>
<br/><br/>
Be careful when entering console commands, you can lock yourself out!<br/>
</div>
</div> </div>
<script src="/config.js"></script> <script src="/config.js"></script>
<script src="/system.js"></script> <script src="/system.js"></script>
+14
View File
@@ -27,6 +27,20 @@ async function ipSub() {
} }
} }
async function cmdSub() {
var cmd = document.getElementById('console_cmd').value;
try {
const response = await fetch('/cmd', {
method: 'POST',
body: cmd
});
console.log('Completed!', response);
} catch(err) {
console.error(`Error: ${err}`);
}
}
async function sendConfig(c) { async function sendConfig(c) {
const form = new FormData(); const form = new FormData();
form.append("MAX_FILE_SIZE", "4096"); form.append("MAX_FILE_SIZE", "4096");