From b60ccec74c31e08ddd6cbc8e58305dcbd547b275 Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Tue, 24 Dec 2024 20:32:44 +0900 Subject: [PATCH] improved device select for apps, files and info --- package-lock.json | 136 +++++------ src-tauri/src/conn_pool/connection.rs | 3 +- src-tauri/src/plugins/cmd.rs | 19 +- .../device-editor/device-editor.component.ts | 2 +- src/app/apps/apps.component.html | 14 +- src/app/apps/apps.component.ts | 6 +- src/app/apps/apps.module.ts | 2 + src/app/core/services/file.session.ts | 13 + .../core/services/remote-command.service.ts | 16 +- src/app/core/services/remote-log.service.ts | 227 +++++++++--------- src/app/files/files.component.html | 2 +- src/app/files/files.component.ts | 83 +++---- src/app/info/info.component.html | 10 +- src/app/info/info.component.ts | 35 ++- src/app/info/info.module.ts | 2 + src/app/types/file-session.ts | 2 + 16 files changed, 314 insertions(+), 258 deletions(-) diff --git a/package-lock.json b/package-lock.json index bbe18a00..3071b869 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,11 +20,11 @@ "@ng-bootstrap/ng-bootstrap": "16.0.0", "@popperjs/core": "2.11.8", "@sentry/angular-ivy": "7.114.0", - "@tauri-apps/api": "^2.0.0-rc.3", - "@tauri-apps/plugin-dialog": "2.0.0-rc.0", - "@tauri-apps/plugin-fs": "2.0.0-rc.1", - "@tauri-apps/plugin-shell": "2.0.0-rc.0", - "@tauri-apps/plugin-upload": "2.0.0-rc.0", + "@tauri-apps/api": "^2.0.1", + "@tauri-apps/plugin-dialog": "2.0.0", + "@tauri-apps/plugin-fs": "2.0.0", + "@tauri-apps/plugin-shell": "2.0.0", + "@tauri-apps/plugin-upload": "2.0.0", "@xterm/addon-fit": "0.10.0", "@xterm/addon-search": "0.15.0", "@xterm/addon-web-links": "0.11.0", @@ -61,7 +61,7 @@ "@angular-eslint/template-parser": "17.4.0", "@angular/cli": "17.3.6", "@angular/compiler-cli": "17.3.7", - "@tauri-apps/cli": "^2.0.0-rc.7", + "@tauri-apps/cli": "^2.0.0", "@types/jasmine": "4.6.4", "@types/jest": "29.5.10", "@types/lodash-es": "4.17.12", @@ -4565,18 +4565,18 @@ "dev": true }, "node_modules/@tauri-apps/api": { - "version": "2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.0.0-rc.3.tgz", - "integrity": "sha512-k1erUfnoOFJwL5VNFZz0BQZ2agNstG7CNOjwpdWMl1vOaVuSn4DhJtXB0Deh9lZaaDlfrykKOyZs9c3XXpMi5Q==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@tauri-apps/api/-/api-2.1.1.tgz", + "integrity": "sha512-fzUfFFKo4lknXGJq8qrCidkUcKcH2UHhfaaCNt4GzgzGaW2iS26uFOg4tS3H4P8D6ZEeUxtiD5z0nwFF0UN30A==", "funding": { "type": "opencollective", "url": "https://opencollective.com/tauri" } }, "node_modules/@tauri-apps/cli": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.0.0-rc.7.tgz", - "integrity": "sha512-FdNcr75EIPfA69gWxpk3xv78og8CVbEa8ih2Rvp9k1tyAyryOth0Ps+jNEqP/WtfFwITWTYm4JqOubSCHoFjpQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.1.0.tgz", + "integrity": "sha512-K2VhcKqBhAeS5pNOVdnR/xQRU6jwpgmkSL2ejHXcl0m+kaTggT0WRDQnFtPq6NljA7aE03cvwsbCAoFG7vtkJw==", "dev": true, "bin": { "tauri": "tauri.js" @@ -4589,22 +4589,22 @@ "url": "https://opencollective.com/tauri" }, "optionalDependencies": { - "@tauri-apps/cli-darwin-arm64": "2.0.0-rc.7", - "@tauri-apps/cli-darwin-x64": "2.0.0-rc.7", - "@tauri-apps/cli-linux-arm-gnueabihf": "2.0.0-rc.7", - "@tauri-apps/cli-linux-arm64-gnu": "2.0.0-rc.7", - "@tauri-apps/cli-linux-arm64-musl": "2.0.0-rc.7", - "@tauri-apps/cli-linux-x64-gnu": "2.0.0-rc.7", - "@tauri-apps/cli-linux-x64-musl": "2.0.0-rc.7", - "@tauri-apps/cli-win32-arm64-msvc": "2.0.0-rc.7", - "@tauri-apps/cli-win32-ia32-msvc": "2.0.0-rc.7", - "@tauri-apps/cli-win32-x64-msvc": "2.0.0-rc.7" + "@tauri-apps/cli-darwin-arm64": "2.1.0", + "@tauri-apps/cli-darwin-x64": "2.1.0", + "@tauri-apps/cli-linux-arm-gnueabihf": "2.1.0", + "@tauri-apps/cli-linux-arm64-gnu": "2.1.0", + "@tauri-apps/cli-linux-arm64-musl": "2.1.0", + "@tauri-apps/cli-linux-x64-gnu": "2.1.0", + "@tauri-apps/cli-linux-x64-musl": "2.1.0", + "@tauri-apps/cli-win32-arm64-msvc": "2.1.0", + "@tauri-apps/cli-win32-ia32-msvc": "2.1.0", + "@tauri-apps/cli-win32-x64-msvc": "2.1.0" } }, "node_modules/@tauri-apps/cli-darwin-arm64": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.0.0-rc.7.tgz", - "integrity": "sha512-DUdO1TCj+cViFkOWtYotq4UNBGfHvl1xLK85n2rmpsCeveGxO9pf1CihOtADuVonHl6ETa9x/uaSTCMeMsKEbA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.1.0.tgz", + "integrity": "sha512-ESc6J6CE8hl1yKH2vJ+ALF+thq4Be+DM1mvmTyUCQObvezNCNhzfS6abIUd3ou4x5RGH51ouiANeT3wekU6dCw==", "cpu": [ "arm64" ], @@ -4618,9 +4618,9 @@ } }, "node_modules/@tauri-apps/cli-darwin-x64": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.0.0-rc.7.tgz", - "integrity": "sha512-T36ncxLyfgKBsPXdgCfw7WeOtHwDrfkvjJoovlBH5nAejlxZC4g4pYm7/Qvpc++FRmQhcHJXP8Y+fBOSEZrfog==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.1.0.tgz", + "integrity": "sha512-TasHS442DFs8cSH2eUQzuDBXUST4ECjCd0yyP+zZzvAruiB0Bg+c8A+I/EnqCvBQ2G2yvWLYG8q/LI7c87A5UA==", "cpu": [ "x64" ], @@ -4634,9 +4634,9 @@ } }, "node_modules/@tauri-apps/cli-linux-arm-gnueabihf": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.0.0-rc.7.tgz", - "integrity": "sha512-afLBeWgpm++9oKsYNShqKsBCHLLgMJy+rodHIiUd9LB4VqjU/1bYfZdia0PxKjnEuOz27mG9Be5v0SDdsZsLww==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.1.0.tgz", + "integrity": "sha512-aP7ZBGNL4ny07Cbb6kKpUOSrmhcIK2KhjviTzYlh+pPhAptxnC78xQGD3zKQkTi2WliJLPmBYbOHWWQa57lQ9w==", "cpu": [ "arm" ], @@ -4650,9 +4650,9 @@ } }, "node_modules/@tauri-apps/cli-linux-arm64-gnu": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.0.0-rc.7.tgz", - "integrity": "sha512-sjT/URsuJ2ImJGe9fH0b8reewGq5R1E5t4DZRF0ZVpCpUC1yTpml0kuPWt4S0rGws/beRICPaZWW8OuColIFtQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.1.0.tgz", + "integrity": "sha512-ZTdgD5gLeMCzndMT2f358EkoYkZ5T+Qy6zPzU+l5vv5M7dHVN9ZmblNAYYXmoOuw7y+BY4X/rZvHV9pcGrcanQ==", "cpu": [ "arm64" ], @@ -4666,9 +4666,9 @@ } }, "node_modules/@tauri-apps/cli-linux-arm64-musl": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.0.0-rc.7.tgz", - "integrity": "sha512-s7OG30ffEBKF5BiMEIVmtd/UNHC956ihEOfZYRJwBZ9cL8qoPLjEMZYMCGB/767M4igXy1bhKaVnl8pZpk+RNw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.1.0.tgz", + "integrity": "sha512-NzwqjUCilhnhJzusz3d/0i0F1GFrwCQbkwR6yAHUxItESbsGYkZRJk0yMEWkg3PzFnyK4cWTlQJMEU52TjhEzA==", "cpu": [ "arm64" ], @@ -4682,9 +4682,9 @@ } }, "node_modules/@tauri-apps/cli-linux-x64-gnu": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.0.0-rc.7.tgz", - "integrity": "sha512-Qj9ibUvq2CwJE5JQ7M/DfOw44xcf59rUGsMGuku/bSKLPu6UXEFyUFjUURcnOgcZkq9o86no7ONoKdMxm4viKQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.1.0.tgz", + "integrity": "sha512-TyiIpMEtZxNOQmuFyfJwaaYbg3movSthpBJLIdPlKxSAB2BW0VWLY3/ZfIxm/G2YGHyREkjJvimzYE0i37PnMA==", "cpu": [ "x64" ], @@ -4698,9 +4698,9 @@ } }, "node_modules/@tauri-apps/cli-linux-x64-musl": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.0.0-rc.7.tgz", - "integrity": "sha512-75ucw3b7MVnyVNvoW+xqB1N8VGjx1vqP7HshAs+p1fSkeCOy2NvtMP7t8pdRlGQ59exH6vGvnQ/LxC5HgDP2Xg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.1.0.tgz", + "integrity": "sha512-/dQd0TlaxBdJACrR72DhynWftzHDaX32eBtS5WBrNJ+nnNb+znM3gON6nJ9tSE9jgDa6n1v2BkI/oIDtypfUXw==", "cpu": [ "x64" ], @@ -4714,9 +4714,9 @@ } }, "node_modules/@tauri-apps/cli-win32-arm64-msvc": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.0.0-rc.7.tgz", - "integrity": "sha512-KaWY7kVbpmJCn5INtcPX+tji7CqwmqtGechith65VIlEUUs+KyOkMdmgbsJvqe0N58VMHLFzEVfx1xtlaKGDUA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.1.0.tgz", + "integrity": "sha512-NdQJO7SmdYqOcE+JPU7bwg7+odfZMWO6g8xF9SXYCMdUzvM2Gv/AQfikNXz5yS7ralRhNFuW32i5dcHlxh4pDg==", "cpu": [ "arm64" ], @@ -4730,9 +4730,9 @@ } }, "node_modules/@tauri-apps/cli-win32-ia32-msvc": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.0.0-rc.7.tgz", - "integrity": "sha512-J2xVw7gcP1JY1Pj6lE+MuAUKtanD7tXyjBD6W8R2S7sD06Job9PHoonOQhm/vWlhQVtRkWPNX7K7MXbdoI/Z9w==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.1.0.tgz", + "integrity": "sha512-f5h8gKT/cB8s1ticFRUpNmHqkmaLutT62oFDB7N//2YTXnxst7EpMIn1w+QimxTvTk2gcx6EcW6bEk/y2hZGzg==", "cpu": [ "ia32" ], @@ -4746,9 +4746,9 @@ } }, "node_modules/@tauri-apps/cli-win32-x64-msvc": { - "version": "2.0.0-rc.7", - "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.0.0-rc.7.tgz", - "integrity": "sha512-0dQzFCUGjrpJBsj/JpV2XRUbH6nDbhW4NKpx6DUnFrwPe7YQwz2eexo7FAu2pLTW8HEPCPd0NvXGOCUrWM/klg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.1.0.tgz", + "integrity": "sha512-P/+LrdSSb5Xbho1LRP4haBjFHdyPdjWvGgeopL96OVtrFpYnfC+RctB45z2V2XxqFk3HweDDxk266btjttfjGw==", "cpu": [ "x64" ], @@ -4762,35 +4762,35 @@ } }, "node_modules/@tauri-apps/plugin-dialog": { - "version": "2.0.0-rc.0", - "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-dialog/-/plugin-dialog-2.0.0-rc.0.tgz", - "integrity": "sha512-DPOXYe8SQ6Radk/67EOdaomlxL7oF99JO/ZUaPp1IBEs3Wro7lhlz63CfdKIBfKIZTLJLzP1R7/EiPL/GTA3Bg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-dialog/-/plugin-dialog-2.0.0.tgz", + "integrity": "sha512-ApNkejXP2jpPBSifznPPcHTXxu9/YaRW+eJ+8+nYwqp0lLUtebFHG4QhxitM43wwReHE81WAV1DQ/b+2VBftOA==", "dependencies": { - "@tauri-apps/api": "^2.0.0-rc.0" + "@tauri-apps/api": "^2.0.0" } }, "node_modules/@tauri-apps/plugin-fs": { - "version": "2.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-fs/-/plugin-fs-2.0.0-rc.1.tgz", - "integrity": "sha512-r6N5dqBNXy9YAK9XbiEqAq3ZKBIN+TWevE7ZFmSRdvdSB1urrLweYu4wxycY2kDaDPzSeeOIJhCmqdNrFT9OSA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-fs/-/plugin-fs-2.0.0.tgz", + "integrity": "sha512-BNEeQQ5aH8J5SwYuWgRszVyItsmquRuzK2QRkVj8Z0sCsLnSvJFYI3JHRzzr3ltZGq1nMPtblrlZzuKqVzRawA==", "dependencies": { - "@tauri-apps/api": "^2.0.0-rc.1" + "@tauri-apps/api": "^2.0.0" } }, "node_modules/@tauri-apps/plugin-shell": { - "version": "2.0.0-rc.0", - "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-shell/-/plugin-shell-2.0.0-rc.0.tgz", - "integrity": "sha512-bhUcQcrqZoK8H1DFXapr5r1Z75oh6Kd5Tltz97XpZFLREEqp+KhN2Fvyh8r/fKAyenYsTYUIsDsyGdjdueuF9g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-shell/-/plugin-shell-2.0.0.tgz", + "integrity": "sha512-OpW2+ycgJLrEoZityWeWYk+6ZWP9VyiAfbO+N/O8VfLkqyOym8kXh7odKDfINx9RAotkSGBtQM4abyKfJDkcUg==", "dependencies": { - "@tauri-apps/api": "^2.0.0-rc.0" + "@tauri-apps/api": "^2.0.0" } }, "node_modules/@tauri-apps/plugin-upload": { - "version": "2.0.0-rc.0", - "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-upload/-/plugin-upload-2.0.0-rc.0.tgz", - "integrity": "sha512-wlRzL4syShxMlvuM7YfeG3Mcj4Ii2UkuQ8HaBh3YnBl0bPoKuVOGP/PaJ3FF84z1pgMfA5Pb1eSG34hlMCYLsw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tauri-apps/plugin-upload/-/plugin-upload-2.0.0.tgz", + "integrity": "sha512-MdBZn4RCVmFDjuC2rbpFGjAZAbePkxrc9T35+SKJJgfXbXYw0YOzvUTsDiU7F3NzDWepO+6EbVN3Upzi9rqt/A==", "dependencies": { - "@tauri-apps/api": "^2.0.0-rc.0" + "@tauri-apps/api": "^2.0.0" } }, "node_modules/@tsconfig/node10": { diff --git a/src-tauri/src/conn_pool/connection.rs b/src-tauri/src/conn_pool/connection.rs index 99333c90..b3a563c1 100644 --- a/src-tauri/src/conn_pool/connection.rs +++ b/src-tauri/src/conn_pool/connection.rs @@ -5,7 +5,7 @@ use std::path::Path; use std::sync::Mutex; use std::time::Duration; -use libssh_rs::{AuthStatus, Session, SshKey, SshOption}; +use libssh_rs::{AuthStatus, LogLevel, Session, SshKey, SshOption}; use regex::Regex; use uuid::Uuid; @@ -21,6 +21,7 @@ impl DeviceConnection { session.set_option(SshOption::Hostname(device.host.clone()))?; session.set_option(SshOption::Port(device.port.clone()))?; session.set_option(SshOption::User(Some(device.username.clone())))?; + session.set_option(SshOption::LogLevel(LogLevel::Protocol))?; session.connect()?; diff --git a/src-tauri/src/plugins/cmd.rs b/src-tauri/src/plugins/cmd.rs index 3938ae80..d15ea510 100644 --- a/src-tauri/src/plugins/cmd.rs +++ b/src-tauri/src/plugins/cmd.rs @@ -7,7 +7,7 @@ use crate::error::Error; use crate::event_channel::{EventChannel, EventHandler}; use crate::session_manager::{Proc, ProcCallback, ProcData, SessionManager}; use crate::spawn_manager::SpawnManager; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use tauri::{ plugin::{Builder, TauriPlugin}, AppHandle, Manager, Runtime, State, @@ -20,7 +20,7 @@ async fn exec( command: String, stdin: Option, encoding: Option, -) -> Result { +) -> Result { let encoding = encoding.unwrap_or(Encoding::Binary); return tokio::task::spawn_blocking(move || { let sessions = app.state::(); @@ -32,8 +32,8 @@ async fn exec( ch.stdin().write_all(&stdin.as_ref())?; ch.send_eof()?; } - let mut buf = Vec::::new(); - ch.stdout().read_to_end(&mut buf)?; + let mut stdout = Vec::::new(); + ch.stdout().read_to_end(&mut stdout)?; let mut stderr = Vec::::new(); ch.stderr().read_to_end(&mut stderr)?; let exit_code = ch.get_exit_status().unwrap_or(0); @@ -48,7 +48,10 @@ async fn exec( unhandled: true, }); } - return Ok(ByteString::parse(&buf, encoding).unwrap()); + return Ok(ExecOutput { + stdout: ByteString::parse(&stdout, encoding).unwrap(), + stderr: ByteString::parse(&stderr, encoding).unwrap(), + }); }); }) .await @@ -113,6 +116,12 @@ struct TxPayload { data: Option>, } +#[derive(Serialize, Debug)] +struct ExecOutput { + stdout: ByteString, + stderr: ByteString, +} + impl ProcCallback for ProcCallbackImpl { fn rx(&self, fd: u32, data: &[u8]) { self.channel.rx(ProcData { diff --git a/src/app/add-device/device-editor/device-editor.component.ts b/src/app/add-device/device-editor/device-editor.component.ts index 5a4aed50..44f74707 100644 --- a/src/app/add-device/device-editor/device-editor.component.ts +++ b/src/app/add-device/device-editor/device-editor.component.ts @@ -284,7 +284,7 @@ export class DeviceEditorComponent implements OnInit { const file = await showOpenDialog({ multiple: false, defaultPath: sshDir, - }).then(result => result?.path); + }).then(result => result); if (typeof (file) !== 'string' || !file) { return; } diff --git a/src/app/apps/apps.component.html b/src/app/apps/apps.component.html index e6228787..50209559 100644 --- a/src/app/apps/apps.component.html +++ b/src/app/apps/apps.component.html @@ -1,7 +1,13 @@