Unverified Commit e7e68da2 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #59 from jumpserver/dev

Dev
parents 2eb94bcf 45e08752
...@@ -56,5 +56,8 @@ ...@@ -56,5 +56,8 @@
"connect": "连接", "connect": "连接",
"rdp resolution": "RDP分辨率", "rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率", "set rdp solution": "设置分辨率",
"select a solution": "选择分辨率" "select a solution": "选择分辨率",
"set font": "设置字体",
"font": "字体",
"font size": "字体大小"
} }
...@@ -56,5 +56,8 @@ ...@@ -56,5 +56,8 @@
"connect": "连接", "connect": "连接",
"rdp resolution": "RDP分辨率", "rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率", "set rdp solution": "设置分辨率",
"select a solution": "选择分辨率" "select a solution": "选择分辨率",
"set font": "设置字体",
"font": "字体",
"font size": "字体大小"
} }
...@@ -56,5 +56,8 @@ ...@@ -56,5 +56,8 @@
"connect": "连接", "connect": "连接",
"rdp resolution": "RDP分辨率", "rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率", "set rdp solution": "设置分辨率",
"select a solution": "选择分辨率" "select a solution": "选择分辨率",
"set font": "设置字体",
"font": "字体",
"font size": "字体大小"
} }
...@@ -129,7 +129,7 @@ class ProxyServer: ...@@ -129,7 +129,7 @@ class ProxyServer:
def ssh_with_password(self, width=80, height=24): def ssh_with_password(self, width=80, height=24):
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.244.142", 22, "root", "redhat") ssh.connect("192.168.244.185", 22, "root", "redhat")
chan = ssh.invoke_shell(term='xterm', width=width, height=height) chan = ssh.invoke_shell(term='xterm', width=width, height=height)
return chan return chan
...@@ -137,6 +137,7 @@ class ProxyServer: ...@@ -137,6 +137,7 @@ class ProxyServer:
class SSHws(ProxyNamespace): class SSHws(ProxyNamespace):
def connect_host(self, message): def connect_host(self, message):
print("Connect host: {}".format(message))
asset_id = message.get('uuid', None) asset_id = message.get('uuid', None)
system_user_id = message.get('userid', None) system_user_id = message.get('userid', None)
secret = message.get('secret', None) secret = message.get('secret', None)
...@@ -162,6 +163,7 @@ class SSHws(ProxyNamespace): ...@@ -162,6 +163,7 @@ class SSHws(ProxyNamespace):
def proxy(): def proxy():
forwarder.proxy() forwarder.proxy()
self.emit('data', {'data': 'Disconnected', 'room': client_id}, room=client_id)
self.logout(client_id, connection) self.logout(client_id, connection)
self.socketio.start_background_task(proxy) self.socketio.start_background_task(proxy)
......
This diff is collapsed.
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
"material-design-icons": "^3.0.1", "material-design-icons": "^3.0.1",
"materialize-css": "^0.100.2", "materialize-css": "^0.100.2",
"metismenu": "^2.7.9", "metismenu": "^2.7.9",
"mstsc.js": "^0.2.4",
"ng2-charts": "^1.5.0", "ng2-charts": "^1.5.0",
"ngx-bootstrap": "^1.6.6", "ngx-bootstrap": "^1.6.6",
"ngx-cookie-service": "^1.0.10", "ngx-cookie-service": "^1.0.10",
...@@ -69,6 +68,7 @@ ...@@ -69,6 +68,7 @@
"ssh-keygen": "^0.4.1", "ssh-keygen": "^0.4.1",
"tether": "^1.4.4", "tether": "^1.4.4",
"tslib": "^1.9.0", "tslib": "^1.9.0",
"utf-8-validate": "^5.0.2",
"uuid-js": "^0.7.5", "uuid-js": "^0.7.5",
"xterm": "^3.3.0", "xterm": "^3.3.0",
"zone.js": "0.8.20" "zone.js": "0.8.20"
...@@ -90,8 +90,8 @@ ...@@ -90,8 +90,8 @@
"karma-coverage-istanbul-reporter": "1.3.3", "karma-coverage-istanbul-reporter": "1.3.3",
"karma-jasmine": "1.1.1", "karma-jasmine": "1.1.1",
"karma-jasmine-html-reporter": "0.2.2", "karma-jasmine-html-reporter": "0.2.2",
"node-sass": "^4.9.0", "node-sass": "^4.11.0",
"protractor": "5.2.2", "protractor": "^5.4.2",
"ts-node": "3.3.0", "ts-node": "3.3.0",
"tslint": "5.9.1", "tslint": "5.9.1",
"typescript": "2.4.2" "typescript": "2.4.2"
......
...@@ -26,7 +26,7 @@ import {MAT_LABEL_GLOBAL_OPTIONS} from '@angular/material'; ...@@ -26,7 +26,7 @@ import {MAT_LABEL_GLOBAL_OPTIONS} from '@angular/material';
import {Pipes} from './pipes/pipes'; import {Pipes} from './pipes/pipes';
import {PagesComponents} from './pages/pages.component'; import {PagesComponents} from './pages/pages.component';
import {ElementComponents} from './elements/elements.component'; import {ElementComponents} from './elements/elements.component';
import {ChangLanWarningDialogComponent, RDPSolutionDialogComponent} from './elements/nav/nav.component'; import {ChangLanWarningDialogComponent, RDPSolutionDialogComponent, FontDialogComponent} from './elements/nav/nav.component';
import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service'; import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service';
import {PluginModules} from './plugins/plugins'; import {PluginModules} from './plugins/plugins';
import {TestPageComponent} from './test-page/test-page.component'; import {TestPageComponent} from './test-page/test-page.component';
...@@ -56,6 +56,7 @@ import {SftpComponent} from './elements/sftp/sftp.component'; ...@@ -56,6 +56,7 @@ import {SftpComponent} from './elements/sftp/sftp.component';
ElementDialogAlertComponent, ElementDialogAlertComponent,
ChangLanWarningDialogComponent, ChangLanWarningDialogComponent,
RDPSolutionDialogComponent, RDPSolutionDialogComponent,
FontDialogComponent
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
providers: [ providers: [
......
...@@ -14,7 +14,7 @@ import {ElementDialogAlertComponent} from './dialog/dialog.service'; ...@@ -14,7 +14,7 @@ import {ElementDialogAlertComponent} from './dialog/dialog.service';
import {ElementGuacamoleComponent} from './guacamole/guacamole.component'; import {ElementGuacamoleComponent} from './guacamole/guacamole.component';
import {ElementSshTermComponent} from './ssh-term/ssh-term.component'; import {ElementSshTermComponent} from './ssh-term/ssh-term.component';
import {AssetTreeDialogComponent, ElementAssetTreeComponent} from './asset-tree/asset-tree.component'; import {AssetTreeDialogComponent, ElementAssetTreeComponent} from './asset-tree/asset-tree.component';
import {RDPSolutionDialogComponent} from './nav/nav.component'; import {RDPSolutionDialogComponent, FontDialogComponent} from './nav/nav.component';
export const ElementComponents = [ export const ElementComponents = [
ElementLeftbarComponent, ElementLeftbarComponent,
...@@ -33,5 +33,6 @@ export const ElementComponents = [ ...@@ -33,5 +33,6 @@ export const ElementComponents = [
ElementAssetTreeComponent, ElementAssetTreeComponent,
ElementSshTermComponent, ElementSshTermComponent,
AssetTreeDialogComponent, AssetTreeDialogComponent,
RDPSolutionDialogComponent RDPSolutionDialogComponent,
FontDialogComponent
]; ];
<h1 mat-dialog-title>{{"Set font"|trans}}</h1>
<mat-form-field>
<input matInput placeholder='{{"Font size"|trans}}' name="fontSize" type="number" min="5" max="60" [(ngModel)]="fontSize">
</mat-form-field>
<div style="float: right">
<button mat-raised-button (click)="onNoClick()">{{"Cancel"|trans}}</button>
<button mat-raised-button color="primary" [disabled]="!isValid()" (click)="onSubmit()">{{"Confirm"|trans}}</button>
</div>
...@@ -12,7 +12,6 @@ import {ControlComponent, NavList, View} from '../../pages/control/control/contr ...@@ -12,7 +12,6 @@ import {ControlComponent, NavList, View} from '../../pages/control/control/contr
import {DataStore, i18n} from '../../globals'; import {DataStore, i18n} from '../../globals';
import * as jQuery from 'jquery/dist/jquery.min.js'; import * as jQuery from 'jquery/dist/jquery.min.js';
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material'; import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import {FormControl, Validators} from '@angular/forms';
declare let layer: any; declare let layer: any;
@Component({ @Component({
...@@ -34,7 +33,7 @@ export class ElementNavComponent implements OnInit { ...@@ -34,7 +33,7 @@ export class ElementNavComponent implements OnInit {
public _dialog: MatDialog, public _dialog: MatDialog,
private _localStorage: LocalStorageService) { private _localStorage: LocalStorageService) {
this._logger.log('nav.ts:NavComponent'); this._logger.log('nav.ts:NavComponent');
this.getnav(); this.getNav();
} }
ngOnInit() { ngOnInit() {
...@@ -111,13 +110,21 @@ export class ElementNavComponent implements OnInit { ...@@ -111,13 +110,21 @@ export class ElementNavComponent implements OnInit {
RDPSolutionDialogComponent, RDPSolutionDialogComponent,
{ {
height: '200px', height: '200px',
width: '300px', width: '300px'
data: { });
title: 'Warning', dialog.afterClosed().subscribe(result => {
note: 'The page will be reload, can you acceptable?', if (result) {
cancel: 'Cancel', console.log(result);
confirm: 'Confirm', }
}, });
break;
}
case 'SetFont': {
const dialog = this._dialog.open(
FontDialogComponent,
{
height: '200px',
width: '300px'
}); });
dialog.afterClosed().subscribe(result => { dialog.afterClosed().subscribe(result => {
if (result) { if (result) {
...@@ -194,7 +201,7 @@ export class ElementNavComponent implements OnInit { ...@@ -194,7 +201,7 @@ export class ElementNavComponent implements OnInit {
}); });
} }
getnav() { getNav() {
DataStore.Nav = [{ DataStore.Nav = [{
'id': 'File', 'id': 'File',
'name': 'Server', 'name': 'Server',
...@@ -235,6 +242,11 @@ export class ElementNavComponent implements OnInit { ...@@ -235,6 +242,11 @@ export class ElementNavComponent implements OnInit {
'click': 'SetResolution', 'click': 'SetResolution',
'name': 'RDP Resolution' 'name': 'RDP Resolution'
}, },
{
'id': 'Font',
'click': 'SetFont',
'name': 'Font'
},
{ {
'id': 'SplitVertical', 'id': 'SplitVertical',
'href': '', 'href': '',
...@@ -345,6 +357,7 @@ export class ElementNavComponent implements OnInit { ...@@ -345,6 +357,7 @@ export class ElementNavComponent implements OnInit {
@Component({ @Component({
selector: 'elements-nav-dialog', selector: 'elements-nav-dialog',
templateUrl: 'changeLanWarning.html', templateUrl: 'changeLanWarning.html',
styles: ['.mat-form-field { width: 100%; }']
}) })
export class ChangLanWarningDialogComponent implements OnInit { export class ChangLanWarningDialogComponent implements OnInit {
...@@ -363,6 +376,7 @@ export class ChangLanWarningDialogComponent implements OnInit { ...@@ -363,6 +376,7 @@ export class ChangLanWarningDialogComponent implements OnInit {
@Component({ @Component({
selector: 'elements-rdp-solution-dialog', selector: 'elements-rdp-solution-dialog',
templateUrl: 'rdpSolutionDialog.html', templateUrl: 'rdpSolutionDialog.html',
styles: ['.mat-form-field { width: 100%; }']
}) })
export class RDPSolutionDialogComponent implements OnInit { export class RDPSolutionDialogComponent implements OnInit {
solutions = ['Auto', '1024x768', '1366x768', '1400x900']; solutions = ['Auto', '1024x768', '1366x768', '1400x900'];
...@@ -390,3 +404,40 @@ export class RDPSolutionDialogComponent implements OnInit { ...@@ -390,3 +404,40 @@ export class RDPSolutionDialogComponent implements OnInit {
this.dialogRef.close(); this.dialogRef.close();
} }
} }
@Component({
selector: 'elements-font-size-dialog',
templateUrl: 'fontDialog.html',
styles: ['.mat-form-field { width: 100%; }']
})
export class FontDialogComponent implements OnInit {
fontSize: string;
solution: string;
cacheKey = 'fontSize';
constructor(public dialogRef: MatDialogRef<FontDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
ngOnInit() {
this.fontSize = localStorage.getItem(this.cacheKey) || '14';
}
setFontSize(value: string) {
localStorage.setItem(this.cacheKey, value);
}
isValid() {
const size = parseInt(this.fontSize, 10);
return size > 5 && size < 60;
}
onSubmit() {
this.setFontSize(this.fontSize);
this.dialogRef.close();
}
onNoClick(): void {
this.dialogRef.close();
}
}
...@@ -26,9 +26,10 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit { ...@@ -26,9 +26,10 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
ngOnInit() { ngOnInit() {
this.secret = this._uuid.gen(); this.secret = this._uuid.gen();
const fontSize = localStorage.getItem('fontSize') || '14';
this.term = new Terminal({ this.term = new Terminal({
fontFamily: '"Monaco", "Consolas", "monospace"', fontFamily: 'monaco, Consolas, "Lucida Console", monospace',
fontSize: 14, fontSize: parseInt(fontSize, 10),
rightClickSelectsWord: true, rightClickSelectsWord: true,
theme: { theme: {
background: '#1f1b1b' background: '#1f1b1b'
......
...@@ -57,10 +57,10 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -57,10 +57,10 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
const elementPaddingVer = elementPadding.top + elementPadding.bottom; const elementPaddingVer = elementPadding.top + elementPadding.bottom;
const elementPaddingHor = elementPadding.right + elementPadding.left; const elementPaddingHor = elementPadding.right + elementPadding.left;
const availableHeight = activeEle.height() - elementPaddingVer; const availableHeight = activeEle.height() - elementPaddingVer;
const availableWidth = activeEle.width() - elementPaddingHor - (<any>this.term)._core.viewport.scrollBarWidth; const availableWidth = activeEle.width() - elementPaddingHor - (<any>this.term).viewport.scrollBarWidth;
const geometry = [ const geometry = [
Math.floor(availableWidth / (<any>this.term)._core.renderer.dimensions.actualCellWidth) - 1, Math.floor(availableWidth / (<any>this.term).renderer.dimensions.actualCellWidth) - 1,
Math.floor(availableHeight / (<any>this.term)._core.renderer.dimensions.actualCellHeight) - 1 Math.floor(availableHeight / (<any>this.term).renderer.dimensions.actualCellHeight) - 1
]; ];
return geometry; return geometry;
} }
...@@ -70,7 +70,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -70,7 +70,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
if (isNaN(size[0]) || isNaN(size[1])) { if (isNaN(size[0]) || isNaN(size[1])) {
fit(this.term); fit(this.term);
} else { } else {
(<any>this.term)._core.renderer.clear(); (<any>this.term).renderer.clear();
this.term.resize(size[0], size[1]); this.term.resize(size[0], size[1]);
} }
this.winSizeChangeTrigger.emit([this.term.cols, this.term.rows]); this.winSizeChangeTrigger.emit([this.term.cols, this.term.rows]);
......
...@@ -23,9 +23,11 @@ export class AppComponent { ...@@ -23,9 +23,11 @@ export class AppComponent {
@HostListener('window:beforeunload', ['$event']) @HostListener('window:beforeunload', ['$event'])
unloadNotification($event: any) { unloadNotification($event: any) {
const notInIframe = window.self === window.top; const notInIframe = window.self === window.top;
if (environment.production && notInIframe) { const notInReplay = location.pathname.indexOf('/luna/replay') === -1;
$event.returnValue = true; if (environment.production && notInIframe && notInReplay) {
return false;
} }
return true;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment