luci/modules/luci-mod-system/luasrc/view/admin_system/clock_status.htm
Florian Eckert a37296dda8 luci-mod-system: add button to sync with ntp server
Especially for systems without RTC this change has two advantages

* manual time sync with time server during configuration
* test possibility of the time sync over the configured servers

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
2019-03-11 16:09:13 +01:00

56 lines
1.3 KiB
HTML

<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
XHR.poll(-1, '<%=url('admin/system/clock_status')%>', null,
function(x, rv)
{
var s = document.getElementById('<%=self.option%>-clock-status');
if (s)
{
s.innerHTML = rv.timestring || '?';
}
}
);
function sync_clock(btn)
{
btn.disabled = true;
btn.value = '<%:Synchronizing...%>';
(new XHR()).post('<%=url('admin/system/clock_status')%>',
{ token: '<%=token%>', set: Math.floor((new Date()).getTime() / 1000) },
function()
{
btn.disabled = false;
btn.value = '<%:Sync with browser%>';
}
);
return false;
}
function btn_action(action)
{
if (action.name === "do_ntp_restart")
{
new XHR.get('<%=luci.dispatcher.build_url("admin", "system", "ntp_restart")%>', null,
function(x)
{
if (!x)
{
return;
}
});
}
}
//]]></script>
<span id="<%=self.option%>-clock-status"><em><%:Collecting data...%></em></span>
<input type="button" class="cbi-button cbi-button-apply" value="<%:Sync with browser%>" onclick="return sync_clock(this)" />
<% if require("nixio.fs").access("/etc/init.d/sysntpd") then %>
<input type="button" class="cbi-button cbi-button-apply" name="do_ntp_restart" value="<%:Sync with NTP-Server%>" onclick="btn_action(this)" />
<% end %>
<%+cbi/valuefooter%>