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
b0526d9d
Commit
b0526d9d
authored
Nov 27, 2023
by
Muhammadali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update-
parent
1db3176d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1321 additions
and
1257 deletions
+1321
-1257
package.json
package.json
+1
-1
index.jsx
src/components/ModalPhoneNumpad/index.jsx
+300
-235
style.js
src/components/ModalPhoneNumpad/style.js
+18
-11
boxDIaler.js
src/lib/boxDIaler.js
+1002
-1010
No files found.
package.json
View file @
b0526d9d
{
"name"
:
"boxdialer"
,
"version"
:
"4.8.6
8
"
,
"version"
:
"4.8.6
9
"
,
"description"
:
""
,
"main"
:
"src/boxDialer.js"
,
"scripts"
:
{
...
...
src/components/ModalPhoneNumpad/index.jsx
View file @
b0526d9d
/** @format */
import
React
,
{
useCallback
,
useEffect
,
useState
}
from
'
react
'
;
import
ModalPhoneNumpadStyle
,
{
NumberButton
,
Input
}
from
'
./style
'
;
import
React
,
{
useCallback
,
useEffect
,
useState
}
from
'
react
'
;
import
ModalPhoneNumpadStyle
,
{
NumberButton
,
Input
}
from
'
./style
'
;
import
numbers
from
'
../../lib/numbers
'
;
import
CallIcon
from
'
@mui/icons-material/Call
'
;
import
{
toast
}
from
'
react-hot-toast
'
;
import
{
toast
}
from
'
react-hot-toast
'
;
import
DropDown
from
'
../DropDown
'
;
import
{
CommentsDisabledOutlined
}
from
'
@mui/icons-material
'
;
import
{
CommentsDisabledOutlined
}
from
'
@mui/icons-material
'
;
import
CallHistoryInputDropdown
from
'
../CallHistoryInputDropdown
'
;
import
KeyboardControlKeyIcon
from
'
@mui/icons-material/KeyboardControlKey
'
;
import
{
Text
,
useTranslator
}
from
'
@eo-locale/react
'
;
import
{
Text
,
useTranslator
}
from
'
@eo-locale/react
'
;
import
SettingsIcon
from
'
@mui/icons-material/Settings
'
;
import
{
useColorConfig
}
from
"
../../storage/globalColorConfig
"
import
{
useColorConfig
}
from
'
../../storage/globalColorConfig
'
;
const
ModalPhoneNumpad
=
({
phoneModal
,
...
...
@@ -24,11 +24,11 @@ const ModalPhoneNumpad = ({
variant
,
extnums
,
setSettingHidden
,
settingHidden
})
=>
{
settingHidden
,
})
=>
{
const
boxDialer
=
window
.
BoxDialer
;
const
useColorConfigStore
=
useColorConfig
((
store
)
=>
store
)
const
useColorConfigStore
=
useColorConfig
((
store
)
=>
store
);
const
[
inputValue
,
setInputValue
]
=
useState
(
''
);
const
[
call_history
,
setCall_history
]
=
useState
([]);
const
[
numberSelectHistory
,
setNumberSelectHistory
]
=
useState
(
0
);
...
...
@@ -36,7 +36,9 @@ const ModalPhoneNumpad = ({
const
translator
=
useTranslator
();
useEffect
(()
=>
{
let
currentCalls
=
localStorage
.
getItem
(
'
callhistory
'
)
?
JSON
.
parse
(
localStorage
.
getItem
(
'
callhistory
'
))
:
false
;
let
currentCalls
=
localStorage
.
getItem
(
'
callhistory
'
)
?
JSON
.
parse
(
localStorage
.
getItem
(
'
callhistory
'
))
:
false
;
if
(
currentCalls
)
{
setCall_history
(
currentCalls
);
}
...
...
@@ -47,14 +49,16 @@ const ModalPhoneNumpad = ({
},
[
modalState
.
bool
]);
useEffect
(()
=>
{
if
(
!
phoneModal
)
setSettingHidden
(
false
)
},
[
phoneModal
])
if
(
!
phoneModal
)
setSettingHidden
(
false
);
},
[
phoneModal
]);
const
inputController
=
({
value
,
type
,
from
})
=>
{
boxDialer
.
onSoundType
({
type
:
'
pick
'
,
bool
:
true
});
const
inputController
=
({
value
,
type
,
from
})
=>
{
boxDialer
.
onSoundType
({
type
:
'
pick
'
,
bool
:
true
});
switch
(
type
)
{
case
'
add
'
:
if
(
value
.
match
(
/^
[
a-zA-Z0-9!@#
\$
%
\^\&
*
\)\(
+=._-
]
+$/g
).
join
(
''
).
length
)
{
if
(
value
.
match
(
/^
[
a-zA-Z0-9!@#
\$
%
\^\&
*
\)\(
+=._-
]
+$/g
).
join
(
''
).
length
)
{
if
(
from
===
'
input
'
)
return
setInputValue
(
value
);
if
(
from
===
'
button
'
)
setInputValue
(
inputValue
+
value
);
}
...
...
@@ -62,10 +66,12 @@ const ModalPhoneNumpad = ({
break
;
case
'
delete
'
:
if
(
from
===
'
button
'
)
{
setInputValue
(
inputValue
setInputValue
(
inputValue
.
split
(
''
)
.
slice
(
0
,
inputValue
.
length
-
1
)
.
join
(
''
),);
.
join
(
''
),
);
}
if
(
from
===
'
input
'
)
{
setInputValue
(
value
);
...
...
@@ -76,13 +82,20 @@ const ModalPhoneNumpad = ({
}
};
const
history
=
({
type
})
=>
{
const
history
=
({
type
})
=>
{
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
))
{
if
((
type
===
'
up
'
&&
numberSelectHistory
<
call_history
.
length
)
||
numberSelectHistory
===
'
zero
'
)
{
setNumberSelectHistory
(
numberSelectHistory
!==
'
zero
'
?
numberSelectHistory
+
1
:
0
+
1
,);
if
(
(
type
===
'
up
'
&&
numberSelectHistory
<
call_history
.
length
)
||
numberSelectHistory
===
'
zero
'
)
{
setNumberSelectHistory
(
numberSelectHistory
!==
'
zero
'
?
numberSelectHistory
+
1
:
0
+
1
,
);
}
if
(
type
===
'
down
'
&&
numberSelectHistory
>
0
)
{
setNumberSelectHistory
(
numberSelectHistory
!==
'
zero
'
?
numberSelectHistory
-
1
:
0
-
1
,);
setNumberSelectHistory
(
numberSelectHistory
!==
'
zero
'
?
numberSelectHistory
-
1
:
0
-
1
,
);
}
}
};
...
...
@@ -93,7 +106,9 @@ const ModalPhoneNumpad = ({
if
(
numberSelectHistory
==
0
)
{
setInputValue
(
''
);
}
selectedNumber
=
call_history
.
slice
(
numberSelectHistory
*
-
1
)[
0
]
?
call_history
.
slice
(
numberSelectHistory
*
-
1
)[
0
]
:
false
;
selectedNumber
=
call_history
.
slice
(
numberSelectHistory
*
-
1
)[
0
]
?
call_history
.
slice
(
numberSelectHistory
*
-
1
)[
0
]
:
false
;
if
(
numberSelectHistory
===
0
)
{
selectedNumber
=
''
;
...
...
@@ -117,7 +132,7 @@ const ModalPhoneNumpad = ({
navigator
.
clipboard
.
readText
()
.
then
((
text
)
=>
{
inputController
({
type
:
'
add
'
,
value
:
text
,
from
:
'
button
'
});
inputController
({
type
:
'
add
'
,
value
:
text
,
from
:
'
button
'
});
})
.
catch
((
err
)
=>
{
console
.
log
(
'
Something went wrong
'
,
err
);
...
...
@@ -130,18 +145,37 @@ const ModalPhoneNumpad = ({
toggleCP
:
(
e
)
=>
{
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Enter
'
)
{
callButton
();
}
else
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Backspace
'
)
{
inputController
({
type
:
'
delete
'
,
from
:
'
button
'
,
value
:
e
.
value
});
}
else
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
!
isNaN
(
+
e
.
key
))
{
inputController
({
type
:
'
add
'
,
value
:
e
.
key
,
from
:
'
button
'
});
}
else
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Backspace
'
)
{
}
else
if
((
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
keyCode
==
38
)
||
e
.
keyCode
==
40
)
history
({
type
:
e
.
keyCode
===
38
?
'
up
'
:
'
down
'
});
}
else
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Backspace
'
)
{
inputController
({
type
:
'
delete
'
,
from
:
'
button
'
,
value
:
e
.
value
});
}
else
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
!
isNaN
(
+
e
.
key
)
)
{
inputController
({
type
:
'
add
'
,
value
:
e
.
key
,
from
:
'
button
'
});
}
else
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Backspace
'
)
{
}
else
if
(
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
keyCode
==
38
)
||
e
.
keyCode
==
40
)
history
({
type
:
e
.
keyCode
===
38
?
'
up
'
:
'
down
'
});
},
};
const
handleKeyUp
=
useCallback
((
event
)
=>
{
const
handleKeyUp
=
useCallback
(
(
event
)
=>
{
gameState
.
toggleCP
(
event
);
},
[
gameState
.
toggleCP
],);
},
[
gameState
.
toggleCP
],
);
useEffect
(()
=>
{
document
.
addEventListener
(
'
keyup
'
,
handleKeyUp
);
...
...
@@ -157,11 +191,17 @@ const ModalPhoneNumpad = ({
// -------------------
var
currentTime
=
new
Date
();
if
(
dynamicValue
===
'
connected
'
)
{
if
(
Boolean
(
inputValue
.
toString
().
length
)
&&
call_history
.
slice
(
-
1
)[
0
]?.
value
!=
inputValue
)
{
let
newCallsStringify
=
JSON
.
stringify
([...
call_history
,
{
if
(
Boolean
(
inputValue
.
toString
().
length
)
&&
call_history
.
slice
(
-
1
)[
0
]?.
value
!=
inputValue
)
{
let
newCallsStringify
=
JSON
.
stringify
([
...
call_history
,
{
value
:
inputValue
,
time
:
`
${
currentTime
.
getHours
()}
:
${
currentTime
.
getMinutes
()}
${
currentTime
.
getDate
()}
.
${
currentTime
.
getMonth
()}
.
${
currentTime
.
getFullYear
()}
`
,
},]);
},
]);
localStorage
.
setItem
(
'
callhistory
'
,
newCallsStringify
);
}
boxDialer
.
initialized
(
inputValue
);
...
...
@@ -184,13 +224,17 @@ const ModalPhoneNumpad = ({
document
.
querySelector
(
'
body
'
).
addEventListener
(
'
click
'
,
function
(
e
)
{
if
(
exNum
)
setExNum
(
false
);
});
return
(<
ModalPhoneNumpadStyle
return
(
<
ModalPhoneNumpadStyle
switchAnim=
{
useColorConfigStore
.
state
?.
switchAnim
}
position=
{
position
}
hiddenValue=
{
!
phoneModal
}
variant=
{
variant
}
onClick=
{
(
e
)
=>
e
.
stopPropagation
()
}
>
<
SettingsIcon
className=
{
'
settingIcon
'
}
onClick=
{
()
=>
setSettingHidden
(
!
settingHidden
)
}
/>
<
SettingsIcon
className=
{
'
settingIcon
'
}
onClick=
{
()
=>
setSettingHidden
(
!
settingHidden
)
}
/>
<
ModalPhoneNumpadStyle
.
InputArea
>
<
CallHistoryInputDropdown
call_history=
{
call_history
}
...
...
@@ -199,35 +243,47 @@ const ModalPhoneNumpad = ({
numberSelectHistory=
{
numberSelectHistory
}
setDefaultHistoryNumberHistory=
{
setDefaultHistoryNumberHistory
}
/>
{
inputValue
?.
length
?
(<
Input
.
BackSpaceIcon
onClick=
{
()
=>
inputController
({
type
:
'
delete
'
,
from
:
'
button
'
})
}
/>)
:
(
''
)
}
{
inputValue
?.
length
?
(
<
Input
.
BackSpaceIcon
onClick=
{
()
=>
inputController
({
type
:
'
delete
'
,
from
:
'
button
'
})
}
/>
)
:
(
''
)
}
</
ModalPhoneNumpadStyle
.
InputArea
>
<
ModalPhoneNumpadStyle
.
ButtonArea
>
{
numbers
?.
map
((
mapItem
)
=>
(<
NumberButton
{
numbers
?.
map
((
mapItem
)
=>
(
<
NumberButton
switchAnim=
{
useColorConfigStore
.
state
?.
switchAnim
}
sizeContext=
{
useColorConfigStore
.
state
.
sizePixel
}
onMouseDown=
{
()
=>
boxDialer
.
dialTone
(
mapItem
.
ringHz
[
0
],
mapItem
.
ringHz
[
1
])
}
onMouseDown=
{
()
=>
boxDialer
.
dialTone
(
mapItem
.
ringHz
[
0
],
mapItem
.
ringHz
[
1
])
}
onMouseUp=
{
()
=>
boxDialer
.
stop
()
}
onMouseOut=
{
()
=>
boxDialer
.
stop
()
}
className=
'nocopy'
key=
{
mapItem
.
id
}
onClick=
{
()
=>
{
mapItem
.
type
===
'
number
'
&&
inputController
({
value
:
mapItem
.
value
,
type
:
'
add
'
,
from
:
'
button
'
,
mapItem
.
type
===
'
number
'
&&
inputController
({
value
:
mapItem
.
value
,
type
:
'
add
'
,
from
:
'
button
'
,
});
}
}
>
{
mapItem
.
nameNumber
}
<
NumberButton
.
Icon
>
{
mapItem
.
icon
}
</
NumberButton
.
Icon
>
</
NumberButton
>))
}
{
!
modalState
.
bool
?
(<>
</
NumberButton
>
))
}
{
!
modalState
.
bool
?
(
<>
<
NumberButton
style=
{
{
gridColumn
:
'
1/4
'
}
}
style=
{
{
gridColumn
:
'
1/4
'
}
}
status=
{
dynamicValue
}
type=
{
'
call_button
'
}
>
<
NumberButton
.
CallButton
exNum=
{
exNum
}
>
<
div
className=
'left'
onClick=
{
()
=>
callButton
()
}
>
<
CallIcon
className=
'callIcon'
/>
<
CallIcon
className=
'callIcon'
/>
<
p
className=
'call_text'
>
{
translator
.
translate
(
'
CALL
'
)
}
</
p
>
</
div
>
<
div
className=
'right'
onClick=
{
()
=>
setExNum
(
!
exNum
)
}
>
...
...
@@ -235,9 +291,13 @@ const ModalPhoneNumpad = ({
<
div
className=
'icon'
></
div
>
</
div
>
</
NumberButton
.
CallButton
>
<
NumberButton
.
CallButtonModal
switchAnim=
{
useColorConfigStore
.
state
?.
switchAnim
}
visiblevalue=
{
exNum
}
>
<
NumberButton
.
CallButtonModalInset
switchAnim=
{
useColorConfigStore
.
state
?.
switchAnim
}
>
{
extnums
?.
map
(({
number
,
title
},
index
)
=>
(<
p
<
NumberButton
.
CallButtonModal
switchAnim=
{
useColorConfigStore
.
state
?.
switchAnim
}
visiblevalue=
{
exNum
}
>
<
NumberButton
.
CallButtonModalInset
switchAnim=
{
useColorConfigStore
.
state
?.
switchAnim
}
>
{
extnums
?.
map
(({
number
,
title
},
index
)
=>
(
<
p
key=
{
index
}
className=
'num_item'
onClick=
{
()
=>
{
...
...
@@ -246,7 +306,8 @@ const ModalPhoneNumpad = ({
callButton
();
}
}
>
{
title
}
</
p
>))
}
</
p
>
))
}
</
NumberButton
.
CallButtonModalInset
>
</
NumberButton
.
CallButtonModal
>
{
/* <ModalPhoneNumpadStyle.Window
...
...
@@ -254,13 +315,17 @@ const ModalPhoneNumpad = ({
onClick={() => setExNum(false)}
/> */
}
</
NumberButton
>
</>)
:
(<>
<
div
style=
{
{
height
:
'
33px
'
}
}
></
div
>
<
div
style=
{
{
height
:
'
33px
'
}
}
></
div
>
</>)
}
<
DropDown
selectFunc=
{
onSetDnd
}
reasons=
{
reasons
}
reason=
{
reason
}
/>
</>
)
:
(
<>
<
div
style=
{
{
height
:
'
33px
'
}
}
></
div
>
<
div
style=
{
{
height
:
'
33px
'
}
}
></
div
>
</>
)
}
<
DropDown
selectFunc=
{
onSetDnd
}
reasons=
{
reasons
}
reason=
{
reason
}
/>
</
ModalPhoneNumpadStyle
.
ButtonArea
>
</
ModalPhoneNumpadStyle
>);
</
ModalPhoneNumpadStyle
>
);
};
export
default
ModalPhoneNumpad
;
src/components/ModalPhoneNumpad/style.js
View file @
b0526d9d
...
...
@@ -3,7 +3,7 @@
import
styled
from
'
styled-components
'
;
import
KeyboardBackspaceIcon
from
'
@mui/icons-material/KeyboardBackspace
'
;
import
{
boxDialerWidjetPosition
}
from
'
../../lib/boxDialerWidjetPosition
'
;
import
{
sizePixelPixelSizeFunc
}
from
"
../../lib/sizeContext
"
import
{
sizePixelPixelSizeFunc
}
from
'
../../lib/sizeContext
'
;
const
ModalPhoneNumpadStyle
=
styled
.
div
`
box-shadow: 0 0 20px #00000047;
...
...
@@ -15,8 +15,9 @@ const ModalPhoneNumpadStyle = styled.div`
width: 230px;
position: fixed;
bottom: 120px;
transition:
${({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
switchAnim
?
'
0.2s
'
:
'
0s
'
:
'
0.2s
'
}
;
${({
switchAnim
})
=>
console
.
log
(
'
switchAnim:
'
,
switchAnim
)}
transition:
${({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
(
switchAnim
?
'
0.2s
'
:
'
0s
'
)
:
'
0.2s
'
}
;
${({
switchAnim
})
=>
console
.
log
(
'
switchAnim:
'
,
switchAnim
)}
z-index: 9999;
${({
hiddenValue
,
position
,
variant
})
=>
hiddenValue
...
...
@@ -28,7 +29,7 @@ const ModalPhoneNumpadStyle = styled.div`
grid-template-rows: 40px 1fr;
grid-gap: 15px;
cursor: default;
.settingIcon{
.settingIcon
{
position: absolute;
font-size: 11px;
cursor: pointer;
...
...
@@ -103,7 +104,7 @@ const NumberButton = styled.div`
display: flex;
justify-content: center;
align-items: center;
${({
sizeContext
})
=>
sizePixelPixelSizeFunc
(
sizeContext
,
22
)}
${({
sizeContext
})
=>
sizePixelPixelSizeFunc
(
sizeContext
,
22
)}
cursor: pointer;
height: 33px;
position: relative;
...
...
@@ -113,7 +114,8 @@ const NumberButton = styled.div`
?
'
orange
'
:
status
===
'
connected
'
&&
'
#a0c13d
'
:
'
#0000007d
'
}
;
transition:
${({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
switchAnim
?
'
0.3s
'
:
'
0s
'
:
'
0.3s
'
}
;
transition:
${({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
(
switchAnim
?
'
0.3s
'
:
'
0s
'
)
:
'
0.3s
'
}
;
.callIcon {
color: #0000007d;
...
...
@@ -169,7 +171,6 @@ NumberButton.CallButton = styled.div`
display: flex;
align-items: center;
.icon {
margin: 0 auto;
border: 4px solid transparent;
width: 8px;
...
...
@@ -210,7 +211,8 @@ NumberButton.CallButtonModal = styled.div`
padding
:
3
px
3
px
15
px
3
px
;
border
-
top
-
left
-
radius
:
8
px
;
border
-
top
-
right
-
radius
:
8
px
;
transition
:
$
{({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
switchAnim
?
'
0.1s
'
:
'
0s
'
:
'
0.1s
'
}
;
transition
:
$
{({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
(
switchAnim
?
'
0.1s
'
:
'
0s
'
)
:
'
0.1s
'
}
;
clip-path: polygon(100% 0, 100% 93%, 57% 93%, 50% 100%, 43% 93%, 0 93%, 0 0);
${({
visiblevalue
})
=>
...
...
@@ -236,7 +238,12 @@ NumberButton.CallButtonModalInset = styled.div`
.
num_item
{
text
-
wrap
:
nowrap
;
color
:
#
000
;
transition
:
$
{({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
switchAnim
?
'
0.2s
'
:
'
0s
'
:
'
0.2s
'
}
;
transition
:
$
{({
switchAnim
})
=>
typeof
switchAnim
!==
'
undefined
'
?
switchAnim
?
'
0.2s
'
:
'
0s
'
:
'
0.2s
'
}
;
padding: 5px 10px;
font-size: 14px;
margin: 2px 0;
...
...
src/lib/boxDIaler.js
View file @
b0526d9d
/** @format */
import
{
toast
}
from
'
react-hot-toast
'
;
import
{
toast
}
from
'
react-hot-toast
'
;
import
outcomingringTone
from
'
../sounds/ringtone.wav
'
;
import
waitRingTone
from
'
../sounds/ringbacktone.wav
'
;
import
pickSound
from
'
../sounds/dtmf.wav
'
;
import
{
WebSocketInterface
,
UA
}
from
'
jssip
'
;
import
{
WebSocketInterface
,
UA
}
from
'
jssip
'
;
import
tugpng
from
'
../img/tug.png
'
;
import
packageJson
from
'
../../package.json
'
;
...
...
@@ -60,8 +60,7 @@ export class BoxDialer {
player
;
strmTrack
;
isRestarting
;
globalHistoryData
globalHistoryData
;
constructor
()
{
this
.
played
=
false
;
...
...
@@ -92,13 +91,13 @@ export class BoxDialer {
this
.
options
=
{
eventHandlers
:
this
.
uaEvents
(),
mediaConstraints
:
{
audio
:
true
,
video
:
false
},
mediaConstraints
:
{
audio
:
true
,
video
:
false
},
};
}
setGlobalHistoryData
(
data
)
{
console
.
log
(
'
setGlobalHistoryData:
'
,
data
)
this
.
globalHistoryData
=
data
setGlobalHistoryData
(
data
)
{
console
.
log
(
'
setGlobalHistoryData:
'
,
data
);
this
.
globalHistoryData
=
data
;
}
dialTone
(
freq1
,
freq2
)
{
...
...
@@ -201,7 +200,7 @@ export class BoxDialer {
});
window
.
navigator
.
mediaDevices
.
getUserMedia
({
audio
:
true
})
.
getUserMedia
({
audio
:
true
})
.
then
(
function
(
stream
)
{
console
.
log
(
'
User_Danied_Media_Access
'
,
...
...
@@ -308,7 +307,7 @@ export class BoxDialer {
greeting
.
addEventListener
(
'
click
'
,
cbk
);
}
onSoundType
({
type
,
bool
})
{
onSoundType
({
type
,
bool
})
{
this
.
ringtone
.
remove
();
this
.
waitRingTone
.
remove
();
this
.
pickSound
.
remove
();
...
...
@@ -355,7 +354,7 @@ export class BoxDialer {
}
}
sipRegister
=
({
number
,
secret
,
wsurl
,
isIce
})
=>
{
sipRegister
=
({
number
,
secret
,
wsurl
,
isIce
})
=>
{
try
{
if
(
window
?.
alovoice_setversion
&&
packageJson
?.
version
)
{
window
.
alovoice_setversion
(
packageJson
?.
version
);
...
...
@@ -401,6 +400,7 @@ export class BoxDialer {
e
,
);
});
this
.
ua
.
on
(
'
disconnected
'
,
(
e
)
=>
{
this
.
onSipStateChange
.
dynamicValue
(
'
pending
'
);
console
.
log
(
...
...
@@ -434,7 +434,6 @@ export class BoxDialer {
});
this
.
ua
.
on
(
'
connecting
'
,
(
e
)
=>
{
console
.
log
(
'
%c connecting:
'
,
'
font-size: 22px; color: yellow;
'
,
e
);
});
this
.
ua
.
on
(
'
registrationExpiring
'
,
(
e
)
=>
{
console
.
log
(
...
...
@@ -489,34 +488,36 @@ export class BoxDialer {
});
if
(
this
.
callSession
.
direction
===
'
incoming
'
)
{
let
second
console
.
log
(
'
auto_answer is work:
'
,
this
.
globalHistoryData
?.
autoAnswer
)
let
second
;
console
.
log
(
'
auto_answer is work:
'
,
this
.
globalHistoryData
?.
autoAnswer
,
);
if
(
this
.
globalHistoryData
?.
autoAnswer
)
{
switch
(
this
.
globalHistoryData
?.
autoAnswerSecond
)
{
case
1
:
second
=
1000
break
second
=
1000
;
break
;
case
50
:
second
=
5000
break
second
=
5000
;
break
;
case
100
:
second
=
10000
break
second
=
10000
;
break
;
default
:
second
=
0
second
=
0
;
}
console
.
log
(
'
auto_answer second:
'
,
second
)
console
.
log
(
'
auto_answer second:
'
,
second
);
setTimeout
(()
=>
{
console
.
log
(
'
auto_answer run boxDialer.answerButtonClick()
'
)
this
.
answerButtonClick
()
},
second
)
console
.
log
(
'
auto_answer run boxDialer.answerButtonClick()
'
);
this
.
answerButtonClick
();
},
second
);
}
this
.
showNotification
(()
=>
{
this
.
answerButtonClick
();
});
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
true
});
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
true
});
this
.
setGuiPhoneState
({
funcName
:
'
modalState
'
,
stateCode
:
'
connectingIncoming
'
,
...
...
@@ -546,7 +547,7 @@ export class BoxDialer {
e
,
);
// the call has answered
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
setGuiPhoneState
({
funcName
:
'
modalState
'
,
funcParam
:
{
...
...
@@ -619,7 +620,7 @@ export class BoxDialer {
type
:
null
,
});
this
.
stopInnerTimer
();
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
closeBxCall
();
this
.
hangupButtonClick
();
this
.
setGuiPhoneState
({
...
...
@@ -765,7 +766,7 @@ export class BoxDialer {
return
sipState
&&
uiStates
[
sipState
]
?
uiStates
[
sipState
]
:
''
;
}
callBxMethods
({
bxMethodName
,
bxFuncParams
,
callback
})
{
callBxMethods
({
bxMethodName
,
bxFuncParams
,
callback
})
{
if
(
window
.
BX24
&&
window
.
BX24
.
placement
)
{
window
?.
BX24
.
placement
.
call
(
bxMethodName
,
bxFuncParams
,
callback
);
}
else
if
(
window
.
alovoicePhone
&&
window
.
alovoicePhone
.
callMethods
)
{
...
...
@@ -778,8 +779,7 @@ export class BoxDialer {
closeBxCall
()
{
if
(
window
.
BX24
&&
window
.
BX24
.
placement
)
{
window
?.
BX24
.
placement
.
call
(
'
CallCardClose
'
,
{},
()
=>
{
});
window
?.
BX24
.
placement
.
call
(
'
CallCardClose
'
,
{},
()
=>
{});
}
else
if
(
window
.
alovoicePhone
&&
window
.
alovoicePhone
.
callMethods
&&
...
...
@@ -789,7 +789,8 @@ export class BoxDialer {
}
}
setGuiPhoneState
({
stateCode
,
funcName
,
funcParam
})
{
setGuiPhoneState
({
stateCode
,
funcName
,
funcParam
})
{
console
.
log
(
'
boxdialer_setGuiPhoneState_states:
'
,
{
stateCode
,
funcName
,
funcParam
})
if
(
window
?.
alovoice_wsphone
&&
!!
stateCode
?.
length
)
{
console
.
log
(
'
this_getBxUiState_stateCode
'
,
...
...
@@ -798,7 +799,7 @@ export class BoxDialer {
);
this
.
callBxMethods
({
bxMethodName
:
'
CallCardSetUiState
'
,
bxFuncParams
:
{
uiState
:
this
.
getBxUiState
(
stateCode
)
},
bxFuncParams
:
{
uiState
:
this
.
getBxUiState
(
stateCode
)
},
callback
:
(
e
)
=>
{
console
.
log
(
e
,
`CallCardSetUiState method done
${
e
}
`
);
},
...
...
@@ -817,12 +818,11 @@ export class BoxDialer {
console
.
log
(
`%c BXLOG:`
,
datas
,
'
background-color: red;
'
);
}
onSessionEvent
({
type
,
event
})
{
}
onSessionEvent
({
type
,
event
})
{}
selectUser
()
{
BX
.
Runtime
.
loadExtension
(
'
ui.entity-selector
'
).
then
((
exports
)
=>
{
const
{
Dialog
,
TagSelector
}
=
exports
;
const
{
Dialog
,
TagSelector
}
=
exports
;
const
dialog
=
new
BX
.
UI
.
EntitySelector
.
Dialog
({
// targetNode: button,
...
...
@@ -832,7 +832,7 @@ export class BoxDialer {
entities
:
[
{
id
:
'
user
'
,
// пользователи
options
:
{
selectFields
:
[
'
ufPhoneInner
'
]
},
options
:
{
selectFields
:
[
'
ufPhoneInner
'
]
},
},
{
id
:
'
department
'
,
// структура компании: выбор только пользователей
...
...
@@ -840,7 +840,7 @@ export class BoxDialer {
],
events
:
{
'
_Item:onSelect
'
:
(
event
)
=>
{
const
{
item
}
=
event
.
getData
();
const
{
item
}
=
event
.
getData
();
const
dialog
=
event
.
getTarget
();
const
selectedItems
=
dialog
.
getSelectedItems
();
...
...
@@ -906,19 +906,10 @@ export class BoxDialer {
}
skipButtonClick
()
{
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
hangupButtonClick
();
}
answerButtonClick
()
{
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
callSession
?.
answer
(
this
.
options
);
this
.
callSession
.
connection
.
addEventListener
(
'
addstream
'
,
(
event
)
=>
{
this
.
remoteAudio
.
srcObject
=
event
.
stream
;
this
.
remoteAudio
.
play
();
});
}
sipSendDTMF
(
code
)
{
this
.
callSession
.
sendDTMF
(
code
);
}
...
...
@@ -928,31 +919,32 @@ export class BoxDialer {
}
muteButtonClick
()
{
let
{
audio
}
=
this
.
callSession
.
isMuted
();
let
{
audio
}
=
this
.
callSession
.
isMuted
();
if
(
audio
)
{
this
.
callSession
.
unmute
();
console
.
log
(
'
muteButtonClick_unmute
'
);
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callMute
:
false
});
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callMute
:
false
});
}
else
{
this
.
callSession
.
mute
();
console
.
log
(
'
muteButtonClick_mute
'
);
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callMute
:
true
});
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callMute
:
true
});
}
}
holdButtonClick
()
{
let
{
local
}
=
this
.
callSession
.
isOnHold
();
let
{
local
}
=
this
.
callSession
.
isOnHold
();
console
.
log
(
'
local:
'
,
local
);
if
(
local
)
{
this
.
callSession
.
unhold
();
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callHold
:
false
});
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callHold
:
false
});
}
else
{
this
.
callSession
.
hold
();
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callHold
:
true
});
this
.
onSipStateChange
[
'
setCallEvents
'
]({
callHold
:
true
});
}
}
...
...
@@ -961,7 +953,7 @@ export class BoxDialer {
}
hangupButtonClick
()
{
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
onSoundType
({
type
:
'
ring
'
,
bool
:
false
});
this
.
onSipStateChange
.
innerCallerModal
({
bool
:
false
,
type
:
null
,
...
...
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