Skip to content

Commit

Permalink
Perf: Add Manual shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Dec 30, 2024
1 parent e504b26 commit 6d2e012
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 20 deletions.
7 changes: 6 additions & 1 deletion src/app/pages/pam/gui.component/gui.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
</div>
</div>

<div class="action-icons" [class.show]="showActionIcons">
<div class="close-icon" (click)="handleCloseConnect()">
<mat-icon matTooltip="退出">close</mat-icon>
</div>
</div>

<elements-iframe
#iFrame
*ngIf="iframeURL"
[src]="iframeURL"
[origin]="'pam'"
Expand Down
45 changes: 44 additions & 1 deletion src/app/pages/pam/gui.component/gui.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

.timer-container {
position: fixed;
top: 20px;
bottom: 70px;
right: 20px;
z-index: 999999;

Expand Down Expand Up @@ -46,6 +46,49 @@
}
}

.action-icons {
position: fixed;
top: 20px;
right: 20px;
z-index: 999999;
display: flex;
gap: 10px;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease;
transition-delay: 0s, 0.3s;

&.show {
opacity: 1;
visibility: visible;
transition-delay: 0s;
}

.close-icon {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 50%;
background: rgba(0, 0, 0, 0.8);
cursor: pointer;
transition: all 0.3s ease;

&:hover {
background: rgba(0, 0, 0, 0.9);
transform: scale(1.05);
}

mat-icon {
color: white;
font-size: 20px;
width: 20px;
height: 20px;
}
}
}

@keyframes blink {
0% {
opacity: 1;
Expand Down
27 changes: 16 additions & 11 deletions src/app/pages/pam/gui.component/gui.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import { ActivatedRoute, Params } from "@angular/router";
import { Component, OnInit, OnDestroy, ViewChild } from "@angular/core";
import { Protocol, Account, Endpoint, Asset } from "@app/model";
import {
View,
Protocol,
Account,
Endpoint,
Asset,
ConnectData,
ConnectionToken,
} from "@app/model";
import {
ViewService,
HttpService,
AppService,
DialogService,
I18nService,
LogService,
Expand Down Expand Up @@ -41,6 +31,8 @@ export class PagePamGUIComponent implements OnInit, OnDestroy {
private timerInterval: any;
private pausedElapsedTime: number = 0;

public showActionIcons: boolean = false;

constructor(
private _http: HttpService,
private _i18n: I18nService,
Expand Down Expand Up @@ -131,6 +123,14 @@ export class PagePamGUIComponent implements OnInit, OnDestroy {
}, 0);
}
});

document.addEventListener("mousemove", this.handleMouseMove.bind(this));
}

public async handleCloseConnect() {
window.confirm("确定要关闭当前连接吗?");

window.close();
}

private getUrl(): string {
Expand Down Expand Up @@ -191,8 +191,13 @@ export class PagePamGUIComponent implements OnInit, OnDestroy {
return String(value).padStart(2, "0");
}

private handleMouseMove(event: MouseEvent): void {
this.showActionIcons = event.clientY <= 65;
}

ngOnDestroy() {
this.stopTimer();
document.removeEventListener("mousemove", this.handleMouseMove.bind(this));
}

public closeDrawer() {
Expand Down
12 changes: 12 additions & 0 deletions src/app/pages/pam/pam.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MatDialogModule } from "@angular/material/dialog";

@NgModule({
declarations: [
// ... 其他组件
],
imports: [
// ... 其他模块
MatDialogModule,
],
})
export class PamModule {}
4 changes: 3 additions & 1 deletion src/app/pages/pam/terminal.component/terminal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
</div>

<div class="exit action-icon">
<mat-icon matTooltip="退出">close</mat-icon>
<mat-icon matTooltip="退出" (click)="handleCloseConnect()"
>close</mat-icon
>
</div>
</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions src/app/pages/pam/terminal.component/terminal.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { EMPTY, Observable } from "rxjs";
import { ActivatedRoute } from "@angular/router";
import { ICustomFile } from "file-input-accessor";
import { MatDialog } from "@angular/material/dialog";
import { MatSidenav } from "@angular/material/sidenav";
import { User } from "../../../model";
import {
Account,
Asset,
Expand Down Expand Up @@ -52,8 +48,7 @@ export class PagePamTerminalComponent implements OnInit, OnDestroy {
private _http: HttpService,
private _i18n: I18nService,
private _logger: LogService,
private route: ActivatedRoute,
private _dialogAlert: DialogService,
private route: ActivatedRoute
) {
this.checkPageVisibility();
this.startTime = new Date();
Expand Down Expand Up @@ -162,6 +157,12 @@ export class PagePamTerminalComponent implements OnInit, OnDestroy {
});
}

public handleCloseConnect() {
window.confirm("确定要关闭当前连接吗?");

window.close();
}

public closeDrawer() {
this.sidenav.close();
}
Expand Down

0 comments on commit 6d2e012

Please sign in to comment.