Skip to content

Commit

Permalink
Merge pull request #110 from cormacmchale1/comchale/CX-16464
Browse files Browse the repository at this point in the history
Updating Major Version and expanding the logout functionality
  • Loading branch information
momeraj authored Oct 15, 2024
2 parents fd8f6fa + 57177d4 commit 7cbe5ad
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lit-element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"test": "jest"
},
"dependencies": {
"@wxcc-desktop/sdk": "^1.2.7",
"@wxcc-desktop/sdk": "^2.0.1",
"@wxcc-desktop/sdk-types": "^1.0.3"
},
"resolutions": {
Expand Down
45 changes: 42 additions & 3 deletions lit-element/src/components/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export default class MyCustomComponent extends LitElement {
agentSessionId = "5a84d32c-691b-4500-b163-d6cdba2a3163";

@property({ type: String }) titleFor = "";
@property({ type: String }) agentIdSignout = "";
@property({ type: String }) orgIdSignout = "";

/**
* Replace this with the logic to obtain interaction ID you need
Expand Down Expand Up @@ -71,7 +73,7 @@ export default class MyCustomComponent extends LitElement {
async connectedCallback() {
super.connectedCallback();

await Desktop.config.init();
await Desktop.config.init({widgetName: "widgetName", widgetProvider: "widgetProvider"});

this.getCurrentInteractionId();
this.subscribeAgentContactDataEvents();
Expand Down Expand Up @@ -187,10 +189,10 @@ export default class MyCustomComponent extends LitElement {
"eAgentConsultConferenceEndFailed",
msg => logger.info("AgentContact eAgentConsultConferenceEndFailed: ", msg)
);
Desktop.agentContact.addEventListener("eAgentMonitorStateChanged", msg =>
Desktop.agentContact.addEventListener("eAgentMonitorStateChanged", (msg: any) =>
logger.info("AgentContact eAgentMonitorStateChanged: ", msg)
);
Desktop.agentContact.addEventListener("eAgentMonitoringEnded", msg =>
Desktop.agentContact.addEventListener("eAgentMonitoringEnded", (msg: any) =>
logger.info("AgentContact eAgentMonitoringEnded: ", msg)
);
}
Expand Down Expand Up @@ -244,6 +246,18 @@ export default class MyCustomComponent extends LitElement {
logger.info(wrapup);
}

async logout()
{
await Desktop.logout.desktopLogout({ data: { logoutReason: "User requested logout" } });
}
async signoutAgent(agentId: string, orgId: any) {
try {
await Desktop.logout.signoutAgent({orgId, data: { agentId, logoutReason: "SupervisorSignout" }});
} catch (e) {
console.log(e);
}
}

async fireNotification() {
const raw: Notifications.ItemMeta.Raw = {
data: {
Expand Down Expand Up @@ -708,6 +722,31 @@ export default class MyCustomComponent extends LitElement {
>Update Title</md-button
>
</md-tab-panel>
<md-tab slot="tab">Desktop.logout</md-tab>
<md-tab-panel slot="panel">
<div class="action-container">
<h2>Signout Functionality</h2>
<md-button @button-click=${() => this.logout()}
>Self Signout</md-button>
<br>
Enter AgentId :
<input
type="text"
id="agentIdSignout"
@change="${(e: any) => (this.agentIdSignout = e?.target?.value)}"
/>
Enter OrgId :
<input
type="text"
id="orgIdSignout"
@change="${(e: any) => (this.orgIdSignout = e?.target?.value)}"
/>
<md-button @click="${() => this.signoutAgent(this.agentIdSignout, this.orgIdSignout)}">
Supervisor Signout Agent
</md-button>
</md-tab-panel>
</md-tabs>
<slot></slot>
</div>
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@types/react": "16.9.3",
"@types/react-dom": "16.9.1",
"@uuip/unified-ui-platform-sdk": "^1.3.6",
"@wxcc-desktop/sdk": "1.3.16",
"@wxcc-desktop/sdk": "2.0.1",
"@wxcc-desktop/sdk-types": "1.0.10",
"copy-webpack-plugin": "^5.0.2",
"direflow-component": "3.5.3",
Expand Down
55 changes: 52 additions & 3 deletions react/src/direflow-component/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const App: FC<IProps> = (props) => {
);

const [titleFor, setTitleFor] = useState("");
const [agentIdSignout, setAgentIdSignout] = useState("");
const [orgIdSignout, setOrgIdSignout] = useState("");
const newInteractionId = useRef<any>(null);

const [buddyAgents, setBuddyAgents] = useState(
Expand Down Expand Up @@ -69,7 +71,7 @@ const App: FC<IProps> = (props) => {
useEffect(() => {}, [props.agentId, props.darkTheme]);

async function init() {
await Desktop.config.init();
await Desktop.config.init({widgetName: "widgetName", widgetProvider: "widgetProvider"});
}

const subscribeScreenpopEvent = () => {
Expand Down Expand Up @@ -272,10 +274,10 @@ const App: FC<IProps> = (props) => {
Desktop.monitoring.addEventListener("eMonitoringUnHoldFailed", (msg: any) =>
logger.info("Monitoring eMonitoringUnHoldFailed: ", msg)
);
Desktop.monitoring.addEventListener("eBargedIn", (msg: any) =>
Desktop.monitoring.addEventListener("eAgentMonitorStateChanged", (msg: any) =>
logger.info("Monitoring eBargedIn: ", msg)
);
Desktop.monitoring.addEventListener("eBargeInFailed", (msg: any) =>
Desktop.monitoring.addEventListener("eAgentMonitorStateChangeFailed", (msg: any) =>
logger.info("Monitoring eBargeInFailed: ", msg)
);
};
Expand All @@ -300,6 +302,16 @@ const App: FC<IProps> = (props) => {
}
};

const logout = async () =>
{
await Desktop.logout.desktopLogout({ data: { logoutReason: "User requested logout" } });
}

const signoutAgent = async (orgIdSignout: string, agentIdSignout:string) =>
{
await Desktop.logout.signoutAgent({orgId: orgIdSignout, data: { agentId: agentIdSignout, logoutReason: "SupervisorSignout" }});
}

const getClientLocale = () => {
logger.info("Client locale: ", Desktop.config.clientLocale);
};
Expand Down Expand Up @@ -977,6 +989,43 @@ const App: FC<IProps> = (props) => {
Update Title
</md-button>
</md-tab-panel>

<md-tab slot="tab">Desktop.logout</md-tab>
<md-tab-panel slot="panel">
<div className="action-container">
<h2>Signout Functionality</h2>
<md-button onClick={() => logout()}>
Self Signout
</md-button>
</div>
<br></br>
<h2>Supervisor sign out</h2>
<md-input
class="input-field"
shape="pill"
placeholder="AgentId"
clear=""
value=""
tabindex="0"
autoFocus
onInput={(e: any) => setAgentIdSignout(e.target.value)}
></md-input>
<md-input
class="input-field"
shape="pill"
placeholder="OrgId"
clear=""
value=""
tabindex="0"
autoFocus
onInput={(e: any) => setOrgIdSignout(e.target.value)}
></md-input>
<md-button onClick={() => signoutAgent(orgIdSignout, agentIdSignout)}>
Supervisor Signout
</md-button>
</md-tab-panel>


</md-tabs>
</div>
</Styled>
Expand Down

0 comments on commit 7cbe5ad

Please sign in to comment.