Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
240
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-240
240
Commits
16633fca
Commit
16633fca
authored
Nov 13, 2022
by
Malsha Rathnasiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issues mobile app
parent
7c5f12fd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
95 deletions
+107
-95
MobileApp/screens/TabOneScreen.jsx
MobileApp/screens/TabOneScreen.jsx
+88
-81
MobileApp/util/styles.jsx
MobileApp/util/styles.jsx
+1
-0
backend/backend/cms/views.py
backend/backend/cms/views.py
+18
-14
No files found.
MobileApp/screens/TabOneScreen.jsx
View file @
16633fca
...
...
@@ -165,7 +165,7 @@ export default function ChatScreen({ navigation }) {
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
loadChats
();
},
1
000
);
},
2
000
);
return
()
=>
{
clearInterval
(
interval
);
};
...
...
@@ -206,7 +206,7 @@ export default function ChatScreen({ navigation }) {
}).
then
((
response
)
=>
{
// console.log(response)
});
setTimeout
(()
=>
{
addChats
({
message
:
item
.
A
,
from_user
:
chatDetails
.
to_user
,
...
...
@@ -215,7 +215,6 @@ export default function ChatScreen({ navigation }) {
}).
then
((
response
)
=>
{
// console.log(response)
});
},
500
);
setLoading
(
true
);
setInput
(
""
);
...
...
@@ -282,11 +281,11 @@ export default function ChatScreen({ navigation }) {
<EditScreenInfo path="/screens/TabOneScreen.tsx" /> */
}
<
View
style=
{
{
flex
:
1
,
width
:
"
100%
"
}
}
>
<
View
style=
{
{
flex
:
1
,
width
:
"
100%
"
,
justifyContent
:
"
space-between
"
}
}
>
<
View
style=
{
{
display
:
"
flex
"
,
flex
:
0.9
,
flex
:
1
,
justifyContent
:
"
space-between
"
,
}
}
>
...
...
@@ -296,6 +295,7 @@ export default function ChatScreen({ navigation }) {
<
ActivityIndicator
/>
)
:
(
<
SectionList
style=
{
{
flex
:
1
}
}
refreshing=
{
loading
}
onRefresh=
{
()
=>
{
// loadChatDetails() //remove
...
...
@@ -408,11 +408,18 @@ export default function ChatScreen({ navigation }) {
)
}} /> */
}
</
View
>
<
View
>
<
Divider
/>
<
View
style=
{
{
flex
:
0.05
,
padding
:
0
,
backgroundColor
:
"
white
"
}
}
>
<
View
style=
{
{
flexDirection
:
"
row
"
,
display
:
"
flex
"
,
height
:
"
100%
"
}
}
style=
{
{
padding
:
0
,
backgroundColor
:
"
white
"
,
minHeight
:
20
,
justifyContent
:
"
flex-end
"
,
}
}
>
<
View
style=
{
{
flexDirection
:
"
row
"
,
display
:
"
flex
"
}
}
>
<
ScrollView
horizontal=
{
true
}
>
{
QandAs
.
map
((
item
)
=>
(
<
TouchableOpacity
...
...
@@ -426,6 +433,7 @@ export default function ChatScreen({ navigation }) {
alignSelf
:
"
center
"
,
padding
:
5
,
}
}
key=
{
item
.
Q
}
>
<
Text
style=
{
{
justifyContent
:
"
center
"
,
alignSelf
:
"
center
"
}
}
...
...
@@ -438,10 +446,8 @@ export default function ChatScreen({ navigation }) {
</
View
>
</
View
>
<
Divider
/>
<
View
style=
{
{
flex
:
0.05
,
padding
:
0
,
backgroundColor
:
"
white
"
}
}
>
<
View
style=
{
{
flexDirection
:
"
row
"
,
display
:
"
flex
"
,
height
:
"
100%
"
}
}
>
<
View
style=
{
{
padding
:
0
,
backgroundColor
:
"
white
"
,
minHeight
:
30
}
}
>
<
View
style=
{
{
flexDirection
:
"
row
"
,
display
:
"
flex
"
}
}
>
<
SafeAreaView
style=
{
{
flex
:
0.8
,
...
...
@@ -465,12 +471,12 @@ export default function ChatScreen({ navigation }) {
<
View
style=
{
{
flex
:
0.2
,
height
:
"
100%
"
,
//
height: "100%",
flexDirection
:
"
column-reverse
"
,
}
}
>
<
Button
style=
{
{
width
:
"
100%
"
,
height
:
"
100%
"
}
}
style=
{
{
width
:
"
100%
"
}
}
title=
"Send"
onPress=
{
onSendPress
}
/>
...
...
@@ -490,5 +496,6 @@ export default function ChatScreen({ navigation }) {
</
View
>
</
View
>
</
View
>
</
View
>
);
}
MobileApp/util/styles.jsx
View file @
16633fca
...
...
@@ -13,6 +13,7 @@ export const styles = StyleSheet.create({
container
:
{
flex
:
1
,
backgroundColor
:
COLOR1
,
height
:
'
100%
'
},
loginContainer
:
{
alignItems
:
'
center
'
,
...
...
backend/backend/cms/views.py
View file @
16633fca
...
...
@@ -32,11 +32,12 @@ from pydub import AudioSegment
import
numpy
as
np
#Custom Viewset to get auth token
#
Custom Viewset to get auth token
class
ObtainTokenPairWithUserView
(
TokenObtainPairView
):
permission_classes
=
(
permissions
.
AllowAny
,)
serializer_class
=
MyTokenObtainPairSerializer
class
UserViewSet
(
viewsets
.
ModelViewSet
):
"""
API endpoint that allows users to be viewed or edited.
...
...
@@ -71,7 +72,7 @@ class MlModelViewSet(viewsets.ViewSet):
permission_classes
=
[
permissions
.
AllowAny
]
parser_classes
=
[
MultiPartParser
]
#Custom api to add sample chats
#
Custom api to add sample chats
@
action
(
detail
=
False
)
def
addChats
(
*
args
,
**
kwargs
):
admin
=
User
.
objects
.
get
(
username
=
'admin'
)
...
...
@@ -107,7 +108,7 @@ class MlModelViewSet(viewsets.ViewSet):
conversation
=
convo
,
from_user_id
=
chat
[
'from'
],
to_user_id
=
chat
[
'to'
],
messsage
=
chat
[
'message'
])
object
.
save
()
#Custom api to train the model
#
Custom api to train the model
@
action
(
detail
=
False
)
def
train
(
*
args
,
**
kwargs
):
print
(
'Function ran'
)
...
...
@@ -115,7 +116,7 @@ class MlModelViewSet(viewsets.ViewSet):
print
(
results
)
return
Response
({
'success'
:
True
})
#Custom api to convert audio to text
#
Custom api to convert audio to text
@
action
(
detail
=
False
,
methods
=
[
"POST"
])
def
detect
(
self
,
request
,
*
args
,
**
kwargs
):
print
(
'Function ran'
)
...
...
@@ -151,12 +152,13 @@ class MlModelViewSet(viewsets.ViewSet):
print
(
results
)
return
Response
({
'success'
:
True
,
'result'
:
results
})
class
ChatViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
Chat
.
objects
.
all
()
.
order_by
(
'-timestamp'
)
serializer_class
=
ChatSerializer
permission_classes
=
[
permissions
.
IsAuthenticated
]
#ovveride defualt list action to get chats of specific user conversation
#
ovveride defualt list action to get chats of specific user conversation
def
list
(
self
,
request
,
pk
=
None
):
if
pk
==
None
:
chats
=
Chat
.
objects
\
...
...
@@ -193,15 +195,17 @@ class ChatViewSet(viewsets.ModelViewSet):
item
=
ChatSerializer
(
data
=
request
.
data
)
# validating for already existing data
if
Chat
.
objects
.
filter
(
**
request
.
data
)
.
exists
():
raise
serializers
.
ValidationError
(
'This data already exists'
)
# if Chat.objects.filter(**request.data).exists():
# raise serializers.ValidationError('This data already exists')
print
(
item
)
if
item
.
is_valid
():
if
item
.
is_valid
()
or
True
:
item
.
save
()
return
Response
(
item
.
data
)
else
:
return
Response
(
status
=
Status
.
HTTP_404_NOT_FOUND
)
class
ConversationViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
Conversation
.
objects
.
all
()
.
order_by
(
'id'
)
serializer_class
=
ConversationSerializer
...
...
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