#1 added get_ssh_server and set_ssh_server

This commit is contained in:
wt
2024-12-28 01:11:49 +07:00
parent 5a1a3a92a2
commit bc17587a15
2 changed files with 19 additions and 1 deletions
+1
View File
@@ -17,6 +17,7 @@ const routes = {
ssh_port_get: () => [host, prefix, 'settings', 'ssh', 'port', 'get'].join('/'),
ssh_port_set: () => [host, prefix, 'settings', 'ssh', 'port', 'set'].join('/'),
ssh_server_get: () => [host, prefix, 'settings', 'ssh', 'server', 'get'].join('/'),
ssh_server_set: () => [host, prefix, 'settings', 'ssh', 'server', 'set'].join('/'),
dns_status: () => [host, prefix, 'settings', 'dns', 'get'].join('/'),
dns_status_set: () => [host, prefix, 'settings', 'dns', 'set'].join('/'),
+18 -1
View File
@@ -45,6 +45,7 @@ set_ssh_settings.addEventListener('click', () => {
if (confirm("Confirm SSH settings?")) {
set_ssh_status()
set_ssh_port()
set_ssh_server()
}
})
@@ -157,4 +158,20 @@ const get_ssh_server = () => {
}).catch((error) => {
notification(`Ошибка на сервере: ${error}`, "error")
})
}
}
const set_ssh_server = () => {
fetch(routes.ssh_server_set(), {
method: 'POST',
body: `{"token":"${localStorage.getItem("token")}","server":"${sshserverinput.options[sshserverinput.selectedIndex].value}"}`
}).then(data => data.json()).then(jsondata => {
for (let i = 0; i < sshserverinput.options.length; i++) {
if (sshserverinput.options[i].value === jsondata.server) {
sshserverinput.selectedIndex = i;
break;
}
}
}).catch((error) => {
notification(`Ошибка на сервере: ${error}`, "error")
})
}