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
7ca5ab40
authored
May 12, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Issue
#208
, timestamps
parent
fee15f4f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
18 additions
and
20 deletions
sails/src/api/controllers/ActionController.js
sails/src/api/controllers/InstructionController.js
sails/src/api/controllers/TryController.js
sails/src/api/controllers/WorkingSessionController.js
sails/src/api/models/Action.js
sails/src/api/models/Try.js
sails/src/api/models/WorkingSession.js
sails/src/assets/scripts/modules/student/controllers/session.js
sails/src/api/controllers/ActionController.js
View file @
7ca5ab40
...
@@ -42,7 +42,6 @@ module.exports = {
...
@@ -42,7 +42,6 @@ module.exports = {
if
(
!
params
.
type
)
return
res
.
json
(
500
,
{
error
:
"No type of action defined"
});
if
(
!
params
.
type
)
return
res
.
json
(
500
,
{
error
:
"No type of action defined"
});
// Optional params
// Optional params
var
timestamp
=
params
.
timestamp
?
params
.
timestamp
:
null
;
var
sup
=
null
;
if
(
params
.
supervisor
)
sup
=
params
.
supervisor
;
var
sup
=
null
;
if
(
params
.
supervisor
)
sup
=
params
.
supervisor
;
var
_try
=
null
;
if
(
params
.
_try
)
_try
=
params
.
_try
;
var
_try
=
null
;
if
(
params
.
_try
)
_try
=
params
.
_try
;
var
description
=
null
;
if
(
params
.
description
)
description
=
params
.
description
;
var
description
=
null
;
if
(
params
.
description
)
description
=
params
.
description
;
...
@@ -52,7 +51,7 @@ module.exports = {
...
@@ -52,7 +51,7 @@ module.exports = {
// Create a generic Action. Return open (=current, new) try
// Create a generic Action. Return open (=current, new) try
Action
.
create
({
Action
.
create
({
"type"
:
params
.
type
,
"type"
:
params
.
type
,
"timestamp"
:
timestamp
,
"timestamp"
:
new
Date
().
toISOString
()
,
"supervisor"
:
sup
,
"supervisor"
:
sup
,
"student"
:
params
.
student
,
"student"
:
params
.
student
,
"_try"
:
_try
,
"_try"
:
_try
,
...
...
sails/src/api/controllers/InstructionController.js
View file @
7ca5ab40
...
@@ -40,7 +40,7 @@ module.exports = {
...
@@ -40,7 +40,7 @@ module.exports = {
name
:
req
.
param
(
'name'
),
name
:
req
.
param
(
'name'
),
objective
:
req
.
param
(
'objective'
),
objective
:
req
.
param
(
'objective'
),
status
:
req
.
param
(
'status'
),
status
:
req
.
param
(
'status'
),
begin
:
req
.
param
(
'begin'
),
begin
:
new
Date
().
toISOString
(
),
end
:
req
.
param
(
'end'
)
end
:
req
.
param
(
'end'
)
}).
then
(
function
(
instruction
)
{
}).
then
(
function
(
instruction
)
{
if
(
instruction
)
{
if
(
instruction
)
{
...
...
sails/src/api/controllers/TryController.js
View file @
7ca5ab40
...
@@ -7,11 +7,10 @@ module.exports = {
...
@@ -7,11 +7,10 @@ module.exports = {
var
params
=
req
.
allParams
();
var
params
=
req
.
allParams
();
if
(
!
params
.
ws
)
return
res
.
badRequest
(
"No workingSession defined"
);
if
(
!
params
.
ws
)
return
res
.
badRequest
(
"No workingSession defined"
);
if
(
!
params
.
begin
)
return
res
.
badRequest
(
"No begin defined"
);
Try
.
create
({
Try
.
create
({
"workingSession"
:
params
.
ws
,
"workingSession"
:
params
.
ws
,
"begin"
:
params
.
begin
"begin"
:
new
Date
().
toISOString
()
}).
exec
(
function
(
err
,
tr
){
}).
exec
(
function
(
err
,
tr
){
if
(
err
||
!
tr
){
if
(
err
||
!
tr
){
sails
.
log
.
debug
(
"Creating new Try: "
+
err
);
sails
.
log
.
debug
(
"Creating new Try: "
+
err
);
...
@@ -23,11 +22,15 @@ module.exports = {
...
@@ -23,11 +22,15 @@ module.exports = {
/**
/**
* Update a try
* Update a try
* Note that in order to update `end` field, value must be sent, the server
* will set the value acording to it's time. If no `end` is submited to this
* method, it wont be updated.
*/
*/
update
:
function
(
req
,
res
)
{
update
:
function
(
req
,
res
)
{
var
params
=
req
.
allParams
();
var
params
=
req
.
allParams
();
if
(
!
params
.
id
)
return
res
.
badRequest
(
"No try defined"
);
if
(
!
params
.
id
)
return
res
.
badRequest
(
"No try defined"
);
if
(
params
.
end
)
prams
.
end
=
new
Date
().
toISOString
();
Try
.
update
(
params
.
id
,
params
)
Try
.
update
(
params
.
id
,
params
)
.
then
(
function
(
t
)
{
.
then
(
function
(
t
)
{
...
...
sails/src/api/controllers/WorkingSessionController.js
View file @
7ca5ab40
...
@@ -19,7 +19,7 @@ module.exports = {
...
@@ -19,7 +19,7 @@ module.exports = {
if
(
!
req
.
params
.
id_ws
)
if
(
!
req
.
params
.
id_ws
)
res
.
badRequest
(
"No working session defined"
);
res
.
badRequest
(
"No working session defined"
);
var
ws_end
=
req
.
params
.
end
?
req
.
params
.
end
:
new
Date
().
toISOString
();
var
ws_end
=
new
Date
().
toISOString
();
WorkingSession
.
update
({
id
:
req
.
params
.
id_ws
},
{
end
:
ws_end
})
WorkingSession
.
update
({
id
:
req
.
params
.
id_ws
},
{
end
:
ws_end
})
.
then
(
function
(
t
)
{
.
then
(
function
(
t
)
{
res
.
ok
({
end
:
ws_end
});
res
.
ok
({
end
:
ws_end
});
...
@@ -48,7 +48,6 @@ module.exports = {
...
@@ -48,7 +48,6 @@ module.exports = {
id_sup: <supervisor ID>
id_sup: <supervisor ID>
id_stu: <student ID>
id_stu: <student ID>
id_ins: <instruction ID>
id_ins: <instruction ID>
begin: <begin timestamp in ISO format>
* }
* }
* @param {response} res
* @param {response} res
* {
* {
...
@@ -63,15 +62,14 @@ module.exports = {
...
@@ -63,15 +62,14 @@ module.exports = {
if
(
!
params
.
id_sup
)
res
.
badRequest
(
"No supervisor defined"
);
if
(
!
params
.
id_sup
)
res
.
badRequest
(
"No supervisor defined"
);
if
(
!
params
.
id_ins
)
res
.
badRequest
(
"No instruction defined"
);
if
(
!
params
.
id_ins
)
res
.
badRequest
(
"No instruction defined"
);
if
(
!
params
.
id_stu
)
res
.
badRequest
(
"No student defined"
);
if
(
!
params
.
id_stu
)
res
.
badRequest
(
"No student defined"
);
if
(
!
params
.
begin
)
res
.
badRequest
(
"No start timestamp defined"
);
if
(
!
params
.
desc
)
params
.
desc
=
""
;
if
(
!
params
.
desc
)
params
.
desc
=
""
;
var
data
=
{};
var
data
=
{};
data
.
supervisor
=
params
.
id_sup
;
data
.
supervisor
=
params
.
id_sup
;
data
.
instruction
=
params
.
id_ins
;
data
.
instruction
=
params
.
id_ins
;
data
.
description
=
params
.
desc
;
data
.
description
=
params
.
desc
;
sails
.
log
.
debug
(
"BEGIN "
+
params
.
begin
);
sails
.
log
.
debug
(
"BEGIN "
+
new
Date
().
toISOString
()
);
data
.
begin
=
params
.
begin
;
// data comes in ISO format
data
.
begin
=
new
Date
().
toISOString
()
;
// data comes in ISO format
StuOpenTry
.
findOne
({
or
:
[
// pending open try?
StuOpenTry
.
findOne
({
or
:
[
// pending open try?
{
id_sup
:
params
.
id_sup
},
{
id_sup
:
params
.
id_sup
},
...
@@ -161,7 +159,7 @@ module.exports = {
...
@@ -161,7 +159,7 @@ module.exports = {
// Create the EndSession Action
// Create the EndSession Action
Action
.
create
({
Action
.
create
({
"type"
:
"endsession"
,
"type"
:
"endsession"
,
"timestamp"
:
ws
[
0
].
end
.
toISOString
(),
"timestamp"
:
new
Date
()
.
toISOString
(),
"supervisor"
:
ws
[
0
].
supervisor
,
"supervisor"
:
ws
[
0
].
supervisor
,
"student"
:
params
.
id_stu
"student"
:
params
.
id_stu
}).
exec
(
function
(
err
,
action
){
}).
exec
(
function
(
err
,
action
){
...
...
sails/src/api/models/Action.js
View file @
7ca5ab40
...
@@ -40,7 +40,8 @@ module.exports = {
...
@@ -40,7 +40,8 @@ module.exports = {
]
]
},
},
timestamp
:
{
timestamp
:
{
type
:
"datetime"
type
:
"datetime"
,
defaultsTo
:
function
()
{
return
new
Date
();
}
},
},
supervisor
:
{
// FK de Supervisor. 1 a N
supervisor
:
{
// FK de Supervisor. 1 a N
columnName
:
"id_sup"
,
columnName
:
"id_sup"
,
...
...
sails/src/api/models/Try.js
View file @
7ca5ab40
...
@@ -29,7 +29,8 @@ module.exports = {
...
@@ -29,7 +29,8 @@ module.exports = {
via
:
'_try'
via
:
'_try'
},
},
begin
:
{
begin
:
{
type
:
"datetime"
type
:
"datetime"
,
defaultsTo
:
function
()
{
return
new
Date
();
}
},
},
end
:
{
end
:
{
type
:
"datetime"
type
:
"datetime"
...
...
sails/src/api/models/WorkingSession.js
View file @
7ca5ab40
...
@@ -34,7 +34,7 @@ module.exports = {
...
@@ -34,7 +34,7 @@ module.exports = {
},
},
begin
:
{
begin
:
{
type
:
"datetime"
,
type
:
"datetime"
,
defaultsTo
:
function
()
{
return
new
Date
();
}
defaultsTo
:
function
()
{
return
new
Date
()
.
toISOString
()
;
}
},
},
end
:
{
end
:
{
type
:
"datetime"
type
:
"datetime"
...
...
sails/src/assets/scripts/modules/student/controllers/session.js
View file @
7ca5ab40
...
@@ -178,8 +178,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -178,8 +178,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
post
(
config
.
backend
+
'/ws'
,
{
.
post
(
config
.
backend
+
'/ws'
,
{
"id_sup"
:
$scope
.
user
.
id
,
"id_sup"
:
$scope
.
user
.
id
,
"id_stu"
:
$scope
.
studentData
.
id
,
"id_stu"
:
$scope
.
studentData
.
id
,
"id_ins"
:
$scope
.
selected
.
instruction
.
id
,
"id_ins"
:
$scope
.
selected
.
instruction
.
id
"begin"
:
new
Date
().
toISOString
()
})
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Actual WS
// Actual WS
...
@@ -240,7 +239,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -240,7 +239,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
post
(
.
post
(
config
.
backend
+
'/ws/'
+
$scope
.
ws
.
id
+
'/close'
,
config
.
backend
+
'/ws/'
+
$scope
.
ws
.
id
+
'/close'
,
{
{
"end"
:
$scope
.
ws
.
end
.
toISOString
(),
"id_stu"
:
$scope
.
studentData
.
id
"id_stu"
:
$scope
.
studentData
.
id
}
}
)
)
...
@@ -272,8 +270,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -272,8 +270,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
post
(
config
.
backend
+
'/action'
,
{
.
post
(
config
.
backend
+
'/action'
,
{
"type"
:
"pausesession"
,
"type"
:
"pausesession"
,
"student"
:
$scope
.
studentData
.
id
,
"student"
:
$scope
.
studentData
.
id
,
"supervisor"
:
$scope
.
user
.
id
,
"supervisor"
:
$scope
.
user
.
id
"timestamp"
:
(
new
Date
()).
toISOString
()
})
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// adding pause action to the list of actions
// adding pause action to the list of actions
...
@@ -301,7 +298,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -301,7 +298,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
"type"
:
"resumesession"
,
"type"
:
"resumesession"
,
"student"
:
$scope
.
studentData
.
id
,
"student"
:
$scope
.
studentData
.
id
,
"supervisor"
:
$scope
.
user
.
id
,
"supervisor"
:
$scope
.
user
.
id
,
"timestamp"
:
(
new
Date
()).
toISOString
()
})
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Adding resume action to the list of actions
// Adding resume action to the list of actions
...
...
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