luci-app-syncthing: add button to open WebUI

This commit is contained in:
CN_SZTL 2020-02-20 21:07:50 +08:00
parent 6b6b284f32
commit 5ec7dcc5fa
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 12 additions and 6 deletions

View File

@ -4,7 +4,7 @@ XHR.poll(1, '<%=url([[admin]], [[nas]], [[syncthing]], [[status]])%>', null,
var tb = document.getElementById('syncthing_status');
if (data && tb) {
if (data.running) {
var links = '<font color=green><%:RUNNING%></font>';
var links = '<font color=green><%:RUNNING%></font><input class="cbi-button mar-10" type="button" value="<%:Open Web Interface%>" onclick="openClient();" />';
tb.innerHTML = links;
} else {
tb.innerHTML = '<font color=red><%:NOT RUNNING%></font>';
@ -12,6 +12,15 @@ XHR.poll(1, '<%=url([[admin]], [[nas]], [[syncthing]], [[status]])%>', null,
}
}
);
function openClient() {
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
var localhostPath = curWwwPath.substring(0, pos);
var clientPort = window.document.getElementById("cbid.syncthing.config.port").value
var url = "http:" + localhostPath.substring(window.location.protocol.length) + ":" + clientPort;
window.open(url)
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>

View File

@ -4,8 +4,5 @@ msgstr "储存同步"
msgid "SyncThing Synchronization Tool"
msgstr "syncthing同步工具"
msgid "Open Web Interface"
msgstr "打开管理页面"