fix: support the old api

parent c6a21ead
......@@ -126,7 +126,11 @@ export class HttpService {
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);
}
......
......@@ -23,21 +23,24 @@ export class JsonComponent implements OnInit {
}
ngOnInit() {
this._http.get_replay_json(Video.src)
.subscribe(
data => {
Video.json = data;
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;
},
err => {
alert('无法下载');
this._logger.error(err);
}
);
if (Video.src !== 'READY') {
this._http.get_replay_data(Video.src)
.subscribe(
data => {
Video.json = data;
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;
},
err => {
alert('无法下载');
this._logger.error(err);
}
);
}
const that = this;
let r = true;
window.onresize = function () {
......
......@@ -23,7 +23,7 @@ export class ReplayPageComponent implements OnInit {
this.activatedRoute.params.subscribe((params: Params) => {
token = params['token'];
});
this._http.get_replay(token)
this._http.get_replay_json(token)
.subscribe(
data => {
Video.type = data['type'];
......@@ -33,8 +33,24 @@ export class ReplayPageComponent implements OnInit {
Video.height = data['height'];
},
err => {
alert('API请求出错');
this._logger.error(err);
this._http.get_replay(token)
.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