-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathmp4.component.ts
More file actions
81 lines (70 loc) · 2.04 KB
/
Copy pathmp4.component.ts
File metadata and controls
81 lines (70 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import {Component, Input, OnInit, Output,
EventEmitter} from '@angular/core';
import {Command, Replay} from '@app/model';
import {HttpService} from '@app/services';
import {TranslateService} from '@ngx-translate/core';
import {formatTime} from '@app/utils/common';
@Component({
standalone: false,
selector: 'elements-replay-mp4',
templateUrl: 'mp4.component.html',
styleUrls: ['mp4.component.scss']
})
export class ElementsReplayMp4Component implements OnInit {
@Input() replay: Replay;
@Input() type: string | undefined;
@Output() ready = new EventEmitter<void>();
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;
this.ready.emit();
}
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('没找到命令记录');
}
);
}
onScroll() {
this.getCommands(++this.page);
}
commandClick(item: Command) {
}
}