Commit 7e047a7e authored by ibuler's avatar ibuler

[Update] 更新tree和优化term

parent e016ab9d
{ {
"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",
"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 +42,43 @@ ...@@ -44,42 +42,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,8 +32,13 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -32,8 +32,13 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
hiddenNodes: any; hiddenNodes: any;
onCzTreeOnClick(event, treeId, treeNode, clickFlag) { onCzTreeOnClick(event, treeId, treeNode, clickFlag) {
if (treeNode.isParent) {
const zTreeObj = $.fn.zTree.getZTreeObj('ztree');
zTreeObj.expandNode(treeNode);
} else {
this.Connect(treeNode); this.Connect(treeNode);
} }
}
constructor(private _appService: AppService, constructor(private _appService: AppService,
public _dialog: MatDialog, public _dialog: MatDialog,
......
import {AfterViewInit, Component, Input, OnInit } from '@angular/core'; import {AfterViewInit, Component, Input, OnInit } from '@angular/core';
import * as Terminal from 'xterm/dist/xterm'; import {Terminal} from '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 {TermWS} from '../../globals'; import {TermWS} from '../../globals';
...@@ -26,8 +26,12 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit { ...@@ -26,8 +26,12 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
ngOnInit() { ngOnInit() {
this.secret = this._uuid.gen(); this.secret = this._uuid.gen();
this.term = new Terminal({ this.term = new Terminal({
useStyle: true, fontFamily: '"Monaco", "Consolas", "monospace"',
screenKeys: true, fontSize: 14,
rightClickSelectsWord: true,
theme: {
background: '#1f1b1b'
}
}); });
} }
......
...@@ -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 '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';
@Component({ @Component({
selector: 'elements-term', selector: 'elements-term',
templateUrl: './term.component.html', templateUrl: './term.component.html',
...@@ -17,8 +17,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -17,8 +17,6 @@ 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() {
...@@ -34,22 +32,23 @@ export class ElementTermComponent implements OnInit, AfterViewInit { ...@@ -34,22 +32,23 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit() { ngAfterViewInit() {
this.term.open(this.el.nativeElement, true); this.term.open(this.el.nativeElement);
this.resizeTerm(); this.resizeTerm();
} }
resizeTerm() { resizeTerm() {
let contentElement = $('.window.active'); fit(this.term);
if (contentElement.length === 0) { // let contentElement = $('.window.active');
contentElement = $('body'); // if (contentElement.length === 0) {
} // contentElement = $('body');
const markerElement = $('#marker'); // }
const col = Math.floor((contentElement.width() - 30) / markerElement.width() * 6) - 1; // const markerElement = $('#marker');
const row = Math.floor((contentElement.height() - 30) / markerElement.height()); // const col = Math.floor((contentElement.width() - 30) / markerElement.width() * 6) - 1;
this.col = col > 80 ? col : 80; // const row = Math.floor((contentElement.height() - 30) / markerElement.height());
this.row = row > 24 ? row : 24; // this.col = col > 80 ? col : 80;
this.term.resize(this.col, this.row); // this.row = row > 24 ? row : 24;
this.winSizeChangeTrigger.emit([this.col, this.row]); // this.term.resize(this.col, this.row);
this.winSizeChangeTrigger.emit([this.term.cols, this.term.rows]);
} }
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();
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>
......
...@@ -11,10 +11,14 @@ function zeroPad(num, minLength) { ...@@ -11,10 +11,14 @@ function zeroPad(num, minLength) {
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);
console.log('1');
console.log('1');
console.log('1');
console.log('1');
return zeroPad(minutes, 2) + ':' + zeroPad(seconds, 2); return zeroPad(minutes, 2) + ':' + zeroPad(seconds, 2);
} }
...@@ -25,7 +29,7 @@ function formatTime(millis) { ...@@ -25,7 +29,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 +68,7 @@ export class ReplayGuacamoleComponent implements OnInit { ...@@ -64,7 +68,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,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;
......
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