1
1
import { Component , ElementRef , OnInit , ViewChild } from '@angular/core' ;
2
2
import { AppService , HttpService , I18nService , SettingService } from '@app/services' ;
3
3
import { ActivatedRoute } from '@angular/router' ;
4
- import { Session , Ticket } from '@app/model' ;
4
+ import { Session , Ticket , User } from '@app/model' ;
5
5
import { ToastrService } from 'ngx-toastr' ;
6
6
7
7
@Component ( {
@@ -14,27 +14,37 @@ export class PagesMonitorComponent implements OnInit {
14
14
iframeURL : string ;
15
15
sessionDetail : Session = null ;
16
16
sessionID : string ;
17
- isPaused : boolean = false ;
17
+ isPaused : boolean = false ;
18
18
ticketID : string ;
19
19
ticketDetail : Ticket ;
20
20
supportedLock : boolean = false ;
21
+ user : User ;
21
22
22
23
constructor ( private _appService : AppService ,
23
24
private _settingSvc : SettingService ,
24
25
private _http : HttpService ,
25
26
private _route : ActivatedRoute ,
26
27
private _toastr : ToastrService ,
27
- private _i18n : I18nService , ) {
28
+ private _i18n : I18nService ) {
29
+ this . getCurrentUser ( ) ;
30
+ }
31
+
32
+ getCurrentUser ( ) {
33
+ this . _http . getUserProfile ( ) . subscribe ( user => {
34
+ this . user = user ;
35
+ } ) ;
28
36
}
29
37
30
38
ngOnInit ( ) {
31
39
this . _route . params . subscribe ( params => {
32
40
this . sessionID = params [ 'sid' ] ;
33
41
this . generateMonitorURL ( ) . then ( ( ) => {
42
+ const sessionObj = this . sessionDetail ;
43
+ const auditorUser = `${ this . _i18n . instant ( 'Viewer' ) } : ${ this . user . name } (${ this . user . username } )` ;
44
+ const sessionContent = `${ this . _i18n . instant ( 'Operator' ) } : ${ sessionObj . user } \n${ sessionObj . asset } ` ;
45
+ const content = `${ auditorUser } \n${ sessionContent } ` ;
34
46
this . _settingSvc . createWaterMarkIfNeed (
35
- this . windowRef . nativeElement ,
36
- `${ this . sessionDetail . user } \n${ this . sessionDetail . asset } `
37
- ) ;
47
+ this . windowRef . nativeElement , content ) ;
38
48
} ) ;
39
49
} ) ;
40
50
this . _route . queryParams . subscribe ( params => {
@@ -81,11 +91,11 @@ export class PagesMonitorComponent implements OnInit {
81
91
if ( this . ticketID && ! this . ticketDetail ) {
82
92
this . _http . toggleLockSessionForTicket ( this . ticketID , this . sessionID , ! this . isPaused
83
93
) . then ( ( res ) => {
84
- this . handleToggleResponse ( res ) . then ( )
94
+ this . handleToggleResponse ( res ) . then ( ) ;
85
95
} ) ;
86
- } else {
96
+ } else {
87
97
this . _http . toggleLockSession ( this . sessionID , ! this . isPaused ) . then ( ( res ) => {
88
- this . handleToggleResponse ( res ) . then ( )
98
+ this . handleToggleResponse ( res ) . then ( ) ;
89
99
} ) ;
90
100
}
91
101
}
@@ -94,8 +104,8 @@ export class PagesMonitorComponent implements OnInit {
94
104
const pauseTaskMsg = await this . _i18n . t ( 'Pause task has been send' ) ;
95
105
const resumeTaskMsg = await this . _i18n . t ( 'Resume task has been send' ) ;
96
106
const session_ids = res [ 'ok' ] ;
97
- const msg = this . isPaused ? resumeTaskMsg : pauseTaskMsg ;
98
- this . _toastr . success ( msg )
107
+ const msg = this . isPaused ? resumeTaskMsg : pauseTaskMsg ;
108
+ this . _toastr . success ( msg ) ;
99
109
if ( session_ids . indexOf ( this . sessionID ) !== - 1 ) {
100
110
101
111
}
0 commit comments