Commit cc52e24f authored by zheng liu's avatar zheng liu

Merged in master (pull request #70)

Master
parents f0ea0559 6676e009
......@@ -16,7 +16,7 @@
"show left manager": "显示左边栏",
"disconnect all": "断开所有链接",
"disconnect": "断开链接",
"website": "我们的网站",
"website": "官网",
"search": "搜索",
"settings": "系统设置",
"job center": "作业中心",
......@@ -46,5 +46,7 @@
"choose a user": "选择一个用户",
"please choose a user": "请选择一个用户",
"cancel": "取消",
"confirm": "确认"
"confirm": "确认",
"document": "文档",
"support": "商业支持"
}
......@@ -5,7 +5,7 @@
[compareWith]="compareFn"
[formControl]="UserSelectControl"
placeholder="{{'Choose a User'|trans}}" required>
<mat-option *ngFor="let u of data.users" value="{{u.id}}">{{u.username}}</mat-option>
<mat-option *ngFor="let u of data.users" value="{{u.id}}">{{u.name}}</mat-option>
</mat-select>
<mat-error *ngIf="UserSelectControl.hasError('required')">{{"Please choose a User"|trans}}</mat-error>
......
......@@ -16,11 +16,7 @@ import {TermWS} from '../../globals';
// term: any;
// }
export class Rdp {
machine: string;
token: string;
client: any;
}
export class View {
nick: string;
......@@ -32,7 +28,7 @@ export class View {
host: any;
user: any;
room: string;
Rdp: Rdp;
Rdp: any;
Term: any;
}
......
......@@ -7,7 +7,7 @@
* @author liuzheng <liuzheng712@gmail.com>
*/
import {Component, OnInit} from '@angular/core';
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {ControlComponent, NavList} from '../control.component';
import * as jQuery from 'jquery/dist/jquery.min.js';
......@@ -44,6 +44,7 @@ export class ControlnavComponent implements OnInit {
if (NavList.List[index].type === 'ssh') {
NavList.List[index].Term.focus();
} else if (NavList.List[index].type === 'rdp') {
NavList.List[index].Rdp.focus();
}
} else {
......
......@@ -14,20 +14,18 @@ import {LoginComponent} from './BasicPage/login/login.component';
import {ControlPageComponent} from './ControlPage/controlpage.component';
import {ReplayPageComponent} from './replay-page/replay-page.component';
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';
import {SettingPageComponent} from './setting-page/setting-page.component';
import {ConnectPageComponent} from './connect-page/connect-page.component';
const appRoutes: Routes = [
// {path: 'users/login', component: LoginComponent},
{path: 'rdp/:token', component: RdpPageComponent},
{path: 'term/:token', component: TermPageComponent},
{path: 'replay/:token', component: ReplayPageComponent},
{path: 'monitor/:token', component: MonitorPageComponent},
{path: 'test', component: TestPageComponent},
{path: 'connect', component: ConnectPageComponent},
// {path: 'setting', component: SettingPageComponent},
{path: 'undefined', component: BlankPageComponent},
{path: '', component: ControlPageComponent},
......
......@@ -39,8 +39,6 @@ import {ControlnavComponent} from './ControlPage/control/controlnav/controlnav.c
import {ControlPageComponent} from './ControlPage/controlpage.component';
import {IndexPageComponent} from './IndexPage/index-page.component';
import {NotFoundComponent} from './BasicPage/not-found/not-found.component';
import {RdpPageComponent} from './rdp-page/rdp-page.component';
import {TermPageComponent} from './term-page/term-page.component';
import {ReplayPageComponent} from './replay-page/replay-page.component';
import {Mp4Component} from './replay-page/mp4/mp4.component';
import {JsonComponent} from './replay-page/json/json.component';
......@@ -66,6 +64,7 @@ import {SettingPageS3Component} from './setting-page/s3/s3.component';
import {TransPipe} from './trans.pipe';
import {MAT_LABEL_GLOBAL_OPTIONS} from '@angular/material';
import {ElementGuacamoleComponent} from './elements/guacamole/guacamole.component';
import {ConnectPageComponent} from './connect-page/connect-page.component';
@NgModule({
imports: [
......@@ -105,8 +104,6 @@ import {ElementGuacamoleComponent} from './elements/guacamole/guacamole.componen
ControlPageComponent,
IndexPageComponent,
NotFoundComponent,
RdpPageComponent,
TermPageComponent,
ReplayPageComponent,
Mp4Component,
JsonComponent,
......@@ -123,6 +120,7 @@ import {ElementGuacamoleComponent} from './elements/guacamole/guacamole.componen
SettingPageTerminalComponent,
SettingPageS3Component,
TransPipe,
ConnectPageComponent,
],
entryComponents: [
CleftbarDialogComponent,
......
......@@ -70,19 +70,47 @@ export class HttpService {
return this.http.get<Array<HostGroup>>('/api/perms/v1/user/nodes-assets/');
}
get_guacamole_token(username: string, assetID: string, systemUserID: string) {
get_guacamole_token(user_id: string) {
const body = new HttpParams()
.set('username', username)
.set('password', 'jumpserver')
.set('asset_id', assetID)
.set('system_user_id', systemUserID);
.set('username', user_id)
.set('password', 'jumpserver');
return this.http.post('/guacamole/api/tokens',
body.toString(),
{headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')});
}
guacamole_add_asset(user_id: string, asset_id: string, system_user_id: string) {
const params = new HttpParams()
.set('user_id', user_id)
.set('asset_id', asset_id)
.set('system_user_id', system_user_id)
.set('token', DataStore.guacamole_token);
return this.http.get(
'/guacamole/api/session/ext/jumpserver/asset/add',
{
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded'),
params: params
}
);
}
guacamole_token_add_asset(token: string) {
const params = new HttpParams()
.set('asset_token', token)
.set('token', DataStore.guacamole_token);
return this.http.get(
'/guacamole/api/session/ext/jumpserver/asset/token/add',
{
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded'),
params: params
}
);
}
search(q: string) {
return this.http.get('/api/search?q=' + q);
const params = new HttpParams()
.set('q', q);
return this.http.get('/api/search', {params: params});
}
get_replay(token: string) {
......
<app-element-term
[token]="token"
[index]="0"
*ngIf="system =='linux'">
</app-element-term>
<app-element-guacamole
[token]="token"
[index]="0"
*ngIf="system=='windows'">
</app-element-guacamole>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TermPageComponent } from './term-page.component';
import { ConnectPageComponent } from './connect-page.component';
describe('TermPageComponent', () => {
let component: TermPageComponent;
let fixture: ComponentFixture<TermPageComponent>;
describe('ConnectPageComponent', () => {
let component: ConnectPageComponent;
let fixture: ComponentFixture<ConnectPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TermPageComponent ]
declarations: [ ConnectPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TermPageComponent);
fixture = TestBed.createComponent(ConnectPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
......
import {Component, OnInit} from '@angular/core';
import {AppService} from '../app.service';
import {DataStore} from '../globals';
import {ActivatedRoute, Params} from '@angular/router';
import * as jQuery from 'jquery/dist/jquery.min.js';
import {LogService} from '../app.service';
@Component({
selector: 'app-term-page',
templateUrl: './term-page.component.html',
styleUrls: ['./term-page.component.scss']
selector: 'app-connect-page',
templateUrl: './connect-page.component.html',
styleUrls: ['./connect-page.component.scss']
})
export class TermPageComponent implements OnInit {
export class ConnectPageComponent implements OnInit {
token: string;
system: string;
constructor(private activatedRoute: ActivatedRoute,
private _logger: LogService) {
constructor(private _appService: AppService) {
DataStore.NavShow = false;
this._logger.debug('TermPageComponent');
}
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
this.token = params['token'];
});
this.system = this._appService.getQueryString('system');
this.token = this._appService.getQueryString('token');
jQuery('body').css('background-color', 'black');
}
}
<iframe [src]="trust(target)"></iframe>
<iframe #rdp [src]="trust(target)" (mouseenter)="active()"></iframe>
import {Component, Input, OnInit} from '@angular/core';
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
import {CookieService} from 'ngx-cookie-service';
import {HttpService, LogService} from '../../app.service';
import {DataStore, User} from '../../globals';
......@@ -14,8 +14,10 @@ import {NavList} from '../../ControlPage/control/control.component';
export class ElementGuacamoleComponent implements OnInit {
@Input() host: any;
@Input() userid: any;
@Input() token: string;
@Input() index: number;
target: string;
@ViewChild('rdp') el: ElementRef;
constructor(private sanitizer: DomSanitizer,
private _http: HttpService,
......@@ -25,26 +27,58 @@ export class ElementGuacamoleComponent implements OnInit {
ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) {
if (DataStore.guacamole_token) {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
if (this.token) {
this._http.get_guacamole_token(User.id).subscribe(
data => {
DataStore.guacamole_token = data['authToken'];
this._http.guacamole_token_add_asset(this.token).subscribe(
_ => {
this.target = document.location.origin + '/guacamole/#/client/' + data['result'] + '?token=' + DataStore.guacamole_token;
},
error2 => {
this._logger.error(error2);
}
);
});
} else {
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) {
if (DataStore.guacamole_token) {
this._http.guacamole_add_asset(User.id, this.host.id, this.userid).subscribe(
data => {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
},
error2 => {
this._logger.error(error2);
}
);
} else {
this._http.get_guacamole_token(User.id).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
DataStore.guacamole_token = data['authToken'];
this._http.guacamole_add_asset(User.id, this.host.id, this.userid).subscribe(
data2 => {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
},
error2 => {
this._logger.error(error2);
}
);
// '/guacamole/#/client/' + base + '?token=' + data['authToken'];
},
error2 => {
this._logger.error(error2);
}
);
}
} else {
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
this.target = document.location.origin +
'/guacamole/#/client/' + base + '?token=' + data['authToken'];
DataStore.guacamole_token = data['authToken'];
},
error2 => {
this._logger.error(error2);
}
);
this.target = this._cookie.get('guacamole');
}
} else {
this.target = this._cookie.get('guacamole');
}
NavList.List[this.index].Rdp = this.el.nativeElement;
}
trust(url) {
......@@ -55,4 +89,9 @@ export class ElementGuacamoleComponent implements OnInit {
NavList.List[this.index].connected = false;
}
active() {
this._logger.debug('focus');
this.el.nativeElement.focus();
}
}
......@@ -25,27 +25,6 @@ export class ElementIframeComponent implements OnInit {
}
ngOnInit() {
// /guacamole/api/tokens will redirect to http://guacamole/api/tokens
const base = window.btoa(this.host.id + '\0' + 'c' + '\0' + 'jumpserver');
if (environment.production) {
if (DataStore.guacamole_token) {
this.target = document.location.origin + '/guacamole/#/client/' + base + '?token=' + DataStore.guacamole_token;
} else {
this._http.get_guacamole_token(User.name, this.host.id, this.userid).subscribe(
data => {
// /guacamole/client will redirect to http://guacamole/#/client
this.target = document.location.origin +
'/guacamole/#/client/' + base + '?token=' + data['authToken'];
DataStore.guacamole_token = data['authToken'];
},
error2 => {
this._logger.error(error2);
}
);
}
} else {
this.target = this._cookie.get('guacamole');
}
}
trust(url) {
......
<script src="../../trans.pipe.spec.ts"></script>
<div class="nav">
<ul>
<li><a [routerLink]="['']"><img src="static/imgs/logo.png" height="26px"/></a>
<li><a href="/"><img src="static/imgs/logo.png" height="26px"/></a>
</li>
<li *ngFor="let v of DataStore.Nav" [ngClass]="{'dropdown': v.children}">
<a>{{v.name | trans}}</a>
......
......@@ -82,8 +82,12 @@ export class ElementNavComponent implements OnInit {
window.open('http://www.jumpserver.org');
break;
}
case 'BBS': {
window.open('http://bbs.jumpserver.org');
case 'Document': {
window.open('http://docs.jumpserver.org/');
break;
}
case 'Support': {
window.open('https://market.aliyun.com/products/53690006/cmgj026011.html?spm=5176.730005.0.0.cY2io1');
break;
}
case 'EnterLicense': {
......@@ -233,9 +237,14 @@ export class ElementNavComponent implements OnInit {
'name': 'Website'
},
{
'id': 'BBS',
'click': 'BBS',
'name': 'BBS'
'id': 'Document',
'click': 'Document',
'name': 'Document'
},
{
'id': 'Support',
'click': 'Support',
'name': 'Support'
}]
}, {
'id': 'Language',
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RdpPageComponent } from './rdp-page.component';
describe('RdpPageComponent', () => {
let component: RdpPageComponent;
let fixture: ComponentFixture<RdpPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RdpPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RdpPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-rdp-page',
templateUrl: './rdp-page.component.html',
styleUrls: ['./rdp-page.component.scss']
})
export class RdpPageComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
<app-element-term
[token]="token"
[index]="0">
</app-element-term>
This diff is collapsed.
......@@ -19,14 +19,12 @@ $roboto-font-path: "~roboto-fontface/fonts";
$asset-path: '../static/imgs/inspinia';
@import "../assets/inspinia/style";
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
@import '~@swimlane/ngx-datatable/release/index.css';
@import '~@swimlane/ngx-datatable/release/themes/material.css';
@import '~@swimlane/ngx-datatable/release/assets/icons.css';
@import './material.css';
$material-design-icons-font-path: '~/material-design-icons/iconfont/';
//@import "~material-design-icons/iconfont/material-icons";
@font-face {
......
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