added get_ssh_server and set_ssh_server

This commit is contained in:
wt committed 2024-12-28 01:05:01 +07:00
1 parent f7b1d75bab
commit 5a1a3a92a2
10 files changed
+133 -3

No files matched your search

+18
View File
@@ -4,6 +4,7 @@ const sshsettingsbody = document.querySelector('#sshsettingsbody')
const sshkeystablebody = document.querySelector('#sshkeystablebody')
const sshportinput = document.querySelector('#sshportinput')
const add_ssh_key_button = document.querySelector('#add_ssh_key')
const sshserverinput = document.querySelector('#sshserverinput')
let sshkeys = []
@@ -140,3 +141,20 @@ const set_ssh_port = () => {
})
}
// ------------------- end SSH port -------------------
const get_ssh_server = () => {
fetch(routes.ssh_server_get(), {
method: 'POST',
body: `{"token":"${localStorage.getItem("token")}"}`
}).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")
})
}