@wazo/sdk 0.38.0 → 0.38.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.
- package/README.md +293 -0
- package/dist/wazo-sdk.js +5 -5
- package/esm/__tests__/web-rtc-client.test.js +1 -1
- package/esm/checker/Checker.js +1 -1
- package/esm/checker/checks/index.js +1 -1
- package/esm/checker/checks/webrtc-transport.js +1 -1
- package/esm/checker/checks/webrtc.js +1 -1
- package/esm/index.js +267 -25
- package/esm/simple/Auth.js +267 -25
- package/esm/simple/Configuration.js +267 -25
- package/esm/simple/Phone.js +267 -25
- package/esm/simple/Softphone.js +266 -24
- package/esm/simple/index.js +267 -25
- package/esm/simple/room/LocalParticipant.js +267 -25
- package/esm/simple/room/Participant.js +267 -25
- package/esm/simple/room/RemoteParticipant.js +267 -25
- package/esm/simple/room/Room.js +267 -25
- package/esm/simple/room/SipRoom.js +267 -25
- package/esm/simple/room/Stream.js +267 -25
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +267 -25
- package/esm/simple/utils.js +267 -25
- package/esm/web-rtc-client.js +1 -1
- package/lib/__tests__/web-rtc-client.test.js +1 -1
- package/lib/checker/Checker.js +1 -1
- package/lib/checker/checks/index.js +1 -1
- package/lib/checker/checks/webrtc-transport.js +1 -1
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/index.js +267 -25
- package/lib/simple/Auth.js +267 -25
- package/lib/simple/Configuration.js +267 -25
- package/lib/simple/Phone.js +267 -25
- package/lib/simple/Softphone.js +266 -24
- package/lib/simple/index.js +267 -25
- package/lib/simple/room/LocalParticipant.js +267 -25
- package/lib/simple/room/Participant.js +267 -25
- package/lib/simple/room/RemoteParticipant.js +267 -25
- package/lib/simple/room/Room.js +267 -25
- package/lib/simple/room/SipRoom.js +267 -25
- package/lib/simple/room/Stream.js +267 -25
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +267 -25
- package/lib/simple/utils.js +267 -25
- package/lib/web-rtc-client.js +1 -1
- package/package.json +1 -1
- package/src/simple/Softphone.js +264 -24
- package/src/web-rtc-client.js +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@ Wazo's Javascript SDK allows you to use these features :
|
|
|
57
57
|
- [Participant](#participant)
|
|
58
58
|
- [Participant events](#participant-events)
|
|
59
59
|
- [Stream](#stream)
|
|
60
|
+
+ [Softphone integration](#softphone-integration)
|
|
60
61
|
* [Advanced API](#advanced-api)
|
|
61
62
|
+ [Libraries](#libraries)
|
|
62
63
|
- [Require / Import](#require--import)
|
|
@@ -599,6 +600,298 @@ Detaches a stream from an existing htmlElement.
|
|
|
599
600
|
|
|
600
601
|
- `htmlElement`: htmlElement.
|
|
601
602
|
|
|
603
|
+
### Softphone integration
|
|
604
|
+
|
|
605
|
+
To be able to integrate Wazo softphone in any web page, you can add :
|
|
606
|
+
|
|
607
|
+
```js
|
|
608
|
+
Wazo.Softphone.init({
|
|
609
|
+
url, // Url of the softphone to be loaded in the iframe (optional).
|
|
610
|
+
width, // Width (in px) of the softphone (optional).
|
|
611
|
+
height, // Height (in px) of the softphone (optional).
|
|
612
|
+
server, // Stack host where the softphone should connect user (optional).
|
|
613
|
+
port, // Stack port where the softphone should connect user (optional).
|
|
614
|
+
language, // Softphone language (optional).
|
|
615
|
+
wrapUpDuration, // How long (in seconds) should the softphone display the card after the call (optional).
|
|
616
|
+
// When the user changes anything on the card, this timeout is canceled
|
|
617
|
+
enableAgent, // display the agent tab in the tab bar (defaults to true).
|
|
618
|
+
tenantId, // Tenant id used for LDAP connection
|
|
619
|
+
debug, // Set to `true` to display wording customization labels
|
|
620
|
+
});
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
#### Methods
|
|
624
|
+
|
|
625
|
+
##### Making a call
|
|
626
|
+
```js
|
|
627
|
+
Wazo.Softphone.makeCall(number);
|
|
628
|
+
```
|
|
629
|
+
- `number`: Number to call through the softphone
|
|
630
|
+
|
|
631
|
+
##### Showing / hidding the softphone
|
|
632
|
+
```js
|
|
633
|
+
Wazo.Softphone.toggleSoftphoneDisplay();
|
|
634
|
+
Wazo.Softphone.displaySoftphone();
|
|
635
|
+
Wazo.Softphone.hideSoftphone();
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
##### Parsing links on the page
|
|
639
|
+
```js
|
|
640
|
+
Wazo.Softphone.parseLinks();
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
Each link with a `href="tel:"` or `href="callto:"` will make a call through the softphone.
|
|
644
|
+
|
|
645
|
+
#### Sending search results to the softphone:
|
|
646
|
+
```js
|
|
647
|
+
Wazo.Softphone.onOptionsResults(fieldId, results);
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
`onOptionsResults` is used to populate Autocomplete fields
|
|
651
|
+
|
|
652
|
+
#### Updating card value:
|
|
653
|
+
```js
|
|
654
|
+
Wazo.Softphone.setCardValue(field, value);
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
#### Customizing page style
|
|
658
|
+
|
|
659
|
+
You can inspect the iframe with your dev tool console to figure out how to override styles.
|
|
660
|
+
|
|
661
|
+
```js
|
|
662
|
+
Wazo.Softphone.injectCss(`
|
|
663
|
+
# Reduce dialer number font size
|
|
664
|
+
.keypad-number, .keypad-number::placeholder {
|
|
665
|
+
font-size: 20px;
|
|
666
|
+
}
|
|
667
|
+
`);
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
#### Override appearance
|
|
671
|
+
```js
|
|
672
|
+
Softphone.customizeAppearance({
|
|
673
|
+
// Theme, default values :
|
|
674
|
+
primary: '#203890',
|
|
675
|
+
button: '#292C87',
|
|
676
|
+
black: '#000',
|
|
677
|
+
white: '#fff',
|
|
678
|
+
greenButton: '#7ed865',
|
|
679
|
+
greenButtonHover: '#6ebf5a',
|
|
680
|
+
redButton: '#FA5846',
|
|
681
|
+
redButtonHover: '#FF604F',
|
|
682
|
+
buttonText: '#fff',
|
|
683
|
+
error: '#E80539',
|
|
684
|
+
secondary: '#203890',
|
|
685
|
+
grey: '#8A95A0',
|
|
686
|
+
secondGrey: '#eee',
|
|
687
|
+
headerColor: '#888',
|
|
688
|
+
avatar: '#bdbdbd',
|
|
689
|
+
divider: 'rgba(0, 0, 0, 0.12)',
|
|
690
|
+
placeholder: 'rgba(22, 44, 66, 0.5)',
|
|
691
|
+
hovered: '#6181F4',
|
|
692
|
+
}, {
|
|
693
|
+
// Translation
|
|
694
|
+
// Set `debug: true` to know where to change translations, eg:
|
|
695
|
+
en: {
|
|
696
|
+
user: {
|
|
697
|
+
login: 'My login button', // will be displayed as `user:login` in the button when settings `debug: true` in the init() method
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
}, {
|
|
701
|
+
// Assets
|
|
702
|
+
// logo: [url to your logo],
|
|
703
|
+
});
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
`onOptionsResults` is used to populate Autocomplete fields
|
|
707
|
+
|
|
708
|
+
#### Customizing card form
|
|
709
|
+
|
|
710
|
+
You can use [JSON schema](http://json-schema.org/) to customize the card form with `Softphone.setFormSchema(schema, uiSchema)`,
|
|
711
|
+
the Softphone uses [React Json schema form](https://react-jsonschema-form.readthedocs.io) internally to display card form :
|
|
712
|
+
|
|
713
|
+
```js
|
|
714
|
+
Softphone.setFormSchema({
|
|
715
|
+
type: 'object',
|
|
716
|
+
required: ['title', 'phone'],
|
|
717
|
+
properties: {
|
|
718
|
+
title: { type: 'string', title: 'Title' },
|
|
719
|
+
phone: { type: 'string', title: 'Phone' },
|
|
720
|
+
note: { type: 'string', title: 'Note' },
|
|
721
|
+
},
|
|
722
|
+
}, {
|
|
723
|
+
note: { 'ui:widget': 'textarea' },
|
|
724
|
+
});
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
##### Auto complete
|
|
728
|
+
We can use an `autocomplete` widget to search on fields in the `uiSchema`:
|
|
729
|
+
|
|
730
|
+
```js
|
|
731
|
+
{
|
|
732
|
+
note :{ 'ui:widget': 'textarea'},
|
|
733
|
+
clientId :{ 'ui:field': 'autocomplete'},
|
|
734
|
+
};
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
In the `schema` field, we can customize if we want to display a `+` button :
|
|
738
|
+
```js
|
|
739
|
+
clientId: {
|
|
740
|
+
type: 'object',
|
|
741
|
+
title: 'Client id',
|
|
742
|
+
// triggers the `onDisplayLinkedOption` event when changing the value
|
|
743
|
+
triggerDisplay: true,
|
|
744
|
+
// createForm is another JSON schema the description the add option form.
|
|
745
|
+
createForm: {
|
|
746
|
+
optionLabel: '%firstname% %lastname%',
|
|
747
|
+
schema: {
|
|
748
|
+
type: 'object',
|
|
749
|
+
required: ['phone'],
|
|
750
|
+
properties: {
|
|
751
|
+
firstname: { type: 'string', title: 'Firstname' },
|
|
752
|
+
lastname: { type: 'string', title: 'Lastname' },
|
|
753
|
+
phone: { type: 'string', title: 'Phone' },
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
uiSchema: {}
|
|
757
|
+
},
|
|
758
|
+
}
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
#### Callbacks
|
|
762
|
+
|
|
763
|
+
You can listen to softphone callback, with :
|
|
764
|
+
|
|
765
|
+
```js
|
|
766
|
+
Wazo.Softphone.onLinkEnabled = link => {
|
|
767
|
+
// link is `<a>` html tag in the page with a href="tel:xx" (or callto:xxx) beeing processed
|
|
768
|
+
// You can make change here, like addind className, etc ...
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
Softphone.onCallIncoming = call => {
|
|
772
|
+
// Invoked when a call is incoming in the softphone
|
|
773
|
+
// You can make action here like redirecting to the contact page (by using `call.number).
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
Softphone.onCallLocallyAnswered = call => {
|
|
777
|
+
// Invoked when the user accepts the call locally
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
Softphone.onCallRemotelyAnswered = call => {
|
|
781
|
+
// Invoked when the other party accepts the call
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
Softphone.onOutgoingCallMade = call => {
|
|
785
|
+
// Invoked when the user makes a call
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
Softphone.onCallRejected = call => {
|
|
789
|
+
// Invoked when the user rejects an incoming call
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
Softphone.onCallEnded = (call, card, direction) => {
|
|
793
|
+
// Invoked when the call is ended
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
Softphone.onCardSaved = card => {
|
|
797
|
+
// Invoked when the user save the card at the end of the call
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
Softphone.onCallMade = call => {
|
|
801
|
+
// Invoked when an outgoing call is made
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
Softphone.onSearchOptions = (fieldId: string, query: string) => {
|
|
805
|
+
// Invoked when the user is making a search from an Autocomplete field in the card form
|
|
806
|
+
// We need to call `onOptionsResults` here to send results to the softphone
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
Softphone.onDisplayLinkedOption = (optionId: string) => {
|
|
810
|
+
// Invoked when the user is selecting a value in a Autocomplete widget
|
|
811
|
+
// useful to display this entity in your application
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
Softphone.onWazoContactSearch = (query: string) => {
|
|
815
|
+
// Invoked when the user is searching from contact page
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
Softphone.onAgentLoggedIn = () => {
|
|
819
|
+
// Invoked when the agent logs in
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
Softphone.onAgentLoggedOut = () => {
|
|
823
|
+
// Invoked when the agent logs out
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
Softphone.onAgentPaused = () => {
|
|
827
|
+
// Invoked when the agent is paused
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
Softphone.onLanguageChanged = (language: string) => {
|
|
831
|
+
// Invoked when the user changed the softphone language
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
Softphone.onCallHeld = () => {
|
|
835
|
+
// Invoked when the current call is held
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
Softphone.onCallResumed = () => {
|
|
839
|
+
// Invoked when the current call is resumed
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
Softphone.onCallMuted = () => {
|
|
843
|
+
// Invoked when the current call is muted
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
Softphone.onCallUnMuted = () => {
|
|
847
|
+
// Invoked when the current call is un muted
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
Softphone.onDtmfSent = (tone: string) => {
|
|
851
|
+
// Invoked when the user is sending a DTMF in the current call
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
Softphone.onDirectTransfer = (number: string) => {
|
|
855
|
+
// Invoked when the user is transfers the current call directly
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
Softphone.onCreateIndirectTransfer = (number: string) => {
|
|
859
|
+
// Invoked when the user initiates an indirect transfer for the current call
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
Softphone.onCancelIndirectTransfer = () => {
|
|
863
|
+
// Invoked when the user cancels the current indirect transfer
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
Softphone.onConfirmIndirectTransfer = () => {
|
|
867
|
+
// Invoked when the user confirms the current indirect transfer
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
Softphone.onIndirectCallMade = (call: Object) => {
|
|
871
|
+
// Invoked when the current indirect transfer is made
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
Softphone.onIndirectTransferDone = (call: Object) => {
|
|
875
|
+
// Invoked when the current indirect transfer is over
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
Softphone.onStartRecording = () => {
|
|
879
|
+
// Invoked when the user records the current call
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
Softphone.onStopRecording = () => {
|
|
883
|
+
// Invoked when the user stops recording the current call
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
Softphone.onAuthenticated = session => {
|
|
887
|
+
// Invoked when the user is authenticated in the softphone
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
Softphone.onLoggedOut = session => {
|
|
891
|
+
// Invoked when the user is is logged out in the softphone
|
|
892
|
+
};
|
|
893
|
+
```
|
|
894
|
+
|
|
602
895
|
## Advanced API
|
|
603
896
|
|
|
604
897
|
### Libraries
|