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