Skip to content

Commit

Permalink
Merge pull request #806 from jumpserver/dev
Browse files Browse the repository at this point in the history
v3.2.0 rc1
  • Loading branch information
BaiJiangJie committed Apr 13, 2023
2 parents 9836a39 + 942581a commit 9a206e1
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/elements/asset-tree/asset-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export class ElementAssetTreeComponent implements OnInit {

onMenuConnectNewTab() {
const node = this.rightClickSelectNode;
connectOnNewPage(node, false);
connectOnNewPage(node, 'auto');
}

onMenuFavorite() {
Expand Down
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 @@ -27,7 +27,7 @@
{{ method.label }}

<span matTooltip="{{'Click to download rdp file'| translate}}">
<i *ngIf="(method.component === 'razor'|| method.component == 'tinker') && !isWebConnectMethod"
<i *ngIf="canDownloadRDPFile(method)"
(click)="downloadRDPFile(method)"
class="fa fa-question-circle-o question"
></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ElementConnectMethodComponent implements OnInit {
@Output() onDownloadRDPFile = new EventEmitter<ConnectMethod>();
public connectMethods = [];
public connectMethodTypes = [];
public isWebConnectMethod = false;
public isAppletClientMethod = false;


constructor(private _i18n: I18nService,
Expand All @@ -39,7 +39,7 @@ export class ElementConnectMethodComponent implements OnInit {

ngOnInit() {
this._settingSvc.appletConnectMethod$.subscribe((state) => {
this.isWebConnectMethod = state === 'web';
this.isAppletClientMethod = state === 'client';
});
this.setConnectMethods();
}
Expand All @@ -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 All @@ -86,6 +95,19 @@ export class ElementConnectMethodComponent implements OnInit {
// return connectMethodTypes;
}

canDownloadRDPFile(method): Boolean {
if (!this._settingSvc.hasXPack()) {
return false;
}
if (method.component === 'razor') {
return true;
}
if (method.type === 'applet' && this.isAppletClientMethod) {
return true;
}
return false;
}

downloadRDPFile(method) {
if (method.disabled) {
return;
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
1 change: 1 addition & 0 deletions src/app/services/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class SettingService {
if (settingData && typeof settingData === 'object') {
this.setting = settingData;
this.setIsLoadTreeAsync();
this.setAppletConnectMethod();
} else {
this.setting = new Setting();
}
Expand Down
28 changes: 22 additions & 6 deletions src/app/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,30 @@ export function launchLocalApp(url, fail) {
/**
* 打开新页卡
* @param {Object} node
* @param {Boolean} newWindow
* @param {String} newWindowMode
*/
export function connectOnNewPage(node: TreeNode, newWindow?: boolean) {
export function connectOnNewPage(node: TreeNode, newWindowMode?: string) {
const url = `/luna/connect?login_to=${node.id}&type=${node.meta.type}`;
if (newWindow) {
const height = window.innerHeight;
const width = window.innerWidth;
const params = `toolbar=yes,scrollbars=yes,resizable=yes,top=300,left=300,width=${width},height=${height}`;
let params = 'toolbar=yes,scrollbars=yes,resizable=yes';
if (newWindowMode === 'auto') {
let count: number;
let top = 50;
count = parseInt(window.sessionStorage.getItem('newWindowCount'), 10);
if (isNaN(count)) {
count = 0;
}
let left = 100 + count * 100;
if (left + screen.width / 3 > screen.width) {
// 支持两排足以
top = screen.height / 3;
count = 1;
left = 100;
}
params = params + `,top=${top},left=${left},width=${screen.width / 3},height=${screen.height / 3}`;
window.sessionStorage.setItem('newWindowCount', `${count + 1}`);
window.open(url, '_blank', params);
} else if (newWindowMode === 'new') {
params = params + `,top=50,left=100,width=${window.innerWidth},height=${window.innerHeight}`;
window.open(url, '_blank', params);
} else {
window.open(url, '_blank');
Expand Down
4 changes: 4 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ body ::-webkit-scrollbar {
height:8px;
}

body ::-webkit-scrollbar-corner {
background: transparent;
}

body ::-webkit-scrollbar-thumb {
background-color: #494141;
border-radius: 6px;
Expand Down

0 comments on commit 9a206e1

Please sign in to comment.