Added DNS to static IP config. Added hostname to config. Added mDNS

This commit is contained in:
Gunnar Skjold
2020-03-22 15:08:17 +01:00
parent 26634f96b0
commit d747c84a14
9 changed files with 206 additions and 61 deletions

View File

@@ -55,6 +55,12 @@
<input type="password" class="form-control" name="wifiPassword" value="${config.wifiPassword}"/>
</div>
</div>
<div class="row form-group">
<label class="col-3">Hostname</label>
<div class="col-9">
<input type="text" class="form-control" name="wifiHostname" value="${config.wifiHostname}"/>
</div>
</div>
</div>
<div class="col-md-4">
<div class="row form-group">
@@ -67,23 +73,35 @@
</div>
</div>
<div class="row form-group">
<label class="col-3">IP</label>
<div class="col-9">
<label class="col-6">IP</label>
<div class="col-6">
<input type="text" class="form-control wifiip-config" name="wifiIp" value="${config.wifiIp}"/>
</div>
</div>
<div class="row form-group">
<label class="col-6">Subnet</label>
<div class="col-6">
<input type="text" class="form-control wifiip-config" name="wifiSubnet" value="${config.wifiSubnet}"/>
</div>
</div>
</div>
<div class="col-md-4">
<div class="row form-group">
<label class="col-3">Subnet</label>
<div class="col-9">
<input type="text" class="form-control wifiip-config" name="wifiSubnet" value="${config.wifiSubnet}"/>
<label class="col-6">Gateway</label>
<div class="col-6">
<input type="text" class="form-control wifiip-config" name="wifiGw" value="${config.wifiGw}"/>
</div>
</div>
<div class="row form-group">
<label class="col-3">Gateway</label>
<div class="col-9">
<input type="text" class="form-control wifiip-config" name="wifiGw" value="${config.wifiGw}"/>
<label class="col-6">Primary DNS</label>
<div class="col-6">
<input type="text" class="form-control wifiip-config" name="wifiDns1" value="${config.wifiDns1}"/>
</div>
</div>
<div class="row form-group">
<label class="col-6">Secondary DNS</label>
<div class="col-6">
<input type="text" class="form-control wifiip-config" name="wifiDns2" value="${config.wifiDns2}"/>
</div>
</div>
</div>

View File

@@ -26,7 +26,7 @@
<a class="nav-link" href="/config-web">Web</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/config-system">System</a>
<a class="nav-link" href="/config-system">System</a>
</li>
</ul>
</div>
@@ -39,23 +39,38 @@
</ul>
</header>
<div class="my-3 p-3 bg-white rounded shadow">
Firmware upload complete, you will be redirected to the main page when the device is finished flashing.
Device is rebooting. You will be redirected to the main page when it is available again.
</div>
</main>
<script>
interval = 5000;
var tries = 0;
var ip = "${ip}";
var hostname = "${hostname}";
var url;
var fetch = function() {
tries++;
if(ip && tries%3 == 0) {
url = "http://" + ip;
} else if(hostname && tries%3 == 1) {
url = "http://" + hostname;
} else if(hostname && tries%3 == 2) {
url = "http://" + hostname + ".local";
} else {
url = "";
}
if(console) console.log("Trying url " + url)
$.ajax({
url: '/data.json',
timeout: interval,
dataType: 'json',
url: url + '/is-alive',
timeout: 5000
}).done(function(json) {
window.location.href="/";
window.location.href = url ? url : "/";
}).fail(function() {
setTimeout(fetch, interval);
setTimeout(fetch, 1000);
});
};
setTimeout(fetch, interval);
setTimeout(fetch, 10000);
</script>
</body>
</html>