Commit 12f3e829 authored by zheng liu's avatar zheng liu

Merged in dev (pull request #49)

Dev
parents 1e55448a 2e1bfb6d
......@@ -84,6 +84,9 @@ class SSHws(Namespace):
self.leave_room(room=self.clients[request.sid]["room"])
join_room(room)
def on_token(self, token):
print(token)
def on_disconnect(self):
print("disconnect")
for connection in self.clients[request.sid]["chan"]:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build -prod --base-href=/luna/ --deploy '/luna/'",
"build": "ng build --environment prod --base-href=/luna/ --deploy '/luna/'",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
......@@ -19,11 +19,11 @@
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.0",
"@angular/material": "^5.1.1",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"animate.css": "^3.5.2",
"base64-js": "^1.2.1",
"body-parser": "^1.18.2",
"bootstrap": "^4.0.0-beta.3",
"clipboard": "^1.7.1",
......@@ -62,6 +62,7 @@
"socket.io-client": "^2.0.4",
"ssh-keygen": "^0.4.1",
"tether": "^1.4.0",
"tslib": "1.8.1",
"uuid-js": "^0.7.5",
"xterm": "^2.9.2",
"zone.js": "0.8.20"
......@@ -87,7 +88,6 @@
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.2.2",
"ts-node": "3.3.0",
"tslib": "1.8.1",
"tslint": "5.9.1",
"typescript": "2.4.2"
}
......
......@@ -15,7 +15,7 @@ import {version} from '../../../environments/environment';
import * as jQuery from 'jquery/dist/jquery.min.js';
import {ElementServerMenuComponent} from '../../elements/server-menu/server-menu.component';
import {NavList, View} from '../control/control.component';
import {LayerService} from '../../elements/layer/layer.service';
import {DialogService} from '../../elements/dialog/dialog.service';
export interface HostGroup {
......@@ -83,7 +83,7 @@ export class CleftbarComponent implements OnInit {
private _search: SearchComponent,
private _logger: LogService,
private _menu: ElementServerMenuComponent,
private _layer: LayerService) {
private _dialog: DialogService) {
this._logger.log('nav.ts:NavComponent');
// this._appService.getnav()
}
......@@ -126,7 +126,7 @@ export class CleftbarComponent implements OnInit {
for (const u of host.system_users_granted) {
options += '<option value="' + u.id + '">' + u.username + '</option>';
}
this._layer.open({
this._dialog.open({
title: 'Please Choose a User',
scrollbar: false,
moveOut: true,
......@@ -142,7 +142,7 @@ export class CleftbarComponent implements OnInit {
}
}
that.login(host, user);
that._layer.close(index);
that._dialog.close(index);
},
btn2: function (index, layero) {
},
......
......@@ -17,6 +17,8 @@ import {MonitorPageComponent} from './monitor-page/monitor-page.component';
import {RdpPageComponent} from './rdp-page/rdp-page.component';
import {TermPageComponent} from './term-page/term-page.component';
import {ElementServerMenuComponent} from './elements/server-menu/server-menu.component';
import {BlankPageComponent} from './blank-page/blank-page.component';
import {TestPageComponent} from './test-page/test-page.component';
const appRoutes: Routes = [
// {path: 'users/login', component: LoginComponent},
......@@ -24,7 +26,8 @@ const appRoutes: Routes = [
{path: 'term/:token', component: TermPageComponent},
{path: 'replay/:token', component: ReplayPageComponent},
{path: 'monitor/:token', component: MonitorPageComponent},
{path: 'test', component: TermPageComponent},
{path: 'test', component: TestPageComponent},
{path: 'undefined', component: BlankPageComponent},
{path: '', component: ControlPageComponent},
{path: '**', component: NotFoundComponent}
];
......
......@@ -10,16 +10,17 @@
* @author liuzheng <liuzheng712@gmail.com>
*/
import {BrowserModule} from '@angular/platform-browser';
import {ClassProvider, NgModule} from '@angular/core';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms'; // <-- NgModel lives here
import {LoggerModule, NGXLogger, NgxLoggerLevel} from 'ngx-logger';
import {HttpClientModule} from '@angular/common/http';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
// service
import {AppService, HttpService, LogService, UUIDService} from './app.service';
import {LayerService} from './elements/layer/layer.service';
import {DialogService} from './elements/dialog/dialog.service';
// Elements
import {ElementFooterComponent} from './elements/footer/footer.component';
......@@ -51,7 +52,7 @@ import {LinuxComponent} from './monitor-page/linux/linux.component';
import {WindowsComponent} from './monitor-page/windows/windows.component';
import {NgProgressModule} from 'ngx-progressbar';
import {TestPageComponent} from './test-page/test-page.component';
import {HttpClientModule} from '@angular/common/http';
import { BlankPageComponent } from './blank-page/blank-page.component';
// import {NgxLayerModule} from 'ngx-layer';
......@@ -95,6 +96,7 @@ import {HttpClientModule} from '@angular/common/http';
LinuxComponent,
WindowsComponent,
TestPageComponent,
BlankPageComponent,
],
bootstrap: [AppComponent],
providers: [
......@@ -104,7 +106,7 @@ import {HttpClientModule} from '@angular/common/http';
HttpService,
LogService,
UUIDService,
LayerService,
DialogService,
NGXLogger
]
})
......
......@@ -12,7 +12,7 @@ import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import {DataStore, User, Browser} from './globals';
import {environment} from '../environments/environment';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {NGXLogger} from 'ngx-logger';
import {HostGroup} from './ControlPage/cleftbar/cleftbar.component';
import * as UUID from 'uuid-js/lib/uuid.js';
......@@ -71,10 +71,12 @@ export class HttpService {
}
get_guacamole_token(username: string, assetID: string, systemUserID: string) {
return this.http.post('/guacamole/api/tokens', {
username: username, password: 'zheng', asset_id:
assetID, system_user_id: systemUserID
}, {headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')});
const body = new HttpParams()
.set('username', username)
.set('password', 'jumpserver')
.set('asset_id', assetID)
.set('system_user_id', systemUserID);
return this.http.post('/guacamole/api/tokens', body.toString(), {headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')});
}
search(q: string) {
......@@ -197,7 +199,9 @@ export class AppService implements OnInit {
User.wechat = data['wechat'];
User.comment = data['comment'];
User.date_expired = data['date_expired'];
User.phone = data['phone'].toString();
if (data['phone']) {
User.phone = data['phone'].toString();
}
User.logined = data['logined'];
this._logger.debug(User);
},
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BlankPageComponent } from './blank-page.component';
describe('BlankPageComponent', () => {
let component: BlankPageComponent;
let fixture: ComponentFixture<BlankPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ BlankPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(BlankPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import {Component, OnInit} from '@angular/core';
import {DataStore} from '../globals';
@Component({
selector: 'app-blank-page',
templateUrl: './blank-page.component.html',
styleUrls: ['./blank-page.component.scss']
})
export class BlankPageComponent implements OnInit {
constructor() {
DataStore.NavShow = false;
}
ngOnInit() {
}
}
......@@ -2,7 +2,7 @@ import {Injectable} from '@angular/core';
import * as layer from 'layui-layer/src/layer.js';
@Injectable()
export class LayerService {
export class DialogService {
constructor() {
}
......
This diff is collapsed.
import {Component, Input, OnInit} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
import {NavList} from '../../ControlPage/control/control.component';
import {User} from '../../globals';
import {HttpService, LogService} from '../../app.service';
import * as Base64 from 'base64-js/base64js.min';
import {Headers} from '@angular/http';
@Component({
selector: 'app-element-iframe',
......@@ -26,11 +25,10 @@ export class ElementIframeComponent implements OnInit {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
data => {
const title = this.host.hostname + '[' + this.host.ip + ']';
const base = Base64.encode(title + '\0' + 'c' + '\0' + 'jumpserver');
const base = window.btoa(this.host.hostname + '\0' + 'c' + '\0' + 'jumpserver');
// /guacamole/client will redirect to http://guacamole/#/client
this.target = document.location.origin +
'/guacamole/client/' + base + '?token=' + data['authToken'];
'/guacamole/#/client/' + base + '?token=' + data['authToken'];
},
error2 => {
this._logger.error(error2);
......
import {Component, OnInit} from '@angular/core';
import {LayerService} from '../layer/layer.service';
import {DialogService} from '../dialog/dialog.service';
export class Menu {
......@@ -18,7 +18,7 @@ export class ElementServerMenuComponent implements OnInit {
top: number;
left: number;
constructor(private ly: LayerService) {
constructor(private _dialog: DialogService) {
}
ngOnInit() {
......@@ -29,7 +29,7 @@ export class ElementServerMenuComponent implements OnInit {
m.type = 'lll';
line.type = 'line';
this.MenuList = [m, m, line, m, m];
this.ly.alert();
this._dialog.alert();
}
public contextmenu(top: number, left: number) {
......
......@@ -15,7 +15,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@Input() host: any;
@Input() userid: any;
@Input() index: number;
// @Input() room: string;
@Input() token: string;
@ViewChild('term') el: ElementRef;
secret: string;
term: any;
......@@ -35,7 +35,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
}
ngAfterViewInit() {
if (this.host) {
if (this.host || this.token) {
if (Cookie.get('cols')) {
term.col = parseInt(Cookie.get('cols'), 10);
}
......@@ -67,38 +67,37 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
};
jQuery(window).resize();
NavList.List[this.index].Term = this.term;
if (this.host) {
NavList.List[this.index].Term = this.term;
// this.term.write('\x1b[31mWelcome to Jumpserver!\x1b[m\r\n');
TermWS.emit('host', {'uuid': this.host.id, 'userid': this.userid, 'secret': this.secret});
}
if (this.token) {
TermWS.emit('token', {'token': this.token, 'secrte': this.secret});
}
this.term.on('data', function (data) {
TermWS.emit('data', {'data': data, 'room': NavList.List[that.index].room});
});
this.term.on('data', function (data) {
TermWS.emit('data', {'data': data, 'room': NavList.List[that.index].room});
});
TermWS.on('data', function (data) {
if (data['room'] === NavList.List[that.index].room) {
that.term.write(data['data']);
}
});
TermWS.on('data', function (data) {
if (data['room'] === NavList.List[that.index].room) {
that.term.write(data['data']);
}
});
TermWS.on('disconnect', function () {
that.TerminalDisconnect();
});
TermWS.on('logout', function (data) {
if (data['room'] === NavList.List[that.index].room) {
NavList.List[this.index].connected = false;
this.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
}
});
TermWS.on('room', function (data) {
if (data['secret'] === that.secret) {
NavList.List[that.index].room = data['room'];
}
});
}
TermWS.on('disconnect', function () {
that.TerminalDisconnect();
});
TermWS.on('logout', function (data) {
if (data['room'] === NavList.List[that.index].room) {
NavList.List[this.index].connected = false;
this.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
}
});
TermWS.on('room', function (data) {
if (data['secret'] === that.secret) {
NavList.List[that.index].room = data['room'];
}
});
}
TerminalDisconnect() {
......
<p>
term-page works!
</p>
<app-element-term
[token]="token"
[index]="0">
</app-element-term>
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {DataStore} from '../globals';
import {ActivatedRoute, Params} from '@angular/router';
import * as jQuery from 'jquery/dist/jquery.min.js';
@Component({
selector: 'app-term-page',
......@@ -6,10 +9,16 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./term-page.component.scss']
})
export class TermPageComponent implements OnInit {
token: string;
constructor() { }
constructor(private activatedRoute: ActivatedRoute) {
DataStore.NavShow = false;
}
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
this.token = params['token'];
});
jQuery('body').css('background-color', 'black');
}
}
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {DataStore} from '../globals';
import {DialogService} from '../elements/dialog/dialog.service';
// import {Mats, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
@Component({
selector: 'app-test-page',
......@@ -7,9 +11,12 @@ import { Component, OnInit } from '@angular/core';
})
export class TestPageComponent implements OnInit {
constructor() { }
constructor(private _dialog: DialogService) {
DataStore.NavShow = false;
}
ngOnInit() {
this._dialog.alert();
}
}
......@@ -31,6 +31,7 @@ app-root {
font-size: 11px !important;
padding-bottom: 16px !important;
font-family: 'Monaco', Inconsolata !important;
color: white;
}
.terminal {
......
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