Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1849ee61
authored
Apr 17, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working on scenes
parent
897c69d3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
46 deletions
sails/src/api/controllers/SceneController.js
sails/src/api/controllers/StudentController.js
sails/src/api/hooks/events.js
sails/src/api/models/Scene.js
sails/src/api/models/StuPicto.js
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/config/routes.js
sails/src/api/controllers/SceneController.js
View file @
1849ee61
...
@@ -34,6 +34,8 @@ module.exports = {
...
@@ -34,6 +34,8 @@ module.exports = {
// Update a scene data
// Update a scene data
//
//
update
:
function
(
req
,
res
)
{
update
:
function
(
req
,
res
)
{
if
(
typeof
req
.
params
.
id
==
'undefined'
||
!
req
.
params
.
id
)
return
res
.
badRequest
(
"scene id not defined"
);
Scene
.
findOne
({
id
:
req
.
params
.
id
}).
then
(
function
(
scene
)
{
Scene
.
findOne
({
id
:
req
.
params
.
id
}).
then
(
function
(
scene
)
{
if
(
!
scene
)
{
if
(
!
scene
)
{
res
.
badRequest
();
res
.
badRequest
();
...
@@ -63,6 +65,8 @@ module.exports = {
...
@@ -63,6 +65,8 @@ module.exports = {
* @param {response} res {}
* @param {response} res {}
*/
*/
destroy
:
function
(
req
,
res
)
{
destroy
:
function
(
req
,
res
)
{
if
(
typeof
req
.
params
.
id
==
'undefined'
||
!
req
.
params
.
id
)
return
res
.
badRequest
(
"scene id not defined"
);
Scene
.
destroy
({
id
:
req
.
params
.
id
}).
exec
(
function
(
error
)
{
Scene
.
destroy
({
id
:
req
.
params
.
id
}).
exec
(
function
(
error
)
{
if
(
error
)
if
(
error
)
return
res
.
badRequest
();
return
res
.
badRequest
();
...
@@ -77,33 +81,25 @@ module.exports = {
...
@@ -77,33 +81,25 @@ module.exports = {
* @param {response} res {}
* @param {response} res {}
*/
*/
getScene
:
function
(
req
,
res
){
getScene
:
function
(
req
,
res
){
if
(
typeof
req
.
params
.
id
==
'undefined'
||
!
req
.
params
.
id
)
return
res
.
badRequest
(
"scene id not defined"
);
Scene
.
findOne
({
id
:
req
.
params
.
id
})
Scene
.
findOne
({
id
:
req
.
params
.
id
})
.
populate
(
'stuPictos'
).
then
(
function
(
scene
){
.
populate
(
'stuPictos'
).
then
(
function
(
scene
){
if
(
!
scene
)
if
(
!
scene
){
return
res
.
badRequest
();
return
res
.
badRequest
();
else
}
console
.
log
(
scene
);
else
{
return
res
.
ok
(
scene
);
Scene
.
pictos
(
scene
.
id
,
function
(
err
,
pictos
){
if
(
err
){
return
res
.
serverError
(
"Error obtaining pictos: "
+
err
);
}
scene
.
pictos
=
pictos
;
return
res
.
ok
(
scene
);
});
}
}).
catch
(
function
(
err
){
}).
catch
(
function
(
err
){
return
res
.
serverError
(
"Error finding scene "
+
err
);
return
res
.
serverError
(
"Error finding scene "
+
err
);
});
});
},
/**
* Return all the scenes of a student
* @param {request} req {} (studentId)
* @param {response} res {}
*/
getScene
:
function
(
req
,
res
){
Scene
.
find
({
student
:
req
.
params
.
id_stu
})
.
populate
(
'stuPictos'
).
then
(
function
(
scenes
){
if
(
!
scenes
)
return
res
.
badRequest
();
else
return
res
.
ok
(
scenes
);
}).
catch
(
function
(
err
){
return
res
.
serverError
(
"Error retrieving scenes "
+
err
);
});
}
}
};
};
sails/src/api/controllers/StudentController.js
View file @
1849ee61
...
@@ -824,20 +824,19 @@ module.exports = {
...
@@ -824,20 +824,19 @@ module.exports = {
* @param {response} res {}
* @param {response} res {}
*/
*/
getActiveScene
:
function
(
req
,
res
){
getActiveScene
:
function
(
req
,
res
){
Scene
.
findOne
({
student
:
req
.
params
.
id_stu
,
active
:
true
})
if
(
typeof
req
.
params
.
id_stu
==
'undefined'
||
!
req
.
params
.
id_stu
)
.
populate
(
'stuPictos'
).
then
(
function
(
scene
){
return
res
.
badRequest
(
"id_stu not defined"
);
Scene
.
findOne
({
student
:
req
.
params
.
id_stu
,
active
:
true
})
.
populate
(
'stuPictos'
)
.
then
(
function
(
scene
){
if
(
!
scene
)
if
(
!
scene
)
return
res
.
badRequest
();
return
res
.
badRequest
(
"Scene not found"
);
else
else
console
.
log
(
scene
);
Scene
.
pictos
(
scene
.
id
,
function
(
err
,
pictos
){
Scene
.
pictos
(
scene
.
id
,
function
(
err
,
pictos
){
if
(
err
){
if
(
err
){
return
res
.
serverError
(
"Error obtaining pictos: "
+
err
);
return
res
.
serverError
(
"Error obtaining pictos: "
+
err
);
}
}
scene
.
pictos
=
pictos
;
scene
.
pictos
=
pictos
;
console
.
log
(
scene
);
return
res
.
ok
(
scene
);
return
res
.
ok
(
scene
);
});
});
}).
catch
(
function
(
err
){
}).
catch
(
function
(
err
){
...
@@ -845,6 +844,25 @@ module.exports = {
...
@@ -845,6 +844,25 @@ module.exports = {
});
});
},
},
/**
* Return all scenes of a student
* @param {request} req {} (with studentId as url parameter)
* @param {response} res {}
*/
getScenes
:
function
(
req
,
res
){
if
(
typeof
req
.
params
.
id_stu
==
'undefined'
||
!
req
.
params
.
id_stu
)
return
res
.
badRequest
(
"id_stu not defined"
);
Scene
.
find
({
student
:
req
.
params
.
id_stu
})
.
then
(
function
(
scenes
){
if
(
!
scenes
)
return
res
.
badRequest
(
"No scenes found"
);
else
return
res
.
ok
(
scenes
);
}).
catch
(
function
(
err
){
return
res
.
serverError
(
"Error finding scene "
+
err
);
});
},
//
//
// Returns all working sessions for the given student
// Returns all working sessions for the given student
//
//
...
@@ -943,6 +961,7 @@ module.exports = {
...
@@ -943,6 +961,7 @@ module.exports = {
StuPicto
.
create
({
StuPicto
.
create
({
student
:
student
.
id
,
student
:
student
.
id
,
picto
:
picto
.
id
,
picto
:
picto
.
id
,
scene
:
params
.
id_scene
,
attributes
:
params
.
attributes
attributes
:
params
.
attributes
})
})
,
,
...
...
sails/src/api/hooks/events.js
View file @
1849ee61
...
@@ -134,7 +134,7 @@ module.exports = function eventsHook(sails) {
...
@@ -134,7 +134,7 @@ module.exports = function eventsHook(sails) {
},
},
/**
/**
* Vocabulary is updated
* Vocabulary is updated
(active scene)
* @param {action} type of the action
* @param {action} type of the action
* @param {attributes} attributes of the action (id_stu, stu_picto)
* @param {attributes} attributes of the action (id_stu, stu_picto)
* @return {Object} {name, data}
* @return {Object} {name, data}
...
...
sails/src/api/models/Scene.js
View file @
1849ee61
...
@@ -31,21 +31,21 @@ module.exports = {
...
@@ -31,21 +31,21 @@ module.exports = {
categories
:
{
categories
:
{
type
:
"boolean"
type
:
"boolean"
},
},
supervisor
:
{
//FK de supervisor 1 a N
N
supervisor
:
{
//FK de supervisor 1 a N
columnName
:
"id_sup"
,
columnName
:
"id_sup"
,
required
:
tru
e
,
required
:
fals
e
,
type
:
"integer"
,
type
:
"integer"
,
model
:
"
S
upervisor"
model
:
"
s
upervisor"
},
},
student
:
{
// FK de student 1 a N
student
:
{
// FK de student 1 a N
columnName
:
"id_stu"
,
columnName
:
"id_stu"
,
required
:
true
,
required
:
true
,
type
:
"integer"
,
type
:
"integer"
,
model
:
"
S
tudent"
model
:
"
s
tudent"
},
},
// Relacion con Stu_picto
// Relacion con Stu_picto
stuPictos
:{
stuPictos
:{
collection
:
"
StuP
icto"
,
collection
:
"
stup
icto"
,
via
:
"scene"
via
:
"scene"
}
}
},
},
...
@@ -67,8 +67,6 @@ module.exports = {
...
@@ -67,8 +67,6 @@ module.exports = {
.
then
((
stuPictos
)
=>
{
.
then
((
stuPictos
)
=>
{
if
(
!
stuPictos
||
stuPictos
.
length
==
0
)
if
(
!
stuPictos
||
stuPictos
.
length
==
0
)
return
[];
return
[];
console
.
log
(
stuPictos
);
return
stuPictos
;
return
stuPictos
;
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
...
@@ -86,7 +84,6 @@ module.exports = {
...
@@ -86,7 +84,6 @@ module.exports = {
return
[
scene
,
stuPictos
,
student
];
return
[
scene
,
stuPictos
,
student
];
})
})
.
spread
((
scene
,
stuPictos
,
student
)
=>
{
.
spread
((
scene
,
stuPictos
,
student
)
=>
{
console
.
log
(
stuPictos
);
async
.
eachSeries
(
stuPictos
,
function
(
stuPicto
,
next_cb
)
{
async
.
eachSeries
(
stuPictos
,
function
(
stuPicto
,
next_cb
)
{
// Populate expressions to get it with the picto
// Populate expressions to get it with the picto
...
@@ -127,6 +124,6 @@ module.exports = {
...
@@ -127,6 +124,6 @@ module.exports = {
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
callback
(
err
,
l
);
callback
(
err
,
l
);
});
// end S
tudent
.findOne
});
// end S
cene
.findOne
}
}
};
};
sails/src/api/models/StuPicto.js
View file @
1849ee61
...
@@ -32,8 +32,8 @@ module.exports = {
...
@@ -32,8 +32,8 @@ module.exports = {
type
:
'integer'
,
type
:
'integer'
,
model
:
'Picto'
model
:
'Picto'
},
},
scene
:{
//FK de Scene 1 a N
scene
:
{
//FK de Scene 1 a N
columName
:
"id_scene"
,
colum
n
Name
:
"id_scene"
,
type
:
"integer"
,
type
:
"integer"
,
model
:
"Scene"
model
:
"Scene"
},
},
...
...
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
1849ee61
...
@@ -47,6 +47,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -47,6 +47,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
studentPictos
=
{};
$scope
.
studentPictos
=
{};
$scope
.
freeCategoryPictos
=
null
;
$scope
.
freeCategoryPictos
=
null
;
$scope
.
loadingPictos
=
true
;
$scope
.
loadingPictos
=
true
;
$scope
.
viewingScene
=
null
;
$scope
.
isCategory
=
function
(
studentPicto
)
{
$scope
.
isCategory
=
function
(
studentPicto
)
{
return
studentPicto
.
attributes
.
id_cat
===
null
&&
return
studentPicto
.
attributes
.
id_cat
===
null
&&
...
@@ -127,10 +128,12 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -127,10 +128,12 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
$scope
.
studentPictos
[
$scope
.
getCategoryId
(
$scope
.
selectedCategory
)]
||
generateGrid
();
// Get user's pictos
// Get user's pictos
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/
pictos
'
)
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/
activeScene
'
)
.
success
(
function
(
studentPictos
)
{
.
success
(
function
(
activeScene
)
{
$scope
.
showFreeCategory
=
!
$scope
.
studentData
.
attributes
.
categories
;
$scope
.
showFreeCategory
=
!
$scope
.
studentData
.
attributes
.
categories
;
studentPictos
.
forEach
(
placePicto
);
$scope
.
viewingScene
=
activeScene
.
id
;
activeScene
.
pictos
.
forEach
(
placePicto
);
//studentPictos.forEach(placePicto);
$scope
.
loadingPictos
=
false
;
$scope
.
loadingPictos
=
false
;
setTimeout
(
function
()
{
$scope
.
$apply
();
});
setTimeout
(
function
()
{
$scope
.
$apply
();
});
...
@@ -384,7 +387,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
...
@@ -384,7 +387,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
status
:
'enabled'
,
status
:
'enabled'
,
free_category_coord_x
:
$scope
.
showFreeCategory
?
col
:
null
,
free_category_coord_x
:
$scope
.
showFreeCategory
?
col
:
null
,
free_category_coord_y
:
$scope
.
showFreeCategory
?
row
:
null
free_category_coord_y
:
$scope
.
showFreeCategory
?
row
:
null
}
},
id_scene
:
$scope
.
viewingScene
})
})
.
success
(
function
(
studentPicto
)
{
.
success
(
function
(
studentPicto
)
{
placePicto
(
studentPicto
);
placePicto
(
studentPicto
);
...
...
sails/src/config/routes.js
View file @
1849ee61
...
@@ -74,7 +74,6 @@ module.exports.routes = {
...
@@ -74,7 +74,6 @@ module.exports.routes = {
'DELETE /picto/:id_sup/tag/:id_tag'
:
'PictoController.del_tag'
,
'DELETE /picto/:id_sup/tag/:id_tag'
:
'PictoController.del_tag'
,
'GET /scene/:id'
:
'SceneController.getScene'
,
'GET /scene/:id'
:
'SceneController.getScene'
,
'GET /stu/:id_stu/scenes'
:
'SceneController.getStudentScenes'
,
'POST /scene/:id'
:
'SceneController.create'
,
'POST /scene/:id'
:
'SceneController.create'
,
'PUT /scene/:id'
:
'SceneController.update'
,
'PUT /scene/:id'
:
'SceneController.update'
,
'DELETE /scene/:id'
:
'SceneController.destroy'
,
'DELETE /scene/:id'
:
'SceneController.destroy'
,
...
@@ -89,6 +88,7 @@ module.exports.routes = {
...
@@ -89,6 +88,7 @@ module.exports.routes = {
'POST /stu/:id_stu/sup/:id_sup'
:
'StudentController.link_supervisor'
,
'POST /stu/:id_stu/sup/:id_sup'
:
'StudentController.link_supervisor'
,
'GET /stu/:id_stu/pictos'
:
'StudentController.pictos'
,
'GET /stu/:id_stu/pictos'
:
'StudentController.pictos'
,
'GET /stu/:id_stu/activeScene'
:
'StudentController.getActiveScene'
,
'GET /stu/:id_stu/activeScene'
:
'StudentController.getActiveScene'
,
'GET /stu/:id_stu/scenes'
:
'StudentController.getScenes'
,
'GET /stu/:id_stu/methods'
:
'StudentController.methods'
,
'GET /stu/:id_stu/methods'
:
'StudentController.methods'
,
'GET /stu/:id_stu/lasttries'
:
'StudentController.lasttries'
,
'GET /stu/:id_stu/lasttries'
:
'StudentController.lasttries'
,
...
...
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