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
418be65a
authored
Jan 13, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Unificados datos a nivel de estudiante en lugar de a nivel de tab
parent
0235e981
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
121 additions
and
322 deletions
sails/src/assets/app/js/app.js
sails/src/assets/app/js/controllers/controllers.js
sails/src/assets/app/js/controllers/main.js
sails/src/assets/app/js/directives/directives.js
sails/src/assets/app/modules/student/controllers/collections.js
sails/src/assets/app/modules/student/controllers/instructions.js
sails/src/assets/app/modules/student/controllers/reports.js
sails/src/assets/app/modules/student/controllers/session.js
sails/src/assets/app/modules/student/controllers/setup.js
sails/src/assets/app/modules/student/controllers/student.js
sails/src/assets/app/js/app.js
View file @
418be65a
...
...
@@ -52,7 +52,22 @@ dashboardApp.config(function($translateProvider) {
//$translateProvider.determinePreferredLanguage();
});
/* Routes with ui-routes */
/*
* ui-routes is used to implement a PAC pattern so views and related controllers are
* hierarchically arranged.
*
* LoginCtrl
* - login.hmtl
* LoginSettingPasswodrCtrl
* - login_setting_password.html
* LoginAdminCtrl
* - login_admin.html
* SignInCtrl
* - signing.html
* SupervisorCtrl
* - supervisor.html
*/
dashboardApp
.
config
(
function
(
$stateProvider
,
$urlRouterProvider
)
{
...
...
@@ -105,6 +120,7 @@ dashboardApp.config(function($stateProvider, $urlRouterProvider) {
templateUrl
:
'modules/student/views/student.html'
,
parent
:
'supervisor'
,
controller
:
'StudentCtrl'
,
data
:
{
studentData1
:
"tomate"
},
abstract
:
true
,
})
.
state
(
'student_collections'
,
{
...
...
sails/src/assets/app/js/controllers/controllers.js
View file @
418be65a
...
...
@@ -2,42 +2,3 @@
/* Controllers */
/*
Pictogram follows a Hierarchical MVC pattern (the old PAC pattern)
We have a main controller (see main.js) and then others that are associated to
different headers (by means of AngularJS directives)
Here we are just defining those directives
*/
var
dashboardControllers
=
angular
.
module
(
'dashboardControllers'
,
[
'dashboardConfig'
]);
// Header Supervisor
dashboardControllers
.
directive
(
'headerSupervisor'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/supervisor/views/header.html'
};
});
// Header Student
dashboardControllers
.
directive
(
'headerStudent'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/student/views/header.html'
};
});
// Header Admin
dashboardControllers
.
directive
(
'headerAdmin'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/admin/views/header.html'
};
});
// Translation footer
dashboardControllers
.
directive
(
'footerTranslate'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/translate/views/footer_translate.html'
};
});
\ No newline at end of file
sails/src/assets/app/js/controllers/main.js
View file @
418be65a
...
...
@@ -15,6 +15,11 @@ String.prototype.hashCode = function() {
//------------------
// Main Controller
//------------------
// Creamos el módulo dashboardControllers, de donde colgarán todos los controladores
var
dashboardControllers
=
angular
.
module
(
'dashboardControllers'
,
[
'dashboardConfig'
]);
// Creamos el controlador principal
dashboardControllers
.
controller
(
'MainCtrl'
,
function
MainCtrl
(
$scope
,
$window
,
$location
,
$translate
)
{
// Always use objects if we want to modify this scope in the childs
...
...
sails/src/assets/app/js/directives/directives.js
View file @
418be65a
'use strict'
;
var
dashboardDirectives
=
angular
.
module
(
'dashboardDirectives'
,
[]);
var
dashboardDirectives
=
angular
.
module
(
'dashboardDirectives'
,
[
'dashboardConfig'
]);
/*-------------------------------------------------------------------------------
Pictogram follows a Hierarchical MVC pattern (the old PAC pattern)
We have a main controller (see main.js) and then others that are associated to
different headers (by means of AngularJS directives)
Here we are just defining those directives
*/
// Header Supervisor
dashboardDirectives
.
directive
(
'headerSupervisor'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/supervisor/views/header.html'
};
});
// Header Student
dashboardDirectives
.
directive
(
'headerStudent'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/student/views/header.html'
};
});
// Header Admin
dashboardDirectives
.
directive
(
'headerAdmin'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/admin/views/header.html'
};
});
// Translation footer
dashboardDirectives
.
directive
(
'footerTranslate'
,
function
(){
return
{
restrict
:
'E'
,
templateUrl
:
'modules/translate/views/footer_translate.html'
};
});
/*-------------------------------------------------------------------------------
*
* Mouse event related directives
*
*/
dashboardDirectives
.
directive
(
'draggable'
,
function
()
{
return
function
(
scope
,
element
)
{
// this gives us the native JS object
...
...
sails/src/assets/app/modules/student/controllers/collections.js
View file @
418be65a
...
...
@@ -3,60 +3,11 @@
//-----------------------
// Student Collections Controller
//-----------------------
dashboardControllers
.
controller
(
'StudentCollectionsCtrl'
,
function
StudentCollectionsCtrl
(
$scope
,
$rootScope
,
$stateParams
,
$
http
,
config
,
$window
,
$filter
,
$modal
,
lodash
)
{
dashboardControllers
.
controller
(
'StudentCollectionsCtrl'
,
function
StudentCollectionsCtrl
(
$scope
,
$rootScope
,
$stateParams
,
$
state
,
$http
,
config
,
$window
,
$filter
,
$modal
,
lodash
)
{
// For tab navigation (here too, if the user refresh the page...)
// For tab navigation (here too, if the user refresh the page...)
$scope
.
nav
.
tab
=
'collections'
;
// List of all student pictos
$scope
.
studentPictos
=
[];
// List of categories pictos
$scope
.
pictosCategory
=
[];
// List of pictos from a catgory
$scope
.
pictosFromCategory
=
[];
// The view of pictos: All | Categories
$scope
.
pictos
=
{
category
:
null
,
idCat
:
null
};
// Initialization of PCB (the tablet view) and PCB-Categories
var
rows
=
5
,
cols
=
10
;
$scope
.
pcb
=
new
Array
();
$scope
.
pcb_cat
=
new
Array
();
// Set te empty elements
for
(
var
i
=
0
;
i
<
rows
;
i
++
)
{
$scope
.
pcb
[
i
]
=
new
Array
();
$scope
.
pcb_cat
[
i
]
=
new
Array
();
for
(
var
j
=
0
;
j
<
cols
;
j
++
)
{
// Default value
$scope
.
pcb
[
i
][
j
]
=
{
'picto'
:
{
'uri'
:
'/app/img/empty.gif'
},
'attributes'
:
{
'coord_x'
:
i
,
'coord_y'
:
j
}};
$scope
.
pcb_cat
[
i
][
j
]
=
{
'picto'
:
{
'uri'
:
'/app/img/empty.gif'
},
'attributes'
:
{
'coord_x'
:
i
,
'coord_y'
:
j
}};
}
}
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/pictos'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
studentPictos
=
data
;
//console.log(JSON.stringify($scope.studentPictos));
console
.
log
(
"Student pictos listed"
);
// Filtered only the categories pictos
$scope
.
pictosCategory
=
$filter
(
'filter'
)(
$scope
.
studentPictos
,
{
attributes
:
{
id_cat
:
null
}});
console
.
log
(
"Pictos Categories: "
+
JSON
.
stringify
(
$scope
.
pictosCategory
));
// Build the pcb_cat with the coords of the pictos
for
(
var
i
=
0
;
i
<
$scope
.
pictosCategory
.
length
;
i
++
)
{
var
pic
=
$scope
.
pictosCategory
[
i
];
$scope
.
pcb_cat
[
pic
.
attributes
.
coord_x
][
pic
.
attributes
.
coord_y
]
=
pic
;
console
.
log
(
"Pic "
+
pic
.
id
+
": "
+
pic
.
attributes
.
color
);
}
//console.log(JSON.stringify($scope.pcb_cat));
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// Reload student pictos (back from addpicto)
$scope
.
reload_pictos
=
function
(){
$http
...
...
sails/src/assets/app/modules/student/controllers/instructions.js
View file @
418be65a
...
...
@@ -8,49 +8,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// For tab navigation (here too, if the user refresh the page...)
$scope
.
nav
.
tab
=
'instructions'
;
// If it is the first time in a student section, it is not
// charged the student info in the user object at parent scope
if
(
!
$scope
.
studentUser
.
id
){
$scope
.
studentUser
.
id
=
$stateParams
.
idStudent
;
}
//
// Array with methods available in meta_methods
//
$scope
.
methods_available
=
[];
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.
get
(
config
.
backend
+
'/metamethods/'
+
$scope
.
user
.
id
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
methods_available
=
data
;
console
.
log
(
"Meta Methods charged:"
);
console
.
log
(
JSON
.
stringify
(
$scope
.
methods_available
));
// Option to add new methods
$scope
.
methods_available
.
push
({
id
:
0
,
name
:
"Nuevo método"
});
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
//
// Array with student methods (with instructions)
//
$scope
.
methods
=
[];
// Query to obtain an array of student methods
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/methods'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
methods
=
data
;
console
.
log
(
JSON
.
stringify
(
$scope
.
methods
));
console
.
log
(
"Methods recovered"
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
//
// Get last method/instruction for this student
...
...
@@ -75,7 +33,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.
post
(
config
.
backend
+
'/method/new'
,
{
'id_stu'
:
$scope
.
student
User
.
id
,
'id_stu'
:
$scope
.
student
Data
.
id
,
'name'
:
"Nuevo método (cambiar nombre)"
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
...
...
@@ -93,7 +51,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.
post
(
config
.
backend
+
'/method'
,
{
'id_mmethod'
:
$scope
.
method_selected
.
id
,
'id_stu'
:
$scope
.
student
User
.
id
'id_stu'
:
$scope
.
student
Data
.
id
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
'Created Method and Instructions'
);
...
...
@@ -102,7 +60,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
$scope
.
method_selected
.
id
+
" "
+
$scope
.
student
User
.
id
);
console
.
log
(
$scope
.
method_selected
.
id
+
" "
+
$scope
.
student
Data
.
id
);
});
}
};
...
...
sails/src/assets/app/modules/student/controllers/reports.js
View file @
418be65a
...
...
@@ -10,8 +10,8 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// It it is the first time in a student section, there is not
// charged the student info in the user object at parent scope
if
(
!
$scope
.
student
User
.
id
){
$scope
.
student
User
.
id
=
$stateParams
.
idStudent
;
if
(
!
$scope
.
student
Data
.
id
){
$scope
.
student
Data
.
id
=
$stateParams
.
idStudent
;
}
// Date vars
...
...
@@ -36,7 +36,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// Get all the working sessions of the student
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/ws'
)
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/ws'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
$scope
.
ws
=
data
;
// Call function to build the charts and statistics
...
...
@@ -221,7 +221,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
//
// Initializing array of methods
$scope
.
m
ethods
=
[];
$scope
.
reportsM
ethods
=
[];
// Statistics vars
$scope
.
instructions_total
=
0
;
...
...
@@ -230,7 +230,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// Get all the tries of the student
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/tries'
)
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/tries'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Call function to build the charts and statistics
// Loop methods
...
...
@@ -321,9 +321,9 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
}
// End of looping methods
$scope
.
m
ethods
=
data
;
$scope
.
selectedMethod
=
$scope
.
m
ethods
[
0
];
// The default method is the first of the array
$scope
.
selectedIns
=
$scope
.
m
ethods
[
0
].
instructions
[
0
];
// And the first instruction
$scope
.
reportsM
ethods
=
data
;
$scope
.
selectedMethod
=
$scope
.
reportsM
ethods
[
0
];
// The default method is the first of the array
$scope
.
selectedIns
=
$scope
.
reportsM
ethods
[
0
].
instructions
[
0
];
// And the first instruction
// Charts of selectedMethod
$scope
.
instructions_charts
();
...
...
sails/src/assets/app/modules/student/controllers/session.js
View file @
418be65a
...
...
@@ -4,68 +4,12 @@
// Student Session Controller
//-----------------------
dashboardControllers
.
controller
(
'StudentSessionCtrl'
,
function
StudentSessionCtrl
(
$rootScope
,
$scope
,
$stateParams
,
$http
,
config
,
$window
)
{
console
.
log
(
"dashboardControllers reload:"
+
$scope
.
$id
);
console
.
log
(
"dashboardControllers reload:"
+
$scope
.
$id
);
// For tab navigation (here too, if the user refresh the page...)
$scope
.
nav
.
tab
=
'session'
;
// It it is the first time in a student section, there is not
// charged the student info in the user object at parent scope
if
(
!
$scope
.
studentUser
.
id
){
$scope
.
studentUser
.
id
=
$stateParams
.
idStudent
;
}
// Actual WS
if
(
!
$rootScope
.
ws
){
$rootScope
.
ws
=
{};
}
if
(
!
$rootScope
.
actual_try
){
$rootScope
.
actual_try
=
{};
}
////////////////////////////////////////////////////////////////////////////
// Devices /////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/*
// For mark in list the actual device (Received from PCB via websocket)
$scope.active_device = null;
// 1) Leer los dispositivos del alumno y mostrar en listado
// Array with student's devices
$scope.devices = [];
// Query to obtain an array of student devices
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/devices')
.success(function(data, status, headers, config) {
// Add to list
$scope.devices = data;
console.log(JSON.stringify($scope.devices));
console.log("Devices recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
*/
////////////////////////////////////////////////////////////////////////////
// Methods and Instructions ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// 2) Leer los métodos del alumno con sus instrucciones
// Array with student methods (with instructions)
$scope
.
methods
=
[];
// Query to obtain an array of student methods
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/methods'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
methods
=
data
;
console
.
log
(
JSON
.
stringify
(
$scope
.
methods
));
console
.
log
(
"Methods recovered"
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// VER SI BORRAR --> SÓLO NECESARIO PARA DEJAR EN BLANCO LOS ENSAYOS CARGADOS
// Cargar instrucciones en select del método seleccionado arriba
$scope
.
load_instructions
=
function
(
method
){
...
...
@@ -84,33 +28,6 @@ console.log("dashboardControllers reload:"+$scope.$id);
// Tries ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Read the last working session to show the last tries when session tab is opened
$rootScope
.
wsessions
=
[];
// Query to obtain an array of only one working session (the last) with its tries/actions
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/lasttries'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$rootScope
.
wsessions
=
data
;
console
.
log
(
JSON
.
stringify
(
$rootScope
.
wsessions
));
console
.
log
(
"Tries of last working session recovered"
);
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
5
;
$scope
.
totalPages
=
Math
.
ceil
(
$rootScope
.
wsessions
.
length
/
$scope
.
numPerPage
);
$scope
.
ws_recover
=
$rootScope
.
wsessions
[
0
]
!=
null
&&
$rootScope
.
wsessions
[
0
].
end
==
null
;
console
.
log
(
"tries: "
+
$rootScope
.
wsessions
.
length
);
console
.
log
(
"numPerPage: "
+
$scope
.
numPerPage
);
console
.
log
(
"pages: "
+
$scope
.
totalPages
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// Initially, show the last try
$scope
.
showLastTry
=
true
;
// When clicking over an instruction in the select control
// load its working sessions with its associated tries and with its actions
$scope
.
load_tries
=
function
(
instruction
){
...
...
@@ -138,8 +55,7 @@ console.log("dashboardControllers reload:"+$scope.$id);
});
}
};
};
// Tries pagination - previous tries
$scope
.
before
=
function
(){
...
...
@@ -274,21 +190,22 @@ console.log("dashboardControllers reload:"+$scope.$id);
});
};
//
//
// update the description of a given working session
//
$scope
.
update_ws
=
function
(
ws
){
console
.
log
(
"WS description - updating: "
+
ws
.
id
+
":"
+
ws
.
description
);
$http
.
put
(
config
.
backend
+
'/workingsession/'
+
ws
.
id
,
{
"description"
:
ws
.
description
})
.
then
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"WS description - updated: "
+
ws
.
description
);
console
.
log
(
"WS description - updating: "
+
ws
.
id
+
":"
+
ws
.
description
);
$http
.
put
(
config
.
backend
+
'/workingsession/'
+
ws
.
id
,
{
"description"
:
ws
.
description
})
.
then
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"WS description - updated: "
+
ws
.
description
);
})
,
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
};
}
})
,
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
};
}
//
// Finish a working session updating its end time
//
...
...
@@ -399,8 +316,6 @@ console.log("dashboardControllers reload:"+$scope.$id);
////////////////////////////////////////////////////////////////////////////
// Timer Control - Show the time counter in view ///////////////////////////
////////////////////////////////////////////////////////////////////////////
$scope
.
paused
=
false
;
$scope
.
startTimer
=
function
(){
$scope
.
$broadcast
(
'timer-start'
);
...
...
sails/src/assets/app/modules/student/controllers/setup.js
View file @
418be65a
...
...
@@ -19,14 +19,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// Get the file extension
var
extension
=
file
.
name
.
split
(
'.'
).
pop
();
var
filename
=
$scope
.
student
User
.
id
+
file
.
name
;
var
filename
=
$scope
.
student
Data
.
id
+
file
.
name
;
console
.
log
(
"Archivo: "
+
filename
);
$upload
.
upload
({
url
:
'/stu/upload'
,
//upload.php script, node.js route, or servlet url
method
:
'POST'
,
// or 'PUT',
// Fields to sent in the body of the request
fields
:
{
'filename'
:
filename
,
'extension'
:
extension
,
'folder'
:
'students'
,
'id'
:
$scope
.
student
User
.
id
},
fields
:
{
'filename'
:
filename
,
'extension'
:
extension
,
'folder'
:
'students'
,
'id'
:
$scope
.
student
Data
.
id
},
// or ['1.jpg', '2.jpg', ...] // to modify the name of the file(s)
file
:
file
,
// or list of files ($files) for html5 only
}).
progress
(
function
(
evt
)
{
...
...
@@ -35,7 +35,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// file is uploaded successfully
console
.
log
(
JSON
.
stringify
(
data
.
file
));
// Assign the new image with new name
$scope
.
student
User
.
pic
=
"/upload/students/"
+
data
.
file
.
name
;
$scope
.
student
Data
.
pic
=
"/upload/students/"
+
data
.
file
.
name
;
//$scope.picture = user.id + "." + extension + "?t=" + new Date().getTime();
});
}
else
{
...
...
@@ -73,20 +73,20 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
}
$http
.
put
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
,
$scope
.
formUser
)
.
put
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
,
$scope
.
formUser
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
$scope
.
showmessagestudent
=
true
;
$scope
.
alertstudent
=
"alert-success"
;
$scope
.
messagestudent
=
"student_updated"
;
// student
User
with new values
$scope
.
student
User
.
surname
=
data
.
surname
;
$scope
.
student
User
.
birthdate
=
data
.
birthdate
;
$scope
.
student
User
.
country
=
data
.
country
;
$scope
.
student
User
.
pic
=
data
.
pic
;
$scope
.
student
User
.
gender
=
data
.
gender
;
$scope
.
student
User
.
lang
=
data
.
lang
;
$scope
.
student
User
.
notes
=
data
.
notes
;
// student
Data
with new values
$scope
.
student
Data
.
surname
=
data
.
surname
;
$scope
.
student
Data
.
birthdate
=
data
.
birthdate
;
$scope
.
student
Data
.
country
=
data
.
country
;
$scope
.
student
Data
.
pic
=
data
.
pic
;
$scope
.
student
Data
.
gender
=
data
.
gender
;
$scope
.
student
Data
.
lang
=
data
.
lang
;
$scope
.
student
Data
.
notes
=
data
.
notes
;
console
.
log
(
"Student updated"
);
})
...
...
@@ -99,38 +99,6 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
});
};
// *******************************************************
// Therapists
// List of student's therapists
$scope
.
studentSupervisors
=
[];
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/therapists'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
studentSupervisors
=
data
;
console
.
log
(
JSON
.
stringify
(
$scope
.
studentSupervisors
));
console
.
log
(
"Supervisors listed"
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// List of student's tutors (parents)
$scope
.
studentTutors
=
[];
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/tutors'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
studentTutors
=
data
;
console
.
log
(
JSON
.
stringify
(
$scope
.
studentTutors
));
console
.
log
(
"Tutors listed"
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// Search supervisor by email
$scope
.
search_sup
=
function
(){
// Find tutor by email
...
...
@@ -164,12 +132,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// Add supervisor (father or mother)
$scope
.
add_sup
=
function
(){
var
stusup
=
{
student
:
$scope
.
student
User
.
id
,
student
:
$scope
.
student
Data
.
id
,
supervisor
:
$scope
.
supToAdd
.
id
}
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/sup/'
+
$scope
.
supToAdd
.
id
)
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/sup/'
+
$scope
.
supToAdd
.
id
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Assign the info of supervisor to add
stusup
.
supervisor
=
$scope
.
supToAdd
;
...
...
@@ -198,7 +166,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
var
deleteSup
=
$window
.
confirm
(
'Are you absolutely sure you want to delete?'
);
if
(
deleteSup
){
$http
.
delete
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/sup/'
+
id_sup
)
.
delete
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/sup/'
+
id_sup
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
...
...
@@ -251,12 +219,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// Add tutor
$scope
.
add_tutor
=
function
(){
var
stusup
=
{
student
:
$scope
.
student
User
.
id
,
student
:
$scope
.
student
Data
.
id
,
supervisor
:
$scope
.
tutorToAdd
.
id
}
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/sup/'
+
$scope
.
tutorToAdd
.
id
)
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/sup/'
+
$scope
.
tutorToAdd
.
id
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Assign the info of supervisor to add
stusup
.
supervisor
=
$scope
.
tutorToAdd
;
...
...
@@ -284,7 +252,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
var
deleteTutor
=
$window
.
confirm
(
'Are you absolutely sure you want to delete?'
);
if
(
deleteTutor
){
$http
.
delete
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/sup/'
+
id_sup
)
.
delete
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/sup/'
+
id_sup
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
...
...
@@ -304,30 +272,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
}
};
// *******************************************************
// Devices
// List of student's devices
$scope
.
studentDevices
=
[];
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentUser
.
id
+
'/devices'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
studentDevices
=
data
;
console
.
log
(
"Devices listed: "
);
console
.
log
(
JSON
.
stringify
(
$scope
.
studentDevices
));
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
$scope
.
delete_device
=
function
(
id_dev
){
var
deleteDevice
=
$window
.
confirm
(
'Are you absolutely sure you want to delete?'
);
if
(
deleteDevice
){
$http
.
delete
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
+
'/dev/'
+
id_dev
)
.
delete
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
+
'/dev/'
+
id_dev
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
...
...
@@ -349,7 +299,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
$scope
.
associate_dev
=
function
(){
var
stu_dev
=
{
"id_stu"
:
$scope
.
student
User
.
id
,
"id_stu"
:
$scope
.
student
Data
.
id
,
"id_dev_firm"
:
$scope
.
device_id_firmware
}
...
...
@@ -379,7 +329,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// *******************************************************
// Devices Setup
// $scope.student
User
.attributes
// $scope.student
Data
.attributes
// Update options attributes
//
$scope
.
update_attributes
=
function
(){
...
...
@@ -388,14 +338,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
$scope
.
messageattributes
=
"attributes_updating"
;
$http
.
put
(
config
.
backend
+
'/stu/'
+
$scope
.
student
User
.
id
,
{
'attributes'
:
JSON
.
stringify
(
$scope
.
studentUser
.
attributes
)})
.
put
(
config
.
backend
+
'/stu/'
+
$scope
.
student
Data
.
id
,
{
'attributes'
:
JSON
.
stringify
(
$scope
.
studentData
.
attributes
)})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
$scope
.
showmessageattributes
=
true
;
$scope
.
alertattributes
=
"alert-success"
;
$scope
.
messageattributes
=
"attributes_updated"
;
// student
User
with new values
$scope
.
student
User
.
attributes
=
data
.
attributes
;
// student
Data
with new values
$scope
.
student
Data
.
attributes
=
data
.
attributes
;
console
.
log
(
"Attributes updated"
);
})
...
...
sails/src/assets/app/modules/student/controllers/student.js
View file @
418be65a
This diff is collapsed.
Click to expand it.
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