Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Tabby
提交
10b21ee0
T
Tabby
项目概览
后端镜像
/
Tabby
通知
38
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tabby
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
10b21ee0
编写于
3月 01, 2020
作者:
E
Eugene Pankov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added serial port detection
上级
f5ffdc17
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
146 addition
and
9 deletion
+146
-9
terminus-core/src/api/index.ts
terminus-core/src/api/index.ts
+1
-0
terminus-core/src/api/selector.ts
terminus-core/src/api/selector.ts
+5
-0
terminus-core/src/components/selectorModal.component.pug
terminus-core/src/components/selectorModal.component.pug
+18
-0
terminus-core/src/components/selectorModal.component.ts
terminus-core/src/components/selectorModal.component.ts
+47
-0
terminus-core/src/index.ts
terminus-core/src/index.ts
+3
-0
terminus-core/src/services/app.service.ts
terminus-core/src/services/app.service.ts
+12
-0
terminus-serial/src/api.ts
terminus-serial/src/api.ts
+9
-0
terminus-serial/src/components/editConnectionModal.component.pug
...s-serial/src/components/editConnectionModal.component.pug
+4
-2
terminus-serial/src/components/editConnectionModal.component.ts
...us-serial/src/components/editConnectionModal.component.ts
+19
-2
terminus-serial/src/components/serialModal.component.pug
terminus-serial/src/components/serialModal.component.pug
+8
-0
terminus-serial/src/components/serialModal.component.ts
terminus-serial/src/components/serialModal.component.ts
+13
-2
terminus-serial/src/services/serial.service.ts
terminus-serial/src/services/serial.service.ts
+7
-3
未找到文件。
terminus-core/src/api/index.ts
浏览文件 @
10b21ee0
...
...
@@ -7,6 +7,7 @@ export { ConfigProvider } from './configProvider'
export
{
HotkeyProvider
,
HotkeyDescription
}
from
'
./hotkeyProvider
'
export
{
Theme
}
from
'
./theme
'
export
{
TabContextMenuItemProvider
}
from
'
./tabContextMenuProvider
'
export
{
SelectorOption
}
from
'
./selector
'
export
{
AppService
}
from
'
../services/app.service
'
export
{
ConfigService
}
from
'
../services/config.service
'
...
...
terminus-core/src/api/selector.ts
0 → 100644
浏览文件 @
10b21ee0
export
interface
SelectorOption
<
T
>
{
name
:
string
description
?:
string
result
:
T
}
terminus-core/src/components/selectorModal.component.pug
0 → 100644
浏览文件 @
10b21ee0
.modal-body
input.form-control(
type='text',
[(ngModel)]='filter',
autofocus,
[placeholder]='name',
(ngModelChange)='onFilterChange()',
(keyup.enter)='onFilterEnter()',
(keyup.escape)='close()'
)
.list-group.mt-3(*ngIf='filteredOptions.length')
a.list-group-item.list-group-item-action.d-flex.align-items-center(
(click)='selectOption(option)',
*ngFor='let option of filteredOptions'
)
.mr-2 {{option.name}}
.text-muted {{option.description}}
terminus-core/src/components/selectorModal.component.ts
0 → 100644
浏览文件 @
10b21ee0
import
{
Component
,
Input
}
from
'
@angular/core
'
import
{
NgbActiveModal
}
from
'
@ng-bootstrap/ng-bootstrap
'
import
{
SelectorOption
}
from
'
../api/selector
'
/** @hidden */
@
Component
({
template
:
require
(
'
./selectorModal.component.pug
'
),
// styles: [require('./selectorModal.component.scss')],
})
export
class
SelectorModalComponent
<
T
>
{
@
Input
()
options
:
SelectorOption
<
T
>
[]
@
Input
()
filteredOptions
:
SelectorOption
<
T
>
[]
@
Input
()
filter
=
''
@
Input
()
name
:
string
constructor
(
public
modalInstance
:
NgbActiveModal
,
)
{
}
ngOnInit
()
{
this
.
onFilterChange
()
}
onFilterChange
()
{
const
f
=
this
.
filter
.
trim
().
toLowerCase
()
if
(
!
f
)
{
this
.
filteredOptions
=
this
.
options
}
else
{
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
this
.
filteredOptions
=
this
.
options
.
filter
(
x
=>
(
x
.
name
+
(
x
.
description
||
''
)).
toLowerCase
().
includes
(
f
))
}
}
onFilterEnter
()
{
if
(
this
.
filteredOptions
.
length
===
1
)
{
this
.
selectOption
(
this
.
filteredOptions
[
0
])
}
}
selectOption
(
option
:
SelectorOption
<
T
>
)
{
this
.
modalInstance
.
close
(
option
.
result
)
}
close
()
{
this
.
modalInstance
.
dismiss
()
}
}
terminus-core/src/index.ts
浏览文件 @
10b21ee0
...
...
@@ -16,6 +16,7 @@ import { TitleBarComponent } from './components/titleBar.component'
import
{
ToggleComponent
}
from
'
./components/toggle.component
'
import
{
WindowControlsComponent
}
from
'
./components/windowControls.component
'
import
{
RenameTabModalComponent
}
from
'
./components/renameTabModal.component
'
import
{
SelectorModalComponent
}
from
'
./components/selectorModal.component
'
import
{
SplitTabComponent
,
SplitTabRecoveryProvider
}
from
'
./components/splitTab.component
'
import
{
SplitTabSpannerComponent
}
from
'
./components/splitTabSpanner.component
'
import
{
WelcomeTabComponent
}
from
'
./components/welcomeTab.component
'
...
...
@@ -82,6 +83,7 @@ const PROVIDERS = [
SafeModeModalComponent
,
AutofocusDirective
,
FastHtmlBindDirective
,
SelectorModalComponent
,
SplitTabComponent
,
SplitTabSpannerComponent
,
WelcomeTabComponent
,
...
...
@@ -89,6 +91,7 @@ const PROVIDERS = [
entryComponents
:
[
RenameTabModalComponent
,
SafeModeModalComponent
,
SelectorModalComponent
,
SplitTabComponent
,
WelcomeTabComponent
,
],
...
...
terminus-core/src/services/app.service.ts
浏览文件 @
10b21ee0
...
...
@@ -2,9 +2,12 @@
import
{
Observable
,
Subject
,
AsyncSubject
}
from
'
rxjs
'
import
{
takeUntil
}
from
'
rxjs/operators
'
import
{
Injectable
}
from
'
@angular/core
'
import
{
NgbModal
}
from
'
@ng-bootstrap/ng-bootstrap
'
import
{
BaseTabComponent
}
from
'
../components/baseTab.component
'
import
{
SplitTabComponent
}
from
'
../components/splitTab.component
'
import
{
SelectorModalComponent
}
from
'
../components/selectorModal.component
'
import
{
SelectorOption
}
from
'
../api/selector
'
import
{
ConfigService
}
from
'
./config.service
'
import
{
HostAppService
}
from
'
./hostApp.service
'
...
...
@@ -69,6 +72,7 @@ export class AppService {
private
hostApp
:
HostAppService
,
private
tabRecovery
:
TabRecoveryService
,
private
tabsService
:
TabsService
,
private
ngbModal
:
NgbModal
,
)
{
if
(
hostApp
.
getWindow
().
id
===
1
)
{
if
(
config
.
store
.
terminal
.
recoverTabs
)
{
...
...
@@ -315,4 +319,12 @@ export class AppService {
stopObservingTabCompletion
(
tab
:
BaseTabComponent
)
{
this
.
completionObservers
.
delete
(
tab
)
}
showSelector
<
T
>
(
name
:
string
,
options
:
SelectorOption
<
T
>
[]):
Promise
<
T
>
{
const
modal
=
this
.
ngbModal
.
open
(
SelectorModalComponent
)
const
instance
:
SelectorModalComponent
<
T
>
=
modal
.
componentInstance
instance
.
name
=
name
instance
.
options
=
options
return
modal
.
result
as
Promise
<
T
>
}
}
terminus-serial/src/api.ts
浏览文件 @
10b21ee0
...
...
@@ -26,6 +26,15 @@ export interface SerialConnection {
color
?:
string
}
export
const
BAUD_RATES
=
[
110
,
150
,
300
,
1200
,
2400
,
4800
,
9600
,
19200
,
38400
,
57600
,
115200
,
230400
,
460800
,
921600
,
]
export
interface
SerialPortInfo
{
name
:
string
description
?:
string
}
export
class
SerialSession
extends
BaseSession
{
scripts
?:
LoginScript
[]
serial
:
SerialPort
...
...
terminus-serial/src/components/editConnectionModal.component.pug
浏览文件 @
10b21ee0
...
...
@@ -24,14 +24,16 @@
input.form-control(
type='text',
[(ngModel)]='connection.port',
[ngbTypeahead]='portsAutocomplete',
[resultFormatter]='portsFormatter',
)
.form-group
label Baud Rate
input.form-control(
type='number',
select.form-control(
[(ngModel)]='connection.baudrate',
)
option([value]='x', *ngFor='let x of baudRates') {{x}}
ngb-tab(id='advanced')
ng-template(ngbTabTitle) Advanced
...
...
terminus-serial/src/components/editConnectionModal.component.ts
浏览文件 @
10b21ee0
import
{
Component
}
from
'
@angular/core
'
import
{
NgbActiveModal
}
from
'
@ng-bootstrap/ng-bootstrap
'
import
{
map
}
from
'
rxjs/operators
'
import
{
ElectronService
,
HostAppService
}
from
'
terminus-core
'
import
{
SerialConnection
,
LoginScript
}
from
'
../api
'
import
{
SerialConnection
,
LoginScript
,
SerialPortInfo
,
BAUD_RATES
}
from
'
../api
'
import
{
SerialService
}
from
'
../services/serial.service
'
// import { PromptModalComponent } from './promptModal.component'
/** @hidden */
...
...
@@ -10,17 +12,32 @@ import { SerialConnection, LoginScript } from '../api'
})
export
class
EditConnectionModalComponent
{
connection
:
SerialConnection
foundPorts
:
SerialPortInfo
[]
baudRates
=
BAUD_RATES
constructor
(
private
modalInstance
:
NgbActiveModal
,
private
electron
:
ElectronService
,
private
hostApp
:
HostAppService
,
// private ngbModal: NgbModal
,
private
serial
:
SerialService
,
)
{
}
portsAutocomplete
=
text$
=>
text$
.
pipe
(
map
(()
=>
{
return
this
.
foundPorts
.
map
(
x
=>
x
.
name
)
}))
portsFormatter
=
port
=>
{
const
p
=
this
.
foundPorts
.
find
(
x
=>
x
.
name
===
port
)
if
(
p
?.
description
)
{
return
`
${
port
}
(
${
p
.
description
}
)`
}
return
port
}
async
ngOnInit
()
{
this
.
connection
.
scripts
=
this
.
connection
.
scripts
||
[]
this
.
foundPorts
=
await
this
.
serial
.
listPorts
()
}
save
()
{
...
...
terminus-serial/src/components/serialModal.component.pug
浏览文件 @
10b21ee0
...
...
@@ -30,3 +30,11 @@
)
.mr-2 {{connection.name}}
.text-muted {{connection.port}}
.list-group.mt-3(*ngIf='foundPorts.length')
a.list-group-item.list-group-item-action.d-flex.align-items-center(
(click)='connectFoundPort(port)',
*ngFor='let port of foundPorts'
)
.mr-2 {{port.name}}
.text-muted {{port.description}}
terminus-serial/src/components/serialModal.component.ts
浏览文件 @
10b21ee0
...
...
@@ -4,7 +4,7 @@ import { ToastrService } from 'ngx-toastr'
import
{
ConfigService
,
AppService
}
from
'
terminus-core
'
import
{
SettingsTabComponent
}
from
'
terminus-settings
'
import
{
SerialService
}
from
'
../services/serial.service
'
import
{
SerialConnection
,
SerialConnectionGroup
}
from
'
../api
'
import
{
SerialConnection
,
SerialConnectionGroup
,
SerialPortInfo
,
BAUD_RATES
}
from
'
../api
'
/** @hidden */
@
Component
({
...
...
@@ -18,6 +18,7 @@ export class SerialModalComponent {
lastConnection
:
SerialConnection
|
null
=
null
childGroups
:
SerialConnectionGroup
[]
groupCollapsed
:
{[
id
:
string
]:
boolean
}
=
{}
foundPorts
:
SerialPortInfo
[]
=
[]
constructor
(
public
modalInstance
:
NgbActiveModal
,
...
...
@@ -27,12 +28,14 @@ export class SerialModalComponent {
private
toastr
:
ToastrService
,
)
{
}
ngOnInit
()
{
async
ngOnInit
()
{
this
.
connections
=
this
.
config
.
store
.
serial
.
connections
if
(
window
.
localStorage
.
lastSerialConnection
)
{
this
.
lastConnection
=
JSON
.
parse
(
window
.
localStorage
.
lastSerialConnection
)
}
this
.
refresh
()
this
.
foundPorts
=
await
this
.
serial
.
listPorts
()
}
quickConnect
()
{
...
...
@@ -105,4 +108,12 @@ export class SerialModalComponent {
group
.
connections
.
push
(
connection
)
}
}
async
connectFoundPort
(
port
:
SerialPortInfo
)
{
const
rate
=
await
this
.
app
.
showSelector
(
'
Baud rate
'
,
BAUD_RATES
.
map
(
x
=>
({
name
:
x
.
toString
(),
result
:
x
,
})))
this
.
quickTarget
=
`
${
port
.
name
}
@
${
rate
}
`
this
.
quickConnect
()
}
}
terminus-serial/src/services/serial.service.ts
浏览文件 @
10b21ee0
...
...
@@ -2,19 +2,23 @@ import { Injectable, NgZone } from '@angular/core'
import
SerialPort
from
'
serialport
'
import
{
ToastrService
}
from
'
ngx-toastr
'
import
{
AppService
,
LogService
}
from
'
terminus-core
'
import
{
SerialConnection
,
SerialSession
}
from
'
../api
'
import
{
SerialConnection
,
SerialSession
,
SerialPortInfo
}
from
'
../api
'
import
{
SerialTabComponent
}
from
'
../components/serialTab.component
'
@
Injectable
({
providedIn
:
'
root
'
})
export
class
SerialService
{
private
constructor
(
private
log
:
LogService
,
private
app
:
AppService
,
private
zone
:
NgZone
,
private
toastr
:
ToastrService
,
)
{
)
{
}
async
listPorts
():
Promise
<
SerialPortInfo
[]
>
{
return
(
await
SerialPort
.
list
()).
map
(
x
=>
({
name
:
x
.
path
,
description
:
x
.
manufacturer
||
x
.
serialNumber
?
`
${
x
.
manufacturer
||
''
}
${
x
.
serialNumber
||
''
}
`
:
undefined
,
}))
}
async
openTab
(
connection
:
SerialConnection
):
Promise
<
SerialTabComponent
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录