Skip to content

Commit c7798c3

Browse files
committed
fix: View replay failed after the user deleted it.
1 parent 9e6e455 commit c7798c3

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/app/pages/monitor/monitor.component.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
22
import {HttpService, I18nService, SettingService} from '@app/services';
33
import {ActivatedRoute} from '@angular/router';
4-
import {Session, Ticket, User} from '@app/model';
4+
import {Asset, Session, Ticket, User} from '@app/model';
55
import {NzNotificationService} from 'ng-zorro-antd/notification';
66
import {getWaterMarkContent} from '@app/utils/common';
77

@@ -41,8 +41,18 @@ export class PagesMonitorComponent implements OnInit {
4141
this.sessionID = params['sid'];
4242
this.generateMonitorURL().then(async () => {
4343
const sessionObj = this.sessionDetail;
44-
const asset = await this._http.getAssetDetail(sessionObj.asset_id).toPromise();
45-
const sessionUser = await this._http.getUserDetail(sessionObj.user_id);
44+
let asset: any = null;
45+
try {
46+
asset = await this._http.getAssetDetail(sessionObj.asset_id).toPromise();
47+
} catch (error) {
48+
asset = new Asset();
49+
}
50+
let sessionUser: User = null;
51+
try {
52+
sessionUser = await this._http.getUserDetail(sessionObj.user_id);
53+
} catch (error) {
54+
sessionUser = new User();
55+
}
4656
const auditorUser = `${this._i18n.instant('Viewer')}: ${this.user.name}(${this.user.username})`;
4757
const sessionContent = getWaterMarkContent(sessionUser, asset, this._settingSvc);
4858
const content = `${auditorUser}\n${sessionContent}`;
@@ -108,7 +118,7 @@ export class PagesMonitorComponent implements OnInit {
108118
const resumeTaskMsg = await this._i18n.t('Resume task has been send');
109119
const session_ids = res['ok'];
110120
const msg = this.isPaused ? resumeTaskMsg : pauseTaskMsg;
111-
this._toastr.success(msg, '', { nzClass: 'custom-success-notification' });
121+
this._toastr.success(msg, '', {nzClass: 'custom-success-notification'});
112122
if (session_ids.indexOf(this.sessionID) !== -1) {
113123

114124
}

src/app/pages/replay/replay.component.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Component, OnInit } from '@angular/core';
2-
import { ActivatedRoute } from '@angular/router';
3-
import { HttpService, I18nService, LogService, SettingService } from '@app/services';
4-
import { Asset, Replay, Session, User } from '@app/model';
5-
import { getWaterMarkContent } from '@app/utils/common';
1+
import {Component, OnInit} from '@angular/core';
2+
import {ActivatedRoute} from '@angular/router';
3+
import {HttpService, I18nService, LogService, SettingService} from '@app/services';
4+
import {Asset, Replay, Session, User} from '@app/model';
5+
import {getWaterMarkContent} from '@app/utils/common';
66

77
@Component({
88
standalone: false,
@@ -48,8 +48,11 @@ export class PagesReplayComponent implements OnInit {
4848
} catch (error) {
4949
this.asset = new Asset();
5050
}
51-
52-
this.sessionUser = await this._http.getUserDetail(this.session.user_id);
51+
try {
52+
this.sessionUser = await this._http.getUserDetail(this.session.user_id);
53+
} catch (error) {
54+
this.sessionUser = new User();
55+
}
5356

5457
const interval = setInterval(() => {
5558
this._http.getReplay(sid).subscribe(

0 commit comments

Comments
 (0)