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

Merge pull request #31 from jumpserver/dev

优化Luna左侧树,使用websocket等
parents fc19819e a0bb32eb
cn.json
\ No newline at end of file
This diff is collapsed.
{ {
"name": "luna", "name": "luna",
"version": "1.0.0", "version": "1.3.0",
"license": "GPLv3", "license": "GPLv3",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json", "start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build --environment prod --base-href=/luna/ --deploy '/luna/'", "build": "ng build --environment prod --aot --prod --base-href=/luna/ --deploy '/luna/'",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e" "e2e": "ng e2e"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^5.2.0", "@angular/animations": "^5.2.10",
"@angular/cdk": "^5.2.0", "@angular/cdk": "^5.2.5",
"@angular/common": "5.2.0", "@angular/common": "5.2.0",
"@angular/compiler": "5.2.0", "@angular/compiler": "5.2.0",
"@angular/core": "5.2.0", "@angular/core": "5.2.0",
"@angular/flex-layout": "^5.0.0-beta.14",
"@angular/forms": "5.2.0", "@angular/forms": "5.2.0",
"@angular/http": "5.2.0", "@angular/http": "5.2.0",
"@angular/material": "^5.1.1", "@angular/material": "^5.2.5",
"@angular/platform-browser": "5.2.0", "@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0", "@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0", "@angular/router": "5.2.0",
"@swimlane/ngx-datatable": "^11.1.7", "@swimlane/ngx-datatable": "^11.3.2",
"@swimlane/ngx-ui": "^20.2.0", "@swimlane/ngx-ui": "^20.2.1",
"ajv": "^6.2.1", "ajv": "^6.5.0",
"animate.css": "^3.5.2", "animate.css": "^3.6.1",
"body-parser": "^1.18.2", "body-parser": "^1.18.2",
"bootstrap": "^4.0.0-beta.3", "bootstrap": "^4.1.1",
"clipboard": "^1.7.1", "clipboard": "^1.7.1",
"compass-mixins": "^0.12.10", "compass-mixins": "^0.12.10",
"core-js": "2.5.3", "core-js": "2.5.3",
"directory-encoder": "^0.9.2", "directory-encoder": "^0.9.2",
"elfinder": "^2.1.33", "elfinder": "git+https://github.com/Studio-42/elFinder.git#2.1.33",
"filetree-css": "^1.0.0", "filetree-css": "^1.0.0",
"font-awesome": "4.7.0", "font-awesome": "4.7.0",
"guacamole-common-js": "^0.9.14-b", "guacamole-common-js": "^0.9.14-b",
...@@ -44,42 +43,43 @@ ...@@ -44,42 +43,43 @@
"jquery-slimscroll": "^1.3.8", "jquery-slimscroll": "^1.3.8",
"jquery-sparkline": "^2.4.0", "jquery-sparkline": "^2.4.0",
"jvectormap": "1.2.2", "jvectormap": "1.2.2",
"lodash": "^4.17.5", "lodash": "^4.17.10",
"material-design-icons": "^3.0.1", "material-design-icons": "^3.0.1",
"materialize-css": "^0.100.2", "materialize-css": "^0.100.2",
"metismenu": "^2.5.0", "metismenu": "^2.7.7",
"mstsc.js": "^0.2.4", "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",
"ngx-layer": "0.0.4", "ngx-layer": "0.0.4",
"ngx-logger": "^1.1.2", "ngx-logger": "^2.2.4",
"ngx-perfect-scrollbar": "5.2.0", "ngx-perfect-scrollbar": "5.2.0",
"ngx-progressbar": "^2.1.1", "ngx-progressbar": "^2.1.1",
"npm-font-open-sans": "^1.1.0", "npm-font-open-sans": "^1.1.0",
"peity": "^3.2.1", "peity": "^3.3.0",
"popper.js": "1.12.9", "popper.js": "1.12.9",
"requirejs": "^2.3.5", "requirejs": "^2.3.5",
"roboto-fontface": "^0.8.0", "roboto-fontface": "^0.8.0",
"rxjs": "5.5.6", "rxjs": "5.5.6",
"sass-math": "^1.0.0", "sass-math": "^1.0.0",
"socket.io": "^2.0.3", "socket.io": "^2.1.0",
"socket.io-client": "^2.1.0", "socket.io-client": "^2.1.0",
"ssh-keygen": "^0.4.1", "ssh-keygen": "^0.4.1",
"tether": "^1.4.0", "tether": "^1.4.4",
"tslib": "^1.9.0", "tslib": "^1.9.0",
"uuid-js": "^0.7.5", "uuid-js": "^0.7.5",
"xterm": "^2.9.2", "xterm": "^3.3.0",
"zone.js": "0.8.20" "zone.js": "0.8.20"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/core": "^0.4.2", "@angular-devkit/core": "^0.4.9",
"@angular-devkit/schematics": "^0.4.2", "@angular-devkit/schematics": "^0.4.9",
"@angular/cli": "^1.7.3", "@angular/cli": "^1.7.4",
"@angular/compiler-cli": "5.2.0", "@angular/compiler-cli": "5.2.0",
"@angular/language-service": "5.2.0", "@angular/language-service": "5.2.0",
"@types/jasmine": "2.8.4", "@types/jasmine": "2.8.4",
"@types/jasminewd2": "~2.0.2", "@types/jasminewd2": "~2.0.2",
"@types/xterm": "^3.0.0",
"codelyzer": "4.0.2", "codelyzer": "4.0.2",
"jasmine-core": "2.8.0", "jasmine-core": "2.8.0",
"jasmine-spec-reporter": "4.2.1", "jasmine-spec-reporter": "4.2.1",
......
@import "~@swimlane/ngx-ui/release/components/tree/tree.component";
@import "~@swimlane/ngx-ui/release/components/icon/icon.component";
.ztree { .ztree {
height: 100%; height: 100%;
......
...@@ -32,7 +32,12 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -32,7 +32,12 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
hiddenNodes: any; hiddenNodes: any;
onCzTreeOnClick(event, treeId, treeNode, clickFlag) { onCzTreeOnClick(event, treeId, treeNode, clickFlag) {
this.Connect(treeNode); if (treeNode.isParent) {
const zTreeObj = $.fn.zTree.getZTreeObj('ztree');
zTreeObj.expandNode(treeNode);
} else {
this.Connect(treeNode);
}
} }
constructor(private _appService: AppService, constructor(private _appService: AppService,
...@@ -58,51 +63,36 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -58,51 +63,36 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
draw() { draw() {
const nodes = {}; const nodes = {};
const assets = {}; const assets = {};
this.Data.forEach((v, i) => { this.Data.forEach(node => {
if (!nodes[v['id']]) { if (!nodes[node['id']]) {
nodes[v['id']] = true; nodes[node['id']] = true;
this.nodes.push({ this.nodes.push({
'id': v['id'], 'id': node['id'],
'key': v['key'], 'key': node['key'],
'name': v['name'], 'name': node['name'],
'value': v['value'], 'value': node['value'],
'pId': v['parent'], 'pId': node['parent'],
'assets_amount': v['assets_amount'], 'assets_amount': node['assets_amount'],
'isParent': true, 'isParent': true,
'open': v['key'] === '0' 'open': node['key'] === '0'
}); });
} }
v['assets_granted'].forEach((vv, ii) => { node['assets_granted'].forEach(asset => {
vv['nodes'].forEach((vvv, iii) => { if (!assets[asset['id']]) {
if (!nodes[vvv['id']]) { this.nodes.push({
this.nodes.push({ 'id': asset['id'],
'id': vvv['id'], 'name': asset['hostname'],
'key': vvv['key'], 'value': asset['hostname'],
'name': vvv['value'], 'system_users_granted': asset['system_users_granted'],
'value': vvv['value'], 'platform': asset['platform'],
'pId': vvv['parent'], 'comment': asset['comment'],
'assets_amount': vvv['assets_amount'], 'isParent': false,
'isParent': true, 'pId': node['id'],
'open': vvv['key'] === '0' 'iconSkin': asset['platform'].toLowerCase()
}); });
nodes[vvv['id']] = true; assets[asset['id'] + '@' + node['id']] = true;
} }
if (!assets[vv['id'] + '@' + vvv['id']]) {
this.nodes.push({
'id': vv['id'],
'name': vv['hostname'],
'value': vv['hostname'],
'system_users_granted': vv['system_users_granted'],
'platform': vv['platform'],
'comment': vv['comment'],
'isParent': false,
'pId': vvv['id'],
'iconSkin': vv['platform'].toLowerCase()
});
assets[vv['id'] + '@' + vvv['id']] = true;
}
});
}); });
}); });
this.nodes.sort(function(node1, node2) { this.nodes.sort(function(node1, node2) {
...@@ -143,6 +133,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -143,6 +133,8 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
} else if (host.system_users_granted.length === 1) { } else if (host.system_users_granted.length === 1) {
user = host.system_users_granted[0]; user = host.system_users_granted[0];
this.login(host, user); this.login(host, user);
} else {
alert('该主机没有授权登录用户');
} }
} }
...@@ -184,10 +176,10 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -184,10 +176,10 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
filter() { filter() {
const zTreeObj = $.fn.zTree.getZTreeObj('ztree'); const zTreeObj = $.fn.zTree.getZTreeObj('ztree');
const _keywords = $('#keyword').val();
zTreeObj.showNodes(this.hiddenNodes); zTreeObj.showNodes(this.hiddenNodes);
function filterFunc(node) { function filterFunc(node) {
const _keywords = $('#keyword').val();
if (node.isParent || node.name.indexOf(_keywords) !== -1) { if (node.isParent || node.name.indexOf(_keywords) !== -1) {
return false; return false;
} }
...@@ -195,9 +187,12 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -195,9 +187,12 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
} }
this.hiddenNodes = zTreeObj.getNodesByFilter(filterFunc); this.hiddenNodes = zTreeObj.getNodesByFilter(filterFunc);
zTreeObj.hideNodes(this.hiddenNodes); zTreeObj.hideNodes(this.hiddenNodes);
zTreeObj.expandAll(true); if (_keywords) {
zTreeObj.expandAll(true);
} else {
zTreeObj.expandAll(false);
}
} }
} }
......
...@@ -13,7 +13,6 @@ import {DataStore, i18n} from '../../globals'; ...@@ -13,7 +13,6 @@ 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'; import {FormControl, Validators} from '@angular/forms';
// import * as layer from 'layui-layer/src/layer.js';
declare let layer: any; declare let layer: any;
@Component({ @Component({
...@@ -66,6 +65,9 @@ export class ElementNavComponent implements OnInit { ...@@ -66,6 +65,9 @@ export class ElementNavComponent implements OnInit {
break; break;
} }
case'Disconnect': { case'Disconnect': {
if (!confirm('断开当前连接? (RDP暂不支持)')) {
break;
}
switch (NavList.List[NavList.Active].type) { switch (NavList.List[NavList.Active].type) {
case 'ssh': { case 'ssh': {
ControlComponent.TerminalDisconnect(NavList.Active); ControlComponent.TerminalDisconnect(NavList.Active);
...@@ -83,6 +85,9 @@ export class ElementNavComponent implements OnInit { ...@@ -83,6 +85,9 @@ export class ElementNavComponent implements OnInit {
break; break;
} }
case'DisconnectAll': { case'DisconnectAll': {
if (!confirm('断开所有连接? (RDP暂不支持)')) {
break;
}
ControlComponent.DisconnectAll(); ControlComponent.DisconnectAll();
break; break;
} }
...@@ -255,12 +260,8 @@ export class ElementNavComponent implements OnInit { ...@@ -255,12 +260,8 @@ export class ElementNavComponent implements OnInit {
'href': '', 'href': '',
'name': 'Share session (read/write)', 'name': 'Share session (read/write)',
'disable': true 'disable': true
}, }
{ ]
'id': 'Settings',
'click': 'Settings',
'name': 'Settings'
}]
}, { }, {
'id': 'Help', 'id': 'Help',
'name': 'Help', 'name': 'Help',
......
import {AfterViewInit, Component, Input, OnInit } from '@angular/core'; import {AfterViewInit, Component, Input, OnInit } from '@angular/core';
import * as io from 'socket.io-client'; import {Terminal} from 'xterm';
// import {ws} from '../../globals';
import * as Terminal from 'xterm/dist/xterm';
import {NavList} from '../../pages/control/control/control.component'; import {NavList} from '../../pages/control/control/control.component';
import {UUIDService} from '../../app.service'; import {UUIDService} from '../../app.service';
import {CookieService} from 'ngx-cookie-service';
import {TermWS} from '../../globals';
const ws = io.connect('/ssh'); const ws = TermWS;
@Component({ @Component({
selector: 'elements-ssh-term', selector: 'elements-ssh-term',
...@@ -21,17 +21,22 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit { ...@@ -21,17 +21,22 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
term: Terminal; term: Terminal;
secret: string; secret: string;
constructor(private _uuid: UUIDService) { constructor(private _uuid: UUIDService, private _cookie: CookieService) {
} }
ngOnInit() { ngOnInit() {
this.secret = this._uuid.gen(); this.secret = this._uuid.gen();
this.term = new Terminal({ this.term = new Terminal({
// cols: 80, fontFamily: '"Monaco", "Consolas", "monospace"',
// rows: 24, fontSize: 14,
useStyle: true, rightClickSelectsWord: true,
screenKeys: true, theme: {
background: '#1f1b1b'
}
}); });
const rowInit = parseInt(this._cookie.get('rows') || '24', 10);
const colsInit = parseInt(this._cookie.get('cols') || '80', 10);
this.term.resize(colsInit, rowInit);
} }
ngAfterViewInit() { ngAfterViewInit() {
...@@ -57,34 +62,35 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit { ...@@ -57,34 +62,35 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
}); });
ws.on('data', data => { ws.on('data', data => {
if (data['room'] === NavList.List[that.index].room) { const view = NavList.List[that.index];
if (view && data['room'] === view.room) {
that.term.write(data['data']); that.term.write(data['data']);
} }
}); });
ws.on('disconnect', () => { ws.on('disconnect', () => {
that.disconnect(); that.close();
}); });
ws.on('logout', (data) => { ws.on('logout', (data) => {
if (data['room'] === NavList.List[that.index].room) { if (data['room'] === NavList.List[that.index].room) {
NavList.List[that.index].connected = false; NavList.List[that.index].connected = false;
// this.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
} }
}); });
ws.on('room', data => { ws.on('room', data => {
console.log('Compile secret: ', data['secret'], this.secret);
if (data['secret'] === this.secret) { if (data['secret'] === this.secret) {
console.log('Set room: ', data['room']);
NavList.List[that.index].room = data['room']; NavList.List[that.index].room = data['room'];
console.log('get', that.index, 'room: ', NavList.List[that.index].room);
} }
}); });
} }
disconnect() { close() {
NavList.List[this.index].connected = false; const view = NavList.List[this.index];
// this.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n'); if (view) {
ws.emit('logout', NavList.List[this.index].room); NavList.List[this.index].connected = false;
ws.emit('logout', NavList.List[this.index].room);
}
} }
active() { active() {
......
...@@ -17,18 +17,18 @@ div { ...@@ -17,18 +17,18 @@ div {
*padding: 15px 0 15px 15px;; *padding: 15px 0 15px 15px;;
} }
div.terminal div span { /*div.terminal div span {*/
min-width: 12px; /*min-width: 12px;*/
} /*}*/
.terminal div { /*.terminal div {*/
user-select: text; /*user-select: text;*/
} /*}*/
/*.terminal, .terminal .xterm-viewport {*/ /*.terminal, .terminal .xterm-viewport {*/
/*background-color: inherit;*/ /*background-color: inherit;*/
/*}*/ /*}*/
.terminal .xterm-rows { /*.terminal .xterm-rows {*/
background-color: #1f1b1b; /*background-color: #1f1b1b;*/
} /*}*/
<div style="padding: 15px"> <div style='padding:15px 0 15px 15px'>
<div #term (mouseenter)="active()"></div> <div #term (mouseenter)="active()"></div>
</div> </div>
import {AfterViewInit, Component, Input, Output, OnInit, ViewChild, EventEmitter} from '@angular/core'; import {AfterViewInit, Component, Input, Output, OnInit, ViewChild, EventEmitter} from '@angular/core';
import {ElementRef} from '@angular/core'; import {ElementRef} from '@angular/core';
import * as Terminal from 'xterm/dist/xterm'; import {Terminal} from 'xterm';
// import { Terminal } from 'xterm'; import {fit} from 'xterm/lib/addons/fit/fit';
import * as $ from 'jquery/dist/jquery.min.js';
import {Observable} from 'rxjs/Rx'; import {Observable} from 'rxjs/Rx';
import {CookieService} from 'ngx-cookie-service';
import * as $ from 'jquery/dist/jquery.min.js';
import 'rxjs/Observable'; import 'rxjs/Observable';
import 'rxjs/add/operator/debounceTime'; import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged'; import 'rxjs/add/operator/distinctUntilChanged';
import {NavList} from '../../pages/control/control/control.component';
@Component({ @Component({
selector: 'elements-term', selector: 'elements-term',
templateUrl: './term.component.html', templateUrl: './term.component.html',
...@@ -17,11 +21,9 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -17,11 +21,9 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@ViewChild('term') el: ElementRef; @ViewChild('term') el: ElementRef;
@Input() term: Terminal; @Input() term: Terminal;
@Output() winSizeChangeTrigger = new EventEmitter<Array<number>>(); @Output() winSizeChangeTrigger = new EventEmitter<Array<number>>();
col = 80;
row = 24;
winSizeChange$: Observable<any>; winSizeChange$: Observable<any>;
constructor() { constructor(private _cookie: CookieService) {
} }
ngOnInit() { ngOnInit() {
...@@ -30,29 +32,37 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -30,29 +32,37 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
.distinctUntilChanged(); .distinctUntilChanged();
this.winSizeChange$ this.winSizeChange$
.subscribe(() => this.resizeTerm()); .subscribe(() => {
if (NavList.List[NavList.Active].type === 'ssh') {
this.resizeTerm();
}
});
} }
ngAfterViewInit() { ngAfterViewInit() {
this.term.open(this.el.nativeElement, true); this.term.open(this.el.nativeElement);
this.resizeTerm(); this.resizeTerm();
} }
getWinSize() {
const activeEle = $('#winContainer');
const markerEle = $('#marker');
const cols = Math.floor(activeEle.width() / markerEle.width() * 6) - 6;
const rows = Math.floor(activeEle.height() / markerEle.height()) - 1;
return [cols, rows];
}
resizeTerm() { resizeTerm() {
let contentElement = $('.window.active'); // fit(this.term);
if (contentElement.length === 0) { const size = this.getWinSize();
contentElement = $('body'); if (isNaN(size[0])) {
fit(this.term);
} else {
this.term.resize(size[0], size[1]);
this.winSizeChangeTrigger.emit([this.term.cols, this.term.rows]);
} }
const markerElement = $('#marker'); this._cookie.set('cols', this.term.cols.toString(), 0, '/', document.domain);
const col = Math.floor((contentElement.width() - 30) / markerElement.width() * 6) - 1; this._cookie.set('rows', this.term.rows.toString(), 0, '/', document.domain);
const row = Math.floor((contentElement.height() - 30) / markerElement.height());
this.col = col > 80 ? col : 80;
this.row = row > 24 ? row : 24;
console.log('Box size: ', contentElement.width(), '*', contentElement.height());
console.log('Mark size: ', markerElement.width(), '*', markerElement.height());
console.log('Resize term size: ', this.col, this.row);
this.term.resize(this.col, this.row);
this.winSizeChangeTrigger.emit([this.col, this.row]);
} }
active() { active() {
......
'use strict'; 'use strict';
import * as terminal from 'xterm/dist/xterm';
import * as io from 'socket.io-client'; import * as io from 'socket.io-client';
import {Terminal} from 'xterm';
export function Terminal(xargs: any) {
return terminal(xargs);
}
export const TermWS = io.connect('/ssh'); export const TermWS = io.connect('/ssh');
export let term: {
term: any;
col: number;
row: number;
} = {
term: Terminal({
cols: 80,
rows: 24,
useStyle: true,
screenKeys: true,
scrollback: 10
}),
col: 80,
row: 24,
};
export const sep = '/'; export const sep = '/';
export let Video: { export let Video: {
id: string, id: string,
...@@ -153,4 +134,3 @@ export let wsEvent: { ...@@ -153,4 +134,3 @@ export let wsEvent: {
}; };
export const i18n = new Map(); export const i18n = new Map();
...@@ -26,14 +26,12 @@ export class PagesConnectComponent implements OnInit { ...@@ -26,14 +26,12 @@ export class PagesConnectComponent implements OnInit {
this.system = this._appService.getQueryString('system'); this.system = this._appService.getQueryString('system');
this.token = this._appService.getQueryString('token'); this.token = this._appService.getQueryString('token');
jQuery('body').css('background-color', 'black');
this.userid = this._localStorage.get('user-' + this.token); this.userid = this._localStorage.get('user-' + this.token);
this.authToken = this._localStorage.get('authToken-' + this.token); this.authToken = this._localStorage.get('authToken-' + this.token);
this.base = this._localStorage.get('base-' + this.token); this.base = this._localStorage.get('base-' + this.token);
jQuery('body').css('background-color', '#1f1b1b');
if (this.system === 'windows') { if (this.system === 'windows') {
if (!this.userid) { if (!this.userid) {
this._http.get_user_id_from_token(this.token) this._http.get_user_id_from_token(this.token)
.subscribe( .subscribe(
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div fxFlex="1 1 20%" minBasis="100px" maxBasis="800px" fxFlexFill ngxSplitArea *ngIf="DataStore.leftbarshow"> <div fxFlex="1 1 20%" minBasis="100px" maxBasis="800px" fxFlexFill ngxSplitArea *ngIf="DataStore.leftbarshow">
<pages-control-cleftbar></pages-control-cleftbar> <pages-control-cleftbar></pages-control-cleftbar>
</div> </div>
<div fxFlex="0" ngxSplitHandle></div> <div fxFlex="0" ngxSplitHandle [style.display]="activeViewIsRdp() ? 'none' : 'block'" (mouseup)="dragSplitBtn($event)"></div>
<div fxFlex="1 1 80%" ngxSplitArea class="content"> <div fxFlex="1 1 80%" ngxSplitArea class="content">
<pages-control-control></pages-control-control> <pages-control-control></pages-control-control>
</div> </div>
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
* @author liuzheng <liuzheng712@gmail.com> * @author liuzheng <liuzheng712@gmail.com>
*/ */
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {AppService} from '../../app.service';
import {DataStore, User} from '../../globals'; import {DataStore, User} from '../../globals';
import {NavList} from './control/control.component';
@Component({ @Component({
selector: 'pages-control', selector: 'pages-control',
...@@ -21,6 +21,14 @@ export class PagesControlComponent implements OnInit { ...@@ -21,6 +21,14 @@ export class PagesControlComponent implements OnInit {
constructor() { constructor() {
} }
activeViewIsRdp() {
return NavList.List[NavList.Active].type === 'rdp';
}
dragSplitBtn(evt) {
window.dispatchEvent(new Event('resize'));
}
ngOnInit() { ngOnInit() {
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div fxFlex="0 0 30px" class="search"> <div fxFlex="0 0 30px" class="search">
<pages-control-nav></pages-control-nav> <pages-control-nav></pages-control-nav>
</div> </div>
<div fxFlex="0 0 calc(100%-35px)"> <div fxFlex="0 0 calc(100%-35px)" id="winContainer">
<div class="window" *ngFor="let m of NavList.List;let i=index" <div class="window" *ngFor="let m of NavList.List;let i=index"
[ngClass]="{'active':i==NavList.Active}" style="height: 100%"> [ngClass]="{'active':i==NavList.Active}" style="height: 100%">
<elements-ssh-term [index]="i" <elements-ssh-term [index]="i"
......
...@@ -69,7 +69,6 @@ export class ControlComponent implements OnInit { ...@@ -69,7 +69,6 @@ export class ControlComponent implements OnInit {
} }
static DisconnectAll() { static DisconnectAll() {
alert('DisconnectAll');
for (let i = 0; i < NavList.List.length; i++) { for (let i = 0; i < NavList.List.length; i++) {
ControlComponent.TerminalDisconnect(i); ControlComponent.TerminalDisconnect(i);
} }
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IleftbarComponent } from './ileftbar.component';
describe('IleftbarComponent', () => {
let component: IleftbarComponent;
let fixture: ComponentFixture<IleftbarComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ IleftbarComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(IleftbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});
/**
* 主页的左边栏
*
*
* @date 2017-11-07
* @author liuzheng <liuzheng712@gmail.com>
*/
import {Component, OnInit} from '@angular/core';
import {AppService, LogService} from '../../../app.service';
@Component({
selector: 'pages-ileftbar',
templateUrl: './ileftbar.component.html',
styleUrls: ['./ileftbar.component.css']
})
export class IleftbarComponent implements OnInit {
constructor(private _appService: AppService,
private _logger: LogService) {
this._logger.log('nav.ts:NavComponent');
// this._appService.getnav()
}
ngOnInit() {
}
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {IleftbarComponent} from './ileftbar.component';
@NgModule({
imports: [
CommonModule
],
declarations: [
IleftbarComponent
]
})
export class IleftbarModule {
}
...@@ -8,7 +8,6 @@ import {PagesReplayComponent} from './replay/replay.component'; ...@@ -8,7 +8,6 @@ import {PagesReplayComponent} from './replay/replay.component';
import {PagesNotFoundComponent} from './not-found/not-found.component'; import {PagesNotFoundComponent} from './not-found/not-found.component';
import {PagesLoginComponent} from './login/login.component'; import {PagesLoginComponent} from './login/login.component';
import {CleftbarComponent} from './control/cleftbar/cleftbar.component'; import {CleftbarComponent} from './control/cleftbar/cleftbar.component';
import {Mp4Component} from './replay/mp4/mp4.component';
import {JsonComponent} from './replay/json/json.component'; import {JsonComponent} from './replay/json/json.component';
import {ControlComponent} from './control/control/control.component'; import {ControlComponent} from './control/control/control.component';
import {PagesControlNavComponent} from './control/control/controlnav/nav.component'; import {PagesControlNavComponent} from './control/control/controlnav/nav.component';
...@@ -24,7 +23,7 @@ export const PagesComponents = [ ...@@ -24,7 +23,7 @@ export const PagesComponents = [
CleftbarComponent, CleftbarComponent,
PagesIndexComponent, PagesIndexComponent,
PagesMonitorComponent, PagesMonitorComponent,
PagesReplayComponent, Mp4Component, JsonComponent, PagesReplayComponent, JsonComponent,
// PagesSettingComponent, // PagesSettingComponent,
PagesNotFoundComponent, PagesNotFoundComponent,
PagesLoginComponent, PagesLoginComponent,
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<div class="seek-notification"> <div class="seek-notification">
<p> <p>
Seek in progress... Seek in progress...
<button id="cancel-seek" class="btn" (click)="cancelSeek()">Cancel</button> <button id="cancel-seek" class="btn" (click)="cancelSeek($event)">Cancel</button>
</p> </p>
</div> </div>
</div> </div>
......
...@@ -3,19 +3,19 @@ import * as Guacamole from 'guacamole-common-js/dist/guacamole-common'; ...@@ -3,19 +3,19 @@ import * as Guacamole from 'guacamole-common-js/dist/guacamole-common';
import { Replay } from '../replay.model'; import { Replay } from '../replay.model';
function zeroPad(num, minLength) { function zeroPad(num, minLength) {
let str = num.toString(); let str = num.toString();
// Add leading zeroes until string is long enough // Add leading zeroes until string is long enough
while (str.length < minLength) { while (str.length < minLength) {
str = '0' + str; str = '0' + str;
} }
return str; return str;
} }
function formatTime(millis) { function formatTime(millis: number) {
const totalSeconds = Math.floor(millis / 1000); const totalSeconds = Math.floor(millis / 1000);
const seconds = totalSeconds % 60; const seconds = totalSeconds % 60;
const minutes = Math.floor(totalSeconds / 60); const minutes = Math.floor(totalSeconds / 60);
return zeroPad(minutes, 2) + ':' + zeroPad(seconds, 2); return zeroPad(minutes, 2) + ':' + zeroPad(seconds, 2);
} }
@Component({ @Component({
...@@ -25,7 +25,7 @@ function formatTime(millis) { ...@@ -25,7 +25,7 @@ function formatTime(millis) {
}) })
export class ReplayGuacamoleComponent implements OnInit { export class ReplayGuacamoleComponent implements OnInit {
isPlaying = false; isPlaying = false;
recording: Guacamole.SessionRecording; recording: any;
playerRef: any; playerRef: any;
displayRef: any; displayRef: any;
max = 100; max = 100;
...@@ -64,7 +64,7 @@ export class ReplayGuacamoleComponent implements OnInit { ...@@ -64,7 +64,7 @@ export class ReplayGuacamoleComponent implements OnInit {
initRecording() { initRecording() {
const that = this; const that = this;
this.recording.connect(); this.recording.connect('');
this.recording.onplay = function() { this.recording.onplay = function() {
that.isPlaying = true; that.isPlaying = true;
}; };
......
import {Component, Input, OnInit} from '@angular/core'; import {Component, Input, OnInit} from '@angular/core';
import * as Terminal from 'xterm/dist/xterm'; import {Terminal} from 'xterm';
import {HttpService, LogService} from '../../../app.service'; import {HttpService, LogService} from '../../../app.service';
import {Replay} from '../replay.model'; import {Replay} from '../replay.model';
...@@ -25,7 +25,14 @@ export class JsonComponent implements OnInit { ...@@ -25,7 +25,14 @@ export class JsonComponent implements OnInit {
constructor(private _http: HttpService) {} constructor(private _http: HttpService) {}
ngOnInit() { ngOnInit() {
this.term = new Terminal(); this.term = new Terminal({
fontFamily: '"Monaco", "Consolas", "monospace"',
fontSize: 14,
rightClickSelectsWord: true,
theme: {
background: '#1f1b1b'
}
});
if (this.replay.src !== 'READY') { if (this.replay.src !== 'READY') {
this._http.get_replay_data(this.replay.src) this._http.get_replay_data(this.replay.src)
.subscribe( .subscribe(
......
<div [ngStyle]="{'width.px': 800,'height.px': 600}">
<video controls>
<source [src]="replay.src" type="video/mp4">
Your browser does not support the video tag.
<br>
您的浏览器不支持,请升级
</video>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Mp4Component } from './mp4.component';
describe('Mp4Component', () => {
let component: Mp4Component;
let fixture: ComponentFixture<Mp4Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Mp4Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Mp4Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import {Component, Input, OnInit} from '@angular/core';
import {Replay} from '../replay.model';
@Component({
selector: 'app-replay-mp4',
templateUrl: './mp4.component.html',
styleUrls: ['./mp4.component.css']
})
export class Mp4Component implements OnInit {
@Input() replay: Replay;
constructor() {
}
ngOnInit() {
if (this.replay.height === 0) {
this.replay.height = 600;
}
if (this.replay.width === 0) {
this.replay.width = 800;
}
}
}
...@@ -27,31 +27,14 @@ export class PagesReplayComponent implements OnInit { ...@@ -27,31 +27,14 @@ export class PagesReplayComponent implements OnInit {
this._http.get_replay_json(token) this._http.get_replay_json(token)
.subscribe( .subscribe(
data => { data => {
// this.replay = data.json() as Replay;
this.replay.type = data['type']; this.replay.type = data['type'];
this.replay.src = data['src']; this.replay.src = data['src'];
this.replay.id = data['id']; this.replay.id = data['id'];
},
err => {
this._http.get_replay(token);
alert('没找到录像文件');
} }
// err => {
// this._http.get_replay(token)
// .subscribe(
// data => {
// this.replay.type = 'json';
// this.replay.json = data;
// this.replay.src = 'READY';
// this.replay.timelist = Object.keys(this.replay.json).map(Number);
// this.replay.timelist = this.replay.timelist.sort(function (a, b) {
// return a - b;
// });
// this.replay.totalTime = this.replay.timelist[this.replay.timelist.length - 1] * 1000;
//
// }, err2 => {
// alert('无法下载');
// this._logger.error(err2);
// },
// );
// }
); );
} }
} }
export const environment = { export const environment = {
production: true production: true
}; };
export const version = '1.3.0-{{BUILD_NUMBER}} GPLv2.'; // export const version = '1.3.0-{{BUILD_NUMBER}} GPLv2.';
\ No newline at end of file // export const version = '1.3.0-101 GPLv2.';
export const version = '1.3.0-{{BUILD_NUMBER}} GPLv2.';
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
<span id="marker" style="display: none">marker</span> <span id="marker" style="display: none;font-size: 14px">marker</span>
</body> </body>
</html> </html>
...@@ -94,6 +94,6 @@ $material-design-icons-font-path: '~/material-design-icons/iconfont/'; ...@@ -94,6 +94,6 @@ $material-design-icons-font-path: '~/material-design-icons/iconfont/';
button.icon-split-handle.ngx-split-button { button.icon-split-handle.ngx-split-button {
height: 100%; height: 100%;
border: 1px solid #3a3333; //border: 1px solid #3a3333;
opacity: 0.5; opacity: 0.0;
} }
...@@ -27,27 +27,49 @@ app-root { ...@@ -27,27 +27,49 @@ app-root {
color: white; color: white;
} }
.terminal { /*.terminal {*/
font-family: 'Monaco', 'Consolas', 'monospace' !important; /*font-family: 'Monaco', 'Consolas', 'monospace' !important;*/
font-size: 13px; /*font-size: 13px;*/
white-space: nowrap; /*white-space: nowrap;*/
/*display: inline-block;*/ /*!*display: inline-block;*!*/
/*background-color: #1f1b1b;*/ /*!*background-color: #1f1b1b;*!*/
} /*}*/
.terminal div { /*.terminal div {*/
user-select: text; /*user-select: text;*/
} /*}*/
.terminal .xterm-rows { /*.terminal .xterm-rows {*/
background-color: #1f1b1b; /*background-color: #1f1b1b;*/
/*margin: 15px;*/ /*!*margin: 15px;*!*/
} /*}*/
/*.xterm-rows {*/ /*.xterm-rows {*/
/*padding: 15px;*/ /*padding: 15px;*/
/*}*/ /*}*/
/*.xterm .composition-view {*/
/*!* TODO: Composition position got messed up somewhere *!*/
/*background: #1f1b1b !important;*/
/*color: #FFF;*/
/*display: none;*/
/*position: absolute;*/
/*white-space: nowrap;*/
/*z-index: 1;*/
/*}*/
/*.xterm .xterm-viewport {*/
/*!* On OS X this is required in order for the scroll bar to appear fully opaque *!*/
/*background: #1f1b1b !important;*/
/*overflow-y: scroll;*/
/*cursor: default;*/
/*position: absolute;*/
/*right: 0;*/
/*left: 0;*/
/*top: 0;*/
/*bottom: 0;*/
/*}*/
.terminal .xterm-viewport { .terminal .xterm-viewport {
background-color: #1f1b1b; background-color: #1f1b1b;
overflow: auto; overflow: auto;
......
...@@ -6,6 +6,6 @@ npm run-script build ...@@ -6,6 +6,6 @@ npm run-script build
rm -fr luna* rm -fr luna*
mv dist luna mv dist luna
cp -R i18n/ luna/ cp -R i18n luna/
tar czf luna.tar.gz luna tar czf luna.tar.gz luna
md5 luna.tar.gz md5 luna.tar.gz
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