refactorized rootScope.user

parent 882fab6a
...@@ -24,7 +24,7 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon ...@@ -24,7 +24,7 @@ var dashboardControllers = angular.module('dashboardControllers', ['dashboardCon
// //
// //
dashboardControllers.controller('MainCtrl', function MainCtrl( dashboardControllers.controller('MainCtrl', function MainCtrl(
$scope, $window, $location, $translate, $rootScope, $timeout) { $scope, $window, $location, $translate, $rootScope, $timeout<) {
$scope.user = $rootScope.user; $scope.user = $rootScope.user;
......
...@@ -8,8 +8,6 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl( ...@@ -8,8 +8,6 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl(
$scope, $window, $http, config, $translate, ngToast) { $scope, $window, $http, config, $translate, ngToast) {
// The parameter 'config' is injected from config.js (defined in dashboardConfig module) // The parameter 'config' is injected from config.js (defined in dashboardConfig module)
$scope.user = $rootScope.user;
// Don't show the message at the begining // Don't show the message at the begining
$scope.showmessagesupervisor = false; $scope.showmessagesupervisor = false;
$scope.new_numbers = []; $scope.new_numbers = [];
...@@ -22,7 +20,7 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl( ...@@ -22,7 +20,7 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl(
// Get all licenses for the user // Get all licenses for the user
$http $http
.get(config.backend + '/license/' + $scope.user.email) .get(config.backend + '/license/' + $rootScope.user.email)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
$scope.licenses = data; $scope.licenses = data;
}) })
......
...@@ -20,8 +20,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -20,8 +20,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$translate, $translate,
ngToast) { ngToast) {
$scope.user = $rootScope.user;
$scope.emptyStudentPicto = { $scope.emptyStudentPicto = {
id: null, id: null,
picto: { picto: {
...@@ -475,7 +473,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -475,7 +473,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
return $scope.studentData; return $scope.studentData;
}, },
supervisor: function () { supervisor: function () {
return $scope.user; return $rootScope.user;
}, },
onlyOwn: function () { onlyOwn: function () {
return false; return false;
...@@ -528,7 +526,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -528,7 +526,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
return $scope.studentData; return $scope.studentData;
}, },
supervisor: function () { supervisor: function () {
return $scope.user; return $rootScope.user;
}, },
onlyOwn: function () { onlyOwn: function () {
return false; return false;
...@@ -588,7 +586,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -588,7 +586,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
return studentPicto; return studentPicto;
}, },
sup: function () { sup: function () {
return $scope.user; return $rootScope.user;
}, },
stu: function () { stu: function () {
return $scope.studentData; return $scope.studentData;
...@@ -614,7 +612,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -614,7 +612,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
return studentPicto; return studentPicto;
}, },
sup: function () { sup: function () {
return $scope.user; return $rootScope.user;
}, },
stu: function () { stu: function () {
return $scope.studentData; return $scope.studentData;
...@@ -651,7 +649,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -651,7 +649,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$http.post(config.backend + '/scene/stu/' + $scope.studentData.id, { $http.post(config.backend + '/scene/stu/' + $scope.studentData.id, {
name: name, name: name,
id_sup: $scope.user.id, id_sup: $rootScope.user.id,
categories: $scope.newSceneCat, categories: $scope.newSceneCat,
id_stu: $scope.studentData.id id_stu: $scope.studentData.id
}) })
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl( dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl(
$rootScope, $scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) { $rootScope, $scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) {
$scope.user = $rootScope.user;
// 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 = 'instructions'; $scope.nav.tab = 'instructions';
...@@ -25,7 +23,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -25,7 +23,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Query to meta_methods to fill the select fill with precharged methods // Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods // and supervisor template methods
$http $http
.get(config.backend+'/method/template/' + $scope.user.id) .get(config.backend+'/method/template/' + $rootScope.user.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
data[i].disabled = data[i].lang != $translate.use(); data[i].disabled = data[i].lang != $translate.use();
...@@ -119,7 +117,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -119,7 +117,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$translate('confirmation').then(function(translation) { $translate('confirmation').then(function(translation) {
newconfirm(translation).then(function() { newconfirm(translation).then(function() {
if($scope.method_selected.supervisor == $scope.user.id){ if($scope.method_selected.supervisor == $rootScope.user.id){
$http $http
.delete(config.backend+'/method/template/' + $scope.method_selected.id) .delete(config.backend+'/method/template/' + $scope.method_selected.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
...@@ -167,13 +165,13 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -167,13 +165,13 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$scope.save_as_template = function(method){ $scope.save_as_template = function(method){
$http $http
.post(config.backend+'/method/save', { 'id_met': method.id, 'id_sup': $scope.user.id, 'lang': $scope.user.lang }) .post(config.backend+'/method/save', { 'id_met': method.id, 'id_sup': $rootScope.user.id, 'lang': $rootScope.user.lang })
.then( //success .then( //success
function(data, status, headers, config) { function(data, status, headers, config) {
//console.log('Saved method as template:' + JSON.stringify(data)); //console.log('Saved method as template:' + JSON.stringify(data));
// Add to select method // Add to select method
$scope.methods_available.push({ id: method.id, name: method.name, lang: $scope.user.lang}); $scope.methods_available.push({ id: method.id, name: method.name, lang: $rootScope.user.lang});
ngToast.success({ ngToast.success({
content: $translate.instant('method_saved', {method_name: method.name}), content: $translate.instant('method_saved', {method_name: method.name}),
......
...@@ -13,8 +13,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -13,8 +13,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$translate, $translate,
ngToast) { ngToast) {
$scope.user = $rootScope.user;
// 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 = 'session'; $scope.nav.tab = 'session';
...@@ -122,7 +120,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -122,7 +120,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.then( .then(
function(data, status, headers, config2) { function(data, status, headers, config2) {
$http // creamos un nuevo try $http // creamos un nuevo try
.post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date().toISOString() }) .post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $rootScope.user.id, begin:new Date().toISOString() })
.then( .then(
function(data, status, headers, config) { function(data, status, headers, config) {
$scope.load_tries(); $scope.load_tries();
...@@ -179,7 +177,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -179,7 +177,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$http $http
.post(config.backend+'/ws', { .post(config.backend+'/ws', {
"id_sup": $scope.user.id, "id_sup": $rootScope.user.id,
"id_stu": $scope.studentData.id, "id_stu": $scope.studentData.id,
"id_ins": $scope.selected.instruction.id "id_ins": $scope.selected.instruction.id
}) })
...@@ -243,7 +241,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -243,7 +241,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+'/action', { .post(config.backend+'/action', {
"type": "endsession", "type": "endsession",
"student": $scope.studentData.id, "student": $scope.studentData.id,
"supervisor": $scope.user.id, "supervisor": $rootScope.user.id,
}) })
.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
...@@ -286,7 +284,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -286,7 +284,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": $rootScope.user.id
}) })
.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
...@@ -313,7 +311,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -313,7 +311,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+'/action', { .post(config.backend+'/action', {
"type": "resumesession", "type": "resumesession",
"student": $scope.studentData.id, "student": $scope.studentData.id,
"supervisor": $scope.user.id, "supervisor": $rootScope.user.id,
}) })
.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
......
...@@ -3,7 +3,17 @@ ...@@ -3,7 +3,17 @@
//----------------------- //-----------------------
// Instructions Controller // Instructions Controller
//----------------------- //-----------------------
dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) { dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl(
$scope,
$rootScope,
$stateParams,
$http,
config,
$window,
$translate,
$modal,
ngToast,
newconfirm) {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// METHODS // METHODS
...@@ -20,7 +30,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s ...@@ -20,7 +30,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
// Query to meta_methods to fill the select fill with precharged methods // Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods // and supervisor template methods
$http $http
.get(config.backend+'/method/template/owned/' + $scope.user.id) .get(config.backend+'/method/template/owned/' + $rootScope.user.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
// Add to list // Add to list
$scope.methods = data; $scope.methods = data;
...@@ -38,8 +48,8 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s ...@@ -38,8 +48,8 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
var new_data = { var new_data = {
name: $translate.instant("new_method"), name: $translate.instant("new_method"),
id_sup: $scope.user.id, id_sup: $rootScope.user.id,
lang: $scope.user.lang, lang: $rootScope.user.lang,
}; };
$http $http
...@@ -101,7 +111,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s ...@@ -101,7 +111,7 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
method: method.id, method: method.id,
name: $translate.instant("new_instruction"), name: $translate.instant("new_instruction"),
objective: $translate.instant("new_objective"), objective: $translate.instant("new_objective"),
lang: $scope.user.lang lang: $rootScope.user.lang
}; };
$http $http
......
...@@ -18,13 +18,11 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -18,13 +18,11 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
config, config,
CONSTANTS) { CONSTANTS) {
$scope.user = $rootScope.user;
// Don't show the message at the begining // Don't show the message at the begining
$scope.showmessage = false; $scope.showmessage = false;
// Restore user values from sessionStorage // Restore user values from sessionStorage
$scope.formdata = JSON.parse(JSON.stringify($scope.user)); $scope.formdata = JSON.parse(JSON.stringify($rootScope.user));
$scope.changeImg = function () { $scope.changeImg = function () {
...@@ -55,15 +53,15 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -55,15 +53,15 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
data: { data: {
filename: name, filename: name,
folder: 'supervisors', folder: 'supervisors',
id: $scope.user.id, id: $rootScope.user.id,
file: Upload.dataUrltoBlob(dataUrl, name) file: Upload.dataUrltoBlob(dataUrl, name)
} }
}) })
.then( .then(
function (res) { function (res) {
$timeout(function () { $timeout(function () {
$scope.user.pic = '/upload/supervisorAvatar/' + res.data.file.name; $rootScope.user.pic = '/upload/supervisorAvatar/' + res.data.file.name;
$window.sessionStorage.user = JSON.stringify($scope.user); $window.sessionStorage.user = JSON.stringify($rootScope.user);
cb(); cb();
}); });
}, function (res) { }, function (res) {
...@@ -99,7 +97,7 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -99,7 +97,7 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
// Comprobation for new email // Comprobation for new email
// If no change, it is deleted from supervisor object // If no change, it is deleted from supervisor object
if (supervisor.email === $scope.user.email) { if (supervisor.email === $rootScope.user.email) {
delete supervisor.email; delete supervisor.email;
} }
...@@ -108,8 +106,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl( ...@@ -108,8 +106,8 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
$http.put(config.backend + '/sup/' + supervisor.id, supervisor) $http.put(config.backend + '/sup/' + supervisor.id, supervisor)
.success(function (data) { .success(function (data) {
$scope.user = JSON.parse(JSON.stringify(data)); $rootScope.user = JSON.parse(JSON.stringify(data));
$window.sessionStorage.user = JSON.stringify($scope.user); $window.sessionStorage.user = JSON.stringify($rootScope.user);
ngToast.success({ content: $translate.instant('data_saved') }); ngToast.success({ content: $translate.instant('data_saved') });
}) })
.error(function () { .error(function () {
......
...@@ -18,8 +18,6 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -18,8 +18,6 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
IOService, IOService,
CONSTANTS) { CONSTANTS) {
$scope.user = $rootScope.user;
// -------------------------------------------------------- // --------------------------------------------------------
// Create new account // Create new account
// -------------------------------------------------------- // --------------------------------------------------------
...@@ -72,7 +70,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -72,7 +70,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
current_method: 'no_method', current_method: 'no_method',
current_instruction: 'no_instruction', current_instruction: 'no_instruction',
license_number: null, license_number: null,
id_sup: $scope.user.id id_sup: $rootScope.user.id
}; };
$scope.slide.state ='accounts'; $scope.slide.state ='accounts';
...@@ -93,7 +91,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -93,7 +91,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$scope.addExisting = function () { $scope.addExisting = function () {
// Send link call to server // Send link call to server
$http.post(config.backend + '/stu/license/sup/' + $scope.user.id, {license: $scope.formdata.license_number}) $http.post(config.backend + '/stu/license/sup/' + $rootScope.user.id, {license: $scope.formdata.license_number})
.success(function (data) { .success(function (data) {
loadStudents(); loadStudents();
$scope.slide.rightTo('confirmation'); $scope.slide.rightTo('confirmation');
...@@ -158,7 +156,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -158,7 +156,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
function loadStudents() { function loadStudents() {
// Get list of supervisor's students // Get list of supervisor's students
$http.get(config.backend + '/sup/' + $scope.user.id + '/students') $http.get(config.backend + '/sup/' + $rootScope.user.id + '/students')
.success(function (data) { .success(function (data) {
$scope.students = data; $scope.students = data;
}) })
...@@ -172,7 +170,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -172,7 +170,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
*/ */
$scope.unlink_student = function (student) { $scope.unlink_student = function (student) {
if ($window.confirm($translate.instant('confirmation'))) { if ($window.confirm($translate.instant('confirmation'))) {
$http.delete(config.backend + '/stu/' + student.id + '/sup/' + $scope.user.id) $http.delete(config.backend + '/stu/' + student.id + '/sup/' + $rootScope.user.id)
.success(function () { .success(function () {
var i; var i;
for (i = 0; i < $scope.students.length; i++) { for (i = 0; i < $scope.students.length; i++) {
...@@ -202,7 +200,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl( ...@@ -202,7 +200,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
IOService.on('linkSupervisorToStudent', function (eventData) { IOService.on('linkSupervisorToStudent', function (eventData) {
eventData.sup_id = parseInt(eventData.sup_id, 10); eventData.sup_id = parseInt(eventData.sup_id, 10);
eventData.stu_id = parseInt(eventData.stu_id, 10); eventData.stu_id = parseInt(eventData.stu_id, 10);
if (eventData.sup_id === $scope.user.id) { if (eventData.sup_id === $rootScope.user.id) {
IOService.get('/stu/' + eventData.stu_id, function (studentData) { IOService.get('/stu/' + eventData.stu_id, function (studentData) {
var i; var i;
var studentAlreadyAdded = false; var studentAlreadyAdded = false;
......
...@@ -21,8 +21,6 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl( ...@@ -21,8 +21,6 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
if (!$window.sessionStorage.user) if (!$window.sessionStorage.user)
return $scope.logout(); return $scope.logout();
$scope.user = $rootScope.user;
// Link to setup // Link to setup
$scope.setup = function(){ $scope.setup = function(){
$location.path('/setup'); $location.path('/setup');
...@@ -32,7 +30,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl( ...@@ -32,7 +30,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
IOService.post('/sup/subscribe', { IOService.post('/sup/subscribe', {
action: 'subscribe', action: 'subscribe',
attributes: { attributes: {
id_sup: $scope.user.id, id_sup: $rootScope.user.id,
ui: 'PDB' ui: 'PDB'
} }
}); });
...@@ -51,7 +49,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl( ...@@ -51,7 +49,7 @@ dashboardControllers.controller('SupervisorCtrl', function SupervisorCtrl(
return null; return null;
}, },
supervisor: function () { supervisor: function () {
return $scope.user; return $rootScope.user;
}, },
onlyOwn: function () { onlyOwn: function () {
return true; return true;
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl( dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl(
$rootScope, $scope, $window, $http, config, $translate, ngToast) { $rootScope, $scope, $window, $http, config, $translate, ngToast) {
$scope.user = $rootScope.user;
$scope.inputs = { $scope.inputs = {
search_str: '', search_str: '',
email: '' email: ''
...@@ -17,7 +15,7 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl( ...@@ -17,7 +15,7 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl(
function loadSupervisors() { function loadSupervisors() {
$http $http
.get(config.backend+'/sup/' + $scope.user.id + '/supervisors') .get(config.backend+'/sup/' + $rootScope.user.id + '/supervisors')
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
$scope.supervisors_list = data; $scope.supervisors_list = data;
console.log($scope.supervisors_list); console.log($scope.supervisors_list);
...@@ -33,7 +31,7 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl( ...@@ -33,7 +31,7 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl(
*/ */
$scope.searchSup = function () { $scope.searchSup = function () {
if (!$scope.user.isOffice) { if (!$rootScope.user.isOffice) {
console.log("Forbidden action. You're not an office!"); console.log("Forbidden action. You're not an office!");
return; return;
} }
...@@ -63,13 +61,13 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl( ...@@ -63,13 +61,13 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl(
*/ */
$scope.confirmLink = function () { $scope.confirmLink = function () {
if (!$scope.user.isOffice) { if (!$rootScope.user.isOffice) {
console.log("Forbidden action. You're not an office!"); console.log("Forbidden action. You're not an office!");
return; return;
} }
$scope.showmessagesupfound = false; $scope.showmessagesupfound = false;
$http $http
.post(config.backend+'/sup/' + $scope.supToAdd.id + '/off/' + $scope.user.id) .post(config.backend+'/sup/' + $scope.supToAdd.id + '/off/' + $rootScope.user.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
loadSupervisors(); loadSupervisors();
ngToast.success($translate.instant('supervisor_added_notified')); ngToast.success($translate.instant('supervisor_added_notified'));
...@@ -90,13 +88,13 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl( ...@@ -90,13 +88,13 @@ dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl(
*/ */
$scope.unlinkSupervisor = function (id) { $scope.unlinkSupervisor = function (id) {
if (!$scope.user.isOffice) { if (!$rootScope.user.isOffice) {
console.log("Forbidden action. You're not an office!"); console.log("Forbidden action. You're not an office!");
return; return;
} }
$http $http
.delete(config.backend+'/sup/' + id + '/off/' + $scope.user.id) .delete(config.backend+'/sup/' + id + '/off/' + $rootScope.user.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
loadSupervisors(); loadSupervisors();
ngToast.success($translate.instant('supervisor_deleted')); ngToast.success($translate.instant('supervisor_deleted'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment