Commit bc1558c6 authored by zheng liu's avatar zheng liu

Merged in test (pull request #29)

Test
parents 1072ed9d 5d9011e2
......@@ -23,6 +23,7 @@
"../node_modules/layui-layer/dist/theme/default/layer.css",
"../node_modules/animate.css/animate.min.css",
"assets/inspinia/style.scss",
"../node_modules/xterm/dist/xterm.css",
"sass/style.scss",
"styles.css"
],
......@@ -32,7 +33,7 @@
"../node_modules/jquery-sparkline/jquery.sparkline.js",
"../node_modules/tether/dist/js/tether.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/term.js/src/term.js",
"../node_modules/xterm/dist/xterm.js",
"../node_modules/layui-layer/dist/layer.js",
"../node_modules/socket.io-client/dist/socket.io.js",
"./assets/js/mstsc.js",
......
......@@ -104,11 +104,11 @@ def asset_groups_assets():
"comment": "Default asset group",
"assets_granted": [
{
"id": 2,
"id": 1,
"hostname": "192.168.1.6",
"ip": "192.168.2.6",
"port": 22,
"system": "linux",
"plantform": "Linux",
"system_users_granted": [
{
"id": 1,
......@@ -117,6 +117,14 @@ def asset_groups_assets():
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
},
{
"id": 2,
"name": "liuzheng",
"username": "liuzheng",
"protocol": "ssh",
"auth_method": "P",
"auto_push": True
}
]
},
......@@ -125,7 +133,7 @@ def asset_groups_assets():
"hostname": "windows server",
"ip": "123.57.183.135",
"port": 3389,
"system": "windows",
"plantform": "Windows",
"assets_granted": [
{
"id": 1,
......
......@@ -5116,6 +5116,11 @@
"integrity": "sha1-4g/146KvwmkDILbcVSaCqcf631E=",
"dev": true
},
"inconsolata": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/inconsolata/-/inconsolata-0.0.2.tgz",
"integrity": "sha1-uqFDP0PUKqHtsmvZ7odzjpKSUOs="
},
"indent-string": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz",
......
......@@ -32,6 +32,7 @@
"filetree-css": "^1.0.0",
"font-awesome": "^4.7.0",
"handlebars": "^4.0.11",
"inconsolata": "0.0.2",
"jquery": "^3.1.0",
"jquery-slimscroll": "^1.3.8",
"jquery-sparkline": "^2.4.0",
......
......@@ -34,7 +34,7 @@ label {
overflow: hidden;
}
.filetree > li input:checked ~ ul {
.filetree > li input:checked ~ ul , .filetree > li ul.insearch{
height: auto;
}
......
......@@ -8,9 +8,9 @@
<li *ngFor="let hostGroup of HostGroups | SearchFilter: q; let i = index ">
<input type="checkbox" id="hostgroup-{{i}}">
<label for="hostgroup-{{i}}">{{hostGroup.name}}</label>
<ul>
<ul [ngClass]="{'insearch': q }">
<li *ngFor="let host of hostGroup.assets_granted | SearchFilter: q" (click)="Connect(host)">
<i class="fa" [ngClass]="'fa-'+host.system" id="fa-{{i}}"></i>
<i class="fa" [ngClass]="'fa-'+(host.plantform||'undefined').toLowerCase()" id="fa-{{i}}"></i>
{{host.hostname}}
</li>
</ul>
......
......@@ -92,12 +92,32 @@ export class CleftbarComponent implements OnInit {
.map(res => res.json())
.subscribe(response => {
this.HostGroups = response;
this.autologin();
});
}
autologin() {
const id = this._appService.getQueryString('id');
if (id) {
for (let g of this.HostGroups) {
if (g['assets_granted']) {
for (let u of g['assets_granted']) {
if (u.id.toString() === id.toString()) {
this.Connect(u);
return;
}
}
}
}
}
}
Connect(host) {
// console.log(host);
let userid: string;
const that = this;
if (host.system_users_granted.length > 1) {
let options = '';
for (let u of host.system_users_granted) {
......@@ -112,6 +132,7 @@ export class CleftbarComponent implements OnInit {
content: '<select id="selectuser">' + options + '</select>',
yes: function (index, layero) {
userid = jQuery('#selectuser').val();
that.login(host, userid);
layer.close(index);
},
btn2: function (index, layero) {
......@@ -123,15 +144,19 @@ export class CleftbarComponent implements OnInit {
});
} else if (host.system_users_granted.length === 1) {
userid = host.system_users_granted[0].id;
this.login(host, userid);
}
}
login(host, userid) {
if (userid === '') {
return;
}
if (host.system === 'linux') {
if (host.plantform.toLowerCase() === 'linux') {
jQuery('app-ssh').show();
jQuery('app-rdp').hide();
this._term.TerminalConnect(host, userid);
} else if (host.system === 'windows') {
} else if (host.plantform.toLowerCase() === 'windows') {
jQuery('app-ssh').hide();
jQuery('app-rdp').show();
this._rdp.Connect(host, userid);
......
......@@ -77,11 +77,11 @@ export class SshComponent implements OnInit {
screenKeys: true,
});
NavList.List.push(new View());
for (let _i = 0; _i < NavList.List.length; _i++) {
if (id === _i) {
for (let i = 0; i < NavList.List.length; i++) {
if (id === i) {
NavList.List[id].hide = false;
} else {
NavList.List[_i].hide = true;
NavList.List[i].hide = true;
}
}
......@@ -109,7 +109,7 @@ export class SshComponent implements OnInit {
});
socket.on('disconnect', function () {
this.TerminalDisconnect(NavList.List[id]);
SshComponent.TerminalDisconnect(NavList.List[id]);
// TermStore.term[id]["term"].destroy();
// TermStore.term[id]["connected"] = false;
});
......
......@@ -7,7 +7,8 @@ div, term-leftbar, term-body {
div {
background-color: black;
margin: 0;
padding-top:30px;
top:30px;
position: absolute;
}
app-cleftbar {
......
......@@ -13,6 +13,7 @@ import {Logger} from 'angular2-logger/core';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import {DataStore, User, Browser} from './globals';
declare function unescape(s: string): string;
@Injectable()
export class HttpService {
......@@ -174,6 +175,14 @@ export class AppService implements OnInit {
this._http.post('/api/browser', JSON.stringify(Browser)).map(res => res.json()).subscribe();
}
getQueryString(name) {
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
const r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
//
//
......
<div class="nav">
<ul>
<li><a [routerLink]="['Index']"><img src="static/imgs/logo.png" height="26px"/></a>
<li><a [routerLink]="['']"><img src="static/imgs/logo.png" height="26px"/></a>
</li>
<li *ngFor="let v of DataStore.Nav" [ngClass]="{'dropdown': v.children}">
<a>{{v.name}}</a>
......
......@@ -2,7 +2,6 @@ import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {ElementRef, Renderer2} from '@angular/core';
import {term} from '../../globals';
import {Terminal} from '../../globals';
import * as jQuery from 'jquery/dist/jquery.min.js';
@Component({
selector: 'app-element-term',
......@@ -21,8 +20,10 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
}
ngAfterViewInit() {
term.col = Math.floor(jQuery(this.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3;
term.row = Math.floor(jQuery(this.el.nativeElement).height() / jQuery('#liuzheng').height()) - 5;
// term.col = Math.floor(jQuery(this.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3;
// term.row = Math.floor(jQuery(this.el.nativeElement).height() / jQuery('#liuzheng').height()) - 5;
term.col = 90;
term.row = 90;
term.term = Terminal({
cols: term.col,
rows: term.row,
......@@ -30,19 +31,19 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
screenKeys: true,
});
term.term.open(this.el.nativeElement, true);
const that = this;
window.onresize = function () {
term.col = Math.floor(jQuery(that.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3;
term.row = Math.floor(jQuery(that.el.nativeElement).height() / jQuery('#liuzheng').height()) - 5;
if (term.col < 80) {
term.col = 80;
}
if (term.row < 24) {
term.row = 24;
}
term.term.resize(term.col, term.row);
};
// const that = this;
// window.onresize = function () {
// term.col = Math.floor(jQuery(that.el.nativeElement).width() / jQuery('#liuzheng').width() * 8) - 3;
// term.row = Math.floor(jQuery(that.el.nativeElement).height() / jQuery('#liuzheng').height()) - 5;
//
// if (term.col < 80) {
// term.col = 80;
// }
// if (term.row < 24) {
// term.row = 24;
// }
// term.term.resize(term.col, term.row);
// };
}
}
......@@ -21,3 +21,7 @@
#term .terminal div span {
min-width: 12px;
}
app-element-term {
position: absolute;
}
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-stop" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-step-backward" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-backward" aria-hidden="true"></i>-->
<!--</button>-->
<button type="button" class="btn" (click)="pause()">
<i class="fa" aria-hidden="true" [ngClass]="{'fa-play':!toggle,'fa-pause': toggle}"></i>
</button>
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-forward" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-step-forward" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-expand" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-compress" aria-hidden="true"></i>-->
<!--</button>-->
<button type="button" class="btn" (click)="restart()">
<i class="fa fa-repeat" aria-hidden="true"></i>
</button>
<div>
<input id="scrubber" type="range" [(ngModel)]="setPercent" min=0 max=100 (mousedown)="stop()" (mouseup)="rununil()"/>
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-stop" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-step-backward" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-backward" aria-hidden="true"></i>-->
<!--</button>-->
<button type="button" class="btn" (click)="pause()">
<i class="fa" aria-hidden="true" [ngClass]="{'fa-play':!toggle,'fa-pause': toggle}"></i>
</button>
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-forward" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-step-forward" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-expand" aria-hidden="true"></i>-->
<!--</button>-->
<!--<button type="button" class="btn">-->
<!--<i class="fa fa-compress" aria-hidden="true"></i>-->
<!--</button>-->
<button type="button" class="btn" (click)="restart()">
<i class="fa fa-repeat" aria-hidden="true"></i>
</button>
{{time | utcDate | date:"HH:mm:ss"}}
<input id="scrubber" type="range" [(ngModel)]="setPercent" min=0 max=100 (mousedown)="stop()" (mouseup)="rununil()"/>
{{time | utcDate | date:"HH:mm:ss"}}
</div>
<app-element-term></app-element-term>
<!--<asciinema-player></asciinema-player>-->
import {Component, OnInit} from '@angular/core';
import {AfterViewInit, Component, OnInit} from '@angular/core';
import {Video} from '../../globals';
import {term} from '../../globals';
......@@ -9,7 +9,7 @@ import * as jQuery from 'jquery/dist/jquery.min.js';
templateUrl: './json.component.html',
styleUrls: ['./json.component.css']
})
export class JsonComponent implements OnInit {
export class JsonComponent implements OnInit, AfterViewInit {
speed = 1;
setPercent = 0;
toggle = false;
......@@ -24,6 +24,9 @@ export class JsonComponent implements OnInit {
}
ngOnInit() {
}
ngAfterViewInit() {
this.restart();
}
......
<app-mp4 *ngIf='Video.type=="mp4"'></app-mp4>
<app-json *ngIf='Video.type=="json"'></app-json>
<app-json></app-json>
......@@ -4,9 +4,10 @@
* --------------------------------------------------
*/
@font-face {
font-family: iosevka;
src: url('assets/fonts/iosevka-term-ss07-1.13.3/woff2/iosevka-term-ss07-light.woff2') format("woff2");
font-family: Inconsolata;
src: url('assets/fonts/inconsolata.woff') format("woff");
font-weight: normal;
font-size: large;
}
html,
......@@ -29,11 +30,11 @@ app-root {
z-index: -1;
font-size: 11px !important;
padding-bottom: 16px !important;
font-family: 'Monaco', iosevka !important;
font-family: 'Monaco', Inconsolata !important;
}
.terminal {
font-family: 'Monaco', iosevka;
font-family: 'Monaco', Inconsolata;
font-size: 11px;
white-space: nowrap;
display: inline-block;
......
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