mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Merge pull request #297 from DrDoof/hostname
system: configurable hostname + show model on the System page
This commit is contained in:
@@ -25,6 +25,7 @@ const conf_cmds = [
|
||||
/^igmp\s+(on|off)$/,
|
||||
/^mtu\s+\d{1,2}\s+\d+$/,
|
||||
/^bw\s+(in|out)\s+\d{1,2}\s+\S+$/,
|
||||
/^hostname\s+.{1,23}$/,
|
||||
];
|
||||
const conf_overwrite = [
|
||||
/^ip\b/,
|
||||
@@ -49,6 +50,7 @@ const conf_overwrite = [
|
||||
/^igmp\b/,
|
||||
/^mtu\s+\d{1,2}\b/,
|
||||
/^bw\s+(in|out)\s+\d{1,2}\b/,
|
||||
/^hostname\b/,
|
||||
];
|
||||
|
||||
function parseConf(s){
|
||||
|
||||
@@ -138,6 +138,9 @@ var LANG = {
|
||||
sys_tab_console: 'Console',
|
||||
sys_heading: 'System Settings',
|
||||
sys_ip: 'IP address:',
|
||||
sys_model: 'Model:',
|
||||
sys_hostname: 'Hostname:',
|
||||
sys_apply: 'Apply',
|
||||
sys_netmask: 'Netmask:',
|
||||
sys_gateway: 'Gateway:',
|
||||
sys_language: 'Language:',
|
||||
@@ -317,6 +320,9 @@ var LANG = {
|
||||
sys_tab_console: 'コンソール',
|
||||
sys_heading: 'システム設定',
|
||||
sys_ip: 'IP アドレス:',
|
||||
sys_model: 'モデル:',
|
||||
sys_hostname: 'ホスト名:',
|
||||
sys_apply: '適用',
|
||||
sys_netmask: 'ネットマスク:',
|
||||
sys_gateway: 'ゲートウェイ:',
|
||||
sys_language: '言語:',
|
||||
@@ -496,6 +502,9 @@ var LANG = {
|
||||
sys_tab_console: '控制台',
|
||||
sys_heading: '系统设置',
|
||||
sys_ip: 'IP 地址:',
|
||||
sys_model: '型号:',
|
||||
sys_hostname: '主机名:',
|
||||
sys_apply: '应用',
|
||||
sys_netmask: '子网掩码:',
|
||||
sys_gateway: '网关:',
|
||||
sys_language: '语言:',
|
||||
|
||||
@@ -25,6 +25,15 @@
|
||||
|
||||
<div id="system-tab" class="tab-content active">
|
||||
<h1 data-i18n="sys_heading">System Settings</h1>
|
||||
<div class="row">
|
||||
<div class="lcol"> <label for="hostname" data-i18n="sys_hostname">Hostname:</label></div>
|
||||
<div class="rcol"> <input id="hostname" type="text" maxlength="23" size="20"/>
|
||||
<button onclick="hostSub()" data-i18n="sys_apply">Apply</button></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="lcol"> <label data-i18n="sys_model">Model:</label></div>
|
||||
<div class="rcol"><span id="model"></span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="lcol"> <label for="ip" data-i18n="sys_ip">IP address:</label></div>
|
||||
<div class="rcol"> <input id="ip" class="ip" type="text" minlength="7" maxlength="15" size="15"/></div>
|
||||
|
||||
@@ -48,6 +48,14 @@ async function cmdSub() {
|
||||
}
|
||||
|
||||
|
||||
async function hostSub() {
|
||||
const h = document.getElementById("hostname").value;
|
||||
try { await fetch('/cmd', { method: 'POST', body: "hostname " + h }); }
|
||||
catch(err) { console.error(`Error: ${err}`); }
|
||||
fetchIP();
|
||||
}
|
||||
|
||||
|
||||
async function sendConfig(c) {
|
||||
if (isSaving) return;
|
||||
isSaving = true;
|
||||
@@ -123,6 +131,8 @@ function fetchIP() {
|
||||
document.getElementById("ip").value=s.ip_address;
|
||||
document.getElementById("netmask").value=s.ip_netmask;
|
||||
document.getElementById("gw").value=s.ip_gateway;
|
||||
document.getElementById("hostname").value=s.hostname;
|
||||
document.getElementById("model").textContent=s.hw_ver;
|
||||
clearInterval(systemInterval);
|
||||
// Fetch and populate the config textbox
|
||||
fetchConfig().then((configText) => {
|
||||
|
||||
Reference in New Issue
Block a user