Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-155
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
2021-155
2021-155
Commits
64622521
Commit
64622521
authored
Oct 17, 2021
by
dasunx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
similar question finding model connected with the ui
parent
6eb6c36e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
56 deletions
+62
-56
client/components/blog-article/BlogArticle.module.css
client/components/blog-article/BlogArticle.module.css
+1
-1
client/components/no-resource/NoResource.jsx
client/components/no-resource/NoResource.jsx
+4
-2
client/components/similar-question-suggestions/index.js
client/components/similar-question-suggestions/index.js
+47
-41
client/components/similar-question-suggestions/similar-question/index.js
...ts/similar-question-suggestions/similar-question/index.js
+9
-12
client/components/similar-question-suggestions/similar-question/similar-question.module.css
...-suggestions/similar-question/similar-question.module.css
+1
-0
No files found.
client/components/blog-article/BlogArticle.module.css
View file @
64622521
...
...
@@ -87,7 +87,7 @@
pre
{
padding
:
20px
;
background-color
:
var
(
black
);
font-size
:
16px
;
font-family
:
'Roboto Mono'
,
monospace
!important
;
max-width
:
780px
;
}
...
...
client/components/no-resource/NoResource.jsx
View file @
64622521
...
...
@@ -5,8 +5,10 @@ const NoResource = ({ source, message }) => {
return
(
<
div
className=
{
Styles
.
noresource
}
>
<
h1
>
No resources found from
<
b
>
{
source
}
</
b
>
for this question. Please refer
the extra resouces section to find more info.
{
message
?
message
:
`No resources found from ${source} for this question. Please refer
the extra resouces section to find more info.`
}
</
h1
>
</
div
>
)
...
...
client/components/similar-question-suggestions/index.js
View file @
64622521
...
...
@@ -4,55 +4,57 @@ import { Title } from '../styled-text-spans/index'
import
styles
from
'
./similar-question-suggestions.module.css
'
import
useDebounce
from
'
../../hooks/useDebounce
'
import
{
Spinner
}
from
'
../icons
'
import
Axios
from
'
axios
'
import
NoResource
from
'
../no-resource/NoResource
'
const
SimilarQuestionSuggestions
=
({
title
,
description
,
tags
})
=>
{
const
[
isLoading
,
setIsLoading
]
=
useState
(
true
)
const
[
similarQuestions
,
setSimilarQuestions
]
=
useState
([
{
url
:
'
https://dasunx.com
'
,
title
:
'
How to center a div element vertically
'
,
author
:
{
username
:
'
dasunx
'
,
profilePhoto
:
'
https://secure.gravatar.com/avatar/608a987a8401796f68c4d11f?s=90&d=monsterid
'
},
views
:
240
,
comments
:
12
},
{
url
:
'
https://dasunx.com
'
,
title
:
"
I can center it horizontally, but the thing is I don't know how to center it vertically.I can center it horizontally, but the thing is I don't know how to center it vertically.
"
,
author
:
{
username
:
'
dasunx
'
,
profilePhoto
:
'
https://secure.gravatar.com/avatar/608a987a8401796f68c4d11f?s=90&d=monsterid
'
},
views
:
20
,
comments
:
1
},
{
url
:
'
https://dasunx.com
'
,
title
:
'
Test question 3
'
,
author
:
{
username
:
'
dasunx
'
,
profilePhoto
:
'
https://secure.gravatar.com/avatar/608a987a8401796f68c4d11f?s=90&d=monsterid
'
},
views
:
40
,
comments
:
6
const
[
similarQuestions
,
setSimilarQuestions
]
=
useState
([])
const
[
error
,
setError
]
=
useState
({
isError
:
false
,
message
:
''
})
const
getSimilarQuestions
=
async
()
=>
{
console
.
log
(
'
getSimilarQuestions
'
)
const
data
=
{
question
:
title
}
const
headers
=
{
'
Content-Type
'
:
'
application/json
'
,
'
Access-Control-Allow-Origin
'
:
'
*
'
}
try
{
const
response
=
await
Axios
.
post
(
'
https://localhost:3002/
'
,
data
,
headers
)
if
(
response
.
status
===
200
)
{
setSimilarQuestions
(
response
.
data
)
}
else
{
setError
({
isError
:
true
,
message
:
'
Something went wrong while searching similar questions. Please try again
'
})
}
}
catch
(
err
)
{
console
.
log
(
err
)
setError
({
isError
:
true
,
message
:
'
Similar question finding is not supported in this environment yet. Hopefully it will be available soon.
'
})
}
])
setIsLoading
(
false
)
}
useDebounce
(
()
=>
{
setIsLoading
(
false
)
async
()
=>
{
await
getSimilarQuestions
(
)
},
1000
,
[
title
]
)
const
{
isError
,
message
}
=
error
return
(
<
div
className
=
{
styles
.
container
}
>
<
h1
>
...
...
@@ -61,10 +63,14 @@ const SimilarQuestionSuggestions = ({ title, description, tags }) => {
<
/h1
>
{
isLoading
?
(
<
Spinner
className
=
{
styles
.
spinner
}
/
>
)
:
(
)
:
isError
?
(
<
NoResource
message
=
{
message
}
/
>
)
:
similarQuestions
.
length
>
0
?
(
similarQuestions
.
map
((
question
,
index
)
=>
{
return
<
SimilarQuestion
question
=
{
question
}
key
=
{
index
}
/
>
return
<
SimilarQuestion
question
_prop
=
{
question
}
key
=
{
index
}
/
>
})
)
:
(
<
NoResource
message
=
"
No similar questions found for this question. Submit your question to get an answer generated in few seconds
"
/>
)}
<
/div
>
)
...
...
client/components/similar-question-suggestions/similar-question/index.js
View file @
64622521
...
...
@@ -3,28 +3,25 @@ import React from 'react'
import
{
Bold
,
Title
}
from
'
../../styled-text-spans/index
'
import
styles
from
'
./similar-question.module.css
'
const
SimilarQuestion
=
({
question
})
=>
{
const
{
title
,
author
,
url
,
views
,
comments
}
=
question
const
SimilarQuestion
=
({
question
_prop
})
=>
{
const
{
id
,
question
,
description
}
=
question_prop
return
(
<
Link
href
=
"
/questions/[slug]
"
as
=
{
`/questions/6087be20b0c06a179059dfa8-how-to-center-a-div-element-vertically`
}
>
<
Link
href
=
"
/questions/[slug]
"
as
=
{
`/questions/
${
id
}
-
${
question
}
`
}
>
<
div
className
=
{
styles
.
similarquestion
}
>
<
Link
href
=
"
/users/[user]
"
as
=
{
`/users/
${
author
.
username
}
`
}
>
<
Link
href
=
"
/users/[user]
"
as
=
{
`/users/
dasun97
`
}
>
<
div
className
=
{
styles
.
userwrapper
}
>
<
img
className
=
{
styles
.
profilephoto
}
src
=
{
author
.
profilePhoto
}
alt
=
{
author
.
username
}
src
=
"
https://www.practiceportuguese.com/wp-content/uploads/2020/06/asking-questions.jpg
"
alt
=
"
dasun97
"
/>
<
Bold
text
=
{
`@
${
author
.
username
}
`
}
/
>
<
Bold
text
=
{
`@
dasun97
`
}
/
>
<
/div
>
<
/Link
>
<
div
className
=
{
styles
.
questionwrapper
}
>
<
Title
title
=
{
title
}
/
>
<
Title
title
=
{
question
}
/
>
<
div
>
<
Bold
text
=
{
views
}
/> Views and <Bold text={comments
} /
>
<
Bold
text
=
{
123
}
/> Views and <Bold text=
{2
}
/
>
Comments
<
/div
>
<
/div
>
...
...
client/components/similar-question-suggestions/similar-question/similar-question.module.css
View file @
64622521
...
...
@@ -5,6 +5,7 @@
display
:
flex
;
flex-direction
:
row
;
border-radius
:
5px
;
cursor
:
pointer
;
}
.userwrapper
{
display
:
flex
;
...
...
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