Skip to content

Commit

Permalink
Merge pull request #336 from jumpserver/dev
Browse files Browse the repository at this point in the history
merge: v2.8 准备发版
  • Loading branch information
ibuler authored Mar 11, 2021
2 parents 10f7cf4 + bce8657 commit 8e3f135
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 18 deletions.
56 changes: 52 additions & 4 deletions src/app/elements/asset-tree/asset-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
setting = {
view: {
dblClickExpand: false,
showLine: true
showLine: true,
// 添加禁用颜色区分
fontCss: (treeId, treeNode) => {
if (treeNode.chkDisabled) {
return {opacity: '0.4'};
}
return {};
}
},
data: {
simpleData: {
Expand Down Expand Up @@ -379,15 +386,56 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
return menuList;
}

reAsyncChildNodes(treeId, treeNode, silent) {
if (treeNode && treeNode.isParent && treeNode.children) {
for (let i = 0; i < treeNode.children.length; i++) {
const childNode = treeNode.children[i];
const self = this;
const targetTree = $.fn.zTree.getZTreeObj(treeId);
targetTree.reAsyncChildNodesPromise(childNode, 'refresh', silent).then(function () {
self.reAsyncChildNodes(treeId, childNode, silent);
});
}
}
}

onRightClick(event, treeId, treeNode) {
expandAllChildren(treeId, treeNode, expandFlag) {
if (expandFlag === treeNode.open) {
return;
}
// 异步加载时需要加载全部子节点
const self = this;
const targetTree = $.fn.zTree.getZTreeObj(treeId);
if (targetTree.setting.async.enable && (!treeNode.children || treeNode.children.length === 0)) {
targetTree.reAsyncChildNodesPromise(treeNode, 'refresh', false).then(function () {
self.reAsyncChildNodes(treeId, treeNode, false);
});
} else {
// 展开时递归展开,防止用户手动展开子级折叠后无法再次展开孙子级
if (expandFlag) {
targetTree.expandNode(treeNode, expandFlag, false, false, false);
if (treeNode.children && treeNode.children.length > 0) {
treeNode.children.forEach(function(childNode) {
self.expandAllChildren(treeId, childNode, expandFlag);
});
}
} else {
targetTree.expandNode(treeNode, expandFlag, true, false, false);
}
}
}

onRightClick(event, treeId, treeNode) {
if (!treeNode) {
return null;
}
if (treeNode.id === 'myAssets') {
this.showRootRMenu(event.clientX, event.clientY);
return;
}
if (!treeNode || treeNode.isParent) {
return null;
if (treeNode.isParent) {
this.expandAllChildren(treeId, treeNode, !treeNode.open);
return;
}
this.rightClickSelectNode = treeNode;

Expand Down
8 changes: 4 additions & 4 deletions src/app/elements/connect/connect.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
}

selectLoginSystemUsers(systemUsers: Array<SystemUser>): Promise<SystemUser> {
const systemUserMaxPriority = this.filterMaxPrioritySystemUsers(systemUsers);
const systemUserMaxPriority = this.filterHighestPrioritySystemUsers(systemUsers);
let user: SystemUser;
const systemUserId = this._appSvc.getQueryString('system_user');
if (systemUserId) {
Expand Down Expand Up @@ -341,10 +341,10 @@ export class ElementConnectComponent implements OnInit, OnDestroy {
this.onNewView.emit(view);
}

filterMaxPrioritySystemUsers(sysUsers: Array<SystemUser>): Array<SystemUser> {
filterHighestPrioritySystemUsers(sysUsers: Array<SystemUser>): Array<SystemUser> {
const priorityAll: Array<number> = sysUsers.map(s => s.priority);
const maxPriority = Math.max(...priorityAll);
return sysUsers.filter(s => s.priority === maxPriority);
const HighestPriority = Math.min(...priorityAll);
return sysUsers.filter(s => s.priority === HighestPriority);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/elements/content/content.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="winContainer">
<elements-content-window *ngFor="let view of viewList" [view]="view" ></elements-content-window>
</div>
<div id="batchCommandDiv">
<div id="batchCommandDiv" *ngIf="settingSvc.setting.command_execution">
<input placeholder=" {{'Send text to all ssh terminals'| translate }} ..."
maxlength="2048"
title="{{'Send text to all ssh terminals'| translate }} ..."
Expand Down
6 changes: 4 additions & 2 deletions src/app/elements/content/content.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {View, ViewAction} from '@app/model';
import {ViewService} from '@app/services';
import {SettingService, ViewService} from '@app/services';
import * as jQuery from 'jquery/dist/jquery.min.js';

@Component({
Expand All @@ -23,7 +23,9 @@ export class ElementContentComponent implements OnInit {
return (this.viewList.length + 1) * 151 + 10;
}

constructor(private viewSrv: ViewService) {
constructor(private viewSrv: ViewService,
public settingSvc: SettingService
) {
}

ngOnInit() {
Expand Down
8 changes: 4 additions & 4 deletions src/app/elements/guacamole/guacamole.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export class ElementGuacamoleComponent implements OnInit {
this._http.getGuacamoleToken(this.token, this.token).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamoleToken = data['authToken'];
localStorage.setItem('guacamoleToken', data['authToken']);
DataStore.guacamoleTokenTime = nowTime;
action = this._http.guacamoleTokenAddAsset(this.token).subscribe(
data2 => {
const base = data2['result'];
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamoleToken;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + localStorage.getItem('guacamoleToken');
setTimeout(() => this.setIdleTimeout(), 500);
},
error => {
Expand All @@ -70,7 +70,7 @@ export class ElementGuacamoleComponent implements OnInit {
action.subscribe(
data => {
const base = data.result;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamoleToken;
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + localStorage.getItem('guacamoleToken');
setTimeout(() => this.setIdleTimeout(), 500);
},
error => {
Expand All @@ -90,7 +90,7 @@ export class ElementGuacamoleComponent implements OnInit {
this._http.getGuacamoleToken(User.id, '').subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamoleToken = data['authToken'];
localStorage.setItem('guacamoleToken', data['authToken']);
DataStore.guacamoleTokenTime = nowTime;
this.registerHost();
},
Expand Down
2 changes: 2 additions & 0 deletions src/app/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export class GlobalSetting {
WINDOWS_SKIP_ALL_MANUAL_PASSWORD: boolean;
SECURITY_MAX_IDLE_TIME: number;
XPACK_LICENSE_IS_VALID: boolean;
SECURITY_COMMAND_EXECUTION: boolean;
}

export class Setting {
Expand All @@ -207,6 +208,7 @@ export class Setting {
isSkipAllManualPassword: string = '0';
quickPaste = '0';
sqlClient = '1';
command_execution: boolean = true;
}


Expand Down
4 changes: 4 additions & 0 deletions src/app/services/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export class AppService implements OnInit {
user => {
Object.assign(User, user);
User.logined = true;
const oldUserId = this._localStorage.get('user');
if (oldUserId !== user.id ) {
this._localStorage.set('guacamoleToken', null);
}
this._localStorage.set('user', user.id);
},
err => {
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class HttpService {
.set('user_id', userId)
.set('asset_id', assetId)
.set('system_user_id', systemUserId)
.set('token', DataStore.guacamoleToken);
.set('token', localStorage.getItem('guacamoleToken'));
let body = new HttpParams();
if (systemUserUsername && systemUserPassword) {
systemUserUsername = btoa(systemUserUsername);
Expand Down Expand Up @@ -216,7 +216,7 @@ export class HttpService {
.set('user_id', userId)
.set('remote_app_id', remoteAppId)
.set('system_user_id', sysUserId)
.set('token', DataStore.guacamoleToken);
.set('token', localStorage.getItem('guacamoleToken'));
let body = new HttpParams();
if (systemUserUsername && systemUserPassword) {
systemUserUsername = btoa(systemUserUsername);
Expand All @@ -243,7 +243,7 @@ export class HttpService {
guacamoleTokenAddAsset(assetToken: string) {
let params = new HttpParams()
.set('asset_token', assetToken)
.set('token', DataStore.guacamoleToken);
.set('token', localStorage.getItem('guacamoleToken'));
const resolution = this.settingSrv.setting.rdpResolution || 'Auto';
if (resolution !== 'Auto') {
const width = resolution.split('x')[0];
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 @@ -22,6 +22,7 @@ export class SettingService {
}
this._http.get<any>('/api/v1/settings/public/').subscribe(resp => {
this.globalSetting = resp.data;
this.setting.command_execution = this.globalSetting.SECURITY_COMMAND_EXECUTION;
const link: any = document.querySelector('link[rel*=\'icon\']') || document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
Expand Down

0 comments on commit 8e3f135

Please sign in to comment.