Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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
2023-029
2023-029
Commits
5378cc0a
Commit
5378cc0a
authored
May 24, 2023
by
janithGamage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
8d807298
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
413 additions
and
68 deletions
+413
-68
Project/Backend/Server_Node/controllers/curriculum.controller.js
.../Backend/Server_Node/controllers/curriculum.controller.js
+72
-0
Project/Backend/Server_Node/controllers/user.controller.js
Project/Backend/Server_Node/controllers/user.controller.js
+54
-49
Project/Backend/Server_Node/models/curriculum.model.js
Project/Backend/Server_Node/models/curriculum.model.js
+38
-0
Project/Backend/Server_Node/models/user.model.js
Project/Backend/Server_Node/models/user.model.js
+3
-4
Project/Backend/Server_Node/routes/curriculum.routes.js
Project/Backend/Server_Node/routes/curriculum.routes.js
+11
-0
Project/Backend/Server_Node/server.js
Project/Backend/Server_Node/server.js
+3
-0
Project/Frontend/Web_App/src/_mock/arrays/curriculums.json
Project/Frontend/Web_App/src/_mock/arrays/curriculums.json
+180
-0
Project/Frontend/Web_App/src/pages/dashboard/learning-module/curriculum/curriculums/[curriculumId]/tutorials/[tutorialId].tsx
...lum/curriculums/[curriculumId]/tutorials/[tutorialId].tsx
+19
-14
Project/Frontend/Web_App/src/sections/@dashboard/learning-module/curriculum/CameraCapture.tsx
...s/@dashboard/learning-module/curriculum/CameraCapture.tsx
+32
-0
Project/Frontend/Web_App/yarn.lock
Project/Frontend/Web_App/yarn.lock
+1
-1
No files found.
Project/Backend/Server_Node/controllers/curriculum.controller.js
0 → 100644
View file @
5378cc0a
import
mongoose
from
'
mongoose
'
;
import
Curriculum
from
'
../models/curriculum.model.js
'
;
export
const
getAllCurricula
=
async
(
req
,
res
)
=>
{
try
{
const
curricula
=
await
Curriculum
.
find
();
res
.
status
(
200
).
json
({
code
:
"
01
"
,
result
:
curricula
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
code
:
"
00
"
,
message
:
"
Something went wrong
"
});
}
};
export
const
getCurriculumById
=
async
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
;
try
{
if
(
!
mongoose
.
Types
.
ObjectId
.
isValid
(
id
))
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Curriculum for this id:
${
id
}
`
});
}
const
curriculum
=
await
Curriculum
.
findById
(
id
);
if
(
!
curriculum
)
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Curriculum found for this id:
${
id
}
`
});
}
res
.
status
(
200
).
json
({
code
:
"
01
"
,
result
:
curriculum
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
code
:
"
00
"
,
message
:
"
Something went wrong
"
});
}
};
export
const
getTutorialsByCurriculumId
=
async
(
req
,
res
)
=>
{
const
{
curriculumId
}
=
req
.
params
;
try
{
if
(
!
mongoose
.
Types
.
ObjectId
.
isValid
(
curriculumId
))
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Curriculum for this id:
${
curriculumId
}
`
});
}
const
curriculum
=
await
Curriculum
.
findById
(
curriculumId
);
if
(
!
curriculum
)
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Curriculum found for this id:
${
curriculumId
}
`
});
}
const
tutorials
=
curriculum
.
tutorials
;
res
.
status
(
200
).
json
({
code
:
"
01
"
,
result
:
tutorials
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
code
:
"
00
"
,
message
:
"
Something went wrong
"
});
}
};
export
const
getTasksByCurriculumAndTutorialId
=
async
(
req
,
res
)
=>
{
const
{
curriculumId
,
tutorialId
}
=
req
.
params
;
try
{
if
(
!
mongoose
.
Types
.
ObjectId
.
isValid
(
curriculumId
))
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Curriculum for this id:
${
curriculumId
}
`
});
}
const
curriculum
=
await
Curriculum
.
findById
(
curriculumId
);
if
(
!
curriculum
)
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Curriculum found for this id:
${
curriculumId
}
`
});
}
const
tutorial
=
curriculum
.
tutorials
.
id
(
tutorialId
);
if
(
!
tutorial
)
{
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No Tutorial found for this id:
${
tutorialId
}
`
});
}
const
tasks
=
tutorial
.
tasks
;
res
.
status
(
200
).
json
({
code
:
"
01
"
,
result
:
tasks
});
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
code
:
"
00
"
,
message
:
"
Something went wrong
"
});
}
};
Project/Backend/Server_Node/controllers/user.controller.js
View file @
5378cc0a
...
...
@@ -102,8 +102,7 @@ export const signUp = async (req, res) => {
const
userDetails
=
new
User
({
email
,
password
:
hashedPassword
,
type
,
password
:
hashedPassword
,
userDetails
:
{
userQNumber
:
uuidv4
(),
userEmail
:
email
,
...
...
@@ -178,53 +177,59 @@ export const updateUser = async (req, res) => {
return
res
.
status
(
404
).
json
({
code
:
"
02
"
,
message
:
`No User for this id:
${
id
}
`
});
}
if
(
data
.
type
==
"
buyer
"
||
data
.
type
==
"
admin
"
)
{
const
updateUser
=
{
...
data
,
_id
:
id
}
await
User
.
findByIdAndUpdate
(
id
,
updateUser
,
{
new
:
true
})
res
.
status
(
200
);
res
.
json
({
code
:
"
01
"
,
result
:
updateUser
})
}
else
if
(
data
.
type
==
"
trader
"
)
{
var
password
=
Math
.
random
().
toString
(
36
).
slice
(
-
8
);
const
hashPassword
=
await
bcrypt
.
hash
(
password
,
12
)
const
updateUser
=
{
...
data
,
password
:
hashPassword
,
_id
:
id
}
await
User
.
findByIdAndUpdate
(
id
,
updateUser
,
{
new
:
true
})
//call email service
let
transporter
=
nodemailer
.
createTransport
({
service
:
'
gmail
'
,
auth
:
{
type
:
'
OAuth2
'
,
user
:
process
.
env
.
MAIL_USERNAME
,
pass
:
process
.
env
.
MAIL_PASSWORD
,
clientId
:
process
.
env
.
OAUTH_CLIENTID
,
clientSecret
:
process
.
env
.
OAUTH_CLIENT_SECRET
,
refreshToken
:
process
.
env
.
OAUTH_REFRESH_TOKEN
}
});
let
mailOptions
=
{
from
:
"
janithgamage1.ed@gmail.com
"
,
to
:
updateUser
.
email
,
subject
:
'
Shop House Project
'
,
text
:
`You are Successfully Approved, you're username:
${
updateUser
.
email
}
, you're password :
${
password
}
`
};
transporter
.
sendMail
(
mailOptions
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
"
Error
"
+
err
);
}
else
{
console
.
log
(
"
Email sent successfully
"
);
}
});
res
.
status
(
200
);
res
.
json
({
code
:
"
01
"
,
result
:
updateUser
})
}
// if (data.type == "buyer" || data.type == "admin") {
// const updateUser = { ...data, _id: id }
// await User.findByIdAndUpdate(id, updateUser, { new: true })
// res.status(200);
// res.json({ code: "01", result: updateUser })
// } else if (data.type == "trader") {
// var password = Math.random().toString(36).slice(-8);
// const hashPassword = await bcrypt.hash(password, 12)
// const updateUser = { ...data, password: hashPassword, _id: id }
// await User.findByIdAndUpdate(id, updateUser, { new: true })
// //call email service
// let transporter = nodemailer.createTransport({
// service: 'gmail',
// auth: {
// type: 'OAuth2',
// user: process.env.MAIL_USERNAME,
// pass: process.env.MAIL_PASSWORD,
// clientId: process.env.OAUTH_CLIENTID,
// clientSecret: process.env.OAUTH_CLIENT_SECRET,
// refreshToken: process.env.OAUTH_REFRESH_TOKEN
// }
// });
// let mailOptions = {
// from: "janithgamage1.ed@gmail.com",
// to: updateUser.email,
// subject: 'Shop House Project',
// text: `You are Successfully Approved, you're username: ${updateUser.email} , you're password : ${password}`
// };
// transporter.sendMail(mailOptions, function (err, data) {
// if (err) {
// console.log("Error " + err);
// } else {
// console.log("Email sent successfully");
// }
// });
// res.status(200);
// res.json({ code: "01", result: updateUser })
// }
const
updateUser
=
{
...
data
,
_id
:
id
}
await
User
.
findByIdAndUpdate
(
id
,
updateUser
,
{
new
:
true
})
res
.
status
(
200
);
res
.
json
({
code
:
"
01
"
,
result
:
updateUser
})
}
catch
(
error
)
{
...
...
Project/Backend/Server_Node/models/curriculum.model.js
0 → 100644
View file @
5378cc0a
import
mongoose
from
"
mongoose
"
;
const
tutorialSchema
=
mongoose
.
Schema
({
id
:
String
,
title
:
String
,
description
:
String
,
image
:
String
,
items
:
[
{
id
:
String
,
title
:
String
,
description
:
String
,
howToDo
:
[
String
],
image
:
String
,
video
:
String
,
},
],
});
const
curriculumSchema
=
mongoose
.
Schema
({
id
:
String
,
title
:
String
,
description
:
String
,
image
:
String
,
tutorials
:
[
tutorialSchema
],
createdAt
:
{
type
:
Date
,
default
:
Date
.
now
,
},
updatedAt
:
{
type
:
Date
,
default
:
Date
.
now
,
},
});
const
curriculum
=
mongoose
.
model
(
"
Curriculums
"
,
curriculumSchema
);
export
default
curriculum
;
Project/Backend/Server_Node/models/user.model.js
View file @
5378cc0a
...
...
@@ -10,8 +10,8 @@ const userSchema = mongoose.Schema({
type
:
String
},
type
:
{
type
:
String
,
required
:
true
type
:
String
,
default
:
"
N/A
"
,
},
userDetails
:
{
userQNumber
:
{
...
...
@@ -36,8 +36,7 @@ const userSchema = mongoose.Schema({
},
userType
:
{
type
:
String
,
default
:
"
N/A
"
,
required
:
true
default
:
"
N/A
"
,
},
},
states
:
{
...
...
Project/Backend/Server_Node/routes/curriculum.routes.js
0 → 100644
View file @
5378cc0a
import
express
from
"
express
"
;
import
{
getAllCurricula
,
getCurriculumById
,
getTasksByCurriculumAndTutorialId
,
getTutorialsByCurriculumId
}
from
"
../controllers/curriculum.controller.js
"
;
const
router
=
express
.
Router
();
router
.
get
(
"
/
"
,
getAllCurricula
);
router
.
get
(
"
/:id
"
,
getCurriculumById
);
router
.
get
(
"
/:curriculumId/tutorials
"
,
getTutorialsByCurriculumId
);
router
.
get
(
"
/:curriculumId/tutorials/:tutorialId/tasks
"
,
getTasksByCurriculumAndTutorialId
);
export
default
router
;
Project/Backend/Server_Node/server.js
View file @
5378cc0a
...
...
@@ -5,9 +5,11 @@ import express from "express";
import
mongoose
from
"
mongoose
"
;
//import routes
import
curriculumRoutes
from
"
./routes/curriculum.routes.js
"
;
import
translateRoutes
from
"
./routes/translate.routes.js
"
;
import
userRoutes
from
"
./routes/user.routes.js
"
;
dotenv
.
config
();
const
app
=
express
();
...
...
@@ -23,6 +25,7 @@ app.get("/", (req, res) => {
//implement routes
app
.
use
(
"
/rest_node/user
"
,
userRoutes
);
app
.
use
(
"
/rest_node/ssl
"
,
translateRoutes
);
app
.
use
(
"
/rest_node/curriculum
"
,
curriculumRoutes
);
const
CONNECTION_URL
=
`mongodb+srv://
${
process
.
env
.
DB_USERNAME
}
:
${
process
.
env
.
DB_PASSWORD
}
@cluster0.dmza8yi.mongodb.net/?retryWrites=true&w=majority`
;
const
PORT
=
process
.
env
.
PORT
||
5000
;
...
...
Project/Frontend/Web_App/src/_mock/arrays/curriculums.json
0 → 100644
View file @
5378cc0a
This diff is collapsed.
Click to expand it.
Project/Frontend/Web_App/src/pages/dashboard/learning-module/curriculum/curriculums/[curriculumId]/tutorials/[tutorialId].tsx
View file @
5378cc0a
...
...
@@ -12,6 +12,7 @@ import Scrollbar from 'src/components/scrollbar/Scrollbar';
import
{
Upload
}
from
'
src/components/upload
'
;
import
{
NAV
}
from
'
src/config
'
;
import
useCountup
from
'
src/hooks/useCountup
'
;
import
CameraCapture
from
'
src/sections/@dashboard/learning-module/curriculum/CameraCapture
'
;
import
{
useSettingsContext
}
from
'
../../../../../../../components/settings
'
;
import
DashboardLayout
from
'
../../../../../../../layouts/dashboard
'
;
...
...
@@ -196,6 +197,7 @@ export default function TutorialViewPage() {
<
StyledListContainer
>
<
List
>
{
menuItems
.
length
<
0
&&
<><
Alert
severity=
'warning'
>
No Items for this tutorials
</
Alert
></>
}
{
menuItems
.
map
((
item
:
{
id
:
string
,
title
:
string
,
onItemClick
:
any
,
icon
:
string
,
handleCheck
:
any
},
index
:
number
)
=>
{
index
=
parseInt
(
item
.
id
)
return
(
...
...
@@ -323,7 +325,7 @@ export default function TutorialViewPage() {
<
CardHeader
title=
{
`${action.toUpperCase()} - ${itemContent?.title}`
}
/>
<
CardContent
>
<
Grid
container
spacing=
{
3
}
>
<
Grid
item
md=
{
5
}
>
<
Grid
item
md=
{
6
}
>
<
ButtonGroup
aria
-
label=
"outlined button group"
>
<
Button
variant=
{
sourceData
==
"
upload
"
?
"
contained
"
:
"
outlined
"
}
onClick=
{
()
=>
{
setSourceData
(
"
upload
"
)
}
}
>
Upload Image
</
Button
>
<
Button
variant=
{
sourceData
==
"
capture
"
?
"
contained
"
:
"
outlined
"
}
onClick=
{
()
=>
{
setSourceData
(
"
capture
"
)
}
}
>
Capture Image
</
Button
>
...
...
@@ -331,11 +333,23 @@ export default function TutorialViewPage() {
{
!
sourceData
&&
<><
Alert
severity=
'info'
>
Select a sourceData Type
</
Alert
></>
}
{
sourceData
==
"
upload
"
&&
<>
<
Upload
sx=
{
{
mt
:
3
}
}
file=
{
file
}
onDrop=
{
handleDropSingleFile
}
onDelete=
{
()
=>
setFile
(
null
)
}
/>
{
/* {file != null &&
<>
<Image
disabledEffect
alt={"Reference Image"}
src={"https://drive.google.com/uc?export=view&id=1T7djlWSfUgCFUNrrW5teXUJglZ-uTHLk"}
ratio={"1/1"}
sx={{ borderRadius: 1, mt: 6 }}
/>
<Alert severity='info' sx={{ mt: 2 }}>Captured source</Alert>
</>
} */
}
</>
}
{
sourceData
==
"
capture
"
&&
<>
<
Card
sx=
{
{
mt
:
3
}
}
>
<
CardContent
>
<
Typography
variant=
"h5"
paragraph
>
{
/*
<Typography variant="h5" paragraph>
Coming Soon!
</Typography>
...
...
@@ -343,13 +357,14 @@ export default function TutorialViewPage() {
We are currently working hard on this page!
</Typography>
<
ComingSoonIllustration
sx=
{
{
my
:
1
,
height
:
200
}
}
/>
<ComingSoonIllustration sx={{ my: 1, height: 200 }} /> */
}
<
CameraCapture
/>
</
CardContent
>
</
Card
>
</>
}
<
Alert
severity=
'info'
sx=
{
{
mt
:
2
}
}
>
Capture a source
</
Alert
>
</
Grid
>
<
Grid
item
md=
{
4
}
>
<
Grid
item
md=
{
6
}
>
<
Grid
container
spacing=
{
3
}
rowSpacing=
{
2
}
sx=
{
{
mt
:
8
}
}
>
<
Grid
item
md=
{
12
}
>
<
TextField
...
...
@@ -382,16 +397,6 @@ export default function TutorialViewPage() {
</
Grid
>
</
Grid
>
</
Grid
>
<
Grid
item
md=
{
3
}
>
<
Image
disabledEffect
alt=
{
"
Reference Image
"
}
src=
{
"
https://drive.google.com/uc?export=view&id=1T7djlWSfUgCFUNrrW5teXUJglZ-uTHLk
"
}
ratio=
{
"
1/1
"
}
sx=
{
{
borderRadius
:
1
,
mt
:
6
}
}
/>
<
Alert
severity=
'info'
sx=
{
{
mt
:
2
}
}
>
Captured source
</
Alert
>
</
Grid
>
</
Grid
>
</
CardContent
>
</
Card
>
...
...
Project/Frontend/Web_App/src/sections/@dashboard/learning-module/curriculum/CameraCapture.tsx
0 → 100644
View file @
5378cc0a
import
React
,
{
useRef
,
useState
}
from
'
react
'
;
import
Webcam
from
'
react-webcam
'
;
import
Button
from
'
@mui/material/Button
'
;
const
CameraCapture
:
React
.
FC
=
()
=>
{
const
webcamRef
=
useRef
<
Webcam
>
(
null
);
const
[
capturedImage
,
setCapturedImage
]
=
useState
<
string
|
null
>
(
null
);
const
capture
=
()
=>
{
if
(
webcamRef
.
current
)
{
const
imageSrc
=
webcamRef
.
current
.
getScreenshot
();
setCapturedImage
(
imageSrc
);
}
};
return
(
<
div
>
<
Webcam
audio=
{
false
}
ref=
{
webcamRef
}
screenshotFormat=
"image/jpeg"
/>
<
Button
variant=
"contained"
onClick=
{
capture
}
fullWidth
>
Capture
</
Button
>
{
capturedImage
&&
(
<
div
>
<
h2
>
Captured Image:
</
h2
>
<
img
src=
{
capturedImage
}
alt=
"Captured"
/>
</
div
>
)
}
</
div
>
);
};
export
default
CameraCapture
;
Project/Frontend/Web_App/yarn.lock
View file @
5378cc0a
...
...
@@ -4706,7 +4706,7 @@ react-transition-group@^4.4.5:
react-webcam@^7.0.1:
version "7.0.1"
resolved "https://registry.
npmjs.org/react-webcam/-/react-webcam-7.0.1.tgz
"
resolved "https://registry.
yarnpkg.com/react-webcam/-/react-webcam-7.0.1.tgz#8249e1d621eb4bba7e3f52135f562439d0528df3
"
integrity sha512-8E/Eb/7ksKwn5QdLn67tOR7+TdP9BZdu6E5/DSt20v8yfW/s0VGBigE6VA7R4278mBuBUowovAB3DkCfVmSPvA==
react@^18.2.0:
...
...
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