Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BoxDialer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
BoxDialer
Commits
11eb633b
Commit
11eb633b
authored
Nov 07, 2023
by
Muhammadali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update-
parent
fe8dfbb8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
179 additions
and
178 deletions
+179
-178
package.json
package.json
+1
-1
controlRenderBX.jsx
src/lib/controlRenderBX.jsx
+2
-2
index.jsx
src/root/index.jsx
+176
-175
No files found.
package.json
View file @
11eb633b
{
"name"
:
"boxdialer"
,
"version"
:
"4.8.5
4
"
,
"version"
:
"4.8.5
5
"
,
"description"
:
""
,
"main"
:
"src/boxDialer.js"
,
"scripts"
:
{
...
...
src/lib/controlRenderBX.jsx
View file @
11eb633b
...
...
@@ -34,13 +34,13 @@ const ControlRenderBX = () => {
console
.
log
(
'
window_alovoice_wsphone:
'
,
window
.
alovoice_wsphone
);
return
(
<
div
>
{
/*{wsphonedata?.number && (*/
}
{
wsphonedata
?.
number
&&
(
<
Root
setWsphonedata=
{
setWsphonedata
}
onSetDnd=
{
window
.
alovoice_onsetdnd
}
wsphonedata=
{
wsphonedata
}
/>
{
/*)}*/
}
)
}
</
div
>
);
};
...
...
src/root/index.jsx
View file @
11eb633b
/** @format */
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'
react
'
;
import
React
,
{
useContext
,
useEffect
,
useState
}
from
'
react
'
;
import
packageJson
from
'
../../package.json
'
;
import
DefaultWidjetUi
from
'
../components/DefaultWidjetUi
'
;
import
ModalPhoneNumpad
from
'
../components/ModalPhoneNumpad
'
;
...
...
@@ -11,180 +11,181 @@ import InnerCaller from '../components/InnerCaller';
import
{
useConfigHoldMute
}
from
"
../storage
"
// import { contextModalEventProperty } from '../context/modalEventProperty';
const
Root
=
({
wsphonedata
,
onSetDnd
,
setWsphonedata
,
callMethod
})
=>
{
const
boxDialer
=
window
.
BoxDialer
;
// // context
// const { callEvents, setCallEvents } = useContext(contextModalEventProperty);
const
configHoldMute
=
useConfigHoldMute
((
state
)
=>
state
)
const
[
phoneModal
,
setPhoneModal
]
=
useState
(
false
);
const
[
dynamicValue
,
setDynamicValue
]
=
useState
(
'
pending
'
);
const
[
modalState
,
setModalState
]
=
useState
(
false
);
const
[
secondLine
,
setSecondLine
]
=
useState
(
false
);
const
[
innerTimer
,
setInnerTimer
]
=
useState
(
null
);
const
[
innerCallerModal
,
setInnerCallerModal
]
=
useState
({
bool
:
false
,
type
:
null
,
from
:
''
,
});
useEffect
(()
=>
{
if
(
secondLine
)
{
setTimeout
(()
=>
{
setSecondLine
(
false
);
},
5000
);
}
},
[
secondLine
]);
useEffect
(()
=>
{
if
(
wsphonedata
&&
wsphonedata
?.
number
)
{
boxDialer
.
setSipStateChangeCallback
(
setDynamicValue
,
'
dynamicValue
'
);
boxDialer
.
setSipStateChangeCallback
(
setModalState
,
'
modalState
'
);
boxDialer
.
setSipStateChangeCallback
(
setSecondLine
,
'
secondLine
'
);
boxDialer
.
setSipStateChangeCallback
(
setPhoneModal
,
'
phoneModal
'
);
boxDialer
.
setSipStateChangeCallback
(
setInnerTimer
,
'
innerTimer
'
);
// // context
boxDialer
.
setSipStateChangeCallback
(
configHoldMute
.
setState
,
'
setCallEvents
'
);
boxDialer
.
setSipStateChangeCallback
(
setInnerCallerModal
,
'
innerCallerModal
'
,
);
if
(
boxDialer
.
isUaRunning
())
console
.
log
(
'
UA is running! in other tab
'
);
else
boxDialer
.
sipRegister
(
wsphonedata
);
setTimeout
(
function
waitUaRegisterLost
()
{
if
(
boxDialer
.
isUaRunning
()
||
boxDialer
.
isRestarting
)
setTimeout
(
waitUaRegisterLost
,
10
);
else
boxDialer
.
sipRegister
(
wsphonedata
);
},
10
);
}
},
[]);
const
hangupButton
=
()
=>
{
boxDialer
.
hangupButtonClick
();
};
window
.
setWSData
=
(
result
)
=>
{
console
.
log
(
'
setWsphonedata
'
,
result
);
setWsphonedata
(
result
);
};
const
reasonSelect
=
async
(
e
)
=>
{
let
result
=
await
onSetDnd
(
e
);
if
(
setWsphonedata
){
setWsphonedata
(
result
);
}
console
.
log
(
'
reasonSelect_setWsphonedata
'
,
typeof
setWsphonedata
)
};
const
getTransferers
=
async
(
e
)
=>
{
let
result
=
await
callMethod
({
method
:
'
getPeers
'
,
});
setWsphonedata
(
result
);
};
const
selectWidjetType
=
(
type
)
=>
{
switch
(
type
)
{
case
'
bxmini
'
:
return
(
<
BxMiniWidjetUi
widjetState=
{
dynamicValue
}
phoneNumber=
{
wsphonedata
?.
number
}
reason=
{
wsphonedata
?.
reason
}
widjetVersion=
{
packageJson
?.
version
}
leftTime=
{
wsphonedata
.
lefttime
}
position=
{
wsphonedata
.
position
||
'
bottomLeft
'
}
onClick=
{
()
=>
{
phoneModal
?
setPhoneModal
(
false
)
:
setPhoneModal
(
true
);
}
}
/>
);
default
:
return
(
<
DefaultWidjetUi
widjetState=
{
dynamicValue
}
phoneNumber=
{
wsphonedata
?.
number
}
reason=
{
wsphonedata
?.
reason
}
widjetVersion=
{
packageJson
?.
version
}
leftTime=
{
wsphonedata
.
lefttime
}
position=
{
wsphonedata
.
position
||
'
bottomLeft
'
}
onClick=
{
()
=>
{
phoneModal
?
setPhoneModal
(
false
)
:
setPhoneModal
(
true
);
}
}
/>
);
}
};
console
.
log
(
'
wsphonedata_all_data:
'
,
wsphonedata
?.
position
,
wsphonedata
?.
number
,
wsphonedata
,
);
window
.
onbeforeunload
=
()
=>
{
if
(
typeof
BX
!==
'
undefined
'
)
{
boxDialer
.
isRestarting
=
true
;
console
.
log
(
'
window_onbeforeunload =============-------------
'
);
localStorage
.
removeItem
(
'
mycall
'
);
localStorage
.
removeItem
(
BX
.
bitrix_sessid
()
+
'
_mycall
'
);
console
.
log
(
'
--==== Checking removed Items:
'
,
localStorage
.
getItem
(
'
mycall
'
),
localStorage
.
getItem
(
BX
.
bitrix_sessid
()
+
'
_mycall
'
),
);
}
};
if
(
!
wsphonedata
||
!
wsphonedata
?.
number
||
!
wsphonedata
?.
position
)
return
;
return
(
<>
{
selectWidjetType
(
wsphonedata
.
variant
)
}
<
ModalPhoneNumpad
modalState=
{
modalState
}
phoneModal=
{
phoneModal
}
reasons=
{
wsphonedata
?.
reasons
}
reason=
{
wsphonedata
?.
reason
}
onClick=
{
(
e
)
=>
e
.
stopPropagation
()
}
dynamicValue=
{
dynamicValue
}
onSetDnd=
{
reasonSelect
}
variant=
{
wsphonedata
.
variant
||
'
defaultWidjet
'
}
position=
{
wsphonedata
.
position
||
'
bottomLeft
'
}
extnums=
{
wsphonedata
.
extnums
}
/>
<
Modal
className=
'tailwindGlobalCss'
hidden=
{
modalState
.
bool
}
// hidden={true}
callType=
{
modalState
.
callType
}
// callType={'connected'}
hangupButton=
{
hangupButton
}
phoneNumber=
{
modalState
.
callType
===
'
outcoming
'
?
'
inputValue
'
:
modalState
.
callFromName
}
/>
<
InnerCaller
hidden=
{
innerCallerModal
.
bool
}
// hidden={true}
type=
{
innerCallerModal
.
type
}
// type={'connectingIncoming'}
from=
{
innerCallerModal
.
from
}
innerTimer=
{
innerTimer
}
/>
<
SecondNotifSip
secondLine=
{
secondLine
}
/>
</>
);
const
Root
=
({
wsphonedata
,
onSetDnd
,
setWsphonedata
,
callMethod
})
=>
{
const
boxDialer
=
window
.
BoxDialer
;
// // context
// const { callEvents, setCallEvents } = useContext(contextModalEventProperty);
const
configHoldMute
=
useConfigHoldMute
((
state
)
=>
state
)
const
[
phoneModal
,
setPhoneModal
]
=
useState
(
false
);
const
[
dynamicValue
,
setDynamicValue
]
=
useState
(
'
pending
'
);
const
[
modalState
,
setModalState
]
=
useState
(
false
);
const
[
secondLine
,
setSecondLine
]
=
useState
(
false
);
const
[
innerTimer
,
setInnerTimer
]
=
useState
(
null
);
const
[
innerCallerModal
,
setInnerCallerModal
]
=
useState
({
bool
:
false
,
type
:
null
,
from
:
''
,
});
useEffect
(()
=>
{
if
(
secondLine
)
{
setTimeout
(()
=>
{
setSecondLine
(
false
);
},
5000
);
}
},
[
secondLine
]);
useEffect
(()
=>
{
if
(
wsphonedata
&&
wsphonedata
?.
number
)
{
boxDialer
.
setSipStateChangeCallback
(
setDynamicValue
,
'
dynamicValue
'
);
boxDialer
.
setSipStateChangeCallback
(
setModalState
,
'
modalState
'
);
boxDialer
.
setSipStateChangeCallback
(
setSecondLine
,
'
secondLine
'
);
boxDialer
.
setSipStateChangeCallback
(
setPhoneModal
,
'
phoneModal
'
);
boxDialer
.
setSipStateChangeCallback
(
setInnerTimer
,
'
innerTimer
'
);
// // context
boxDialer
.
setSipStateChangeCallback
(
configHoldMute
.
setState
,
'
setCallEvents
'
);
boxDialer
.
setSipStateChangeCallback
(
setInnerCallerModal
,
'
innerCallerModal
'
,
);
if
(
boxDialer
.
isUaRunning
())
console
.
log
(
'
UA is running! in other tab
'
);
else
boxDialer
.
sipRegister
(
wsphonedata
);
setTimeout
(
function
waitUaRegisterLost
()
{
if
(
boxDialer
.
isUaRunning
()
||
boxDialer
.
isRestarting
)
setTimeout
(
waitUaRegisterLost
,
10
);
else
boxDialer
.
sipRegister
(
wsphonedata
);
},
10
);
}
},
[]);
const
hangupButton
=
()
=>
{
boxDialer
.
hangupButtonClick
();
};
window
.
setWSData
=
(
result
)
=>
{
console
.
log
(
'
setWsphonedata
'
,
result
);
setWsphonedata
(
result
);
};
const
reasonSelect
=
async
(
e
)
=>
{
let
result
=
await
onSetDnd
(
e
);
if
(
setWsphonedata
)
{
setWsphonedata
(
result
);
}
console
.
log
(
'
reasonSelect_setWsphonedata
'
,
typeof
setWsphonedata
)
};
const
getTransferers
=
async
(
e
)
=>
{
let
result
=
await
callMethod
({
method
:
'
getPeers
'
,
});
setWsphonedata
(
result
);
};
const
selectWidjetType
=
(
type
)
=>
{
switch
(
type
)
{
case
'
bxmini
'
:
return
(
<
BxMiniWidjetUi
widjetState=
{
dynamicValue
}
phoneNumber=
{
wsphonedata
?.
number
}
reason=
{
wsphonedata
?.
reason
}
widjetVersion=
{
packageJson
?.
version
}
leftTime=
{
wsphonedata
.
lefttime
}
position=
{
wsphonedata
.
position
||
'
bottomLeft
'
}
onClick=
{
()
=>
{
phoneModal
?
setPhoneModal
(
false
)
:
setPhoneModal
(
true
);
}
}
/>
);
default
:
return
(
<
DefaultWidjetUi
widjetState=
{
dynamicValue
}
phoneNumber=
{
wsphonedata
?.
number
}
reason=
{
wsphonedata
?.
reason
}
widjetVersion=
{
packageJson
?.
version
}
leftTime=
{
wsphonedata
.
lefttime
}
position=
{
wsphonedata
.
position
||
'
bottomLeft
'
}
onClick=
{
()
=>
{
phoneModal
?
setPhoneModal
(
false
)
:
setPhoneModal
(
true
);
}
}
/>
);
}
};
console
.
log
(
'
wsphonedata_all_data:
'
,
wsphonedata
?.
position
,
wsphonedata
?.
number
,
wsphonedata
,
);
window
.
onbeforeunload
=
()
=>
{
if
(
typeof
BX
!==
'
undefined
'
)
{
boxDialer
.
isRestarting
=
true
;
console
.
log
(
'
window_onbeforeunload =============-------------
'
);
localStorage
.
removeItem
(
'
mycall
'
);
localStorage
.
removeItem
(
BX
.
bitrix_sessid
()
+
'
_mycall
'
);
console
.
log
(
'
--==== Checking removed Items:
'
,
localStorage
.
getItem
(
'
mycall
'
),
localStorage
.
getItem
(
BX
.
bitrix_sessid
()
+
'
_mycall
'
),
);
}
};
// if (!wsphonedata || !wsphonedata?.number || !wsphonedata?.position) return;
console
.
log
(
'
wsphonedata_variant:
'
,
wsphonedata
.
variant
,
!
wsphonedata
,
!
wsphonedata
?.
number
,
!
wsphonedata
?.
position
)
return
(
<>
{
selectWidjetType
(
wsphonedata
.
variant
)
}
<
ModalPhoneNumpad
modalState=
{
modalState
}
phoneModal=
{
phoneModal
}
reasons=
{
wsphonedata
?.
reasons
}
reason=
{
wsphonedata
?.
reason
}
onClick=
{
(
e
)
=>
e
.
stopPropagation
()
}
dynamicValue=
{
dynamicValue
}
onSetDnd=
{
reasonSelect
}
variant=
{
wsphonedata
.
variant
||
'
defaultWidjet
'
}
position=
{
wsphonedata
.
position
||
'
bottomLeft
'
}
extnums=
{
wsphonedata
.
extnums
}
/>
<
Modal
className=
'tailwindGlobalCss'
hidden=
{
modalState
.
bool
}
// hidden={true}
callType=
{
modalState
.
callType
}
// callType={'connected'}
hangupButton=
{
hangupButton
}
phoneNumber=
{
modalState
.
callType
===
'
outcoming
'
?
'
inputValue
'
:
modalState
.
callFromName
}
/>
<
InnerCaller
hidden=
{
innerCallerModal
.
bool
}
// hidden={true}
type=
{
innerCallerModal
.
type
}
// type={'connectingIncoming'}
from=
{
innerCallerModal
.
from
}
innerTimer=
{
innerTimer
}
/>
<
SecondNotifSip
secondLine=
{
secondLine
}
/>
</>
);
};
export
default
Root
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment