mirror of
https://github.com/eugeny/tabby
synced 2026-09-25 14:36:01 +00:00
feat(serial): allow empty port selection on connect
This commit is contained in:
@@ -11,7 +11,7 @@ export interface SerialProfile extends ConnectableTerminalProfile {
|
||||
}
|
||||
|
||||
export interface SerialProfileOptions extends StreamProcessingOptions, LoginScriptsOptions {
|
||||
port: string
|
||||
port: string | null
|
||||
baudrate: number | null
|
||||
databits: 5 | 6 | 7 | 8
|
||||
stopbits: 1 | 1.5 | 2
|
||||
|
||||
@@ -9,6 +9,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
||||
input.form-control(
|
||||
type='text',
|
||||
alwaysVisibleTypeahead,
|
||||
placeholder='Ask every time',
|
||||
[(ngModel)]='profile.options.port',
|
||||
[ngbTypeahead]='portsAutocomplete',
|
||||
[resultFormatter]='portsFormatter'
|
||||
|
||||
@@ -83,6 +83,30 @@ export class SerialProfilesService extends ConnectableProfileProvider<SerialProf
|
||||
}
|
||||
|
||||
async getNewTabParameters (profile: SerialProfile): Promise<NewTabParameters<SerialTabComponent>> {
|
||||
// Show port selector first if not set
|
||||
if (!profile.options.port) {
|
||||
profile = deepClone(profile)
|
||||
let port: string|undefined = undefined
|
||||
|
||||
try {
|
||||
const ports = await this.serial.listPorts()
|
||||
|
||||
port = await this.selector.show(
|
||||
this.translate.instant('Select port'),
|
||||
[
|
||||
...ports.map(x => ({
|
||||
name: x.description ? `${x.name} (${x.description})` : x.name, result: x.name, weight: 0,
|
||||
})),
|
||||
],
|
||||
)
|
||||
} catch {
|
||||
throw new Error('Port selection canceled')
|
||||
}
|
||||
|
||||
profile.options.port = port
|
||||
}
|
||||
|
||||
// Then show baudrate selector if not set
|
||||
if (!profile.options.baudrate) {
|
||||
profile = deepClone(profile)
|
||||
let baudrate: number|undefined = undefined
|
||||
@@ -132,6 +156,6 @@ export class SerialProfilesService extends ConnectableProfileProvider<SerialProf
|
||||
}
|
||||
|
||||
getDescription (profile: SerialProfile): string {
|
||||
return profile.options.port
|
||||
return profile.options.port ?? ''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user