diff --git a/src/main/kotlin/org/bm00/DataAccessor/main.kt b/src/main/kotlin/org/bm00/DataAccessor/main.kt index cd0da04..4a127a9 100644 --- a/src/main/kotlin/org/bm00/DataAccessor/main.kt +++ b/src/main/kotlin/org/bm00/DataAccessor/main.kt @@ -15,7 +15,6 @@ class Application : TApplication(backendType, 80, 40, 18) { // This creates a Jexer application (and calls the "backend type" which is how its rendered) @Throws(Exception::class) fun main(args: Array) { - Runtime.getRuntime().exec("echo Hello-World") Config() val app = Application() app.run() diff --git a/src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt b/src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt index 421c086..c544279 100644 --- a/src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt +++ b/src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt @@ -1,15 +1,73 @@ package org.bm00.DataAccessor.windows -import jexer.TAction -import jexer.TApplication -import jexer.TPasswordField -import jexer.TWindow +import jexer.* +import jexer.TWindow.CENTERED import jexer.layout.StretchLayoutManager +import java.awt.SystemColor.text class LoginWindow private constructor(parent: TApplication, flags: Int) : - TWindow(parent, "Login", 0, 0, 36, 16, flags) { + TWindow(parent, "Login", 0, 0, 36, 19, flags) { constructor(parent: TApplication) : this(parent, CENTERED) + var loginField = addPasswordField(CENTERED + 5, CENTERED - 1, 16, false, "", + // enterAction - function to call when enter key is pressed + object : TAction() { + override fun DO() { + loginActivity() + } + }, + // updateAction - function to call when the text is updated + object : TAction() { + override fun DO() { + return + } + } + ); + + var passField = addPasswordField(CENTERED + 5, CENTERED + 3, 16, false, "", + // enterAction - function to call when enter key is pressed + object : TAction() { + override fun DO() { + loginActivity() + } + }, + // updateAction - function to call when the text is updated + object : TAction() { + override fun DO() { + return + } + } + ); + + var serverField = addPasswordField(CENTERED + 5, CENTERED + 7, 16, false, "", + // enterAction - function to call when enter key is pressed + object : TAction() { + override fun DO() { + loginActivity() + } + }, + // updateAction - function to call when the text is updated + object : TAction() { + override fun DO() { + return + } + } + ); + + fun loginActivity() { + var usernameDetail = loginField.text + var passwordDetail = passField.text + var serverDetail = serverField.text + var remoteCommand = "echo hello" + // For windows, instead of ssh pass?? https://github.com/PowerShell/Win32-OpenSSH/issues/1943 + val loginProcess = ProcessBuilder( + "sshpass", "-p", "$passwordDetail", "ssh", "$usernameDetail@$serverDetail", remoteCommand) + .redirectOutput(ProcessBuilder.Redirect.INHERIT) + .redirectError(ProcessBuilder.Redirect.INHERIT) + .start() + .waitFor() + } + init { setLayoutManager( StretchLayoutManager( @@ -18,7 +76,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) : ) ) - addButton("Back...", CENTERED + 8, CENTERED + 8, + addButton("Back...", CENTERED + 8, CENTERED + 11, object : TAction() { override fun DO() { TODO("Instead of full program exit, make it close the login window") @@ -26,47 +84,21 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) : } ) - addButton("Login", CENTERED + 9, CENTERED + 6, + addButton("Login", CENTERED + 9, CENTERED + 9, object : TAction() { override fun DO() { - TODO("Once activated, start SSH login process") + loginActivity() } } ) //Password addLabel("Password", CENTERED + 9, CENTERED + 1) - //TODO: Once enter is pressed, getText and save as var, then activate login process. - var passField = addPasswordField(CENTERED + 5, CENTERED + 3, 16, false, "", - // enterAction - function to call when enter key is pressed - object : TAction() { - override fun DO() { - TODO("get all the text entered and save as variables") - } - }, - // updateAction - function to call when the text is updated - object : TAction() { - override fun DO() { - TODO("Not yet implemented") - } - } - ); //Login addLabel("Username", CENTERED + 9, CENTERED - 3) - //TODO: Once enter is pressed, getText and save as var, then activate login process. - addPasswordField(CENTERED + 5, CENTERED - 1, 16, false, "", - // enterAction - function to call when enter key is pressed - object : TAction() { - override fun DO() { - TODO("get all the text entered and save as variables") - } - }, - // updateAction - function to call when the text is updated - object : TAction() { - override fun DO() { - TODO("Not yet implemented") - } - } - ); - }} + + // Server + addLabel("Server", CENTERED + 10, CENTERED + 5) + } +}