Skip to content

Commit

Permalink
perf: 关闭SFTP后,luna界面不显示相应选项
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Jiangweidong authored and BaiJiangJie committed Apr 13, 2023
1 parent 25491f5 commit 942581a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ export class ElementConnectDialogComponent implements OnInit {
this.accounts = this.data.accounts;
this.asset = this.data.asset;
this.preConnectData = this.data.preConnectData;
this.protocols = this.asset.protocols || [];
this.protocols = this.getProtocols();
if (this.protocols.length === 0) {
this.protocols = [{name: 'ssh', port: 22}];
this.protocols = [{name: 'ssh', port: 22, public: true, setting: {sftp_enabled: true}}];
}
this.setDefaults();
}

getProtocols() {
const protocols = this.asset.protocols.filter((item) => item.public);
return protocols || [];
}

setDefaults() {
if (this.preConnectData) {
this.protocol = this.protocols.find(p => p.name === this.preConnectData.protocol.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class ElementConnectMethodComponent implements OnInit {
if (this.protocol.name === 'oracle') {
this.oracleFilterConnectMethods();
}
if (this.protocol.name === 'ssh') {
this.sshFilterConnectMethods();
}
this.groupConnectMethods();
if (!this.connectMethod || !this.connectMethod.value) {
this.connectMethod = this.connectMethods[0];
Expand All @@ -72,6 +75,12 @@ export class ElementConnectMethodComponent implements OnInit {
this.connectMethod = this.connectMethods[0];
}

sshFilterConnectMethods() {
if (!this.protocol.setting.sftp_enabled) {
this.connectMethods = this.connectMethods.filter((item) => (item.value !== 'web_sftp'));
}
}

groupConnectMethods() {
const connectMethodTypes = [
{value: 'web', label: 'Web', fa: 'fa-globe', methods: []},
Expand Down
6 changes: 5 additions & 1 deletion src/app/elements/connect/connect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
connectInfo.account = account;
connectInfo.protocol = {
'name': type,
'port': undefined
'port': undefined,
'public': true,
'setting': {
sftp_enabled: true
}
};
connectInfo.manualAuthInfo = {
alias: account.alias,
Expand Down
4 changes: 4 additions & 0 deletions src/app/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ export class ConnectionToken {
export class Protocol {
name: string;
port: number;
public: boolean;
setting: {
sftp_enabled: boolean
};
}

export class Endpoint {
Expand Down

0 comments on commit 942581a

Please sign in to comment.