Skip to content

Commit

Permalink
perf: 发送快捷命令增加发送范围
Browse files Browse the repository at this point in the history
  • Loading branch information
huailei000 committed Nov 30, 2023
1 parent a6efcca commit 05f0b8e
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 20 deletions.
7 changes: 6 additions & 1 deletion src/app/elements/content/content.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@
<elements-content-window *ngFor="let view of viewList" [view]="view"></elements-content-window>
</div>
<div *ngIf="showBatchCommand" id="batchCommandDiv">
<mat-select [(ngModel)]="sendCommandRange" class="send-range" panelClass="command-panel">
<mat-option *ngFor="let option of sendCommandOptions" class="command-option" [value]="option.value">
{{ option.label | translate }}
</mat-option>
</mat-select>
<i
class="fa fa-exchange"
matTooltip="{{ (isShowInputCommand ? 'Switch to quick command' : 'Switch to input command') | translate }}"
(click)="switchCommand()"
></i>
<div *ngIf="isShowInputCommand; else quickCommand" class="input-box">
<input
(keydown.enter)="sendBatchCommand('current')"
(keydown.enter)="sendBatchCommand()"
[(ngModel)]="batchCommand"
maxlength="2048"
placeholder=" {{'Send text to all ssh terminals'| translate }} ..."
Expand Down
42 changes: 41 additions & 1 deletion src/app/elements/content/content.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ $-border-y: #1f1b1b;
vertical-align: middle;
display: inline-block;
}

.view_icon::before {
font-family: FontAwesome;
color: #ffffff;
Expand All @@ -119,6 +119,21 @@ $-border-y: #1f1b1b;
}

#batchCommandDiv {
.send-range {
width: auto;
margin-left: 5px;
&::ng-deep .mat-select-trigger {
min-width: 70px;
line-height: 29px;
.mat-select-value {
max-width: none;
color: #ffffff;
}
.mat-select-arrow {
color: #ffffff;
}
}
}
.command-list {
width: 100%;
height: 100%;
Expand Down Expand Up @@ -151,6 +166,7 @@ $-border-y: #1f1b1b;
}
}
.not-command {
flex: 1;
line-height: 29px;
padding-left: 6px;
color: #717171;
Expand All @@ -164,6 +180,30 @@ $-border-y: #1f1b1b;
}
}

::ng-deep .command-panel.mat-select-panel {
margin-top: 27px;
min-width: 100%!important;
border-radius: initial!important;
background: black;
padding: 10px 0 !important;
}
::ng-deep .command-panel .mat-option {
color: #f0f0f1;
&:hover {
background-color: rgba(53, 54, 51, 0.7)!important;
}
}
::ng-deep .command-panel .mat-option.mat-active {
color: #f0f0f1;
font-weight: bold;
background-color: rgba(53, 54, 51, 0.8)!important;
}
.command-option {
line-height: 2.2em!important;
height: 2.2em!important;
}


.view-menu {
background: #000;
border: none;
Expand Down
32 changes: 22 additions & 10 deletions src/app/elements/content/content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ export class ElementContentComponent implements OnInit {
pos = {left: '100px', top: '100px'};
isShowRMenu = false;
rIdx = -1;
sendCommandRange = 'current';
sendCommandOptions = [
{
value: 'all',
label: 'All sessions'
},
{
value: 'current',
label: 'Current session'
}
];
systemTips = [
{
content: 'Reselect connection method',
Expand Down Expand Up @@ -128,15 +139,15 @@ export class ElementContentComponent implements OnInit {
return item.id;
}

sendBatchCommand(value) {
sendBatchCommand() {
let list = this.viewList;
this.batchCommand = this.batchCommand.trim();
if (this.batchCommand === '') {
return;
}

const cmd = this.batchCommand + '\r';
if (value === 'current') {
if (this.sendCommandRange === 'current') {
const view = this.viewList.filter(i => i.id === this.viewSrv.currentView.id);
list = view;
}
Expand All @@ -161,14 +172,15 @@ export class ElementContentComponent implements OnInit {

sendQuickCommand(command) {
this.batchCommand = command.args;
this._dialog.open(
ElementSendCommandDialogComponent,
{
height: 'auto',
width: '500px',
data: {send: this.sendBatchCommand.bind(this)}
}
);
this.sendBatchCommand();
// this._dialog.open(
// ElementSendCommandDialogComponent,
// {
// height: 'auto',
// width: '500px',
// data: {send: this.sendBatchCommand.bind(this)}
// }
// );
}

rMenuItems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export class ElementSendCommandDialogComponent implements OnInit {
public value = 'current';
public options = [
{
label: 'Current window',
label: 'Current session',
value: 'current'
},
{
label: 'All window',
label: 'All sessions',
value: 'all'
}
];
Expand Down
4 changes: 2 additions & 2 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"Save command": "Save command",
"Save success": "Save success",
"Send command": "Send command",
"Current window": "Current window",
"All window": "All window",
"Current session": "Current session",
"All sessions": "All sessions",
"Module": "Module",
"Setting": "Setting",
"Show left manager": "Show left manager",
Expand Down
4 changes: 2 additions & 2 deletions src/assets/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"Save command": "保存コマンド",
"Save success": "保存に成功",
"Send command": "コマンドを送信",
"Current window": "現在のウィンドウ",
"All window": "すべてのウィンドウ",
"Current session": "現在のセッション",
"All sessions": "すべてのセッション",
"Module": "ユニット",
"Setting": "設定",
"Show left manager": "左サイドバーを表示",
Expand Down
4 changes: 2 additions & 2 deletions src/assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"Save command": "保存命令",
"Save success": "保存成功",
"Send command": "发送命令",
"Current window": "当前窗口",
"All window": "全部窗口",
"Current session": "当前会话",
"All sessions": "全部会话",
"Module": "模块",
"Setting": "设置",
"Show left manager": "显示左边栏",
Expand Down

0 comments on commit 05f0b8e

Please sign in to comment.