Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-066
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
2022-066
2022-066
Commits
8f9524df
Commit
8f9524df
authored
May 08, 2022
by
Navodya Pasqual
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
digital human UI changed
parent
480c74be
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
2121 additions
and
2987 deletions
+2121
-2987
frontend/package-lock.json
frontend/package-lock.json
+1669
-2969
frontend/src/digitalHuman/digitalHuman.js
frontend/src/digitalHuman/digitalHuman.js
+199
-3
frontend/src/digitalHuman/sections/cardChat.js
frontend/src/digitalHuman/sections/cardChat.js
+31
-0
frontend/src/digitalHuman/sections/messageChat.js
frontend/src/digitalHuman/sections/messageChat.js
+39
-0
frontend/src/digitalHuman/styles/digitalHuman.css
frontend/src/digitalHuman/styles/digitalHuman.css
+119
-0
frontend/src/digitalHuman/styles/sectionStyles.css
frontend/src/digitalHuman/styles/sectionStyles.css
+16
-0
frontend/src/functions/actions/digitalHuman_actions.js
frontend/src/functions/actions/digitalHuman_actions.js
+7
-0
frontend/src/functions/reducers/digitalHuman_reducer.js
frontend/src/functions/reducers/digitalHuman_reducer.js
+11
-0
frontend/src/functions/reducers/index.js
frontend/src/functions/reducers/index.js
+8
-0
frontend/src/index.js
frontend/src/index.js
+10
-6
frontend/src/main/ContactUs/styles/contactUs.css
frontend/src/main/ContactUs/styles/contactUs.css
+12
-9
frontend/src/setupProxy.js
frontend/src/setupProxy.js
+0
-0
No files found.
frontend/package-lock.json
View file @
8f9524df
This diff is collapsed.
Click to expand it.
frontend/src/digitalHuman/digitalHuman.js
View file @
8f9524df
...
@@ -3,12 +3,208 @@ import Axios from 'axios';
...
@@ -3,12 +3,208 @@ import Axios from 'axios';
import
{
useDispatch
,
useSelector
}
from
'
react-redux
'
;
import
{
useDispatch
,
useSelector
}
from
'
react-redux
'
;
import
{
List
,
Icon
,
Avatar
}
from
'
antd
'
;
import
{
List
,
Icon
,
Avatar
}
from
'
antd
'
;
import
{
saveMessage
}
from
'
../functions/actions/digitalHuman_actions
'
;
import
Message
from
'
./sections/messageChat
'
;
import
Card
from
"
./sections/cardChat
"
;
import
'
./styles/digitalHuman.css
'
;
const
SpeechRecognition
=
window
.
SpeechRecognition
||
window
.
webkitSpeechRecognition
const
mic
=
new
SpeechRecognition
();
mic
.
continuous
=
true
mic
.
interimResults
=
true
mic
.
lang
=
'
en-US
'
function
DigitalHuman
()
{
function
DigitalHuman
()
{
const
dispatch
=
useDispatch
();
const
messagesFromRedux
=
useSelector
(
state
=>
state
.
message
.
messages
);
const
[
isListening
,
setIsListening
]
=
useState
(
false
)
const
[
note
,
setNote
]
=
useState
(
null
)
const
[
cls
,
setCls
]
=
useState
(
"
green
"
);
useEffect
(()
=>
{
eventQuery
(
'
welcomeToMyWebsite
'
);
},
[])
useEffect
(()
=>
{
handleListen
()
},
[
isListening
])
const
handleListen
=
()
=>
{
if
(
isListening
)
{
mic
.
start
()
mic
.
onend
=
()
=>
{
console
.
log
(
'
continue..
'
)
mic
.
start
()
}
}
else
{
mic
.
stop
()
mic
.
onend
=
()
=>
{
console
.
log
(
'
Stopped Mic on Click
'
)
}
}
mic
.
onstart
=
()
=>
{
console
.
log
(
'
Mics on
'
)
}
mic
.
onresult
=
event
=>
{
const
transcript
=
Array
.
from
(
event
.
results
)
.
map
(
result
=>
result
[
0
])
.
map
(
result
=>
result
.
transcript
)
.
join
(
''
)
console
.
log
(
transcript
)
setNote
(
transcript
)
mic
.
onerror
=
event
=>
{
console
.
log
(
event
.
error
)
}
}
}
const
textQuery
=
async
(
text
)
=>
{
// First Need to take care of the message I sent
let
conversation
=
{
who
:
'
user
'
,
content
:
{
text
:
{
text
:
text
}
}
}
dispatch
(
saveMessage
(
conversation
))
// console.log('text I sent', conversation)
// We need to take care of the message Chatbot sent
const
textQueryVariables
=
{
text
}
try
{
//I will send request to the textQuery ROUTE
const
response
=
await
Axios
.
post
(
'
/api/dialogflow/textQuery
'
,
textQueryVariables
)
for
(
let
content
of
response
.
data
.
fulfillmentMessages
)
{
conversation
=
{
who
:
'
Bot
'
,
content
:
content
}
dispatch
(
saveMessage
(
conversation
))
}
}
catch
(
error
)
{
conversation
=
{
who
:
'
Bot
'
,
content
:
{
text
:
{
text
:
"
Error just occured, please check the problem
"
}
}
}
dispatch
(
saveMessage
(
conversation
))
}
}
const
eventQuery
=
async
(
event
)
=>
{
// We need to take care of the message Chatbot sent
const
eventQueryVariables
=
{
event
}
try
{
//I will send request to the textQuery ROUTE
const
response
=
await
Axios
.
post
(
'
/api/dialogflow/eventQuery
'
,
eventQueryVariables
)
for
(
let
content
of
response
.
data
.
fulfillmentMessages
)
{
let
conversation
=
{
who
:
'
Bot
'
,
content
:
content
}
dispatch
(
saveMessage
(
conversation
))
}
}
catch
(
error
)
{
let
conversation
=
{
who
:
'
Bot
'
,
content
:
{
text
:
{
text
:
"
Error just occured, please check the problem
"
}
}
}
dispatch
(
saveMessage
(
conversation
))
}
}
const
keyPressHanlder
=
(
e
)
=>
{
if
(
e
.
key
===
"
Enter
"
)
{
if
(
!
e
.
target
.
value
)
{
return
alert
(
'
you need to type somthing first
'
)
}
//we will send request to text query route
textQuery
(
e
.
target
.
value
)
e
.
target
.
value
=
""
;
}
}
const
onClicksHanlder
=
()
=>
{
if
(
!
note
)
{
return
alert
(
'
you need to type somthing first
'
)
}
//we will send request to text query route
textQuery
(
note
);
setNote
(
''
);
}
const
renderCards
=
(
cards
)
=>
{
return
cards
.
map
((
card
,
i
)
=>
<
Card
key
=
{
i
}
cardInfo
=
{
card
.
structValue
}
/>
)
}
const
renderOneMessage
=
(
message
,
i
)
=>
{
console
.
log
(
'
message
'
,
message
)
// we need to give some condition here to separate message kinds
// template for normal text
if
(
message
.
content
&&
message
.
content
.
text
&&
message
.
content
.
text
.
text
)
{
return
<
Message
key
=
{
i
}
who
=
{
message
.
who
}
text
=
{
message
.
content
.
text
.
text
}
/
>
}
else
if
(
message
.
content
&&
message
.
content
.
payload
.
fields
.
card
)
{
const
AvatarSrc
=
message
.
who
===
'
Bot
'
?
<
Icon
type
=
"
robot
"
/>
:
<
Icon
type
=
"
smile
"
/>
return
<
div
>
<
List
.
Item
style
=
{{
padding
:
'
1rem
'
}}
>
<
List
.
Item
.
Meta
avatar
=
{
<
Avatar
icon
=
{
AvatarSrc
}
/>
}
title
=
{
message
.
who
}
description
=
{
renderCards
(
message
.
content
.
payload
.
fields
.
card
.
listValue
.
values
)}
/
>
<
/List.Item
>
<
/div
>
}
// template for card message
}
const
renderMessage
=
(
returnedMessages
)
=>
{
if
(
returnedMessages
)
{
return
returnedMessages
.
map
((
message
,
i
)
=>
{
return
renderOneMessage
(
message
,
i
);
})
}
else
{
return
null
;
}
}
return
(
return
(
<
div
className
=
'
chat
'
>
<
div
className
=
'
chat
'
>
Hi
<
div
className
=
'
chat_body
'
>
{
renderMessage
(
messagesFromRedux
)}
<
/div
>
<
div
className
=
'
chat_footer
'
>
<
button
className
=
{
cls
}
onClick
=
{()
=>
{
setCls
((
cls
)
=>
(
cls
===
"
red
"
?
"
green
"
:
"
red
"
));
setIsListening
(
prevState
=>
!
prevState
);
}}
>
<
i
className
=
"
fas fa-microphone
"
style
=
{{
color
:
'
white
'
}}
><
/i
>
<
/button
>
<
input
placeholder
=
"
Send a message...
"
onKeyPress
=
{
keyPressHanlder
}
type
=
"
text
"
value
=
{
note
}
/
>
<
button
onClick
=
{
onClicksHanlder
}
disabled
=
{
!
note
}
>
<
i
className
=
"
fas fa-paper-plane
"
><
/i
>
<
/button
>
<
/div
>
<
/div
>
<
/div
>
)
)
}
}
export
default
DigitalHuman
;
export
default
DigitalHuman
;
\ No newline at end of file
frontend/src/digitalHuman/sections/cardChat.js
0 → 100644
View file @
8f9524df
import
React
from
'
react
'
import
{
Card
,
Icon
}
from
'
antd
'
;
const
{
Meta
}
=
Card
;
function
CardComponent
(
props
)
{
return
(
<
Card
style
=
{{
width
:
300
}}
cover
=
{
<
img
alt
=
{
props
.
cardInfo
.
fields
.
description
.
stringValue
}
src
=
{
props
.
cardInfo
.
fields
.
image
.
stringValue
}
/
>
}
actions
=
{[
<
a
target
=
"
_blank
"
rel
=
"
noopener noreferrer
"
href
=
{
props
.
cardInfo
.
fields
.
link
.
stringValue
}
>
<
Icon
type
=
"
ellipsis
"
key
=
"
ellipsis
"
/>
<
/a
>
]}
>
<
Meta
title
=
{
props
.
cardInfo
.
fields
.
stack
.
stringValue
}
description
=
{
props
.
cardInfo
.
fields
.
description
.
stringValue
}
/
>
<
/Card
>
)
}
export
default
CardComponent
frontend/src/digitalHuman/sections/messageChat.js
0 → 100644
View file @
8f9524df
import
React
from
'
react
'
import
{
List
,
Icon
,
Avatar
}
from
'
antd
'
;
import
'
../styles/sectionStyles.css
'
;
function
Message
(
props
)
{
const
AvatarSrc
=
props
.
who
===
'
Bot
'
?
<
Icon
type
=
"
robot
"
/>
:
<
Icon
type
=
"
smile
"
/>
return
(
<
div
>
{
props
.
who
===
'
Bot
'
&&
<
div
className
=
'
chat_message
'
>
<
List
.
Item
>
<
List
.
Item
.
Meta
avatar
=
{
<
Avatar
icon
=
{
AvatarSrc
}
/>
}
// title={props.who}
description
=
{
props
.
text
}
/
>
<
/List.Item
>
<
/div
>
}
{
props
.
who
===
'
user
'
&&
<
div
className
=
'
chat_message chat_recieve
'
>
<
List
.
Item
>
<
List
.
Item
.
Meta
//avatar={<Avatar icon={AvatarSrc} />}
//title={props.who}
description
=
{
props
.
text
}
/
>
<
/List.Item
>
<
/div
>
}
<
/div
>
)
}
export
default
Message
frontend/src/digitalHuman/styles/digitalHuman.css
0 → 100644
View file @
8f9524df
body
{
background
:
-moz-radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
/* safari 5.1+,chrome 10+ */
background
:
-webkit-radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
/* opera 11.10+ */
background
:
-o-radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
/* ie 10+ */
background
:
-ms-radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
/* global 92%+ browsers support */
background
:
radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
}
.red
{
background-color
:
red
;
width
:
45px
;
height
:
45px
;
border
:
1px
solid
#eee
;
border-radius
:
100%
;
bottom
:
0
;
box-shadow
:
0
2px
5px
var
(
--border
)
rgb
(
0
0
0
/
10%
);
cursor
:
pointer
;
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
}
.red
:hover
{
-webkit-transform
:
scale
(
1.1
);
-moz-transform
:
scale
(
1.1
);
transform
:
scale
(
1.1
);
background-color
:
rgba
(
255
,
0
,
0
,
0.863
);
}
.green
{
background-color
:
green
;
width
:
45px
;
height
:
45px
;
border
:
1px
solid
#eee
;
border-radius
:
100%
;
bottom
:
0
;
box-shadow
:
0
2px
5px
var
(
--border
)
rgb
(
0
0
0
/
10%
);
cursor
:
pointer
;
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
}
.green
:hover
{
-webkit-transform
:
scale
(
1.1
);
-moz-transform
:
scale
(
1.1
);
transform
:
scale
(
1.1
);
background-color
:
rgba
(
0
,
128
,
0
,
0.863
);
}
body
{
background-color
:
black
;
}
.chat
{
display
:
flex
;
flex
:
1
;
}
.chat_body
{
padding
:
10px
;
flex
:
1
;
background-position
:
center
;
margin-bottom
:
50px
;
}
::-webkit-scrollbar
{
width
:
8px
;
height
:
8px
;
}
::-webkit-scrollbar-thumb
{
background
:
rgb
(
110
,
110
,
110
);
border-radius
:
3px
;
}
.chat_footer
{
padding
:
10px
;
flex
:
1
;
display
:
flex
;
position
:
fixed
;
bottom
:
0
;
width
:
100%
;
overflow-y
:
hidden
;
justify-content
:
space-between
;
align-items
:
center
;
height
:
62px
;
background-color
:
antiquewhite
;
border-top
:
1px
solid
rgb
(
175
,
37
,
37
);
}
.chat_footer
>
input
{
flex
:
1
;
border-radius
:
30px
;
padding
:
10px
;
border
:
none
;
}
.chat_footer
>
button
{
display
:
flex
;
border
:
none
;
}
.chat_footer
>
i
{
padding
:
10px
;
color
:
gray
;
}
.ant-list-item-meta-description
{
display
:
flex
;
color
:
black
!important
;
}
\ No newline at end of file
frontend/src/digitalHuman/styles/sectionStyles.css
0 → 100644
View file @
8f9524df
.chat_message
{
font-size
:
16px
;
padding-left
:
10px
;
padding-right
:
10px
;
margin-left
:
20px
;
width
:
fit-content
;
border-radius
:
10px
;
background-color
:
aquamarine
;
margin-bottom
:
10px
;
}
.chat_recieve
{
margin-left
:
auto
;
margin-right
:
20px
;
background-color
:
aqua
;
}
frontend/src/functions/actions/digitalHuman_actions.js
0 → 100644
View file @
8f9524df
export
function
saveMessage
(
dataToSubmit
)
{
return
{
type
:
'
save_message
'
,
payload
:
dataToSubmit
}
}
frontend/src/functions/reducers/digitalHuman_reducer.js
0 → 100644
View file @
8f9524df
export
default
function
(
state
=
{
messages
:[]},
action
)
{
switch
(
action
.
type
)
{
case
'
save_message
'
:
return
{
...
state
,
messages
:
state
.
messages
.
concat
(
action
.
payload
)
}
default
:
return
state
;
}
}
\ No newline at end of file
frontend/src/functions/reducers/index.js
0 → 100644
View file @
8f9524df
import
{
combineReducers
}
from
'
redux
'
;
import
message
from
'
./digitalHuman_reducer
'
;
const
rootReducer
=
combineReducers
({
message
,
});
export
default
rootReducer
;
\ No newline at end of file
frontend/src/index.js
View file @
8f9524df
...
@@ -2,8 +2,9 @@ import React from 'react';
...
@@ -2,8 +2,9 @@ import React from 'react';
import
ReactDOM
from
'
react-dom
'
;
import
ReactDOM
from
'
react-dom
'
;
import
'
./index.css
'
;
import
'
./index.css
'
;
import
App
from
'
./App
'
;
import
App
from
'
./App
'
;
import
"
antd/dist/antd.css
"
;
import
"
antd/dist/antd.css
"
;
import
Reducer
from
'
../src/functions/reducers
'
;
import
{
Provider
}
from
'
react-redux
'
;
import
{
Provider
}
from
'
react-redux
'
;
import
{
createStore
,
applyMiddleware
}
from
'
redux
'
;
import
{
createStore
,
applyMiddleware
}
from
'
redux
'
;
import
promiseMiddleware
from
'
redux-promise
'
;
import
promiseMiddleware
from
'
redux-promise
'
;
...
@@ -15,13 +16,16 @@ const createStoreWithMiddleware = applyMiddleware(promiseMiddleware, ReduxThunk)
...
@@ -15,13 +16,16 @@ const createStoreWithMiddleware = applyMiddleware(promiseMiddleware, ReduxThunk)
ReactDOM
.
render
(
ReactDOM
.
render
(
<
Provider
<
Provider
store
=
{
createStoreWithMiddleware
(
store
=
{
createStoreWithMiddleware
(
Reducer
,
window
.
__REDUX_DEVTOOLS_EXTENSION__
&&
window
.
__REDUX_DEVTOOLS_EXTENSION__
&&
window
.
__REDUX_DEVTOOLS_EXTENSION__
()
window
.
__REDUX_DEVTOOLS_EXTENSION__
()
)}
>
)}
>
<
BrowserRouter
>
<
BrowserRouter
>
<
App
/>
<
App
/>
<
/BrowserRouter
>
<
/BrowserRouter
>
<
/Provider>
,
<
/Provider
>
document
.
getElementById
(
'
root
'
)
);
,
document
.
getElementById
(
"
root
"
)
);
\ No newline at end of file
frontend/src/main/ContactUs/styles/contactUs.css
View file @
8f9524df
...
@@ -19,17 +19,17 @@ body {
...
@@ -19,17 +19,17 @@ body {
/* global 92%+ browsers support */
/* global 92%+ browsers support */
background
:
radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
background
:
radial-gradient
(
circle
at
3%
25%
,
rgba
(
0
,
40
,
83
,
1
)
0%
,
rgba
(
4
,
12
,
24
,
1
)
25%
);
}
}
.contact
{
background
:
transparent
;
}
.contact__container
{
.contact__container
{
font-family
:
var
(
--font-family
);
font-family
:
var
(
--font-family
);
padding
:
4
rem
;
padding
:
3
rem
;
display
:
grid
;
display
:
grid
;
background
:
#1f2641
;
grid-template-columns
:
40%
60%
;
grid-template-columns
:
40%
60%
;
gap
:
4rem
;
gap
:
4rem
;
height
:
28
rem
;
height
:
31
rem
;
margin
:
7rem
7rem
;
margin
:
7rem
7rem
;
border-radius
:
1rem
;
border-radius
:
1rem
;
}
}
...
@@ -40,7 +40,7 @@ body {
...
@@ -40,7 +40,7 @@ body {
padding-left
:
3rem
;
padding-left
:
3rem
;
padding-right
:
3rem
;
padding-right
:
3rem
;
border-radius
:
1rem
;
border-radius
:
1rem
;
bottom
:
7
rem
;
bottom
:
6
rem
;
position
:
relative
;
position
:
relative
;
}
}
...
@@ -99,6 +99,12 @@ body {
...
@@ -99,6 +99,12 @@ body {
margin-bottom
:
1rem
;
margin-bottom
:
1rem
;
}
}
.contact__details
li
h5
{
color
:
var
(
--color-text
);
font-size
:
0.9rem
;
font-family
:
var
(
--font-family
);
}
.contact__socials
{
.contact__socials
{
display
:
flex
;
display
:
flex
;
gap
:
0.9rem
;
gap
:
0.9rem
;
...
@@ -169,9 +175,6 @@ body {
...
@@ -169,9 +175,6 @@ body {
text-decoration
:
none
;
text-decoration
:
none
;
}
}
@media
screen
and
(
max-width
:
1024px
)
{
@media
screen
and
(
max-width
:
1024px
)
{
.contact
{
.contact
{
padding-bottom
:
0
;
padding-bottom
:
0
;
...
...
frontend/src/
proxySetup
→
frontend/src/
setupProxy.js
View file @
8f9524df
File moved
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