Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Tabby
提交
2ea2c028
T
Tabby
项目概览
后端镜像
/
Tabby
通知
31
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,发现更多精彩内容 >>
提交
2ea2c028
编写于
8月 27, 2018
作者:
D
Domain
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support login scripts. Fix #344
上级
4b1ba786
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
194 addition
and
41 deletion
+194
-41
terminus-ssh/src/api.ts
terminus-ssh/src/api.ts
+59
-2
terminus-ssh/src/components/editConnectionModal.component.pug
...inus-ssh/src/components/editConnectionModal.component.pug
+92
-36
terminus-ssh/src/components/editConnectionModal.component.ts
terminus-ssh/src/components/editConnectionModal.component.ts
+41
-2
terminus-ssh/src/components/sshSettingsTab.component.ts
terminus-ssh/src/components/sshSettingsTab.component.ts
+1
-0
terminus-ssh/src/services/ssh.service.ts
terminus-ssh/src/services/ssh.service.ts
+1
-1
未找到文件。
terminus-ssh/src/api.ts
浏览文件 @
2ea2c028
import
{
BaseSession
}
from
'
terminus-terminal
'
export
interface
LoginScript
{
expect
?:
string
send
:
string
}
export
interface
SSHConnection
{
name
?:
string
host
:
string
...
...
@@ -7,18 +12,48 @@ export interface SSHConnection {
user
:
string
password
?:
string
privateKey
?:
string
scripts
?:
LoginScript
[]
}
export
class
SSHSession
extends
BaseSession
{
constructor
(
private
shell
:
any
)
{
scripts
?:
LoginScript
[]
constructor
(
private
shell
:
any
,
conn
:
SSHConnection
)
{
super
()
this
.
scripts
=
conn
.
scripts
.
slice
(
0
);
}
start
()
{
this
.
open
=
true
this
.
shell
.
on
(
'
data
'
,
data
=>
{
this
.
emitOutput
(
data
.
toString
())
let
dataString
=
data
.
toString
()
this
.
emitOutput
(
dataString
)
if
(
this
.
scripts
&&
this
.
scripts
.
length
>
0
)
{
let
found
=
false
for
(
let
i
=
0
;
i
<
this
.
scripts
.
length
;
i
++
)
{
if
(
dataString
.
indexOf
(
this
.
scripts
[
i
].
expect
)
>=
0
)
{
console
.
log
(
"
Executing:
"
+
this
.
scripts
[
i
].
send
)
this
.
shell
.
write
(
this
.
scripts
[
i
].
send
+
"
\n
"
)
this
.
scripts
.
splice
(
i
,
1
)
i
--
found
=
true
}
else
{
break
;
}
}
if
(
found
)
{
this
.
executeScripts
()
}
}
})
this
.
shell
.
on
(
'
end
'
,
()
=>
{
...
...
@@ -26,6 +61,28 @@ export class SSHSession extends BaseSession {
this
.
destroy
()
}
})
this
.
executeScripts
()
}
executeScripts
()
{
if
(
this
.
scripts
&&
this
.
scripts
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
this
.
scripts
.
length
;
i
++
)
{
if
(
!
this
.
scripts
[
i
].
expect
)
{
console
.
log
(
"
Executing:
"
+
this
.
scripts
[
i
].
send
)
this
.
shell
.
write
(
this
.
scripts
[
i
].
send
+
"
\n
"
)
this
.
scripts
.
splice
(
i
,
1
)
i
--
}
else
{
break
;
}
}
}
}
resize
(
columns
,
rows
)
{
...
...
terminus-ssh/src/components/editConnectionModal.component.pug
浏览文件 @
2ea2c028
.modal-body
.form-group
label Name
input.form-control(
type='text',
[(ngModel)]='connection.name',
)
ngb-tabset(type='tabs', [activeId]='basic')
ngb-tab(id='basic')
ng-template(ngbTabTitle)
| Basic Setting
ng-template(ngbTabContent)
h4 Basic Setting
.form-group
label Name
input.form-control(
type='text',
[(ngModel)]='connection.name',
)
.form-group
label Host
input.form-control(
type='text',
[(ngModel)]='connection.host',
)
.form-group
label Host
input.form-control(
type='text',
[(ngModel)]='connection.host',
)
.form-group
label Port
input.form-control(
type='number',
placeholder='22',
[(ngModel)]='connection.port',
)
.form-group
label Port
input.form-control(
type='number',
placeholder='22',
[(ngModel)]='connection.port',
)
.form-group
label Username
input.form-control(
type='text',
[(ngModel)]='connection.user',
)
.form-group
label Username
input.form-control(
type='text',
[(ngModel)]='connection.user',
)
.form-group
label Private key
.input-group
input.form-control(
type='text',
placeholder='Key file path',
[(ngModel)]='connection.privateKey'
)
.input-group-btn
button.btn.btn-secondary((click)='selectPrivateKey()')
i.fa.fa-folder-open
.form-group
label Private key
.input-group
input.form-control(
type='text',
placeholder='Key file path',
[(ngModel)]='connection.privateKey'
)
.input-group-btn
button.btn.btn-secondary((click)='selectPrivateKey()')
i.fa.fa-folder-open
ngb-tab(id='scripts')
ng-template(ngbTabTitle)
| Login Scripts
ng-template(ngbTabContent)
h4 Login Scripts
.list-group
table
tr
th String to wait
th String to be sent
th Actions
tr(*ngFor='let script of connection.scripts')
td
input.form-control(
type='text',
value='{{script.expect}}',
)
td
input.form-control(
type='text',
value='{{script.send}}',
)
td
.input-group
button.btn.btn-outline-info.ml-0((click)='up(script)')
i.fa.fa-arrow-up
button.btn.btn-outline-info.ml-0((click)='down(script)')
i.fa.fa-arrow-down
button.btn.btn-outline-danger.ml-0((click)='delete(script)')
i.fa.fa-trash-o
tr
td
input.form-control(
type='text',
placeholder='Enter a string to wait',
[(ngModel)]='newScript.expect'
)
td
input.form-control(
type='text',
placeholder='Enter a string to be sent',
[(ngModel)]='newScript.send'
)
td
.input-group
button.btn.btn-outline-info.ml-0((click)='add()')
i.fa.fa-save
button.btn.btn-outline-danger.ml-0((click)='clear()')
i.fa.fa-trash-o
.modal-footer
button.btn.btn-outline-primary((click)='save()') Save
button.btn.btn-outline-danger((click)='cancel()') Cancel
terminus-ssh/src/components/editConnectionModal.component.ts
浏览文件 @
2ea2c028
import
{
Component
}
from
'
@angular/core
'
import
{
NgbActiveModal
}
from
'
@ng-bootstrap/ng-bootstrap
'
import
{
ElectronService
,
HostAppService
}
from
'
terminus-core
'
import
{
SSHConnection
}
from
'
../api
'
import
{
SSHConnection
,
LoginScript
}
from
'
../api
'
@
Component
({
template
:
require
(
'
./editConnectionModal.component.pug
'
),
})
export
class
EditConnectionModalComponent
{
connection
:
SSHConnection
newScript
:
LoginScript
constructor
(
private
modalInstance
:
NgbActiveModal
,
private
electron
:
ElectronService
,
private
hostApp
:
HostAppService
,
)
{
}
)
{
this
.
newScript
=
{
expect
:
""
,
send
:
""
}
}
selectPrivateKey
()
{
let
path
=
this
.
electron
.
dialog
.
showOpenDialog
(
...
...
@@ -34,4 +37,40 @@ export class EditConnectionModalComponent {
cancel
()
{
this
.
modalInstance
.
dismiss
()
}
up
(
script
:
LoginScript
)
{
let
index
=
this
.
connection
.
scripts
.
indexOf
(
script
)
if
(
index
>
0
)
{
this
.
connection
.
scripts
.
splice
(
index
,
1
);
this
.
connection
.
scripts
.
splice
(
index
-
1
,
0
,
script
);
}
}
down
(
script
:
LoginScript
)
{
let
index
=
this
.
connection
.
scripts
.
indexOf
(
script
)
if
(
index
>=
0
&&
index
<
this
.
connection
.
scripts
.
length
-
1
)
{
this
.
connection
.
scripts
.
splice
(
index
,
1
);
this
.
connection
.
scripts
.
splice
(
index
+
1
,
0
,
script
);
}
}
delete
(
script
:
LoginScript
)
{
if
(
confirm
(
`Delete?`
))
{
this
.
connection
.
scripts
=
this
.
connection
.
scripts
.
filter
(
x
=>
x
!==
script
)
}
}
add
()
{
if
(
!
this
.
connection
.
scripts
)
this
.
connection
.
scripts
=
[]
this
.
connection
.
scripts
.
push
(
Object
.
assign
({},
this
.
newScript
))
this
.
clear
();
}
clear
()
{
this
.
newScript
.
expect
=
""
this
.
newScript
.
send
=
""
}
}
terminus-ssh/src/components/sshSettingsTab.component.ts
浏览文件 @
2ea2c028
...
...
@@ -24,6 +24,7 @@ export class SSHSettingsTabComponent {
port
:
22
,
user
:
'
root
'
,
}
let
modal
=
this
.
ngbModal
.
open
(
EditConnectionModalComponent
)
modal
.
componentInstance
.
connection
=
connection
modal
.
result
.
then
(
result
=>
{
...
...
terminus-ssh/src/services/ssh.service.ts
浏览文件 @
2ea2c028
...
...
@@ -148,7 +148,7 @@ export class SSHService {
})
})
let
session
=
new
SSHSession
(
shell
)
let
session
=
new
SSHSession
(
shell
,
connection
)
return
this
.
zone
.
run
(()
=>
this
.
app
.
openNewTab
(
TerminalTabComponent
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录