-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div class="controls"> | ||
<span id="user" style="padding-left: 20px" *ngIf="replay.user">{{"user"| translate}} : {{replay.user}}</span> | ||
<span id="asset" style="padding-left: 20px" *ngIf="replay.asset">{{"asset"| translate}} : {{replay.asset}}</span> | ||
<span id="system_user" style="padding-left: 20px" *ngIf="replay.system_user">{{"system user"| translate}} : {{replay.system_user}}</span> | ||
<span id="date_start" style="padding-left: 20px" *ngIf="replay.date_start">{{"start time"| translate}} : {{startTime}} </span> | ||
<span id="download" style="padding-left: 30px" *ngIf="replay.download_url"><a type="button" [href]="replay.download_url">{{"download"| translate}}</a></span> | ||
</div> | ||
<div id="player"> | ||
<as-split direction="horizontal" gutterSize="0"> | ||
<as-split-area *ngIf="commands.length" [size]="15" [maxSize]="15" [minSize]="0" order="0"> | ||
<div class="command-results" | ||
infiniteScroll | ||
[infiniteScrollDistance]="2" | ||
[infiniteScrollThrottle]="50" | ||
(scrolled)="onScroll()" | ||
[scrollWindow]="false"> | ||
<div class="item" *ngFor="let item of commands" (click)="commandClick(item)"> | ||
<div class="command" [title]="item.input">{{ item.input }}</div> | ||
<div class="timestamp">{{ item.atime }}</div> | ||
</div> | ||
</div> | ||
</as-split-area> | ||
<as-split-area [size]="85" [maxSize]="100" [minSize]="85" order="1"> | ||
<div id="screen"> | ||
<video controls [height]="height" [width]="width"> | ||
<source [src]="replay.src" type="video/mp4"> | ||
</video> | ||
</div> | ||
</as-split-area> | ||
</as-split> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ElementsReplayMp4Component } from './mp4.component'; | ||
|
||
describe('ElementsReplayMp4Component', () => { | ||
let component: ElementsReplayMp4Component; | ||
let fixture: ComponentFixture<ElementsReplayMp4Component>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ElementsReplayMp4Component ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ElementsReplayMp4Component); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Component, OnInit,Input } from '@angular/core'; | ||
import {Replay,Command} from '@app/model'; | ||
import {HttpService} from '@app/services'; | ||
import {TranslateService} from '@ngx-translate/core'; | ||
import {formatTime} from '@app/utils/common'; | ||
|
||
@Component({ | ||
selector: 'elements-replay-mp4', | ||
templateUrl: './mp4.component.html', | ||
styleUrls: ['./mp4.component.css'] | ||
}) | ||
export class ElementsReplayMp4Component implements OnInit { | ||
@Input() replay: Replay; | ||
startTime = null; | ||
startTimeStamp = null; | ||
commands: Command[]; | ||
page = 0; | ||
height = 0; | ||
width = 0; | ||
|
||
constructor(private _http: HttpService, private _translate: TranslateService) { } | ||
|
||
ngOnInit() { | ||
this.commands = new Array<Command>(); | ||
const date = new Date(Date.parse(this.replay.date_start)); | ||
this.startTime = this.toSafeLocalDateStr(date); | ||
this.startTimeStamp = Date.parse(this.replay.date_start); | ||
this.getCommands(this.page); | ||
this.height = window.innerHeight - 100; | ||
this.width = window.innerWidth - 100; | ||
} | ||
|
||
toSafeLocalDateStr(d) { | ||
const date_s = d.toLocaleString(this.getUserLang(), {hour12: false}); | ||
return date_s.split('/').join('-'); | ||
} | ||
|
||
getUserLang() { | ||
const userLangEN = document.cookie.indexOf('django_language=en'); | ||
if (userLangEN === -1) { | ||
return 'zh-CN'; | ||
} else { | ||
return 'en-US'; | ||
} | ||
} | ||
|
||
getCommands(page: number) { | ||
if (!this.startTimeStamp) { | ||
return; | ||
} | ||
this._http.getCommandsData(this.replay.id, page) | ||
.subscribe( | ||
data => { | ||
const results = data.results; | ||
results.forEach(element => { | ||
element.atime = formatTime(element.timestamp * 1000 - this.startTimeStamp); | ||
}); | ||
this.commands = this.commands.concat(results); | ||
}, | ||
err => { | ||
alert('没找到命令记录'); | ||
} | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters