mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-12 00:16:42 +02:00
implemented #336 set time manually or resync NTP
This commit is contained in:
parent
f53933b473
commit
e3532f4464
7 changed files with 71 additions and 13 deletions
|
@ -64,6 +64,10 @@
|
|||
<input type="text" class="text" name="ntpAddr"/>
|
||||
<label for="ntpPort">NTP Port</label>
|
||||
<input type="text" class="text" name="ntpPort"/>
|
||||
<label for="ntpBtn">set system time</label>
|
||||
<input type="button" name="ntpBtn" id="ntpBtn" class="btn" value="from browser" onclick="setTime()"/>
|
||||
<input type="button" name="ntpSync" id="ntpSync" class="btn" value="sync NTP" onclick="syncTime()"/>
|
||||
<span id="apiResult">n/a</span>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
@ -106,7 +110,7 @@
|
|||
|
||||
<label for="reboot">Reboot device after successful save</label>
|
||||
<input type="checkbox" class="cb" name="reboot"/>
|
||||
<input type="submit" value="save" class="btn"/>
|
||||
<input type="submit" value="save" class="btn right"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -128,6 +132,28 @@
|
|||
ivHtml(JSON.parse('{"name":"","serial":"","channels":4,"ch_max_power":[0,0,0,0],"ch_name":["","","",""],"power_limit":1500,"power_limit_option":65535}'), highestId + 1);
|
||||
});
|
||||
|
||||
function apiCb(obj) {
|
||||
var e = document.getElementById("apiResult");
|
||||
if(obj["success"])
|
||||
e.innerHTML = "ok";
|
||||
else
|
||||
e.innerHTML = "Error: " + obj["error"];
|
||||
}
|
||||
|
||||
function setTime() {
|
||||
var date = new Date();
|
||||
var obj = new Object();
|
||||
obj.cmd = "set_time";
|
||||
obj.ts = parseInt(date.getTime() / 1000);
|
||||
getAjax("/api/setup", apiCb, "POST", JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function syncTime() {
|
||||
var obj = new Object();
|
||||
obj.cmd = "sync_ntp";
|
||||
getAjax("/api/setup", apiCb, "POST", JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function ivHtml(obj, id) {
|
||||
highestId = id;
|
||||
if(highestId == (maxInv - 1))
|
||||
|
|
|
@ -133,9 +133,8 @@ input.btn {
|
|||
background-color: #006ec0;
|
||||
color: #fff;
|
||||
border: 0px;
|
||||
float: right;
|
||||
margin: 10px 0px 30px 10px;
|
||||
padding: 7px 20px 7px 20px;
|
||||
margin-bottom: 10px;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue