Skip to content

Commit

Permalink
Merge pull request #263 from jumpserver/pr@dev@perf_event_listner
Browse files Browse the repository at this point in the history
perf: 优化事件监听
  • Loading branch information
orangemio authored Sep 15, 2020
2 parents ff6b542 + 5d251ff commit cfdd038
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/app/elements/connect/connect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
view.connected = true;
view.editable = false;
view.closed = false;
view.shareroomId = node.id;
view.shareRoomId = node.id;
view.type = 'ssh';
this.onNewView.emit(view);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[token]="view.token"
[sysUser]="view.user"
[host]="view.host"
[shareroomId] = "view.shareroomId"
[shareRoomId] = "view.shareRoomId"
*ngIf="view.type=='ssh' || view.type=='database'|| view.type=='k8s'"
>
</elements-ssh-term>
Expand Down
2 changes: 1 addition & 1 deletion src/app/elements/ssh-term/ssh-term.component.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!--<elements-term (winSizeChangeTrigger)="changeWinSize($event)" (contextmenu)="contextMenu($event)" [term]="term"></elements-term>-->
<iframe #terminal [src]="target" *ngIf="target" width="100%" height="100%" scrolling="no" [id]="terminalID"></iframe>
<iframe #terminal [src]="target" *ngIf="target" (load)="listenEvent()" width="100%" height="100%" [id]="terminalID"></iframe>
2 changes: 1 addition & 1 deletion src/app/elements/ssh-term/ssh-term.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
iframe{
iframe {
border-width: 0;
}
14 changes: 4 additions & 10 deletions src/app/elements/ssh-term/ssh-term.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {DomSanitizer} from '@angular/platform-browser';
templateUrl: './ssh-term.component.html',
styleUrls: ['./ssh-term.component.scss']
})
export class ElementSshTermComponent implements OnInit, AfterViewInit {
export class ElementSshTermComponent implements OnInit {
@Input() view: View;
@Input() host: any;
@Input() sysUser: any;
@Input() token: string;
@Input() shareroomId: string;
@Input() shareRoomId: string;
@ViewChild('terminal') iframe: ElementRef;

target: any;
Expand Down Expand Up @@ -55,9 +55,9 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
break;
}
}
if (this.shareroomId) {
if (this.shareRoomId) {
this.target = this.trust(
`${document.location.origin}/koko/terminal/?target_id=${this.shareroomId}&type=shareroom`
`${document.location.origin}/koko/terminal/?target_id=${this.shareRoomId}&type=shareroom`
);
}
if (this.token) {
Expand All @@ -70,12 +70,6 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {

}

ngAfterViewInit() {
setTimeout(() => {
this.listenEvent();
}, 2000);
}

listenEvent() {
const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
input !== null && input.tagName === 'IFRAME';
Expand Down
2 changes: 1 addition & 1 deletion src/app/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class View {
token: any;
DatabaseApp: string;
K8SApp: string;
shareroomId: string;
shareRoomId: string;
termComp: ElementSshTermComponent;
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/connect/connect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class PagesConnectComponent implements OnInit {
this.system = this._appService.getQueryString('system');
this.token = this._appService.getQueryString('token');
const assetId = this._appService.getQueryString('asset');
const shareroomId = this._appService.getQueryString('shareroom');
const shareRoomId = this._appService.getQueryString('shareroom');
const remoteAppId = this._appService.getQueryString('remote_app');
const databaseAppId = this._appService.getQueryString('database_app');
const k8sId = this._appService.getQueryString('k8s_app');
Expand All @@ -49,9 +49,9 @@ export class PagesConnectComponent implements OnInit {
}
);
}
if (shareroomId) {
if (shareRoomId) {
const node = new TreeNode;
node.id = shareroomId;
node.id = shareRoomId;
node.meta = {
type: 'shareroom'
};
Expand Down

0 comments on commit cfdd038

Please sign in to comment.