Skip to content

Commit b60ccec

Browse files
committed
improved device select for apps, files and info
1 parent eb6ab1f commit b60ccec

File tree

16 files changed

+314
-258
lines changed

16 files changed

+314
-258
lines changed

package-lock.json

Lines changed: 68 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/src/conn_pool/connection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::Path;
55
use std::sync::Mutex;
66
use std::time::Duration;
77

8-
use libssh_rs::{AuthStatus, Session, SshKey, SshOption};
8+
use libssh_rs::{AuthStatus, LogLevel, Session, SshKey, SshOption};
99
use regex::Regex;
1010
use uuid::Uuid;
1111

@@ -21,6 +21,7 @@ impl DeviceConnection {
2121
session.set_option(SshOption::Hostname(device.host.clone()))?;
2222
session.set_option(SshOption::Port(device.port.clone()))?;
2323
session.set_option(SshOption::User(Some(device.username.clone())))?;
24+
session.set_option(SshOption::LogLevel(LogLevel::Protocol))?;
2425

2526
session.connect()?;
2627

src-tauri/src/plugins/cmd.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::error::Error;
77
use crate::event_channel::{EventChannel, EventHandler};
88
use crate::session_manager::{Proc, ProcCallback, ProcData, SessionManager};
99
use crate::spawn_manager::SpawnManager;
10-
use serde::Deserialize;
10+
use serde::{Deserialize, Serialize};
1111
use tauri::{
1212
plugin::{Builder, TauriPlugin},
1313
AppHandle, Manager, Runtime, State,
@@ -20,7 +20,7 @@ async fn exec<R: Runtime>(
2020
command: String,
2121
stdin: Option<ByteString>,
2222
encoding: Option<Encoding>,
23-
) -> Result<ByteString, Error> {
23+
) -> Result<ExecOutput, Error> {
2424
let encoding = encoding.unwrap_or(Encoding::Binary);
2525
return tokio::task::spawn_blocking(move || {
2626
let sessions = app.state::<SessionManager>();
@@ -32,8 +32,8 @@ async fn exec<R: Runtime>(
3232
ch.stdin().write_all(&stdin.as_ref())?;
3333
ch.send_eof()?;
3434
}
35-
let mut buf = Vec::<u8>::new();
36-
ch.stdout().read_to_end(&mut buf)?;
35+
let mut stdout = Vec::<u8>::new();
36+
ch.stdout().read_to_end(&mut stdout)?;
3737
let mut stderr = Vec::<u8>::new();
3838
ch.stderr().read_to_end(&mut stderr)?;
3939
let exit_code = ch.get_exit_status().unwrap_or(0);
@@ -48,7 +48,10 @@ async fn exec<R: Runtime>(
4848
unhandled: true,
4949
});
5050
}
51-
return Ok(ByteString::parse(&buf, encoding).unwrap());
51+
return Ok(ExecOutput {
52+
stdout: ByteString::parse(&stdout, encoding).unwrap(),
53+
stderr: ByteString::parse(&stderr, encoding).unwrap(),
54+
});
5255
});
5356
})
5457
.await
@@ -113,6 +116,12 @@ struct TxPayload {
113116
data: Option<Vec<u8>>,
114117
}
115118

119+
#[derive(Serialize, Debug)]
120+
struct ExecOutput {
121+
stdout: ByteString,
122+
stderr: ByteString,
123+
}
124+
116125
impl<R: Runtime> ProcCallback for ProcCallbackImpl<R> {
117126
fn rx(&self, fd: u32, data: &[u8]) {
118127
self.channel.rx(ProcData {

src/app/add-device/device-editor/device-editor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export class DeviceEditorComponent implements OnInit {
284284
const file = await showOpenDialog({
285285
multiple: false,
286286
defaultPath: sshDir,
287-
}).then(result => result?.path);
287+
}).then(result => result);
288288
if (typeof (file) !== 'string' || !file) {
289289
return;
290290
}

src/app/apps/apps.component.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<div class="w-100 h-100 d-flex flex-column overflow-hidden" xmlns="http://www.w3.org/1999/html">
22
<nav class="manager-toolbar navbar bg-panel border-bottom px-2">
3-
<div class="me-auto">
4-
<ul ngbNav #nav="ngbNav" class="nav-pills" [(activeId)]="tabId">
3+
<div class="d-flex flex-row w-100">
4+
<select class="form-select w-auto" [value]="device?.name" (change)="deviceManager.setDefault(deviceSelect.value)"
5+
#deviceSelect>
6+
@for (dev of devices$ | async; track dev.name) {
7+
<option [ngValue]="dev.name" [selected]="dev.name === device?.name">{{ dev.name }}</option>
8+
}
9+
</select>
10+
<ul ngbNav #nav="ngbNav" class="nav-pills flex-nowrap ms-2" [(activeId)]="tabId">
511
<li ngbNavItem="installed">
612
<a ngbNavLink>Installed</a>
713
<ng-template ngbNavContent>
@@ -15,9 +21,7 @@
1521
</ng-template>
1622
</li>
1723
</ul>
18-
</div>
19-
<div>
20-
<button class="btn btn-primary" (click)="openInstallChooser()">
24+
<button class="btn btn-primary text-nowrap ms-auto" (click)="openInstallChooser()">
2125
<i class="bi bi-folder-fill me-2"></i>Install
2226
</button>
2327
</div>

src/app/apps/apps.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class AppsComponent implements OnInit, OnDestroy {
2323
packages$?: Observable<PackageInfo[] | null>;
2424
instPackages?: Record<string, RawPackageInfo>;
2525
device: Device | null = null;
26+
devices$?: Observable<Device[]|null>;
2627
tabId: string = 'installed';
2728

2829
@ViewChild('storageInfo') storageInfo?: StatStorageInfoComponent;
@@ -31,13 +32,14 @@ export class AppsComponent implements OnInit, OnDestroy {
3132
private packagesSubscription?: Subscription;
3233

3334
constructor(
35+
public deviceManager: DeviceManagerService,
3436
private modalService: NgbModal,
35-
private deviceManager: DeviceManagerService,
3637
private appManager: AppManagerService,
3738
) {
3839
}
3940

4041
ngOnInit(): void {
42+
this.devices$ = this.deviceManager.devices$;
4143
this.deviceSubscription = this.deviceManager.selected$.subscribe((device) => {
4244
this.device = device;
4345
if (device) {
@@ -77,7 +79,7 @@ export class AppsComponent implements OnInit, OnDestroy {
7779
filters: [{name: 'IPK package', extensions: ['ipk']}],
7880
multiple: false,
7981
defaultPath: await downloadDir(),
80-
}).then(result => result?.path);
82+
}).then(result => result);
8183
if (!path) {
8284
return;
8385
}

0 commit comments

Comments
 (0)