Skip to content

Commit

Permalink
Pcm 1667 (#15)
Browse files Browse the repository at this point in the history
* PCM-1667 built with CRA instead

* PCM-1667 another attempt

* PCM-1667 correct configuration issues; touched up unit tests

* PCM-1667 removing unnecessary layers

* PCM-1667 touched up file structure to reduce redundancy

* PCM-1667 working on ways to mock server for fetch/ajax calls

* PCM-1667 attempting unit test set up

* hack the jsonp testing

* PCM-1667 worked on tests to almost 80% coverage for Plantronics

* PCM-1667 resolve merge conflict

* PCM-1667 merge conflict resolution; switching React component back to TSX

* PCM-1667 fixing yarn lock

* fix plantronics tests

* PCM-1667 adding to unit tests

* PCM-1667 added tests for headset events

* PCM-1667 removed commented out code

* PCM-1667 fixed issue with hold call test

* PCM-1667 addressed some PR comments

* PCM-1667 updated pacakge.json to have better scripting

* PCM-1667 laying groundwork for Jabra

* PCM-1667 Jabra functionality foundation worked out

* PCM-1667

* PCM-1667 worked on unit tests for Jabra

* PCM-1667 added in unit tests for Jabra headset up to ~95% coverage

* PCM-1667 updated unit tests and fixed test app issues

* PCM-1667 updated application-service to proper determine when app is hosted

* PCM-1667 removed duplicate function and went back to deviceLabelMatchesVendor which already existed

* PCM-1667 fixed unit tests to no longer check canHandleMic and flesh out deviceLabelMatchesVendor

* PCM-1667 addressed pr comments and concerns

* PCM-1667 updated scripts to help builds find proper directories

* PCM-1667 updated Jenkinsfile

* PCM-1667 removed redundant part of script for now

* PCM-1667 updated lint script

* PCM-1667 removed eslint config for the time

* PCM-1667 updated react package json

* PCM-1667 made linting changes to help pass tests

* PCM-1667 test commit

* PCM-1667 undo test commit

* PCM-1667 renamed mock server scripts

* PCM-1667 updated package.json with new script names

* PCM-1667 fixed typo in package.json

* PCM-1667 removed mock server scripts

* PCM-1667 added in mock server test scripts

* PCM-1667 added in 'bash' for scripts

* PCM-1667 updated Jenkinsfile to use proper test script

* PCM-1667 added install statement for 'react-app'

* PCM-1667 trying new approaches in Jenkinsfile and package.json to help with package installation

* PCM-1667 updated tsconfig to have 'react' rather than 'react-jsx'

* PCM-1667 updated tsconfig

* PCM-1667 reverted tsconfig; added module compile script for tsconfig

* PCM-1667 switching around order of scripts

* PCM-1667 updated include statement for both tsconfigs

* PCM-1667 changed include to a ts extension rather than tsx and pointed to internal tsconfig rather than root

* PCM-1667 set jsx to 'react' instead of 'react-jsx'

* PCM-1667 added webpack

* PCM-1667 updated webpack to point at correct entry

* PCM-1667 updated webpack script

* PCM-1667 update webpack script

* PCM-1667 updated README.md for Github

* PCM-1667 added publish config to package.json

* PCM-1667 made changes to hopefully help with other apps consuming

* PCM-1667 addressed a lot of pr comments; still working on Jabra WebHID permissions; updating build configs to be consumed by other apps

* PCM-1667 temporarily removing test coverage check strictly for build purposes; will be added back in later

* PCM-1667 typo on Jenkinsfile

* PCM-1667 commented out problematic line in jabra.ts and fixed linting issues

* PCM-1667 updated cjs, module, main and typings in package.json

* PCM-1667 updated Call Info interface to let contact name be optional

* PCM-1668 added console logs for testing purposes and updated Jenkinsfile

* PCM-1667 changed headsetEvent$ to a BehaviorSubject

* PCM-1667 changed headsetEvent$ to a BehaviorSubject

* PCM-1667 removing isActive flag temporarily

* PCM-1667 touched up Jabra implementation to add temporary timer; added showRetry and updated proper translation names; added 'retry' button to test app

* PCM-1667 touched up Jabra implementation to add temporary timer; added showRetry and updated proper translation names; added 'retry' button to test app

* PCM-1667 updated connectionStatus return values

* PCM-1667 added in new event to be emitted when connection status changes

* PCM-1667 added connection flags to event

* PCM-1667 added checks to make sure connection status event doesn't fire more than once for the same flag

* PCM-1667 added in device connectivity flags for other vendors (jabra and sennheiser)

* PCM-1667 added in device connectivity flags for other vendors (jabra and sennheiser)

* PCM-1667 removed other Jabra instances (chrome and native) temporarily

* PCM-1667 fixed typo with logic

* PCM-1667 removed unnecessary functions

* PCM-1667 added jabra-native back in; TODO: still need to work on that

* PCM-1667 made changes to hopefully help jabra native work

* PCM-1667 added in a special case for call lock logging

* PCM-1667 added in a special case for call lock logging

* PCM-1667 removed getHeadSetEventsSubject

* remove application service and update jabra native

* PCM-1667 worked on jabra tests and made minor change to incoming call function

* PCM-1667 addressed PR comments; removed console logs; typed message and error type

* PCM-1667 replaced default value for selectedImplementation

* PCM-1667 removed commented out and unused lines

* add tests

* fix test-utils coverage

* PCM-1667 reached 100% coverage for Jabra

* PCM-1667 100% test coverage

* PCM-1667 updated typing in headset.ts; updated error in App.tsx

* PCM-1667 updated typing in headset.ts; updated error in App.tsx

* PCM-1667 fixed or ignored linting issues

* update publish config

* PCM-1667 added coverage thresholds

* PCM-1667 addressed easier PR comments

Co-authored-by: Maxwell Mooney <[email protected]>
Co-authored-by: Garrett Jensen <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2022
1 parent 47e9f43 commit d230063
Show file tree
Hide file tree
Showing 101 changed files with 22,001 additions and 24,146 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
],
"rules": {
"@typescript-eslint/no-var-requires": 1,
"no-prototype-builtins": 0
}
"no-prototype-builtins": 0,
"@typescript-eslint/no-explicit-any": 0
},
"ignorePatterns": [
"**/jabra-*/*.ts"
]
}
16 changes: 6 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
// this will need to be pipeline-library@master when the pr merges
@Library('pipeline-library') _
@Library('pipeline-library@ui-pipeline-legacy') _

webappPipeline {
slaveLabel = 'dev_v2'
nodeVersion = '14.17.5'
useArtifactoryRepo = false
projectName = 'vendor-headsets'
manifest = customManifest('dist') {
sh('node ./create-manifest.js')
readJSON(file: 'dist/manifest.json')
}
manifest = directoryManifest('dist')
buildType = { (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('release/')) ? 'MAINLINE' : 'FEATURE' }
publishPackage = { 'prod' }
publishPackage = { 'dev' }
testJob = null

buildStep = {
sh('''
export CDN_URL="$(npx cdn --ecosystem pc --name $APP_NAME --build $BUILD_ID --version $VERSION)"
echo "CDN_URL $CDN_URL"
npm ci && npm run lint && npm test && npm run build
cd demo-app && npm ci && npm run build
export CDN_URL="$(npx cdn --ecosystem pc --name \$APP_NAME --build \$BUILD_ID --version \$VERSION)"
echo "CDN_URL: \$CDN_URL"
npm run install:all && npm run compile:module && npm run build && npm run lint && npm run test:coverage
''')
}

Expand Down
67 changes: 64 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
# softphone-vendor-headsets
# Softphone Vendor Headsets

Softphone integrations for vendor specific headset hardware and software
### Overview
This library's goal is to abstract all the different headset implementations behind a single interface.

This project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).
This project has a [React](https://github.com/facebook/react/) test app bootstrapped with [create-react-app](https://reactjs.org/docs/create-a-new-react-app.html).

At this moment (12/10/2021) there are three supported vendors already handled with this library:
- Plantronics/Poly
- Sennheiser/EPOS
- Jabra

### Installation

``` sh
# npm
npm install --save softphone-headset-vendors
# yarn
yarn softphone-headset-vendors
```

### Documentation
#### Structure and flow
- The consuming app will first above anything else hit the HeadsetService (`headsets.ts`).
- From there, the service will determine what vendor is currently selected out of the supported vendors above. This will also be a hub to call the proper functions that correspond with app to headset events (More on that later)
- Once the desired vendor has been determined, an instance of that vendor's adapter/service will be created. This adapter will interact with the service or sdk the vendor requires to communicate information to and from the headset.
- If an event is received from the headset itself, the vendor adapters will emit an event that `headset.ts` is listening for. This event will then be passed to the consuming app to properly reflect the state on screen to match that of the headset

**Example 1 - User clicks mute in the consuming app**:
- From the consuming app, the user clicks on an on-screen mute button
- The consuming app calls headsetService.mute(...)
- Which is passed to the corresponding function of the vendor adapter that aligns with the selected device (for example, plantronics.ts -> setMute(true))
- This function will then send a message to the headset itself
- The user will then see the light on their device that represents the "muted" state light up.

**Example 2 - User presses the mute button from the headset**:
- From the headset, the user presses the button which corresponds to mute
- This is then received by the vendor instance (for example sennheiser.ts)
- This event is then sent to `headset.ts` which in turn lets the consuming app know so that the screen properly reflect the state of the headset

#### WebHID
One of our supported vendors has began working with a technology known as [WebHID][1]. This is a relatively newer technology with a lot of promise but with its own caveats as well - https://wicg.github.io/webhid/
- At this moment, WebHID only works with Chromium browsers (Google Chrome/Microsoft Edge). Keep this in mind when developing and using the vendors we currently support
- In order to use WebHID, you must grant permissions for the site you are currently on. There is a function that must be called that causes a popup to show on screen where the user is then required to select their device and approve its use for WebHID purposes. This function MUST be called with user action (i.e. clicking a button). The solution we currently have in place is after the `user` takes the `action` of changing and selecting a new microphone, we check if it is the specific vendor that supports WebHID, then we emit an event that a consuming app should listen for and then fire the WebHID consent function

### Contributing
This repo uses [Jest][3] for tests and code coverage

To get started in development:
```sh
npm install
cd react-app
yarn start
```
Then navigate to https://localhost:8443 to see the test app. This way you can see the effects of the events from the headset on the app and vice versa.

### Testing
Run the tests using `npm run test:watch` or `npm run test:coverage`. Both commands should be run in the folder.
- `test:watch` will rerun the tests after changes to the code or the test itself
- `test:coverage` will run the test suites and produce a report on coverage of the code

**Important Note**: Out of the box, the test scripts will not work on Windows machines. A developer will more than likely need to make modifications to the scripts in the package.json as well as the shell scripts found in the `scripts` folder. If you do not want to modify the scripts out of the box, using a Linux instance seemed to help. The author of the library used an Ubuntu instance

[1]: https://developer.mozilla.org/en-US/docs/Web/API/WebHID_API
[2]: https://wicg.github.io/webhid/
[3]: https://jestjs.io/en/
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ["@babel/preset-env"]
}
9 changes: 0 additions & 9 deletions copy-version.js

This file was deleted.

4 changes: 0 additions & 4 deletions demo-app/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions demo-app/.npmignore

This file was deleted.

Loading

0 comments on commit d230063

Please sign in to comment.