mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-16 05:13:36 +00:00
feat: terminal theme improvemnts, file manager improvements, host manager improvements (ready for initial user testing?)
This commit is contained in:
+6
-173
@@ -1107,102 +1107,18 @@ export async function getSSHHosts(): Promise<SSHHostWithStatus[]> {
|
||||
|
||||
export async function createSSHHost(hostData: SSHHostData): Promise<SSHHost> {
|
||||
try {
|
||||
const submitData = {
|
||||
connectionType: hostData.connectionType || "ssh",
|
||||
name: hostData.name || "",
|
||||
ip: hostData.ip,
|
||||
port: parseInt(hostData.port.toString()) || 22,
|
||||
username: hostData.username,
|
||||
folder: hostData.folder || "",
|
||||
tags: hostData.tags || [],
|
||||
pin: Boolean(hostData.pin),
|
||||
authType: hostData.authType,
|
||||
password:
|
||||
hostData.connectionType !== "ssh"
|
||||
? hostData.password || null
|
||||
: hostData.authType === "password"
|
||||
? hostData.password
|
||||
: null,
|
||||
key: hostData.authType === "key" ? hostData.key : null,
|
||||
keyPassword: hostData.authType === "key" ? hostData.keyPassword : null,
|
||||
keyType: hostData.authType === "key" ? hostData.keyType : null,
|
||||
credentialId:
|
||||
hostData.authType === "credential" ? hostData.credentialId : null,
|
||||
overrideCredentialUsername: Boolean(hostData.overrideCredentialUsername),
|
||||
enableTerminal: Boolean(hostData.enableTerminal),
|
||||
enableTunnel: Boolean(hostData.enableTunnel),
|
||||
enableFileManager: Boolean(hostData.enableFileManager),
|
||||
enableDocker: Boolean(hostData.enableDocker),
|
||||
showTerminalInSidebar: Boolean(hostData.showTerminalInSidebar),
|
||||
showFileManagerInSidebar: Boolean(hostData.showFileManagerInSidebar),
|
||||
showTunnelInSidebar: Boolean(hostData.showTunnelInSidebar),
|
||||
showDockerInSidebar: Boolean(hostData.showDockerInSidebar),
|
||||
showServerStatsInSidebar: Boolean(hostData.showServerStatsInSidebar),
|
||||
defaultPath: hostData.defaultPath || "/",
|
||||
tunnelConnections: hostData.tunnelConnections || [],
|
||||
jumpHosts: hostData.jumpHosts || [],
|
||||
quickActions: hostData.quickActions || [],
|
||||
sudoPassword: hostData.sudoPassword || null,
|
||||
statsConfig: hostData.statsConfig || null,
|
||||
dockerConfig: hostData.dockerConfig || null,
|
||||
terminalConfig: hostData.terminalConfig || null,
|
||||
forceKeyboardInteractive: Boolean(hostData.forceKeyboardInteractive),
|
||||
domain: hostData.domain || null,
|
||||
security: hostData.security || null,
|
||||
ignoreCert: Boolean(hostData.ignoreCert),
|
||||
guacamoleConfig: hostData.guacamoleConfig || null,
|
||||
notes: hostData.notes || "",
|
||||
useSocks5: Boolean(hostData.useSocks5),
|
||||
socks5Host: hostData.socks5Host || null,
|
||||
socks5Port: hostData.socks5Port || null,
|
||||
socks5Username: hostData.socks5Username || null,
|
||||
socks5Password: hostData.socks5Password || null,
|
||||
socks5ProxyChain: hostData.socks5ProxyChain || null,
|
||||
macAddress: hostData.macAddress || null,
|
||||
portKnockSequence: hostData.portKnockSequence || null,
|
||||
enableSsh: hostData.enableSsh !== false,
|
||||
enableRdp: Boolean(hostData.enableRdp),
|
||||
enableVnc: Boolean(hostData.enableVnc),
|
||||
enableTelnet: Boolean(hostData.enableTelnet),
|
||||
sshPort: hostData.sshPort || hostData.port || 22,
|
||||
rdpPort: hostData.rdpPort || 3389,
|
||||
vncPort: hostData.vncPort || 5900,
|
||||
telnetPort: hostData.telnetPort || 23,
|
||||
rdpUser: hostData.rdpUser || null,
|
||||
rdpPassword: hostData.rdpPassword || null,
|
||||
rdpDomain: hostData.rdpDomain || null,
|
||||
rdpSecurity: hostData.rdpSecurity || null,
|
||||
rdpIgnoreCert: Boolean(hostData.rdpIgnoreCert),
|
||||
vncPassword: hostData.vncPassword || null,
|
||||
vncUser: hostData.vncUser || null,
|
||||
telnetUser: hostData.telnetUser || null,
|
||||
telnetPassword: hostData.telnetPassword || null,
|
||||
};
|
||||
|
||||
if (!submitData.enableTunnel) {
|
||||
submitData.tunnelConnections = [];
|
||||
}
|
||||
|
||||
if (!submitData.enableFileManager) {
|
||||
submitData.defaultPath = "";
|
||||
}
|
||||
|
||||
if (hostData.authType === "key" && hostData.key instanceof File) {
|
||||
const formData = new FormData();
|
||||
formData.append("key", hostData.key);
|
||||
|
||||
const dataWithoutFile = { ...submitData };
|
||||
delete dataWithoutFile.key;
|
||||
const dataWithoutFile = { ...hostData, key: undefined };
|
||||
formData.append("data", JSON.stringify(dataWithoutFile));
|
||||
|
||||
const response = await sshHostApi.post("/db/host", formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return response.data;
|
||||
} else {
|
||||
const response = await sshHostApi.post("/db/host", submitData);
|
||||
return response.data;
|
||||
}
|
||||
const response = await sshHostApi.post("/db/host", hostData);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "create SSH host");
|
||||
}
|
||||
@@ -1213,101 +1129,18 @@ export async function updateSSHHost(
|
||||
hostData: SSHHostData,
|
||||
): Promise<SSHHost> {
|
||||
try {
|
||||
const submitData = {
|
||||
connectionType: hostData.connectionType || "ssh",
|
||||
name: hostData.name || "",
|
||||
ip: hostData.ip,
|
||||
port: parseInt(hostData.port.toString()) || 22,
|
||||
username: hostData.username,
|
||||
folder: hostData.folder || "",
|
||||
tags: hostData.tags || [],
|
||||
pin: Boolean(hostData.pin),
|
||||
authType: hostData.authType,
|
||||
password:
|
||||
hostData.connectionType !== "ssh"
|
||||
? hostData.password || null
|
||||
: hostData.authType === "password"
|
||||
? hostData.password
|
||||
: null,
|
||||
key: hostData.authType === "key" ? hostData.key : null,
|
||||
keyPassword: hostData.authType === "key" ? hostData.keyPassword : null,
|
||||
keyType: hostData.authType === "key" ? hostData.keyType : null,
|
||||
credentialId:
|
||||
hostData.authType === "credential" ? hostData.credentialId : null,
|
||||
overrideCredentialUsername: Boolean(hostData.overrideCredentialUsername),
|
||||
enableTerminal: Boolean(hostData.enableTerminal),
|
||||
enableTunnel: Boolean(hostData.enableTunnel),
|
||||
enableFileManager: Boolean(hostData.enableFileManager),
|
||||
enableDocker: Boolean(hostData.enableDocker),
|
||||
showTerminalInSidebar: Boolean(hostData.showTerminalInSidebar),
|
||||
showFileManagerInSidebar: Boolean(hostData.showFileManagerInSidebar),
|
||||
showTunnelInSidebar: Boolean(hostData.showTunnelInSidebar),
|
||||
showDockerInSidebar: Boolean(hostData.showDockerInSidebar),
|
||||
showServerStatsInSidebar: Boolean(hostData.showServerStatsInSidebar),
|
||||
defaultPath: hostData.defaultPath || "/",
|
||||
tunnelConnections: hostData.tunnelConnections || [],
|
||||
jumpHosts: hostData.jumpHosts || [],
|
||||
quickActions: hostData.quickActions || [],
|
||||
sudoPassword: hostData.sudoPassword || null,
|
||||
statsConfig: hostData.statsConfig || null,
|
||||
dockerConfig: hostData.dockerConfig || null,
|
||||
terminalConfig: hostData.terminalConfig || null,
|
||||
forceKeyboardInteractive: Boolean(hostData.forceKeyboardInteractive),
|
||||
domain: hostData.domain || null,
|
||||
security: hostData.security || null,
|
||||
ignoreCert: Boolean(hostData.ignoreCert),
|
||||
guacamoleConfig: hostData.guacamoleConfig || null,
|
||||
notes: hostData.notes || "",
|
||||
useSocks5: Boolean(hostData.useSocks5),
|
||||
socks5Host: hostData.socks5Host || null,
|
||||
socks5Port: hostData.socks5Port || null,
|
||||
socks5Username: hostData.socks5Username || null,
|
||||
socks5Password: hostData.socks5Password || null,
|
||||
socks5ProxyChain: hostData.socks5ProxyChain || null,
|
||||
macAddress: hostData.macAddress || null,
|
||||
portKnockSequence: hostData.portKnockSequence || null,
|
||||
enableSsh: hostData.enableSsh !== false,
|
||||
enableRdp: Boolean(hostData.enableRdp),
|
||||
enableVnc: Boolean(hostData.enableVnc),
|
||||
enableTelnet: Boolean(hostData.enableTelnet),
|
||||
sshPort: hostData.sshPort || hostData.port || 22,
|
||||
rdpPort: hostData.rdpPort || 3389,
|
||||
vncPort: hostData.vncPort || 5900,
|
||||
telnetPort: hostData.telnetPort || 23,
|
||||
rdpUser: hostData.rdpUser || null,
|
||||
rdpPassword: hostData.rdpPassword || null,
|
||||
rdpDomain: hostData.rdpDomain || null,
|
||||
rdpSecurity: hostData.rdpSecurity || null,
|
||||
rdpIgnoreCert: Boolean(hostData.rdpIgnoreCert),
|
||||
vncPassword: hostData.vncPassword || null,
|
||||
vncUser: hostData.vncUser || null,
|
||||
telnetUser: hostData.telnetUser || null,
|
||||
telnetPassword: hostData.telnetPassword || null,
|
||||
};
|
||||
|
||||
if (!submitData.enableTunnel) {
|
||||
submitData.tunnelConnections = [];
|
||||
}
|
||||
if (!submitData.enableFileManager) {
|
||||
submitData.defaultPath = "";
|
||||
}
|
||||
|
||||
if (hostData.authType === "key" && hostData.key instanceof File) {
|
||||
const formData = new FormData();
|
||||
formData.append("key", hostData.key);
|
||||
|
||||
const dataWithoutFile = { ...submitData };
|
||||
delete dataWithoutFile.key;
|
||||
const dataWithoutFile = { ...hostData, key: undefined };
|
||||
formData.append("data", JSON.stringify(dataWithoutFile));
|
||||
|
||||
const response = await sshHostApi.put(`/db/host/${hostId}`, formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return response.data;
|
||||
} else {
|
||||
const response = await sshHostApi.put(`/db/host/${hostId}`, submitData);
|
||||
return response.data;
|
||||
}
|
||||
const response = await sshHostApi.put(`/db/host/${hostId}`, hostData);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleApiError(error, "update SSH host");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user