Commit 9b62f42b authored by Muhammadali's avatar Muhammadali

update-

parent 4a51d89e
{ {
"name": "boxdialer", "name": "boxdialer",
"version": "4.8.59", "version": "4.8.60",
"description": "", "description": "",
"main": "src/boxDialer.js", "main": "src/boxDialer.js",
"scripts": { "scripts": {
......
/** @format */ /** @format */
import { toast } from 'react-hot-toast'; import {toast} from 'react-hot-toast';
import outcomingringTone from '../sounds/ringtone.wav'; import outcomingringTone from '../sounds/ringtone.wav';
import waitRingTone from '../sounds/ringbacktone.wav'; import waitRingTone from '../sounds/ringbacktone.wav';
import pickSound from '../sounds/dtmf.wav'; import pickSound from '../sounds/dtmf.wav';
import { WebSocketInterface, UA } from 'jssip'; import {WebSocketInterface, UA} from 'jssip';
import tugpng from '../img/tug.png'; import tugpng from '../img/tug.png';
import packageJson from '../../package.json'; import packageJson from '../../package.json';
export class BoxDialer { export class BoxDialer {
sTransferNumber; sTransferNumber;
oRingTone; oRingTone;
...@@ -91,10 +92,15 @@ export class BoxDialer { ...@@ -91,10 +92,15 @@ export class BoxDialer {
this.options = { this.options = {
eventHandlers: this.uaEvents(), eventHandlers: this.uaEvents(),
mediaConstraints: { audio: true, video: false }, mediaConstraints: {audio: true, video: false},
}; };
} }
setGlobalHistoryData(data){
console.log('setGlobalHistoryData: ', data)
this.globalHistoryData = data
}
dialTone(freq1, freq2) { dialTone(freq1, freq2) {
// merger = context.createChannelMerger(2); // merger = context.createChannelMerger(2);
// setTimeout(() => { // setTimeout(() => {
...@@ -130,6 +136,7 @@ export class BoxDialer { ...@@ -130,6 +136,7 @@ export class BoxDialer {
// ? this.oscillator2.start(0) // ? this.oscillator2.start(0)
// : this.oscillator2.noteOn(0); // : this.oscillator2.noteOn(0);
} }
start() { start() {
// if (typeof this.oscillator1 != 'undefined') this.oscillator1.disconnect(); // if (typeof this.oscillator1 != 'undefined') this.oscillator1.disconnect();
// if (typeof this.oscillator2 != 'undefined') this.oscillator2.disconnect(); // if (typeof this.oscillator2 != 'undefined') this.oscillator2.disconnect();
...@@ -149,6 +156,7 @@ export class BoxDialer { ...@@ -149,6 +156,7 @@ export class BoxDialer {
// this.oscillator1 = null; // this.oscillator1 = null;
// this.oscillator2 = null; // this.oscillator2 = null;
} }
uaEvents() { uaEvents() {
return { return {
progress: (e) => { progress: (e) => {
...@@ -193,7 +201,7 @@ export class BoxDialer { ...@@ -193,7 +201,7 @@ export class BoxDialer {
}); });
window.navigator.mediaDevices window.navigator.mediaDevices
.getUserMedia({ audio: true }) .getUserMedia({audio: true})
.then(function (stream) { .then(function (stream) {
console.log( console.log(
'User_Danied_Media_Access', 'User_Danied_Media_Access',
...@@ -300,7 +308,7 @@ export class BoxDialer { ...@@ -300,7 +308,7 @@ export class BoxDialer {
greeting.addEventListener('click', cbk); greeting.addEventListener('click', cbk);
} }
onSoundType({ type, bool }) { onSoundType({type, bool}) {
this.ringtone.remove(); this.ringtone.remove();
this.waitRingTone.remove(); this.waitRingTone.remove();
this.pickSound.remove(); this.pickSound.remove();
...@@ -347,7 +355,7 @@ export class BoxDialer { ...@@ -347,7 +355,7 @@ export class BoxDialer {
} }
} }
sipRegister = ({ number, secret, wsurl, isIce }) => { sipRegister = ({number, secret, wsurl, isIce}) => {
try { try {
if (window?.alovoice_setversion && packageJson?.version) { if (window?.alovoice_setversion && packageJson?.version) {
window.alovoice_setversion(packageJson?.version); window.alovoice_setversion(packageJson?.version);
...@@ -479,11 +487,36 @@ export class BoxDialer { ...@@ -479,11 +487,36 @@ export class BoxDialer {
type: 'connectingIncoming', type: 'connectingIncoming',
from: this?.callSession?._remote_identity?._uri?.user, from: this?.callSession?._remote_identity?._uri?.user,
}); });
if (this.callSession.direction === 'incoming') { if (this.callSession.direction === 'incoming') {
let second
console.log('auto_answer is work: ', this.globalHistoryData?.autoAnswer)
if (this.globalHistoryData?.autoAnswer) {
switch (this.globalHistoryData?.autoAnswerSecond) {
case 1:
second = 1000
break
case 40:
second = 3000
break
case 100:
second = 6000
break
default:
second = 0
}
console.log('auto_answer second: ', second)
setTimeout(() => {
console.log('auto_answer run boxDialer.answerButtonClick()')
this.answerButtonClick()
}, second)
}
this.showNotification(() => { this.showNotification(() => {
this.answerButtonClick(); this.answerButtonClick();
}); });
this.onSoundType({ type: 'ring', bool: true }); this.onSoundType({type: 'ring', bool: true});
this.setGuiPhoneState({ this.setGuiPhoneState({
funcName: 'modalState', funcName: 'modalState',
stateCode: 'connectingIncoming', stateCode: 'connectingIncoming',
...@@ -513,7 +546,7 @@ export class BoxDialer { ...@@ -513,7 +546,7 @@ export class BoxDialer {
e, e,
); );
// the call has answered // the call has answered
this.onSoundType({ type: 'ring', bool: false }); this.onSoundType({type: 'ring', bool: false});
this.setGuiPhoneState({ this.setGuiPhoneState({
funcName: 'modalState', funcName: 'modalState',
funcParam: { funcParam: {
...@@ -586,7 +619,7 @@ export class BoxDialer { ...@@ -586,7 +619,7 @@ export class BoxDialer {
type: null, type: null,
}); });
this.stopInnerTimer(); this.stopInnerTimer();
this.onSoundType({ type: 'ring', bool: false }); this.onSoundType({type: 'ring', bool: false});
this.closeBxCall(); this.closeBxCall();
this.hangupButtonClick(); this.hangupButtonClick();
this.setGuiPhoneState({ this.setGuiPhoneState({
...@@ -732,7 +765,7 @@ export class BoxDialer { ...@@ -732,7 +765,7 @@ export class BoxDialer {
return sipState && uiStates[sipState] ? uiStates[sipState] : ''; return sipState && uiStates[sipState] ? uiStates[sipState] : '';
} }
callBxMethods({ bxMethodName, bxFuncParams, callback }) { callBxMethods({bxMethodName, bxFuncParams, callback}) {
if (window.BX24 && window.BX24.placement) { if (window.BX24 && window.BX24.placement) {
window?.BX24.placement.call(bxMethodName, bxFuncParams, callback); window?.BX24.placement.call(bxMethodName, bxFuncParams, callback);
} else if (window.alovoicePhone && window.alovoicePhone.callMethods) { } else if (window.alovoicePhone && window.alovoicePhone.callMethods) {
...@@ -742,9 +775,11 @@ export class BoxDialer { ...@@ -742,9 +775,11 @@ export class BoxDialer {
this.removeViExternalCard(); this.removeViExternalCard();
} }
} }
closeBxCall() { closeBxCall() {
if (window.BX24 && window.BX24.placement) { if (window.BX24 && window.BX24.placement) {
window?.BX24.placement.call('CallCardClose', {}, () => {}); window?.BX24.placement.call('CallCardClose', {}, () => {
});
} else if ( } else if (
window.alovoicePhone && window.alovoicePhone &&
window.alovoicePhone.callMethods && window.alovoicePhone.callMethods &&
...@@ -754,7 +789,7 @@ export class BoxDialer { ...@@ -754,7 +789,7 @@ export class BoxDialer {
} }
} }
setGuiPhoneState({ stateCode, funcName, funcParam }) { setGuiPhoneState({stateCode, funcName, funcParam}) {
if (window?.alovoice_wsphone && !!stateCode?.length) { if (window?.alovoice_wsphone && !!stateCode?.length) {
console.log( console.log(
'this_getBxUiState_stateCode', 'this_getBxUiState_stateCode',
...@@ -763,7 +798,7 @@ export class BoxDialer { ...@@ -763,7 +798,7 @@ export class BoxDialer {
); );
this.callBxMethods({ this.callBxMethods({
bxMethodName: 'CallCardSetUiState', bxMethodName: 'CallCardSetUiState',
bxFuncParams: { uiState: this.getBxUiState(stateCode) }, bxFuncParams: {uiState: this.getBxUiState(stateCode)},
callback: (e) => { callback: (e) => {
console.log(e, `CallCardSetUiState method done ${e}`); console.log(e, `CallCardSetUiState method done ${e}`);
}, },
...@@ -782,11 +817,12 @@ export class BoxDialer { ...@@ -782,11 +817,12 @@ export class BoxDialer {
console.log(`%c BXLOG:`, datas, 'background-color: red;'); console.log(`%c BXLOG:`, datas, 'background-color: red;');
} }
onSessionEvent({ type, event }) {} onSessionEvent({type, event}) {
}
selectUser() { selectUser() {
BX.Runtime.loadExtension('ui.entity-selector').then((exports) => { BX.Runtime.loadExtension('ui.entity-selector').then((exports) => {
const { Dialog, TagSelector } = exports; const {Dialog, TagSelector} = exports;
const dialog = new BX.UI.EntitySelector.Dialog({ const dialog = new BX.UI.EntitySelector.Dialog({
// targetNode: button, // targetNode: button,
...@@ -796,7 +832,7 @@ export class BoxDialer { ...@@ -796,7 +832,7 @@ export class BoxDialer {
entities: [ entities: [
{ {
id: 'user', // пользователи id: 'user', // пользователи
options: { selectFields: ['ufPhoneInner'] }, options: {selectFields: ['ufPhoneInner']},
}, },
{ {
id: 'department', // структура компании: выбор только пользователей id: 'department', // структура компании: выбор только пользователей
...@@ -804,7 +840,7 @@ export class BoxDialer { ...@@ -804,7 +840,7 @@ export class BoxDialer {
], ],
events: { events: {
'_Item:onSelect': (event) => { '_Item:onSelect': (event) => {
const { item } = event.getData(); const {item} = event.getData();
const dialog = event.getTarget(); const dialog = event.getTarget();
const selectedItems = dialog.getSelectedItems(); const selectedItems = dialog.getSelectedItems();
...@@ -832,9 +868,11 @@ export class BoxDialer { ...@@ -832,9 +868,11 @@ export class BoxDialer {
sipHangUp() { sipHangUp() {
console.log('sipHangUp'); console.log('sipHangUp');
} }
sipUnRegister() { sipUnRegister() {
console.log('sipUnRegister'); console.log('sipUnRegister');
} }
sipTransfer() { sipTransfer() {
console.log('sipTransfer'); console.log('sipTransfer');
} }
...@@ -868,12 +906,12 @@ export class BoxDialer { ...@@ -868,12 +906,12 @@ export class BoxDialer {
} }
skipButtonClick() { skipButtonClick() {
this.onSoundType({ type: 'ring', bool: false }); this.onSoundType({type: 'ring', bool: false});
this.hangupButtonClick(); this.hangupButtonClick();
} }
answerButtonClick() { answerButtonClick() {
this.onSoundType({ type: 'ring', bool: false }); this.onSoundType({type: 'ring', bool: false});
this.callSession?.answer(this.options); this.callSession?.answer(this.options);
this.callSession.connection.addEventListener('addstream', (event) => { this.callSession.connection.addEventListener('addstream', (event) => {
this.remoteAudio.srcObject = event.stream; this.remoteAudio.srcObject = event.stream;
...@@ -888,39 +926,42 @@ export class BoxDialer { ...@@ -888,39 +926,42 @@ export class BoxDialer {
addCommentButtonClick() { addCommentButtonClick() {
console.log('addCommentButtonClick'); console.log('addCommentButtonClick');
} }
muteButtonClick() { muteButtonClick() {
let { audio } = this.callSession.isMuted(); let {audio} = this.callSession.isMuted();
if (audio) { if (audio) {
this.callSession.unmute(); this.callSession.unmute();
console.log('muteButtonClick_unmute'); console.log('muteButtonClick_unmute');
this.onSipStateChange['setCallEvents']({ callMute: false }); this.onSipStateChange['setCallEvents']({callMute: false});
} else { } else {
this.callSession.mute(); this.callSession.mute();
console.log('muteButtonClick_mute'); console.log('muteButtonClick_mute');
this.onSipStateChange['setCallEvents']({ callMute: true }); this.onSipStateChange['setCallEvents']({callMute: true});
} }
} }
holdButtonClick() { holdButtonClick() {
let { local } = this.callSession.isOnHold(); let {local} = this.callSession.isOnHold();
console.log('local: ', local); console.log('local: ', local);
if (local) { if (local) {
this.callSession.unhold(); this.callSession.unhold();
this.onSipStateChange['setCallEvents']({ callHold: false }); this.onSipStateChange['setCallEvents']({callHold: false});
} else { } else {
this.callSession.hold(); this.callSession.hold();
this.onSipStateChange['setCallEvents']({ callHold: true }); this.onSipStateChange['setCallEvents']({callHold: true});
} }
} }
closeButtonClick() { closeButtonClick() {
this.hangupButtonClick(); this.hangupButtonClick();
} }
hangupButtonClick() { hangupButtonClick() {
this.onSoundType({ type: 'ring', bool: false }); this.onSoundType({type: 'ring', bool: false});
this.onSipStateChange.innerCallerModal({ this.onSipStateChange.innerCallerModal({
bool: false, bool: false,
type: null, type: null,
...@@ -937,12 +978,15 @@ export class BoxDialer { ...@@ -937,12 +978,15 @@ export class BoxDialer {
transferButtonClick(number) { transferButtonClick(number) {
this.callSession.refer(number, this.options); this.callSession.refer(number, this.options);
} }
cancelTransferButtonClick() { cancelTransferButtonClick() {
console.log('cancelTransferButtonClick'); console.log('cancelTransferButtonClick');
} }
completeTransferButtonClick() { completeTransferButtonClick() {
console.log('completeTransferButtonClick'); console.log('completeTransferButtonClick');
} }
nextButtonClick() { nextButtonClick() {
console.log('nextButtonClick'); console.log('nextButtonClick');
} }
...@@ -950,13 +994,16 @@ export class BoxDialer { ...@@ -950,13 +994,16 @@ export class BoxDialer {
entityChanged() { entityChanged() {
console.log('entityChanged'); console.log('entityChanged');
} }
qualityMeterClick() { qualityMeterClick() {
console.log('qualityMeterClick'); console.log('qualityMeterClick');
} }
dialpadButtonClick(c) { dialpadButtonClick(c) {
console.log('dialpadButtonClick'); console.log('dialpadButtonClick');
this.sipSendDTMF(c); this.sipSendDTMF(c);
} }
notifyAdminButtonClick() { notifyAdminButtonClick() {
console.log('notifyAdminButtonClick'); console.log('notifyAdminButtonClick');
} }
......
...@@ -39,9 +39,11 @@ const Root = ({wsphonedata, onSetDnd, setWsphonedata, callMethod}) => { ...@@ -39,9 +39,11 @@ const Root = ({wsphonedata, onSetDnd, setWsphonedata, callMethod}) => {
} }
}, [secondLine]); }, [secondLine]);
useEffect(()=> {
boxDialer.setGlobalHistoryData(useColorConfigStore.state)
}, [useColorConfigStore.state])
useEffect(() => { useEffect(() => {
boxDialer.globalHistoryData = useColorConfigStore.state
if (wsphonedata && wsphonedata?.number) { if (wsphonedata && wsphonedata?.number) {
boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue'); boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue');
boxDialer.setSipStateChangeCallback(setModalState, 'modalState'); boxDialer.setSipStateChangeCallback(setModalState, 'modalState');
...@@ -90,33 +92,11 @@ const Root = ({wsphonedata, onSetDnd, setWsphonedata, callMethod}) => { ...@@ -90,33 +92,11 @@ const Root = ({wsphonedata, onSetDnd, setWsphonedata, callMethod}) => {
}; };
useEffect(()=> { // useEffect(()=> {
console.log('auto_answer running: ', modalState.callType === 'incoming' && modalState.bool) // console.log('auto_answer running: ', modalState.callType === 'incoming' && modalState.bool)
if(modalState.callType === 'incoming' && modalState.bool){ //
let second // }, [modalState.callType, modalState.bool, useColorConfigStore.state?.autoAnswer, useColorConfigStore.state?.autoAnswerSecond])
if(useColorConfigStore.state?.autoAnswer) { //
switch (useColorConfigStore.state?.autoAnswerSecond) {
case 1:
second = 1000
break
case 40:
second = 3000
break
case 100:
second = 6000
break
default:
second = 0
}
console.log('auto_answer second: ', second)
setTimeout(() => {
console.log('auto_answer run boxDialer.answerButtonClick()')
boxDialer.answerButtonClick()
}, second)
}
}
}, [modalState.callType, modalState.bool, useColorConfigStore.state?.autoAnswer, useColorConfigStore.state?.autoAnswerSecond])
const selectWidjetType = (type) => { const selectWidjetType = (type) => {
switch (type) { switch (type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment