Commit c026b578 authored by ibuler's avatar ibuler

[Update] 优化录像播放

parent 6993e7a8
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
}, },
"secure": false "secure": false
}, },
"/media/": {
"target": "http://127.0.0.1:8080",
"secure": false
},
"/guacamole/": { "/guacamole/": {
"target": "http://127.0.0.1:8083", "target": "http://127.0.0.1:8083",
"secure": false, "secure": false,
......
...@@ -91,10 +91,6 @@ export class HttpService { ...@@ -91,10 +91,6 @@ export class HttpService {
return this.http.get<Array<SystemUser>>(url); return this.http.get<Array<SystemUser>>(url);
} }
refreshMyGrantedNodes() {
return this.http.get<Array<TreeNode>>('/api/perms/v1/user/nodes-assets/tree/?cache_policy=2');
}
getGuacamoleToken(user_id: string, authToken: string) { getGuacamoleToken(user_id: string, authToken: string) {
const body = new HttpParams() const body = new HttpParams()
.set('username', user_id) .set('username', user_id)
......
...@@ -93,7 +93,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy { ...@@ -93,7 +93,7 @@ export class ElementAssetTreeComponent implements OnInit, OnDestroy {
if (this._navSvc.treeLoadAsync) { if (this._navSvc.treeLoadAsync) {
setting['async'] = { setting['async'] = {
enable: true, enable: true,
url: '/api/perms/v1/users/nodes/children-with-assets/tree/', url: '/api/perms/v1/users/nodes/children-with-assets/tree/?cache_policy=1',
autoParam: ['id=key', 'name=n', 'level=lv'], autoParam: ['id=key', 'name=n', 'level=lv'],
type: 'get' type: 'get'
}; };
......
<div id="player"> <div id="player">
<div class="controls"> <div class="controls">
<button id="play-pause" class="btn" (click)="toggle()"> <button id="play-pause" class="btn" (click)="toggle()">
<i class="fa" [ngClass]="{'fa-play':!isPlaying,'fa-pause': isPlaying}"></i> <i class="fa" [ngClass]="{'fa-play':!isPlaying,'fa-pause': isPlaying}"></i>
</button> </button>
<button type="button" class="btn" (click)="restart()"> <button type="button" class="btn" (click)="restart()">
<i class="fa fa-repeat" aria-hidden="true"></i> <i class="fa fa-repeat" aria-hidden="true"></i>
</button> </button>
<input id="position-slider" type="range" [(ngModel)]="percent" [attr.max]="max" (mouseup)="runFrom()"> <input id="position-slider" type="range" [(ngModel)]="percent" [attr.max]="max" (mouseup)="runFrom()">
<span id="position">{{ position }}</span> <span id="position">{{ position }}</span>
<span>/</span> <span>/</span>
<span id="duration">{{ duration }}</span> <span id="duration">{{ duration }}</span>
</div> </div>
<div id="display" (click)="toggle()"> <div id="display" (click)="toggle()">
<div class="notification-container"> <div class="notification-container">
<div class="seek-notification"> <div class="seek-notification">
<p> <p>
Seek in progress... Seek in progress...
<button id="cancel-seek" class="btn" (click)="cancelSeek($event)">Cancel</button> <button id="cancel-seek" class="btn" (click)="cancelSeek($event)">Cancel</button>
</p> </p>
</div>
</div> </div>
</div>
<div id="screen"></div>
</div> </div>
</div> </div>
#player { #player {
width: 800px; width: 100%;
height: 100%;
padding: 5px;
} }
#display { #display {
position: relative; position: relative;
width: calc(100vw - 10px);
height: calc(100vh - 40px);
}
#screen * {
} }
#player .notification-container { #player .notification-container {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
top: 0; top: 0;
right: 0; right: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
} }
#player .seek-notification { #player .seek-notification {
color: white;
background: rgba(0, 0, 0, 0.75);
color: white; display: none; /* Initially hidden */
background: rgba(0, 0, 0, 0.75); width: 100%;
height: 100%;
display: none; /* Initially hidden */
width: 100%;
height: 100%;
} }
#player.seeking .seek-notification { #player.seeking .seek-notification {
display: table; display: table;
} }
#player .seek-notification p { #player .seek-notification p {
display: table-cell; display: table-cell;
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
font-family: sans-serif; font-family: sans-serif;
} }
#player .controls { #player .controls {
width: 100%; width: 100%;
height: 30px;
/* IE10 */
display: -ms-flexbox;
-ms-flex-align: center;
-ms-flex-direction: row;
/* IE10 */ /* Ancient Mozilla */
display: -ms-flexbox; display: -moz-box;
-ms-flex-align: center; -moz-box-align: center;
-ms-flex-direction: row; -moz-box-orient: horizontal;
/* Ancient Mozilla */ /* Ancient WebKit */
display: -moz-box; display: -webkit-box;
-moz-box-align: center; -webkit-box-align: center;
-moz-box-orient: horizontal; -webkit-box-orient: horizontal;
/* Ancient WebKit */ /* Old WebKit */
display: -webkit-box; display: -webkit-flex;
-webkit-box-align: center; -webkit-align-items: center;
-webkit-box-orient: horizontal; -webkit-flex-direction: row;
/* Old WebKit */ /* W3C */
display: -webkit-flex; display: flex;
-webkit-align-items: center; align-items: center;
-webkit-flex-direction: row; flex-direction: row;
/* W3C */ padding-right: 10px;
display: flex;
align-items: center;
flex-direction: row;
} }
#player .controls > * { #player .controls > * {
margin: 0.25em; margin: 0.25em;
} }
#player .controls #position-slider { #player .controls #position-slider {
-ms-flex: 1 1 auto; -ms-flex: 1 1 auto;
-moz-box-flex: 1; -moz-box-flex: 1;
-webkit-box-flex: 1; -webkit-box-flex: 1;
-webkit-flex: 1 1 auto; -webkit-flex: 1 1 auto;
flex: 1 1 auto; flex: 1 1 auto;
} }
#player .controls #play-pause { #player .controls #play-pause {
margin-left: 0; margin-left: 0;
//min-width: 5em; //min-width: 5em;
} }
#player .controls #position, #player .controls #position,
#player .controls #duration { #player .controls #duration {
font-family: monospace; font-family: monospace;
} }
#player .controls #duration { #player .controls #duration {
margin-right: 0; margin-right: 0;
} }
...@@ -55,6 +55,7 @@ export class ReplayGuacamoleComponent implements OnInit { ...@@ -55,6 +55,7 @@ export class ReplayGuacamoleComponent implements OnInit {
recording: any; recording: any;
playerRef: any; playerRef: any;
displayRef: any; displayRef: any;
screenRef: any;
max = 100; max = 100;
percent = 0; percent = 0;
duration = '00:00'; duration = '00:00';
...@@ -70,21 +71,28 @@ export class ReplayGuacamoleComponent implements OnInit { ...@@ -70,21 +71,28 @@ export class ReplayGuacamoleComponent implements OnInit {
} }
this.playerRef = document.getElementById('player'); this.playerRef = document.getElementById('player');
this.displayRef = document.getElementById('display'); this.displayRef = document.getElementById('display');
this.screenRef = document.getElementById('screen');
const tunnel = new Guacamole.StaticHTTPTunnel(this.replay.src); const tunnel = new Guacamole.StaticHTTPTunnel(this.replay.src);
this.recording = new Guacamole.SessionRecording(tunnel); this.recording = new Guacamole.SessionRecording(tunnel);
const recordingDisplay = this.recording.getDisplay(); const recordingDisplay = this.recording.getDisplay();
const recordingElement = recordingDisplay.getElement();
this.displayRef.appendChild(recordingDisplay.getElement()); recordingElement.style.margin = '0 auto';
this.screenRef.appendChild(recordingElement);
this.initRecording(); this.initRecording();
const that = this; const that = this;
recordingDisplay.onresize = function displayResized(width, height) { recordingDisplay.onresize = function onDisplayResize(width, height) {
// Do not scale if displayRef has no width // Do not scale if displayRef has no width
if (!width) { if (!height) {
return; return;
} }
// Scale displayRef to fit width of container // Scale displayRef to fit width of container
recordingDisplay.scale(that.displayRef.offsetWidth / width); const widthScale = that.displayRef.offsetWidth / width;
const heightScale = that.displayRef.offsetHeight / height;
console.log('old => new: ', widthScale, heightScale);
const minScale = widthScale < heightScale ? widthScale : heightScale;
recordingDisplay.scale(minScale);
// recordingDisplay.scale(that.displayRef.offsetHeigth / height);
}; };
// this.toggle(); // this.toggle();
} }
......
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Params} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {HttpService, LogService} from '@app/app.service'; import {HttpService, LogService} from '@app/app.service';
import {DataStore} from '@app/globals';
import {Replay} from './replay.model'; import {Replay} from './replay.model';
@Component({ @Component({
...@@ -15,25 +14,22 @@ export class PagesReplayComponent implements OnInit { ...@@ -15,25 +14,22 @@ export class PagesReplayComponent implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _http: HttpService, private _http: HttpService,
private _logger: LogService) { private _logger: LogService) {
DataStore.NavShow = false;
} }
ngOnInit() { ngOnInit() {
let token = ''; let sid = '';
this.route.params this.route.params.subscribe(params => {
.subscribe(params => { sid = params['sid'];
token = params['token']; });
}); this._http.getReplay(sid).subscribe(
this._http.getReplay(token) data => {
.subscribe( this.replay.type = data['type'];
data => { this.replay.src = data['src'];
this.replay.type = data['type']; this.replay.id = data['id'];
this.replay.src = data['src']; },
this.replay.id = data['id']; err => {
}, alert('没找到录像文件');
err => { }
alert('没找到录像文件'); );
}
);
} }
} }
...@@ -10,7 +10,7 @@ import {ElementSftpComponent} from '../elements/sftp/sftp.component'; ...@@ -10,7 +10,7 @@ import {ElementSftpComponent} from '../elements/sftp/sftp.component';
const appRoutes: Routes = [ const appRoutes: Routes = [
{path: 'replay/:token', component: PagesReplayComponent}, {path: 'replay/:sid', component: PagesReplayComponent},
{path: 'monitor/:token', component: PagesMonitorComponent}, {path: 'monitor/:token', component: PagesMonitorComponent},
{path: 'connect', component: PagesConnectComponent}, {path: 'connect', component: PagesConnectComponent},
{path: 'sftp', component: ElementSftpComponent}, {path: 'sftp', component: ElementSftpComponent},
......
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