feat(tracker/ui): send current agent info for assist sessions

This commit is contained in:
sylenien 2022-11-03 10:51:39 +01:00 committed by Delirium
parent df8aed3464
commit e323a96267
5 changed files with 30 additions and 13 deletions

View file

@ -29,10 +29,19 @@ function LivePlayer ({
assistCredendials,
request,
isEnterprise,
userEmail,
userName
}) {
useEffect(() => {
if (!loadingCredentials) {
initPlayer(session, assistCredendials, true);
const sessionWithAgentData = {
...session,
agentInfo: {
email: userEmail,
name: userName,
},
}
initPlayer(sessionWithAgentData, assistCredendials, true);
}
return () => cleanPlayer()
}, [ session.sessionId, loadingCredentials, assistCredendials ]);
@ -79,6 +88,8 @@ export default withRequest({
showAssist: state.getIn([ 'sessions', 'showChatWindow' ]),
fullscreen: state.getIn([ 'components', 'player', 'fullscreen' ]),
isEnterprise: state.getIn([ 'user', 'account', 'edition' ]) === 'ee',
userEmail: state.getIn(['user', 'account', 'email']),
userName: state.getIn(['user', 'account', 'name']),
}
},
{ toggleFullscreen, closeBottomBlock },

View file

@ -215,7 +215,7 @@ export default class MessageDistributor extends StatedScreen {
this.setMessagesLoading(false)
}
private loadMessages() {
private loadMessages() {
// TODO: reuseable decryptor instance
const createNewParser = (shouldDecrypt=true) => {
const decrypt = shouldDecrypt && this.session.fileKey
@ -242,7 +242,7 @@ export default class MessageDistributor extends StatedScreen {
)
)
.then(this.onFileReadSuccess)
.catch(this.onFileReadFailed)
.catch(this.onFileReadFailed)
.finally(this.onFileReadFinally)
// load devtools

View file

@ -142,7 +142,6 @@ export default class AssistManager {
// @ts-ignore
const urlObject = new URL(window.env.API_EDP || window.location.origin) // does it handle ssl automatically?
// @ts-ignore WTF, socket.io ???
const socket: Socket = this.socket = io(urlObject.origin, {
path: '/ws-assist/socket',
auth: {
@ -151,7 +150,10 @@ export default class AssistManager {
query: {
peerId: this.peerID,
identity: "agent",
//agentInfo: JSON.stringify({})
agentInfo: JSON.stringify({
...this.session.agentInfo,
query: document.location.search
})
}
})
socket.on("connect", () => {
@ -314,7 +316,10 @@ export default class AssistManager {
if (remoteControl === RemoteControlStatus.Requesting) { return }
if (remoteControl === RemoteControlStatus.Disabled) {
update({ remoteControl: RemoteControlStatus.Requesting })
this.socket.emit("request_control")
this.socket.emit("request_control", JSON.stringify({
...this.session.agentInfo,
query: document.location.search
}))
// setTimeout(() => {
// if (getState().remoteControl !== RemoteControlStatus.Requesting) { return }
// this.socket?.emit("release_control")

View file

@ -15,7 +15,7 @@ import type { Options as ConfirmOptions, } from './ConfirmWindow/defaults.js'
// TODO: fully specified strict check with no-any (everywhere)
type StartEndCallback = () => ((()=>Record<string, unknown>) | void)
type StartEndCallback = (agentInfo?: Record<string, any>) => (((agentInfo?: Record<string, any>)=>Record<string, unknown>) | void)
export interface Options {
onAgentConnect: StartEndCallback;
@ -49,7 +49,7 @@ type OptionalCallback = (()=>Record<string, unknown>) | void
type Agent = {
onDisconnect?: OptionalCallback,
onControlReleased?: OptionalCallback,
//name?: string
agentInfo: Record<string, string>
//
}
@ -174,7 +174,7 @@ export default class Assist {
if (this.remoteControl){
callUI?.showRemoteControl(this.remoteControl.releaseControl)
}
this.agents[id].onControlReleased = this.options.onRemoteControlStart()
this.agents[id].onControlReleased = this.options.onRemoteControlStart(this.agents[id].agentInfo)
this.emit('control_granted', id)
annot = new AnnotationCanvas()
annot.mount()
@ -220,8 +220,8 @@ export default class Assist {
socket.on('NEW_AGENT', (id: string, info) => {
this.agents[id] = {
onDisconnect: this.options.onAgentConnect?.(),
...info, // TODO
onDisconnect: this.options.onAgentConnect?.(info),
agentInfo: info, // TODO ?
}
this.assistDemandedRestart = true
this.app.stop()
@ -230,7 +230,8 @@ export default class Assist {
socket.on('AGENTS_CONNECTED', (ids: string[]) => {
ids.forEach(id =>{
this.agents[id] = {
onDisconnect: this.options.onAgentConnect?.(),
...this.agents[id],
onDisconnect: this.options.onAgentConnect?.( this.agents[id].agentInfo),
}
})
this.assistDemandedRestart = true

View file

@ -366,4 +366,4 @@ module.exports = {
socketsLive,
socketsLiveByProject
}
};
};