Commit cc52e24f authored by zheng liu's avatar zheng liu

Merged in master (pull request #70)

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