generated from navikt/crm-shared-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from navikt/NKS-1746
chat v. 2
- Loading branch information
Showing
24 changed files
with
1,055 additions
and
50 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...lt/aura/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2.auradoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<aura:documentation> | ||
<aura:description>Documentation</aura:description> | ||
<aura:example name="ExampleName" ref="exampleComponentName" label="Label"> | ||
Example Description | ||
</aura:example> | ||
</aura:documentation> |
38 changes: 38 additions & 0 deletions
38
...efault/aura/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2.cmp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<aura:component | ||
implements="flexipage:availableForAllPageTypes, force:hasRecordId" | ||
controller="NKS_ChatTranscriptService" | ||
> | ||
<aura:attribute name="loggingEnabled" type="boolean" default="true" /> | ||
<aura:attribute name="authenticated" type="boolean" default="false" /> | ||
<aura:attribute name="accountFields" type="String" /> | ||
<aura:attribute name="caseFields" type="String" /> | ||
<aura:attribute name="personFields" type="String" /> | ||
<aura:attribute name="copyPersonFields" type="String" /> | ||
<aura:attribute name="conversation" type="object[]" /> | ||
<aura:attribute name="subscription" type="Map" /> | ||
<aura:attribute name="chatRecord" type="Object" /> | ||
<aura:attribute name="recordLoadError" type="String" /> | ||
|
||
<lightning:conversationToolkitApi aura:id="chatToolkit" /> | ||
<lightning:workspaceAPI aura:id="workspace" /> | ||
<lightning:empApi aura:id="empApi" /> | ||
|
||
<aura:handler name="init" value="{!this}" action="{!c.onInit}" /> | ||
|
||
<force:recordData | ||
aura:id="recordLoader" | ||
recordId="{!v.recordId}" | ||
fields="CRM_Authentication_Status__c" | ||
targetFields="{!v.chatRecord}" | ||
targetError="{!v.recordLoadError}" | ||
/> | ||
|
||
<c:nksChatAuthenticationInfoV2 | ||
recordId="{!v.recordId}" | ||
loggingEnabled="{!v.loggingEnabled}" | ||
onrequestauthentication="{!c.requestAuthentication}" | ||
onauthenticationcomplete="{!c.handleAuthCompleted}" | ||
aura:id="chatAuthInfo" | ||
> | ||
</c:nksChatAuthenticationInfoV2> | ||
</aura:component> |
5 changes: 5 additions & 0 deletions
5
...ra/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2.cmp-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>59.0</apiVersion> | ||
<description>A Lightning Component Bundle</description> | ||
</AuraDefinitionBundle> |
2 changes: 2 additions & 0 deletions
2
...efault/aura/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.THIS { | ||
} |
3 changes: 3 additions & 0 deletions
3
...ult/aura/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2.design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<design:component label="Chat Authentication Container v. 2"> | ||
<design:attribute label="Enable logging to console" name="loggingEnabled" default="false" /> | ||
</design:component> |
7 changes: 7 additions & 0 deletions
7
...a/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
...ra/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2Controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
({ | ||
onInit: function (component, event, helper) { | ||
const empApi = component.find('empApi'); | ||
empApi.onError( | ||
$A.getCallback((error) => { | ||
console.error('EMP API error: ', JSON.stringify(error)); | ||
}) | ||
); | ||
helper.subscribeEmpApi(component); | ||
}, | ||
|
||
requestAuthentication: function (component, event) { | ||
const chatToolkit = component.find('chatToolkit'); | ||
const recordId = component.get('v.recordId'); | ||
const authInfoCmp = component.find('chatAuthInfo'); | ||
let authUrl = event.getParam('authUrl'); | ||
|
||
chatToolkit | ||
.sendMessage({ | ||
recordId: recordId, | ||
message: { | ||
text: | ||
'Trykk for å logge inn på nav.no og gi veilederen tilgang til saken din. ' + authUrl + recordId | ||
} | ||
}) | ||
.then(function (result) { | ||
authInfoCmp.authRequestHandling(result); | ||
}); | ||
}, | ||
|
||
handleAuthCompleted: function (component, event, helper) { | ||
helper.showLoginMsg(component, event); | ||
} | ||
}); |
74 changes: 74 additions & 0 deletions
74
...t/aura/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2Helper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
({ | ||
showLoginMsg: function (component, event) { | ||
const chatToolkit = component.find('chatToolkit'); | ||
const recordId = component.get('v.recordId'); | ||
const loginMsg = event.getParam('loginMessage'); | ||
|
||
chatToolkit | ||
.sendMessage({ | ||
recordId: recordId, | ||
message: { | ||
text: loginMsg | ||
} | ||
}) | ||
.then(function () {}); | ||
}, | ||
|
||
setTabIcon: function (component, newTabId, iconName, iconAlt) { | ||
let workspace = component.find('workspace'); | ||
workspace.setTabIcon({ | ||
tabId: newTabId, | ||
icon: iconName, | ||
iconAlt: iconAlt | ||
}); | ||
}, | ||
|
||
subscribeEmpApi: function (component) { | ||
const empApi = component.find('empApi'); | ||
const channel = '/topic/Chat_Auth_Status_Changed'; | ||
const replayId = -1; | ||
|
||
empApi | ||
.subscribe( | ||
channel, | ||
replayId, | ||
$A.getCallback((eventReceived) => { | ||
this.onEmpApiEvent(component, eventReceived); | ||
}) | ||
) | ||
.then((subscription) => { | ||
component.set('v.subscription', subscription); | ||
}); | ||
}, | ||
|
||
unsubscribeEmpApi: function (component) { | ||
const empApi = component.find('empApi'); | ||
const subscription = component.get('v.subscription'); | ||
|
||
empApi.unsubscribe( | ||
subscription, | ||
$A.getCallback(() => { | ||
component.set('v.subscription', null); | ||
}) | ||
); | ||
}, | ||
|
||
onEmpApiEvent: function (component, eventReceived) { | ||
const authStatus = eventReceived.data.sobject.CRM_Authentication_Status__c; | ||
const changedRecordId = eventReceived.data.sobject.Id; | ||
const recordId = component.get('v.recordId'); | ||
|
||
if (changedRecordId === recordId) { | ||
component | ||
.find('workspace') | ||
.getEnclosingTabId() | ||
.then((tabId) => { | ||
if (authStatus === 'Completed') { | ||
this.setTabIcon(component, tabId, 'utility:lock', 'Innlogget chat'); | ||
} else { | ||
this.setTabIcon(component, tabId, 'standard:live_chat', 'Uinnlogget chat'); | ||
} | ||
}); | ||
} | ||
} | ||
}); |
3 changes: 3 additions & 0 deletions
3
...aura/nksChatAuthenticationInfoContainerV2/nksChatAuthenticationInfoContainerV2Renderer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
({ | ||
// Your renderer method overrides go here | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.