fix: support the old api

parent c6a21ead
...@@ -126,7 +126,11 @@ export class HttpService { ...@@ -126,7 +126,11 @@ export class HttpService {
return this.http.get('/api/terminal/v1/sessions/' + token + '/replay'); return this.http.get('/api/terminal/v1/sessions/' + token + '/replay');
} }
get_replay_json(src: string) { get_replay_json(token: string) {
return this.http.get('/api/terminal/v2/sessions/' + token + '/replay');
}
get_replay_data(src: string) {
return this.http.get(src); return this.http.get(src);
} }
......
...@@ -23,21 +23,24 @@ export class JsonComponent implements OnInit { ...@@ -23,21 +23,24 @@ export class JsonComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this._http.get_replay_json(Video.src) if (Video.src !== 'READY') {
.subscribe( this._http.get_replay_data(Video.src)
data => { .subscribe(
Video.json = data; data => {
Video.timelist = Object.keys(Video.json).map(Number); Video.json = data;
Video.timelist = Video.timelist.sort(function (a, b) { Video.timelist = Object.keys(Video.json).map(Number);
return a - b; Video.timelist = Video.timelist.sort(function (a, b) {
}); return a - b;
Video.totalTime = Video.timelist[Video.timelist.length - 1] * 1000; });
}, Video.totalTime = Video.timelist[Video.timelist.length - 1] * 1000;
err => { },
alert('无法下载'); err => {
this._logger.error(err); alert('无法下载');
} this._logger.error(err);
); }
);
}
const that = this; const that = this;
let r = true; let r = true;
window.onresize = function () { window.onresize = function () {
......
...@@ -23,7 +23,7 @@ export class ReplayPageComponent implements OnInit { ...@@ -23,7 +23,7 @@ export class ReplayPageComponent implements OnInit {
this.activatedRoute.params.subscribe((params: Params) => { this.activatedRoute.params.subscribe((params: Params) => {
token = params['token']; token = params['token'];
}); });
this._http.get_replay(token) this._http.get_replay_json(token)
.subscribe( .subscribe(
data => { data => {
Video.type = data['type']; Video.type = data['type'];
...@@ -33,8 +33,24 @@ export class ReplayPageComponent implements OnInit { ...@@ -33,8 +33,24 @@ export class ReplayPageComponent implements OnInit {
Video.height = data['height']; Video.height = data['height'];
}, },
err => { err => {
alert('API请求出错'); this._http.get_replay(token)
this._logger.error(err); .subscribe(
data => {
Video.type = 'json';
Video.json = data;
Video.src = 'READY';
Video.timelist = Object.keys(Video.json).map(Number);
Video.timelist = Video.timelist.sort(function (a, b) {
return a - b;
});
Video.totalTime = Video.timelist[Video.timelist.length - 1] * 1000;
}, err2 => {
alert('无法下载');
this._logger.error(err2);
},
);
} }
); );
......
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