Skip to content

Commit

Permalink
Perf: Add Directive Connect
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Dec 26, 2024
1 parent f872f21 commit b8e90e1
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 137 deletions.
4 changes: 4 additions & 0 deletions src/app/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,16 @@ export class Endpoint {

getPort(protocol?: string): string {
let _protocol = protocol || window.location.protocol;

_protocol = _protocol.replace(':', '');

let port = this[_protocol + '_port'];

// 处理 http(s) 协议的后台端口为0的时候, 使用当前地址中的端口
if (['http', 'https'].indexOf(_protocol) !== -1 && port === 0) {
port = window.location.port;
}

return port;
}

Expand Down
26 changes: 22 additions & 4 deletions src/app/pages/pam/gui.component/gui.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export class PagePamGUIComponent implements OnInit, OnDestroy {
return;
}

console.log("🚀 ~ PagePamGUIComponent ~ accountToUse:", accountToUse);

switch (protocol.name) {
case "ssh":
case "telnet":
Expand All @@ -117,18 +115,38 @@ export class PagePamGUIComponent implements OnInit, OnDestroy {
{
asset: asset.id,
account: accountToUse[0].name,
protocol: protocol,
protocol: protocol.name,
input_username: accountToUse[0].username,
input_secret: "",
},
method
)
.subscribe((res) => {
console.log(res);
if (res) {
const url = this.getUrl();

this.iframeURL = `${url}/koko/connect?token=${res.id}`;
}
});
});
}

private getUrl(): string {
let host: string = "";

const endpoint = window.location.host.split(":")[0];
const protocole = window.location.protocol;
const port = "9529";

if (port) {
host = `${endpoint}:${port}`;
}

this._logger.info(`Current host: ${protocole}//${host}`);

return `${protocole}//${host}`;
}

/**
* 开始计时器
*/
Expand Down
8 changes: 2 additions & 6 deletions src/app/pages/pam/terminal.component/terminal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<mat-icon>home</mat-icon>
<div class="delimiter">/</div>
</div>

<div class="file-list">
<!-- 文件列表内容 -->
</div>
</div>
</mat-sidenav>

Expand All @@ -35,7 +31,7 @@
<mat-icon matTooltip="资产信息">dvr</mat-icon>
<div class="desc">
<div style="font-weight: 700; margin-right: 5px">资产信息:</div>
[email protected] - (yy)
{{ assetName }}
</div>
</div>

Expand All @@ -44,7 +40,7 @@

<div class="desc">
<div style="font-weight: 700; margin-right: 5px">连接时间:</div>
九月 24,2024 10:46 上午
{{ startTime.toLocaleString() }}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit b8e90e1

Please sign in to comment.