amazon-connect-reference-dialer 1.0.0 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of amazon-connect-reference-dialer might be problematic. Click here for more details.

Files changed (239) hide show
  1. package/.babelrc +10 -0
  2. package/.eslintrc +24 -0
  3. package/Dockerfile +12 -0
  4. package/LICENSE +21 -0
  5. package/README.md +8 -0
  6. package/README.salesforce.md +50 -0
  7. package/config/appconfig.json +10 -0
  8. package/config/config.js +46 -0
  9. package/docker-compose.yml +16 -0
  10. package/index.js +46 -0
  11. package/nodemon.json +3 -0
  12. package/package.json +5 -4
  13. package/src/client/App.js +20 -0
  14. package/src/client/api/acManager.js +79 -0
  15. package/src/client/api/agentHandler.js +46 -0
  16. package/src/client/api/audioFrequencyMonitor.js +62 -0
  17. package/src/client/api/csioHandler.js +204 -0
  18. package/src/client/api/databaseManager.js +59 -0
  19. package/src/client/api/eventhandler.js +278 -0
  20. package/src/client/api/feedbackHandler.js +21 -0
  21. package/src/client/api/manager/agent.js +203 -0
  22. package/src/client/api/manager/connection.js +181 -0
  23. package/src/client/api/manager/contact.js +114 -0
  24. package/src/client/api/mediaManager.js +138 -0
  25. package/src/client/api/networkStrengthMonitor.js +64 -0
  26. package/src/client/api/precalltest.js +37 -0
  27. package/src/client/api/sessionManager.js +312 -0
  28. package/src/client/configs/consts.js +158 -0
  29. package/src/client/container/agentduration/duration.js +63 -0
  30. package/src/client/container/agentduration/index.js +3 -0
  31. package/src/client/container/agentview/conferenceconnection/agentview.css +100 -0
  32. package/src/client/container/agentview/conferenceconnection/components/bothhold.js +20 -0
  33. package/src/client/container/agentview/conferenceconnection/components/bothjoined.js +25 -0
  34. package/src/client/container/agentview/conferenceconnection/components/dialnumber.js +21 -0
  35. package/src/client/container/agentview/conferenceconnection/components/holdall.js +20 -0
  36. package/src/client/container/agentview/conferenceconnection/components/join.js +21 -0
  37. package/src/client/container/agentview/conferenceconnection/components/oneHoldOtherConnected.js +37 -0
  38. package/src/client/container/agentview/conferenceconnection/components/resumeall.js +21 -0
  39. package/src/client/container/agentview/conferenceconnection/components/swap.js +21 -0
  40. package/src/client/container/agentview/conferenceconnection/components/togglemute.js +23 -0
  41. package/src/client/container/agentview/conferenceconnection/index.js +3 -0
  42. package/src/client/container/agentview/conferenceconnection/lowerBody.js +154 -0
  43. package/src/client/container/agentview/conferenceconnection/main.js +22 -0
  44. package/src/client/container/agentview/conferenceconnection/primaryconnection.js +109 -0
  45. package/src/client/container/agentview/conferenceconnection/quickFeedback.js +118 -0
  46. package/src/client/container/agentview/conferenceconnection/thirdpartyconnection.js +107 -0
  47. package/src/client/container/agentview/conferenceconnection/upperBody.js +36 -0
  48. package/src/client/container/agentview/footer.js +190 -0
  49. package/src/client/container/agentview/index.js +3 -0
  50. package/src/client/container/agentview/main.js +39 -0
  51. package/src/client/container/agentview/primaryconnection/agentMutedLabel.js +23 -0
  52. package/src/client/container/agentview/primaryconnection/agentStatusAndAudioLabel.js +28 -0
  53. package/src/client/container/agentview/primaryconnection/agentview.css +73 -0
  54. package/src/client/container/agentview/primaryconnection/index.js +3 -0
  55. package/src/client/container/agentview/primaryconnection/lowerBody.js +159 -0
  56. package/src/client/container/agentview/primaryconnection/main.js +22 -0
  57. package/src/client/container/agentview/primaryconnection/peerAndAgentDuration.js +48 -0
  58. package/src/client/container/agentview/primaryconnection/quickFeedback.js +123 -0
  59. package/src/client/container/agentview/primaryconnection/upperBody.js +59 -0
  60. package/src/client/container/agentview/thirdparyconnection/agentMutedLabel.js +23 -0
  61. package/src/client/container/agentview/thirdparyconnection/agentStatusAndAudioLabel.js +28 -0
  62. package/src/client/container/agentview/thirdparyconnection/agentview.css +73 -0
  63. package/src/client/container/agentview/thirdparyconnection/index.js +3 -0
  64. package/src/client/container/agentview/thirdparyconnection/lowerBody.js +139 -0
  65. package/src/client/container/agentview/thirdparyconnection/main.js +22 -0
  66. package/src/client/container/agentview/thirdparyconnection/peerAndAgentDuration.js +49 -0
  67. package/src/client/container/agentview/thirdparyconnection/quickFeedback.js +118 -0
  68. package/src/client/container/agentview/thirdparyconnection/upperBody.js +59 -0
  69. package/src/client/container/audiolabelview/controller.js +104 -0
  70. package/src/client/container/audiolabelview/localaudiolevel.js +157 -0
  71. package/src/client/container/audiolabelview/noaudio.js +86 -0
  72. package/src/client/container/audiolabelview/remoteaudiolevel.js +110 -0
  73. package/src/client/container/audiolabelview/settingpageaudiolevel.js +154 -0
  74. package/src/client/container/common/contactField.js +30 -0
  75. package/src/client/container/common/each.contact.js +41 -0
  76. package/src/client/container/common/findContact.js +31 -0
  77. package/src/client/container/connectivitycheckview/body.js +113 -0
  78. package/src/client/container/connectivitycheckview/components/fractionalLoss.js +57 -0
  79. package/src/client/container/connectivitycheckview/components/mediaConnectivity.js +41 -0
  80. package/src/client/container/connectivitycheckview/components/roundTripTime.js +57 -0
  81. package/src/client/container/connectivitycheckview/components/rttgraph/rttgraph.js +176 -0
  82. package/src/client/container/connectivitycheckview/components/rttgraph/utils.js +96 -0
  83. package/src/client/container/connectivitycheckview/components/throughput.js +53 -0
  84. package/src/client/container/connectivitycheckview/components/throughputMessage.js +36 -0
  85. package/src/client/container/connectivitycheckview/connectivitycheck.css +44 -0
  86. package/src/client/container/connectivitycheckview/footer.js +43 -0
  87. package/src/client/container/connectivitycheckview/index.js +3 -0
  88. package/src/client/container/connectivitycheckview/loading/loading.css +73 -0
  89. package/src/client/container/connectivitycheckview/loading/loading.js +15 -0
  90. package/src/client/container/connectivitycheckview/main.js +19 -0
  91. package/src/client/container/dialerview/body.js +135 -0
  92. package/src/client/container/dialerview/dialpad.css +104 -0
  93. package/src/client/container/dialerview/dialpad.js +29 -0
  94. package/src/client/container/dialerview/index.js +3 -0
  95. package/src/client/container/dialerview/main.js +19 -0
  96. package/src/client/container/errors/error.css +30 -0
  97. package/src/client/container/errors/error.js +58 -0
  98. package/src/client/container/errors/index.js +3 -0
  99. package/src/client/container/footer/components/acceptOrReject.js +26 -0
  100. package/src/client/container/footer/components/availableOrEnd.js +28 -0
  101. package/src/client/container/footer/components/connectivitycheck.js +21 -0
  102. package/src/client/container/footer/components/downloadlogs.js +23 -0
  103. package/src/client/container/footer/components/info.js +22 -0
  104. package/src/client/container/footer/components/language.js +22 -0
  105. package/src/client/container/footer/components/reportcall.js +35 -0
  106. package/src/client/container/footer/components/version.js +22 -0
  107. package/src/client/container/header/header.css +46 -0
  108. package/src/client/container/header/header.js +135 -0
  109. package/src/client/container/header/index.js +3 -0
  110. package/src/client/container/home.js +129 -0
  111. package/src/client/container/login/body.js +67 -0
  112. package/src/client/container/login/ccpinputbox.js +23 -0
  113. package/src/client/container/login/footer.js +19 -0
  114. package/src/client/container/login/index.js +2 -0
  115. package/src/client/container/login/login.css +134 -0
  116. package/src/client/container/login/main.js +23 -0
  117. package/src/client/container/networkstrengthview/index.js +3 -0
  118. package/src/client/container/networkstrengthview/loading/loading.css +74 -0
  119. package/src/client/container/networkstrengthview/loading/loading.js +15 -0
  120. package/src/client/container/networkstrengthview/networkstrength.js +102 -0
  121. package/src/client/container/popups/confirmreport/confirmreport.css +47 -0
  122. package/src/client/container/popups/confirmreport/confirmreport.js +55 -0
  123. package/src/client/container/popups/quality/quality.css +32 -0
  124. package/src/client/container/popups/quality/quality.js +44 -0
  125. package/src/client/container/quickconnects/body.js +141 -0
  126. package/src/client/container/quickconnects/close.js +23 -0
  127. package/src/client/container/quickconnects/index.js +3 -0
  128. package/src/client/container/quickconnects/main.js +18 -0
  129. package/src/client/container/quickconnects/quickconnects.css +95 -0
  130. package/src/client/container/reportissueview/body.js +73 -0
  131. package/src/client/container/reportissueview/feedbackRatings.js +37 -0
  132. package/src/client/container/reportissueview/footer.js +20 -0
  133. package/src/client/container/reportissueview/index.js +3 -0
  134. package/src/client/container/reportissueview/issueNotes.js +22 -0
  135. package/src/client/container/reportissueview/issues.js +44 -0
  136. package/src/client/container/reportissueview/main.js +105 -0
  137. package/src/client/container/reportissueview/predefinedIssues.js +38 -0
  138. package/src/client/container/reportissueview/reportissue.css +102 -0
  139. package/src/client/container/settingsview/body.js +156 -0
  140. package/src/client/container/settingsview/components/audiooutputdevice.js +25 -0
  141. package/src/client/container/settingsview/components/deskphone.js +29 -0
  142. package/src/client/container/settingsview/components/desktopsettings.js +38 -0
  143. package/src/client/container/settingsview/components/dropdown-options.js +44 -0
  144. package/src/client/container/settingsview/components/phonetype.js +14 -0
  145. package/src/client/container/settingsview/components/settings.js +23 -0
  146. package/src/client/container/settingsview/components/softphone.js +30 -0
  147. package/src/client/container/settingsview/components/softphonesettings.js +35 -0
  148. package/src/client/container/settingsview/footer.js +96 -0
  149. package/src/client/container/settingsview/index.js +3 -0
  150. package/src/client/container/settingsview/main.js +20 -0
  151. package/src/client/container/settingsview/settings.css +126 -0
  152. package/src/client/container/statechangeview/body.js +61 -0
  153. package/src/client/container/statechangeview/footer.js +43 -0
  154. package/src/client/container/statechangeview/index.js +3 -0
  155. package/src/client/container/statechangeview/main.js +21 -0
  156. package/src/client/container/statechangeview/statuschange.css +47 -0
  157. package/src/client/container/transfercall/body.js +139 -0
  158. package/src/client/container/transfercall/close.js +23 -0
  159. package/src/client/container/transfercall/index.js +3 -0
  160. package/src/client/container/transfercall/main.js +18 -0
  161. package/src/client/container/transfercall/transfercall.css +99 -0
  162. package/src/client/index.js +13 -0
  163. package/src/client/reducers/acReducer.js +277 -0
  164. package/src/client/reducers/reducer.js +8 -0
  165. package/src/client/reducers.js +2 -0
  166. package/src/client/res/images/agent-voice-freq-icon.svg +61 -0
  167. package/src/client/res/images/change-status-icon.svg +16 -0
  168. package/src/client/res/images/csio-logo.png +0 -0
  169. package/src/client/res/images/csioLogo.png +0 -0
  170. package/src/client/res/images/dialer-setting-icon.svg +15 -0
  171. package/src/client/res/images/fa-circle-mark.svg +3 -0
  172. package/src/client/res/images/fa-circle-unmark.svg +3 -0
  173. package/src/client/res/images/fa-close-or-dismiss.svg +17 -0
  174. package/src/client/res/images/fa-danger.svg +3 -0
  175. package/src/client/res/images/fa-dial-button.svg +13 -0
  176. package/src/client/res/images/fa-dial-number.svg +15 -0
  177. package/src/client/res/images/fa-download.svg +3 -0
  178. package/src/client/res/images/fa-hold.svg +13 -0
  179. package/src/client/res/images/fa-ico-join.svg +27 -0
  180. package/src/client/res/images/fa-ico-swap.svg +27 -0
  181. package/src/client/res/images/fa-info.svg +3 -0
  182. package/src/client/res/images/fa-input-sound.svg +5 -0
  183. package/src/client/res/images/fa-language.svg +3 -0
  184. package/src/client/res/images/fa-mark-false.svg +3 -0
  185. package/src/client/res/images/fa-mark-true.svg +3 -0
  186. package/src/client/res/images/fa-mic-freq-temporary.gif +0 -0
  187. package/src/client/res/images/fa-mic.svg +3 -0
  188. package/src/client/res/images/fa-mini-endcall.svg +48 -0
  189. package/src/client/res/images/fa-mini-hold.svg +47 -0
  190. package/src/client/res/images/fa-mini-resume.svg +45 -0
  191. package/src/client/res/images/fa-mute.svg +13 -0
  192. package/src/client/res/images/fa-network-strength-1.svg +5 -0
  193. package/src/client/res/images/fa-network-strength-2.svg +6 -0
  194. package/src/client/res/images/fa-network-strength-3.svg +6 -0
  195. package/src/client/res/images/fa-network-strength-4.svg +6 -0
  196. package/src/client/res/images/fa-network-strength-5.svg +5 -0
  197. package/src/client/res/images/fa-network-strength-unknown-2.svg +9 -0
  198. package/src/client/res/images/fa-network-strength-unknown.svg +6 -0
  199. package/src/client/res/images/fa-quick-connect.svg +15 -0
  200. package/src/client/res/images/fa-refresh.svg +3 -0
  201. package/src/client/res/images/fa-resume.svg +3 -0
  202. package/src/client/res/images/fa-return.svg +3 -0
  203. package/src/client/res/images/fa-three-dots.svg +32 -0
  204. package/src/client/res/images/fa-tick-green.svg +3 -0
  205. package/src/client/res/images/fa-tick-mark.svg +3 -0
  206. package/src/client/res/images/fa-transfer.svg +3 -0
  207. package/src/client/res/images/fa-version.svg +4 -0
  208. package/src/client/res/images/fa-voice-no-freq.svg +5 -0
  209. package/src/client/res/images/favicon.ico +0 -0
  210. package/src/client/res/images/muted-icon.svg +13 -0
  211. package/src/client/res/images/network-strength-icon.svg +13 -0
  212. package/src/client/res/images/peer-voice-freq-icon.svg +26 -0
  213. package/src/client/res/images/star-white.svg +6 -0
  214. package/src/client/res/images/star-yellow.svg +6 -0
  215. package/src/client/res/scss/global.css +14 -0
  216. package/src/client/router.js +17 -0
  217. package/src/client/store.js +11 -0
  218. package/src/client/utils/acutils.js +114 -0
  219. package/src/client/utils/agetStateMap.js +36 -0
  220. package/src/client/utils/feedback.js +3 -0
  221. package/src/client/utils/initialStateManager.js +14 -0
  222. package/src/server/index.js +53 -0
  223. package/src/server/logger.js +93 -0
  224. package/src/server/public/fonts/AmazonEmber_Lt.ttf +0 -0
  225. package/src/server/public/fonts/AmazonEmber_Rg.ttf +0 -0
  226. package/src/server/public/img/favicon.ico +0 -0
  227. package/src/server/public/js/amazon-connect-pre-shim.js +2 -0
  228. package/src/server/router/compare.js +36 -0
  229. package/src/server/router/index.js +36 -0
  230. package/src/server/router/stock.js +33 -0
  231. package/src/server/views/_heap_prod.ejs +8 -0
  232. package/src/server/views/_hotjar_prod.ejs +14 -0
  233. package/src/server/views/_hotjar_test.ejs +12 -0
  234. package/src/server/views/compare.ejs +69 -0
  235. package/src/server/views/index.ejs +69 -0
  236. package/src/server/views/stock.ejs +101 -0
  237. package/webpack.common.config.js +48 -0
  238. package/webpack.dev.config.js +21 -0
  239. package/webpack.prod.config.js +10 -0
@@ -0,0 +1,37 @@
1
+ import csioHandler from './csioHandler';
2
+
3
+ const PCT_INTERVAL_MS = 1 * 60 * 1000; // Every two minutes
4
+ // const PCT_INTERVAL_MS = 15 * 1000; // Every two minutes
5
+
6
+ class PrecallTest {
7
+ constructor () {
8
+ this.inProgress = false;
9
+ this.lastRuntimeInMs = 0;
10
+ }
11
+
12
+ shouldRun () {
13
+ let now = (new Date()).getTime();
14
+ if (now - this.lastRuntimeInMs < PCT_INTERVAL_MS) {
15
+ return false;
16
+ }
17
+ if (this.inProgress) {
18
+ return false;
19
+ }
20
+ return true;
21
+ }
22
+
23
+ async doPrecallTest () {
24
+ this.inProgress = true;
25
+ try {
26
+ // console.warn('doPrecallTest');
27
+ await csioHandler.doPrecallTest();
28
+ } catch (err) {
29
+ console.warn('->', err);
30
+ }
31
+ this.inProgress = false;
32
+ this.lastRuntimeInMs = (new Date()).getTime();
33
+ }
34
+ }
35
+
36
+ const precallTest = new PrecallTest();
37
+ export default precallTest;
@@ -0,0 +1,312 @@
1
+ import agentHandler from './agentHandler';
2
+ import acManager from './acManager';
3
+ import libphonenumber from 'google-libphonenumber';
4
+
5
+ import {
6
+ dialNumber,
7
+ getQuickConnectionList,
8
+ getTransferConnList,
9
+ mute,
10
+ unmute,
11
+ setAgentState,
12
+ getAgentDeskphoneNumber,
13
+ isAgentSoftphoneEnabled,
14
+ changeToSoftPhone,
15
+ changeToDeskphone,
16
+ getDialableCountries,
17
+ setAgentAvailable,
18
+ getEndpointByPhone,
19
+ getCallbackQueue
20
+ } from './manager/agent';
21
+
22
+ import {
23
+ isNeedToTransferCall,
24
+ acceptCall,
25
+ rejectCall,
26
+ dialContact,
27
+ holdAll,
28
+ resumeAll,
29
+ swapCall
30
+ } from './manager/contact';
31
+
32
+ import {
33
+ holdConnection,
34
+ resumeConnection,
35
+ getPrimaryAgentState,
36
+ getPrimaryConnectionDuration,
37
+ getThirdPartyConnectionDuration,
38
+ getPrimaryConnectionPhone,
39
+ getThirdPartyConnectionPhone,
40
+ hangupPrimaryConnection,
41
+ getPrimaryConnection,
42
+ getThirdPartyConnection,
43
+ endConnection,
44
+ sendDigit
45
+ } from './manager/connection';
46
+ import lo from 'lodash';
47
+
48
+ class SessionManager {
49
+ constructor () {
50
+ this.phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
51
+ this.PNF = libphonenumber.PhoneNumberFormat;
52
+ this.lastStateAsString = null;
53
+ }
54
+
55
+ isNeedToTransferCall () {
56
+ const contact = acManager.getCurrentContact();
57
+ return isNeedToTransferCall(contact);
58
+ }
59
+
60
+ // it can be simply just dialing a number
61
+ // or can be a transfer call to another number
62
+ dialNumber (phoneNumber = null) {
63
+ if (!this.isNeedToTransferCall()) {
64
+ // simply dial the number
65
+ const agent = agentHandler.getAgent();
66
+ return dialNumber(agent, phoneNumber);
67
+ } else {
68
+ // get the contact (endpoint) by phone number, and transfer it
69
+ // by using addConnection method of contact using dialContact wrapper
70
+ const agent = agentHandler.getAgent();
71
+ return getEndpointByPhone(agent, phoneNumber).then(endpoint => {
72
+ const currentContact = acManager.getCurrentContact();
73
+ return dialContact(currentContact, endpoint);
74
+ }).catch(err => {
75
+ return new Promise((resolve, reject) => {
76
+ reject(err);
77
+ });
78
+ });
79
+ }
80
+ }
81
+
82
+ getQuickConnectionList () {
83
+ const agent = agentHandler.getAgent();
84
+ return getQuickConnectionList(agent);
85
+ }
86
+
87
+ getTransferConnList () {
88
+ const agent = agentHandler.getAgent();
89
+ return getTransferConnList(agent);
90
+ }
91
+
92
+ mute () {
93
+ const agent = agentHandler.getAgent();
94
+ return mute(agent);
95
+ }
96
+
97
+ unmute () {
98
+ const agent = agentHandler.getAgent();
99
+ return unmute(agent);
100
+ }
101
+
102
+ holdConnection (connection = undefined) {
103
+ return holdConnection(connection);
104
+ }
105
+
106
+ resumeConnection (connection = undefined) {
107
+ return resumeConnection(connection);
108
+ }
109
+
110
+ endConnection (connection = undefined) {
111
+ return endConnection(connection);
112
+ }
113
+
114
+ getPrimaryAgentState () {
115
+ const currentState = acManager.getCurrentState();
116
+ return getPrimaryAgentState(currentState);
117
+ }
118
+
119
+ getPrimaryConnectionDuration () {
120
+ const currentState = acManager.getCurrentState();
121
+ return getPrimaryConnectionDuration(currentState);
122
+ }
123
+
124
+ getThirdPartyConnectionDuration () {
125
+ const currentState = acManager.getCurrentState();
126
+ return getThirdPartyConnectionDuration(currentState);
127
+ }
128
+
129
+ getPrimaryConnectionPhone () {
130
+ const currentState = acManager.getCurrentState();
131
+ const phoneNumber = getPrimaryConnectionPhone(currentState);
132
+ if (phoneNumber && phoneNumber.length > 0) {
133
+ try {
134
+ const temp = this.phoneUtil.parse(phoneNumber, '');
135
+ const formatPhoneNumber = this.phoneUtil.format(temp, this.PNF.INTERNATIONAL);
136
+ return formatPhoneNumber;
137
+ } catch (err) {
138
+ console.warn('~', phoneNumber, err && err.message);
139
+ return phoneNumber;
140
+ }
141
+ } else {
142
+ return phoneNumber;
143
+ }
144
+ }
145
+
146
+ getThirdPartyConnectionPhone () {
147
+ const currentState = acManager.getCurrentState();
148
+ const phoneNumber = getThirdPartyConnectionPhone(currentState);
149
+ if (phoneNumber && phoneNumber.length > 0) {
150
+ try {
151
+ const temp = this.phoneUtil.parse(phoneNumber, '');
152
+ const formatPhoneNumber = this.phoneUtil.format(temp, this.PNF.INTERNATIONAL);
153
+ return formatPhoneNumber;
154
+ } catch (err) {
155
+ console.warn('~', phoneNumber, err && err.message);
156
+ return phoneNumber;
157
+ }
158
+ } else {
159
+ return phoneNumber;
160
+ }
161
+ }
162
+
163
+ getAgentStates () {
164
+ const agent = agentHandler.getAgent();
165
+ return agent.getAgentStates() || [];
166
+ }
167
+
168
+ setAgentState (agentState = undefined) {
169
+ let agent = agentHandler.getAgent();
170
+ return setAgentState(agent, agentState);
171
+ }
172
+
173
+ getAgentDeskphoneNumber () {
174
+ let agent = agentHandler.getAgent();
175
+ return getAgentDeskphoneNumber(agent);
176
+ }
177
+
178
+ isAgentSoftphoneEnabled () {
179
+ let agent = agentHandler.getAgent();
180
+ return isAgentSoftphoneEnabled(agent);
181
+ }
182
+
183
+ changeToSoftPhone () {
184
+ let agent = agentHandler.getAgent();
185
+ return changeToSoftPhone(agent);
186
+ }
187
+
188
+ changeToDeskphone (phoneNumber = null) {
189
+ let agent = agentHandler.getAgent();
190
+ return changeToDeskphone(agent, phoneNumber);
191
+ }
192
+
193
+ getDialableCountries () {
194
+ let agent = agentHandler.getAgent();
195
+ return getDialableCountries(agent);
196
+ }
197
+
198
+ setAgentAvailable () {
199
+ let agent = agentHandler.getAgent();
200
+ return setAgentAvailable(agent);
201
+ }
202
+
203
+ hangupPrimaryConnection () {
204
+ const currentState = acManager.getCurrentState();
205
+ return hangupPrimaryConnection(currentState);
206
+ }
207
+
208
+ acceptCall () {
209
+ const currentContact = acManager.getCurrentContact();
210
+ return acceptCall(currentContact);
211
+ }
212
+
213
+ rejectCall () {
214
+ const currentContact = acManager.getCurrentContact();
215
+ return rejectCall(currentContact);
216
+ }
217
+
218
+ // hangup contact, and reject are basically same
219
+ hangupContact () {
220
+ const currentContact = acManager.getCurrentContact();
221
+ return rejectCall(currentContact);
222
+ }
223
+
224
+ dialContact (selectedContact = undefined) {
225
+ const currentContact = acManager.getCurrentContact();
226
+ return dialContact(currentContact, selectedContact);
227
+ }
228
+
229
+ holdAll () {
230
+ const currentState = acManager.getCurrentState();
231
+ const primaryConnection = getPrimaryConnection(currentState);
232
+ const thirdPartyConnection = getThirdPartyConnection(currentState);
233
+ return holdAll(holdConnection, primaryConnection, thirdPartyConnection);
234
+ }
235
+
236
+ resumeAll () {
237
+ const currentContact = acManager.getCurrentContact();
238
+ return resumeAll(currentContact);
239
+ }
240
+
241
+ swapCall () {
242
+ const currentContact = acManager.getCurrentContact();
243
+ return swapCall(currentContact);
244
+ }
245
+
246
+ getPrimaryConnection () {
247
+ const currentState = acManager.getCurrentState();
248
+ return getPrimaryConnection(currentState);
249
+ }
250
+
251
+ getThirdPartyConnection () {
252
+ const currentState = acManager.getCurrentState();
253
+ return getThirdPartyConnection(currentState);
254
+ }
255
+
256
+ isConference (currentState = undefined) {
257
+ return currentState && currentState.primaryConnectionState && currentState.thirdPartyConnectionState;
258
+ }
259
+
260
+ isOnlyPrimary (currentState = undefined) {
261
+ return currentState && currentState.primaryConnectionState && !currentState.thirdPartyConnectionState;
262
+ }
263
+
264
+ getCurrentStateString (currentState = undefined, isPrimary = true) {
265
+ const stateAsString = lo.get(currentState,
266
+ isPrimary ? 'primaryConnectionState.state' : 'thirdPartyConnectionState.state', this.lastStateAsString);
267
+ this.lastStateAsString = stateAsString;
268
+ return stateAsString;
269
+ }
270
+
271
+ isActive (currentState = undefined) {
272
+ const primaryConnection = this.getPrimaryConnection();
273
+ const thirdParyConnection = this.getThirdPartyConnection();
274
+
275
+ return (primaryConnection && primaryConnection.isActive()) || (thirdParyConnection && thirdParyConnection.isActive());
276
+ }
277
+
278
+ sendDigit (currentDigit = null) {
279
+ const primaryConnection = this.getPrimaryConnection();
280
+ const thirdParyConnection = this.getThirdPartyConnection();
281
+ // if primary connection is active
282
+ if (primaryConnection && primaryConnection.isActive()) {
283
+ return sendDigit(primaryConnection, currentDigit);
284
+ } else if (thirdParyConnection && thirdParyConnection.isActive()) {
285
+ return sendDigit(thirdParyConnection, currentDigit);
286
+ } else {
287
+ return Promise.reject(new Error('no active connection'));
288
+ }
289
+ }
290
+
291
+ setLoginWindow (loginWindow = undefined) {
292
+ // current it is disposed when initialized is success from agentHandler
293
+ agentHandler.setLoginWindow(loginWindow);
294
+ }
295
+
296
+ // not calling from anywhere for now
297
+ disposeLoginWindow () {
298
+ agentHandler.disposeLoginWindow();
299
+ }
300
+
301
+ getIsLoggedIn () {
302
+ return acManager.getIsLoggedIn();
303
+ }
304
+
305
+ getCallbackQueue () {
306
+ const agent = agentHandler.getAgent();
307
+ return getCallbackQueue(agent);
308
+ }
309
+ }
310
+
311
+ const sessionManage = new SessionManager();
312
+ export default sessionManage;
@@ -0,0 +1,158 @@
1
+ // eslint-disable-next-line no-unused-vars
2
+
3
+ export function checkForNan (value) {
4
+ return isNaN(value) ? null : value;
5
+ }
6
+
7
+ export function isNaNOrUndefined (value) {
8
+ return value !== undefined && checkForNan(value) !== null;
9
+ }
10
+
11
+ const qualityRating = {
12
+ excellent: 5,
13
+ good: 4,
14
+ fair: 3,
15
+ poor: 2,
16
+ bad: 1
17
+ };
18
+
19
+ /* const MAX_VALUE = 1023456789;
20
+ const throughputthreshold = [
21
+ { threshold: 8, qualityRating: 1 },
22
+ { threshold: 15, qualityRating: 2 },
23
+ { threshold: 25, qualityRating: 3 },
24
+ { threshold: 30, qualityRating: 4 },
25
+ { threshold: MAX_VALUE, qualityRating: 5 }
26
+ ]; */
27
+
28
+ export const qualityAsString = (nextworkStrength) => {
29
+ switch (nextworkStrength) {
30
+ case -1:
31
+ return 'loading';
32
+ case 1:
33
+ return 'bad';
34
+ case 2:
35
+ return 'poor';
36
+ case 3:
37
+ return 'fair';
38
+ case 4:
39
+ return 'good';
40
+ case 5:
41
+ return 'excellent';
42
+ }
43
+ return 'Unknown';
44
+ };
45
+
46
+ export const throughputThreshold2 = {
47
+ audio: {
48
+ green: 30,
49
+ red: 8
50
+ }
51
+ };
52
+
53
+ export const rttThreshold = {
54
+ audio: {
55
+ green: 400,
56
+ red: 1000
57
+ }
58
+ };
59
+
60
+ export const fractionalLossThreshold = {
61
+ audio: {
62
+ green: 0.15,
63
+ red: 0.30
64
+ }
65
+ };
66
+
67
+ export const avQualityRatings = {
68
+ excellent: 'excellent',
69
+ fair: 'fair',
70
+ bad: 'bad',
71
+ unknown: 'unknown'
72
+ };
73
+
74
+ export function getDescendentRating (value, thresholds) {
75
+ if (thresholds.green <= value) {
76
+ return avQualityRatings.excellent;
77
+ }
78
+ if (thresholds.red < value) {
79
+ return avQualityRatings.fair;
80
+ }
81
+ return avQualityRatings.bad;
82
+ }
83
+
84
+ export function getAscendingRating (value, thresholds) {
85
+ let result;
86
+ if (thresholds.red < value) {
87
+ result = avQualityRatings.bad;
88
+ } else if (thresholds.green <= value) {
89
+ result = avQualityRatings.fair;
90
+ } else {
91
+ result = avQualityRatings.excellent;
92
+ }
93
+ return result;
94
+ }
95
+
96
+ export function fromQualityString (qualityString = avQualityRatings.unknown) {
97
+ switch (qualityString) {
98
+ case avQualityRatings.bad:
99
+ return qualityRating.bad;
100
+ case avQualityRatings.fair:
101
+ return qualityRating.fair;
102
+ case avQualityRatings.excellent:
103
+ return qualityRating.excellent;
104
+ }
105
+ return 0;
106
+ }
107
+
108
+ export function toQualityString (_qualityRating = qualityRating.excellent) {
109
+ switch (_qualityRating) {
110
+ case qualityRating.excellent:
111
+ return avQualityRatings.excellent;
112
+ case qualityRating.good:
113
+ return avQualityRatings.fair;
114
+ case qualityRating.fair:
115
+ return avQualityRatings.fair;
116
+ case qualityRating.poor:
117
+ return avQualityRatings.fair;
118
+ case qualityRating.bad:
119
+ return avQualityRatings.bad;
120
+ }
121
+ return avQualityRatings.unknown;
122
+ }
123
+
124
+ function getOverallTrackQuality (qualities = []) {
125
+ let totalWeight = 0;
126
+ let result = 0;
127
+ for (let i = 0, len = qualities.length; i < len; i += 1) {
128
+ let curQuality = qualities[i];
129
+ totalWeight += curQuality.weight;
130
+ }
131
+ for (let i = 0, len = qualities.length; i < len; i += 1) {
132
+ let curQuality = qualities[i];
133
+ result += (curQuality.result * curQuality.weight) / Math.max(totalWeight, 1);
134
+ }
135
+ result = Math.floor(result);
136
+ // let qualityString = this.toQualityString(result);
137
+ return result;
138
+ }
139
+
140
+ export function getQuality (bitrate, rtt, fl) {
141
+ let bitrateQualityRating = getDescendentRating(bitrate, throughputThreshold2.audio);
142
+ let rttQualityRating = getAscendingRating(rtt, rttThreshold.audio);
143
+ let flQualityRating = getAscendingRating(fl, fractionalLossThreshold.audio);
144
+
145
+ let qualities = [];
146
+ if (!isNaNOrUndefined(bitrateQualityRating)) {
147
+ qualities.push({ result: fromQualityString(bitrateQualityRating), weight: 1 });
148
+ }
149
+ if (!isNaNOrUndefined(rttQualityRating)) {
150
+ qualities.push({ result: fromQualityString(rttQualityRating), weight: 1 });
151
+ }
152
+ if (!isNaNOrUndefined(flQualityRating)) {
153
+ qualities.push({ result: fromQualityString(flQualityRating), weight: 1 });
154
+ }
155
+
156
+ // console.warn('-> ', bitrate, rtt, fl, qualities);
157
+ return getOverallTrackQuality(qualities);
158
+ }
@@ -0,0 +1,63 @@
1
+ import React, { Component } from 'react';
2
+ import sessionManager from './../../api/sessionManager';
3
+ import PropTypes from 'prop-types';
4
+
5
+ const DURATION_MS = 1 * 1000;
6
+
7
+ const durationCSS = {
8
+ div: 'col-4 align-self-center text-right',
9
+ p: 'm-0',
10
+ pStyle: {
11
+ fontFamily: 'AmazonEmber',
12
+ color: '#ffffff',
13
+ fontSize: '14px'
14
+ }
15
+ };
16
+
17
+ // Will show the duration of current agent state duration
18
+ // todo might need to update for conference
19
+ class Duration extends Component {
20
+ constructor (props) {
21
+ super(props);
22
+ this.intervalId = undefined;
23
+ this.state = {
24
+ duration: '00:00:00'
25
+ };
26
+ }
27
+
28
+ _dispose () {
29
+ if (this.intervalId) {
30
+ clearInterval(this.intervalId);
31
+ }
32
+ }
33
+
34
+ componentDidMount () {
35
+ this._dispose();
36
+ this.intervalId = setInterval(() => {
37
+ let duration = this.props.isPrimary ? sessionManager.getPrimaryConnectionDuration() : sessionManager.getThirdPartyConnectionDuration();
38
+ this.setState({
39
+ duration: duration
40
+ });
41
+ }, DURATION_MS);
42
+ }
43
+
44
+ componentWillUnmount () {
45
+ this._dispose();
46
+ }
47
+
48
+ render () {
49
+ return (
50
+ <div className={durationCSS.div}>
51
+ <p className={durationCSS.p}
52
+ style={durationCSS.pStyle}>{this.state.duration}</p>
53
+ </div>
54
+ );
55
+ }
56
+ }
57
+
58
+ Duration.propTypes = {
59
+ currentState: PropTypes.string,
60
+ isPrimary: PropTypes.bool.isRequired
61
+ };
62
+
63
+ export default Duration;
@@ -0,0 +1,3 @@
1
+ import Duration from './duration';
2
+
3
+ export default Duration;
@@ -0,0 +1,100 @@
1
+ .buttonCommon {
2
+ cursor: pointer;
3
+ width: 132px;
4
+ height: 36px;
5
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
6
+ background-color: #ffffff;
7
+ color: #000000;
8
+ font-family: AmazonEmber;
9
+ font-size: 14px;
10
+ border-radius: 0 !important;
11
+
12
+ }
13
+
14
+ .toggleMute {
15
+ width: 132px;
16
+ height: 36px;
17
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
18
+ background-color: #ffffff;
19
+ color: #000000;
20
+ font-family: AmazonEmber;
21
+ font-size: 14px;
22
+ border-radius: 0 !important;
23
+ }
24
+
25
+ .quickConnectOrTransfer {
26
+ width: 132px;
27
+ height: 36px;
28
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
29
+ background-color: #ffffff;
30
+ color: #000000;
31
+ font-family: AmazonEmber;
32
+ font-size: 14px;
33
+ border-radius: 0 !important;
34
+ }
35
+
36
+ .agentStateDiv {
37
+ max-height: 0em;
38
+ }
39
+
40
+ .agentState {
41
+ font-family: AmazonEmber-light;
42
+ color: #ffffff;
43
+ font-size: 26px;
44
+ }
45
+
46
+ .agentStateMini {
47
+ font-family: AmazonEmber-light;
48
+ color: #ffffff;
49
+ font-size: 26px;
50
+ }
51
+
52
+ .phoneAndDurationMini {
53
+ font-family: AmazonEmber;
54
+ color: #ffffff;
55
+ font-size: 14px;
56
+ }
57
+
58
+ .agentMutedState {
59
+ /*max-height: 0em;*/
60
+ }
61
+
62
+ .agentMutedText {
63
+ font-family: AmazonEmber;
64
+ color: #ffffff;
65
+ font-size: 12px;
66
+ }
67
+
68
+ .agentMutedSpan {
69
+ margin-left: 2%;
70
+ }
71
+
72
+ .agentMutedIcon {
73
+ margin-top: -1%;
74
+ }
75
+
76
+ .peerAndAgentDurationText {
77
+ font-family: AmazonEmber;
78
+ color: #ffffff;
79
+ font-size: 14px;
80
+ }
81
+
82
+ .miniHoldResume {
83
+ background-size: 24px 24px;
84
+ width: 24px;
85
+ height: 24px;
86
+ /*margin-left: 7%;*/
87
+
88
+ margin-right: 5% !important;
89
+ margin-top: 10% !important;
90
+ cursor: pointer;
91
+ }
92
+
93
+ .miniEnd {
94
+ background-size: 24px 24px;
95
+ width: 24px;
96
+ height: 24px;
97
+ /*margin-left: 5% !important;*/
98
+ cursor: pointer;
99
+ margin-top: 10% !important;
100
+ }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import MuteUnmute from './togglemute';
5
+ import ResumeAll from './resumeall';
6
+
7
+ const BothHoldView = ({ muted = false, toggleMuteUnmute, resumeAll }) => (
8
+ <div className={`row mt-3`}>
9
+ <ResumeAll resumeAll={resumeAll}/>
10
+ <MuteUnmute muted={muted} toggleMuteUnmute={toggleMuteUnmute}/>
11
+ </div>
12
+ );
13
+
14
+ BothHoldView.propTypes = {
15
+ muted: PropTypes.bool,
16
+ toggleMuteUnmute: PropTypes.func,
17
+ resumeAll: PropTypes.func
18
+ };
19
+
20
+ export default BothHoldView;