Various fixes

This commit is contained in:
Reynaldo Reyes
2016-05-20 23:00:34 -04:00
parent b220f21065
commit 48e8b73111
55 changed files with 714 additions and 690 deletions

View File

@@ -15,8 +15,21 @@
.config(function($stateProvider, $urlRouterProvider) { .config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/'); $urlRouterProvider.otherwise('/');
$stateProvider $stateProvider
.state('index', {
abstract: true,
views: {
'sidebar': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
'navbar': {
templateUrl: 'partials/sidebar/navbar.html',
controller: 'NavbarCtrl',
controllerAs: 'vm'
},
}
})
.state('login', { .state('login', {
url: '/login', url: '/login',
views: { views: {
@@ -31,7 +44,6 @@
.run(function ($rootScope) { .run(function ($rootScope) {
$rootScope.domainUrl = 'Localhost:3000'; $rootScope.domainUrl = 'Localhost:3000';
$rootScope.professorId = '56f5fd3a20047f3c15b05f0e';
}); });
})(); })();

View File

@@ -55,6 +55,7 @@
<!-- ====================================================--> <!-- ====================================================-->
<script src="app.js"></script> <script src="app.js"></script>
<script src="partials/sidebar/sidebar.controllers.js"></script> <script src="partials/sidebar/sidebar.controllers.js"></script>
<script src="partials/sidebar/navbar.controllers.js"></script>
<script src="partials/course/course.module.js"></script> <script src="partials/course/course.module.js"></script>
<script src="partials/course/course_create.controller.js"></script> <script src="partials/course/course_create.controller.js"></script>
@@ -64,6 +65,7 @@
<script src="partials/login/login.module.js"></script> <script src="partials/login/login.module.js"></script>
<script src="partials/login/login.controllers.js"></script> <script src="partials/login/login.controllers.js"></script>
<script src="partials/login/login.services.js"></script> <script src="partials/login/login.services.js"></script>
<script src="partials/login/authentication.service.js"></script>
<script src="partials/professor/professor.module.js"></script> <script src="partials/professor/professor.module.js"></script>
<script src="partials/professor/professor_create.controller.js"></script> <script src="partials/professor/professor_create.controller.js"></script>

View File

@@ -15,43 +15,28 @@
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider']; getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){ function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/CourseList'); $urlRouterProvider.otherwise('/CourseList');
$stateProvider $stateProvider
.state('CourseList', { .state('CourseList', {
parent: 'index',
url: '/CourseList', url: '/CourseList',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/course/course_list.html', templateUrl: 'partials/course/course_list.html',
controller: 'CourseListCtrl', controller: 'CourseListCtrl',
controllerAs: "vm" controllerAs: "vm"
} }
} }
}) })
.state('CourseCreate', { .state('CourseCreate', {
parent:'index',
url: '/CourseCreate', url: '/CourseCreate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/course/course_create.html', templateUrl: 'partials/course/course_create.html',
controller: 'CourseCreateCtrl', controller: 'CourseCreateCtrl',
controllerAs: "vm" controllerAs: "vm"
} }
} }
}) })
}; };
})(); })();

View File

@@ -7,6 +7,13 @@
courses.$inject = ['$resource','$rootScope']; courses.$inject = ['$resource','$rootScope'];
function courses($resource, $rootScope){ function courses($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/professors/:id/courses', null); return $resource('http://'+$rootScope.domainUrl+'/professors/:id/courses', {}, {
get: {
method: 'GET',
headers: {
Authorization: 'Bearer '+ authentication.getToken()
}
}
});
}; };
})(); })();

View File

@@ -6,11 +6,12 @@
.controller('CourseCreateCtrl', CourseCreateCtrl) .controller('CourseCreateCtrl', CourseCreateCtrl)
CourseCreateCtrl.$inject = CourseCreateCtrl.$inject =
['$scope', '$rootScope', '$modal', '$state', 'professors']; ['$scope', '$modal', '$state', 'professors', 'authentication'];
function CourseCreateCtrl($scope, $rootScope, $modal, $state, professors) { function CourseCreateCtrl($scope, $modal, $state, professors, authentication) {
var vm = this; var vm = this;
$scope.mensaje = ""; $scope.mensaje = "";
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
professors.get({ id: professorid }, professors.get({ id: professorid },
function (successResult){ function (successResult){

View File

@@ -6,10 +6,11 @@
.controller('CourseListCtrl',CourseListCtrl) .controller('CourseListCtrl',CourseListCtrl)
CourseListCtrl.$inject = CourseListCtrl.$inject =
['$scope', '$rootScope', '$state', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse']; ['$scope', '$state', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse', 'authentication'];
function CourseListCtrl($scope, $rootScope, $state, professors, $modal, profesorSeleccionado, selectedCourse) { function CourseListCtrl($scope, $state, professors, $modal, profesorSeleccionado, selectedCourse, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
professors.get({ id: professorid }, professors.get({ id: professorid },
function (successResult){ function (successResult){

View File

@@ -8,28 +8,15 @@
<tr> <tr>
<th width="10%"> <th width="10%">
Código Código
<span ng-show="sortType == 'code' &&
!sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'code' &&
sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%"> <th width="20%">
Nombre Nombre
<span ng-show="sortType == 'name' &&
!sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'name' &&
sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="10%"> <th width="10%">
Creditos Creditos
<span ng-show="sortType == 'credits' &&
!sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'credits' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="40%" style="text-align: center"> <th width="40%" style="text-align: center">
Descripción Descripción
</th> </th>
<th width="10%" style="text-align: center"> <th width="10%" style="text-align: center">
Secciones Secciones
@@ -47,7 +34,7 @@
<td style="vertical-align:middle">{{ course.description }}</td> <td style="vertical-align:middle">{{ course.description }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span <span
title="Click aqui para ver Secciones" title="Haga click para listar las secciones de esta materia"
class="glyphicon glyphicon-list" class="glyphicon glyphicon-list"
aria-hidden="true" aria-hidden="true"
ng-click="vm.listarSecciones($index)" ng-click="vm.listarSecciones($index)"
@@ -55,7 +42,7 @@
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<span <span
title="Click aqui para Eliminar la Materia" title="Haga click para eliminar esta materia"
class="glyphicon glyphicon-remove" class="glyphicon glyphicon-remove"
aria-hidden="true" aria-hidden="true"
ng-click="vm.eliminarMateriaModal($index)" ng-click="vm.eliminarMateriaModal($index)"

View File

@@ -0,0 +1,65 @@
(function(){
'use strict';
angular
.module('app.login')
.service('authentication', authentication);
authentication.$inject = ['$http', '$window'];
function authentication ($http, $window) {
var saveToken = function (token) {
$window.localStorage['mean-token'] = token;
};
var getToken = function () {
return $window.localStorage['mean-token'];
};
var logout = function() {
$window.localStorage.removeItem('mean-token');
};
var isLoggedIn = function() {
var token = getToken();
var payload;
if(token){
payload = token.split('.')[1];
payload = $window.atob(payload);
payload = JSON.parse(payload);
return payload.exp > Date.now() / 1000;
} else {
return false;
}
};
var currentUser = function() {
if(isLoggedIn()){
var token = getToken();
var payload = token.split('.')[1];
payload = $window.atob(payload);
payload = JSON.parse(payload);
return {
_id: payload._id,
role: payload.role
};
}
};
var login = function(user) {
return $http.post('http://'+$rootScope.domainUrl+'/login', user).success(function(data) {
saveToken(data.token);
});
};
return {
saveToken : saveToken,
getToken : getToken,
logout : logout,
isLoggedIn : isLoggedIn,
currentUser : currentUser
};
}
})();

View File

@@ -5,69 +5,49 @@
.module('app.login') .module('app.login')
.controller('loginCtrl', loginCtrl) .controller('loginCtrl', loginCtrl)
loginCtrl.$inject = ['$rootScope', '$scope', '$state']; loginCtrl.$inject = ['$scope', '$state', 'login', 'authentication', '$modal'];
function loginCtrl($rootScope, $scope, $state){ function loginCtrl($scope, $state, login, authentication, $modal){
var vm = this; var vm = this;
vm.user; vm.credentials = {};
vm.submit = function() { vm.submit = function() {
if (vm.data_input_form.$valid){ if (vm.data_input_form.$valid){
vm.pkg = { var professor = {
"Nickname": vm.user.nickname, "id": vm.user.nickname,
"Password": vm.user.password "password": vm.user.password
}; };
/*$rootScope.mensaje = ""; login.save(professor,
$rootScope.bcancel = false; function(data){
authentication.saveToken(data.token);
var permission = authentication.currentUser();
if(permission.role=='admin'){
$state.go('ProfessorList');
};
if(permission.role=='professor'){
$state.go('CourseList');
};
},
function(data){
vm.message = 'Usuario/Clave incorrecto. Por favor intente de nuevo.'
vm.botonOk = true;
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled, templateUrl:
templateUrl: 'LoginModal.html', '/partials/login/modal/login_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm',
resolve: { resolve: {
items: function () { items: function () {
return $rootScope.items;
} }
} }
}); });
});
Login.save(vm.pkg,
function(data){
if(data.Data._value != null){
$rootScope.actOk = true;
$rootScope.urlLo = 'listarProfesor';
$rootScope.bcancel = false;
}else{
$rootScope.bcancel = true;
$rootScope.mensaje = data.Data._error;
}
},
function(data){
verificar = data.Data;
if(verificar){
alert("no existe el usuario");
}
})
GetRol.get({id:vm.user.Nickname},
function(data){
$rootScope.role = data.Data;
},
function(){
});*/
$state.go('CourseList');
} }
}; };
/*$rootScope.open = function($event) { $scope.ok = function () {
$event.preventDefault(); $state.reload();
$event.stopPropagation();
$rootScope.opened = true;
};*/
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel'); $scope.modalInstance.dismiss('cancel');
}; };

View File

@@ -21,7 +21,7 @@
</div> </div>
<div class="col-md-4 column"> <div class="col-md-4 column">
<label for="password">Contraseña</label> <label for="password">Contraseña</label>
<input type="password" class="form-control" id="password" name="password" ng-model="vm.user.password" maxlength="8" required/> <input type="password" class="form-control" id="password" name="password" ng-model="vm.user.password" required/>
<div ng-show=false> {{ vm.password = vm.user.Password }}</div> <div ng-show=false> {{ vm.password = vm.user.Password }}</div>
<div class="error" ng-show="vm.submitted && vm.data_input_form.password.$invalid"> <div class="error" ng-show="vm.submitted && vm.data_input_form.password.$invalid">
<small class="error" ng-show="vm.data_input_form.password.$error.required"> <small class="error" ng-show="vm.data_input_form.password.$error.required">

View File

@@ -3,47 +3,12 @@
angular angular
.module('app.login') .module('app.login')
.factory('Login', Login) .factory('login', login)
.factory('GetRol', GetRol)
.factory('hash', hash)
.value('algoritmo','SHA-1')
.value('user',{}) .value('user',{})
.value('id',{}) .value('id',{})
login.$inject = ['$resource','$rootScope'];
Login.$inject = ['$resource','$rootScope']; function login($resource, $rootScope){
function Login($resource, $rootScope){ return $resource('http://'+$rootScope.domainUrl+'/login');
return $resource('http://'+$rootScope.domainUrl+'/api/VerifyUser');
};
GetRol.$inject = ['$resource','$rootScope'];
function GetRol($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/api/User/:id');
};
hash.$inject = ['algoritmo'];
function hash(algoritmo){
var hashFunction;
if (algoritmo==="MD5") {
hashFunction=CryptoJS.MD5;
} else if (algoritmo==="SHA-1") {
hashFunction=CryptoJS.SHA1;
} else if (algoritmo==="SHA-2-256") {
hashFunction=CryptoJS.SHA256;
} else if (algoritmo==="SHA-2-512") {
hashFunction=CryptoJS.SHA512;
} else {
throw Error("El tipo de algoritmo no es válido:"+algoritmo);
}
var hash=function(message) {
var objHashResult=hashFunction(message);
var strHashResult=objHashResult.toString(CryptoJS.enc.Base64);
return strHashResult;
}
return hash;
}; };
})(); })();

View File

@@ -0,0 +1,10 @@
<div class="modal-header">
<h3 class="modal-title">Error</h3>
</div>
<div style="text-align: center" class="modal-body">
{{ vm.message }}
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-show="vm.botonOk" type="button"
ng-click="ok()">Aceptar</button>
</div>

View File

@@ -2,9 +2,9 @@
<h3 class="modal-title">Crear Profesor</h3> <h3 class="modal-title">Crear Profesor</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary" ng-show="vm.botonOk" type="button"
ng-click="ok(urlLo)">OK</button> ng-click="ok()">OK</button>
</div> </div>

View File

@@ -2,13 +2,19 @@
<h3 class="modal-title">Eliminar Profesor</h3> <h3 class="modal-title">Eliminar Profesor</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="acceptButton" type="button" <button class="btn btn-primary"
ng-click="ok(urlLo)">Aceptar</button> ng-show="vm.acceptButton"
<button class="btn btn-primary" ng-show="botonOK" type="button" type="button"
ng-click="ok()">Aceptar</button>
<button class="btn btn-primary"
ng-show="vm.botonOK"
type="button"
ng-click="vm.eliminarProfesor(index)">OK</button> ng-click="vm.eliminarProfesor(index)">OK</button>
<button class="btn btn-warning" ng-show="botonCancelar" type="button" <button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancel</button> ng-click="cancel()">Cancel</button>
</div> </div>

View File

@@ -2,11 +2,15 @@
<h3 class="modal-title">Modificar Profesor</h3> <h3 class="modal-title">Modificar Profesor</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary"
ng-click="ok(urlLo)">OK</button> ng-show="vm.botonOk"
<button class="btn btn-warning" ng-show="botonCancelar" type="button" type="button"
ng-click="ok()">OK</button>
<button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancel</button> ng-click="cancel()">Cancel</button>
</div> </div>

View File

@@ -18,17 +18,10 @@
$stateProvider $stateProvider
.state('ProfessorList', { .state('ProfessorList', {
parent: 'index',
url: '/ProfessorList', url: '/ProfessorList',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/professor/professor_list.html', templateUrl: 'partials/professor/professor_list.html',
controller: 'ProfessorListCtrl', controller: 'ProfessorListCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -37,16 +30,10 @@
}) })
.state('ProfessorCreate', { .state('ProfessorCreate', {
parent: 'index',
url: '/ProfessorCreate', url: '/ProfessorCreate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/professor/professor_create.html', templateUrl: 'partials/professor/professor_create.html',
controller: 'ProfessorCreateCtrl', controller: 'ProfessorCreateCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -55,16 +42,10 @@
}) })
.state('ProfessorUpdate', { .state('ProfessorUpdate', {
parent: 'index',
url: '/ProfessorUpdate', url: '/ProfessorUpdate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/professor/professor_update.html', templateUrl: 'partials/professor/professor_update.html',
controller: 'ProfessorUpdateCtrl', controller: 'ProfessorUpdateCtrl',
controllerAs: 'vm' controllerAs: 'vm'

View File

@@ -10,11 +10,34 @@
.value('profesorSeleccionado',{}) .value('profesorSeleccionado',{})
.value('data',{}); .value('data',{});
professors.$inject = ['$resource','$rootScope']; professors.$inject = ['$resource','$rootScope','authentication'];
function professors($resource, $rootScope){ function professors($resource, $rootScope, authentication){
return $resource('http://'+$rootScope.domainUrl+'/professors/:id', null, return $resource('http://'+$rootScope.domainUrl+'/professors/:id', {}, {
{ get: {
'update': {method:'PUT'} method: 'GET',
headers: {
Authorization: 'Bearer '+ authentication.getToken()
}
},
update: {
method: 'PUT',
headers: {
Authorization: 'Bearer '+ authentication.getToken()
}
},
delete: {
method: 'DELETE',
headers: {
Authorization: 'Bearer '+ authentication.getToken()
}
},
query: {
method: 'GET',
isArray:true,
headers: {
Authorization: 'Bearer '+ authentication.getToken()
}
}
}); });
}; };
})(); })();

View File

@@ -6,11 +6,12 @@
.controller('ProfessorCreateCtrl', ProfessorCreateCtrl) .controller('ProfessorCreateCtrl', ProfessorCreateCtrl)
ProfessorCreateCtrl.$inject = ProfessorCreateCtrl.$inject =
['$scope','$rootScope', '$state', 'professors', '$modal']; ['$scope', '$state', 'professors', '$modal','authentication'];
function ProfessorCreateCtrl($scope, $rootScope, $state, professors, $modal){ function ProfessorCreateCtrl($scope, $state, professors, $modal, authentication){
var vm = this; var vm = this;
$rootScope.mensaje = ""; vm.botonOk = false;
vm.mensaje = "";
vm.submit = function() { vm.submit = function() {
if (vm.data_input_form.$valid){ if (vm.data_input_form.$valid){
@@ -24,39 +25,32 @@
"password": vm.profesor.Password "password": vm.profesor.Password
}; };
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/professor/modal/create_professor_modal.html', templateUrl: 'partials/professor/modal/create_professor_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm',
resolve: { resolve: {
items: function () { items: function () {
return $rootScope.items;
} }
} }
}); });
professors.save(professor, professors.save(professor,
function(){ function(data){
$rootScope.botonOk = true; authentication.saveToken(data.token);
$rootScope.mensaje = vm.botonOk = true;
vm.mensaje =
"Profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre + " agregado"; "Profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre + " agregado";
}, },
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.urlLo = 'listarProfesor'; vm.mensaje =
$rootScope.mensaje =
"Error al agregar al profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre; "Error al agregar al profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre;
}); });
}else{
vm.submitted = true;
} }
} }
$scope.ok = function (urlLo) { $scope.ok = function () {
$state.go('ProfessorList'); $state.go('ProfessorList');
$scope.modalInstance.dismiss('cancel'); $scope.modalInstance.dismiss('cancel');
}; };

View File

@@ -78,7 +78,7 @@
</div> </div>
<div class="col-md-4 column"> <div class="col-md-4 column">
<label for="password">Contraseña *</label> <label for="password">Contraseña *</label>
<input type="password" class="form-control" ng-model="vm.profesor.Password" maxlength="8" required/> <input type="password" class="form-control" ng-model="vm.profesor.Password" maxlength="20" required/>
<div class="error" ng-show="vm.submitted && vm.data_input_form.password.$invalid"> <div class="error" ng-show="vm.submitted && vm.data_input_form.password.$invalid">
<small class="error" ng-show="vm.data_input_form.password.$error.required"> <small class="error" ng-show="vm.data_input_form.password.$error.required">
La Contraseña del Profesor es obligatorio. La Contraseña del Profesor es obligatorio.

View File

@@ -6,14 +6,11 @@
.controller('ProfessorListCtrl', ProfessorListCtrl) .controller('ProfessorListCtrl', ProfessorListCtrl)
ProfessorListCtrl.$inject = ProfessorListCtrl.$inject =
[ '$scope', '$rootScope', '$state', 'professors', '$modal', 'profesorSeleccionado' ]; [ '$scope', '$state', 'professors', '$modal', 'profesorSeleccionado' ];
function ProfessorListCtrl( $scope, $rootScope, $state, professors, $modal, profesorSeleccionado ){ function ProfessorListCtrl( $scope, $state, professors, $modal, profesorSeleccionado ){
var vm = this; var vm = this;
vm.lista = true; vm.lista = true;
$rootScope.actOk = false;
$rootScope.loading = true;
$rootScope.table = false;
var profesorArray = []; var profesorArray = [];
professors.query( professors.query(
@@ -28,8 +25,6 @@
Correo: value.email Correo: value.email
}); });
}); });
$rootScope.loading = false;
$rootScope.table = true;
vm.listaProfesor = profesorArray; vm.listaProfesor = profesorArray;
}, },
@@ -38,50 +33,42 @@
}); });
vm.eliminarProfesorModal = function (index) { vm.eliminarProfesorModal = function (index) {
$rootScope.index = index; $scope.index = index;
$rootScope.botonOK = true; vm.botonOK = true;
$rootScope.botonCancelar = true; vm.botonCancelar = true;
$rootScope.acceptButton = false; vm.acceptButton = false;
$rootScope.rsplice = false; vm.rsplice = false;
$rootScope.mensaje = "¿Seguro que desea eliminar el Profesor?"; vm.mensaje = "¿Seguro que desea eliminar el Profesor?";
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/professor/modal/list_professor_modal.html', templateUrl: 'partials/professor/modal/list_professor_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return "";
}
}
}); });
}; };
vm.eliminarProfesor = function (index) { vm.eliminarProfesor = function (index) {
vm.botonOK = false;
$rootScope.botonOK = false; vm.acceptButton = true;
$rootScope.acceptButton = true; vm.botonCancelar = false;
$rootScope.botonCancelar = false;
professors.delete({id: vm.profesor[index]._id}, professors.delete({id: vm.profesor[index]._id},
function () { function () {
$rootScope.rsplice = true; vm.rsplice = true;
$rootScope.mensaje = vm.mensaje =
"Profesor " + vm.profesor[index].name + " eliminado"; "Profesor " + vm.profesor[index].name + " eliminado";
}, },
function () { function () {
$rootScope.listarProfesorsLoading = false; vm.mensaje =
$rootScope.mensaje =
"Error eliminando al Profesor " + vm.profesor[index].name; "Error eliminando al Profesor " + vm.profesor[index].name;
}); });
}; };
vm.removeProfesorSplice = function(index, rsplice) { vm.removeProfesorSplice = function(index, rsplice) {
if(rsplice){ if(vm.rsplice){
vm.listaProfesor.splice(index, 1); vm.listaProfesor.splice(index, 1);
$rootScope.rsplice = false; vm.rsplice = false;
} }
}; };
@@ -95,13 +82,7 @@
$state.go('ProfessorUpdate'); $state.go('ProfessorUpdate');
}; };
$rootScope.open = function($event) { $scope.ok = function () {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
$scope.ok = function (urlLo) {
$state.reload(); $state.reload();
$scope.modalInstance.dismiss('cancel'); $scope.modalInstance.dismiss('cancel');
}; };
@@ -109,7 +90,5 @@
$scope.cancel = function () { $scope.cancel = function () {
$scope.modalInstance.dismiss('cancel'); $scope.modalInstance.dismiss('cancel');
}; };
return vm;
}; };
})(); })();

View File

@@ -7,18 +7,12 @@
<tr> <tr>
<th width="20%"> <th width="20%">
Cedula Cedula
<span ng-show="sortType == 'Cedula' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'Cedula' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%"> <th width="20%">
Nombre Nombre
<span ng-show="sortType == 'Nombre' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'Nombre' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%"> <th width="20%">
Apellido Apellido
<span ng-show="sortType == 'Apellido' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'Apellido' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%" style="text-align: center"> <th width="20%" style="text-align: center">
Modificar Modificar
@@ -34,10 +28,18 @@
<td style="vertical-align:middle">{{ profesor.Nombre }}</td> <td style="vertical-align:middle">{{ profesor.Nombre }}</td>
<td style="vertical-align:middle">{{ profesor.Apellido }}</td> <td style="vertical-align:middle">{{ profesor.Apellido }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span title="Click aqui para Modificar un Profesor" class="glyphicon glyphicon-edit" aria-hidden="true" ng-click="vm.modificarProfesor($index)" style="cursor:pointer"></span> <span title="Haga click para Modificar un Profesor"
class="glyphicon glyphicon-edit"
aria-hidden="true"
ng-click="vm.modificarProfesor($index)"
style="cursor:pointer"></span>
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<span title="Click aqui para Eliminar un Profesor" class="glyphicon glyphicon-remove" aria-hidden="true" ng-click="vm.eliminarProfesorModal($index)" style="cursor:pointer"></span> <span title="Haga click para Eliminar un Profesor"
class="glyphicon glyphicon-remove"
aria-hidden="true"
ng-click="vm.eliminarProfesorModal($index)"
style="cursor:pointer"></span>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -6,13 +6,14 @@
.controller('ProfessorUpdateCtrl', ProfessorUpdateCtrl) .controller('ProfessorUpdateCtrl', ProfessorUpdateCtrl)
ProfessorUpdateCtrl.$inject = ProfessorUpdateCtrl.$inject =
['$scope','$rootScope', '$state', 'professors', '$modal', 'profesorSeleccionado' ]; ['$scope', '$state', 'professors', '$modal', 'profesorSeleccionado' ];
function ProfessorUpdateCtrl ( $scope, $rootScope, $state, professors, $modal, profesorSeleccionado ){ function ProfessorUpdateCtrl ( $scope, $state, professors, $modal, profesorSeleccionado ){
var vm = this; var vm = this;
vm.botonOk = false;
vm.mensaje = "";
vm.profesor = profesorSeleccionado; vm.profesor = profesorSeleccionado;
$rootScope.mensaje = "";
$rootScope.actOk = false;
vm.submit = function() { vm.submit = function() {
@@ -26,35 +27,28 @@
"password": vm.profesor.Password "password": vm.profesor.Password
}; };
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/professor/modal/update_professor_modal.html', templateUrl: 'partials/professor/modal/update_professor_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
}); });
professors.update({ id: vm.profesor._id}, professor, professors.update({ id: vm.profesor._id}, professor,
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
$rootScope.mensaje = vm.mensaje =
"Profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre + " actualizado"; "Profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre + " actualizado";
}, },
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
$rootScope.mensaje = vm.mensaje =
"Error al modificar al profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre; "Error al modificar al profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre;
}); });
} }
$scope.ok = function (urlLo) { $scope.ok = function () {
$state.go('ProfessorList'); $state.go('ProfessorList');
$scope.modalInstance.dismiss('cancel'); $scope.modalInstance.dismiss('cancel');
}; };

View File

@@ -6,10 +6,11 @@
.controller('CourseAssistCtrl', CourseAssistCtrl) .controller('CourseAssistCtrl', CourseAssistCtrl)
CourseAssistCtrl.$inject = CourseAssistCtrl.$inject =
['$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedCourse']; ['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'authentication'];
function CourseAssistCtrl($scope, $rootScope, $state, professors, $modal, selectedCourse) { function CourseAssistCtrl($scope, $state, professors, $modal, selectedCourse, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.course = null; vm.course = null;
vm.lectures = 0; vm.lectures = 0;
vm.percentage = 0; vm.percentage = 0;

View File

@@ -6,10 +6,11 @@
.controller('CourseReportCtrl', CourseReportCtrl) .controller('CourseReportCtrl', CourseReportCtrl)
CourseReportCtrl.$inject = CourseReportCtrl.$inject =
['$scope', '$rootScope', '$state', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse']; ['$scope', '$state', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse', 'authentication'];
function CourseReportCtrl($scope, $rootScope, $state, professors, $modal, profesorSeleccionado, selectedCourse) { function CourseReportCtrl($scope, $state, professors, $modal, profesorSeleccionado, selectedCourse, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
professors.get({ id: professorid }, professors.get({ id: professorid },
function (successResult){ function (successResult){

View File

@@ -33,14 +33,14 @@
<td style="vertical-align:middle">{{ course.credits }}</td> <td style="vertical-align:middle">{{ course.credits }}</td>
<td style="vertical-align:middle">{{ course.description }}</td> <td style="vertical-align:middle">{{ course.description }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span <span title="Haga click para ver los reportes de esta materia"
class="glyphicon glyphicon-list-alt" class="glyphicon glyphicon-list-alt"
aria-hidden="true" aria-hidden="true"
ng-click="vm.courseReports($index)" ng-click="vm.courseReports($index)"
style="cursor:pointer"></span> style="cursor:pointer"></span>
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<span <span title="Haga click para ver el listado de las secciones de esta materia"
class="glyphicon glyphicon-list" class="glyphicon glyphicon-list"
aria-hidden="true" aria-hidden="true"
ng-click="vm.listSections($index)" ng-click="vm.listSections($index)"

View File

@@ -18,16 +18,10 @@
$stateProvider $stateProvider
.state('courseReport', { .state('courseReport', {
parent: 'index',
url: '/reportesPorMateria', url: '/reportesPorMateria',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/report/course_report.html', templateUrl: 'partials/report/course_report.html',
controller: 'CourseReportCtrl', controller: 'CourseReportCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -35,16 +29,10 @@
} }
}) })
.state('sectionReport', { .state('sectionReport', {
parent: 'index',
url: '/reportesPorSeccion', url: '/reportesPorSeccion',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/report/section_report.html', templateUrl: 'partials/report/section_report.html',
controller: 'SectionReportCtrl', controller: 'SectionReportCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -52,16 +40,10 @@
} }
}) })
.state('studentReport', { .state('studentReport', {
parent: 'index',
url: '/reportesPorEstudiante', url: '/reportesPorEstudiante',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/report/student_report.html', templateUrl: 'partials/report/student_report.html',
controller: 'StudentReportCtrl', controller: 'StudentReportCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -69,16 +51,10 @@
} }
}) })
.state('studentAssist', { .state('studentAssist', {
parent: 'index',
url: '/asistenciaPorEstudiante', url: '/asistenciaPorEstudiante',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/report/student_assist.html', templateUrl: 'partials/report/student_assist.html',
controller: 'StudentAssistCtrl', controller: 'StudentAssistCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -86,16 +62,10 @@
} }
}) })
.state('sectionAssist', { .state('sectionAssist', {
parent: 'index',
url: '/asistenciaPorSeccion', url: '/asistenciaPorSeccion',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/report/section_assist.html', templateUrl: 'partials/report/section_assist.html',
controller: 'SectionAssistCtrl', controller: 'SectionAssistCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -103,16 +73,10 @@
} }
}) })
.state('courseAssist', { .state('courseAssist', {
parent: 'index',
url: '/asistenciaPorMateria', url: '/asistenciaPorMateria',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/report/course_assist.html', templateUrl: 'partials/report/course_assist.html',
controller: 'CourseAssistCtrl', controller: 'CourseAssistCtrl',
controllerAs: 'vm' controllerAs: 'vm'

View File

@@ -6,10 +6,11 @@
.controller('SectionAssistCtrl', SectionAssistCtrl) .controller('SectionAssistCtrl', SectionAssistCtrl)
SectionAssistCtrl.$inject = SectionAssistCtrl.$inject =
['$scope', '$rootScope','$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent']; ['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent', 'authentication'];
function SectionAssistCtrl($scope, $rootScope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent) { function SectionAssistCtrl($scope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.section = []; vm.section = [];
vm.lectures = 0; vm.lectures = 0;
vm.percentage = 0; vm.percentage = 0;

View File

@@ -6,9 +6,17 @@
<div> Estadisticas </div> <div> Estadisticas </div>
<div> Porcentaje de Asistencia: {{vm.percentage}} % </div> <div> Porcentaje de Asistencia: {{vm.percentage}} % </div>
<div> Total de Dias de Clase: {{vm.lectures}} </div> <div> Total de Dias de Clase: {{vm.lectures}} </div>
<br><br/> <br>
</div> </div>
<button class = "btn-warning btn"
type = "button"
style = "margin: 10px"
ng-click = "vm.back()">
Regresar
</button>
<br><br/>
<div ng-show="vm.flag"> <div ng-show="vm.flag">
<h4 style="color: red"> Estudiantes con menos de 75% de Asistencia </h4> <h4 style="color: red"> Estudiantes con menos de 75% de Asistencia </h4>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
@@ -57,11 +65,4 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<button class = "btn-warning btn"
type = "button"
style = "margin: 10px"
ng-click = "vm.back()">
Regresar
</button>
</div> </div>

View File

@@ -6,10 +6,11 @@
.controller('SectionReportCtrl', SectionReportCtrl) .controller('SectionReportCtrl', SectionReportCtrl)
SectionReportCtrl.$inject = SectionReportCtrl.$inject =
['$scope', '$rootScope', '$state', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse', 'selectedSection']; ['$scope', '$state', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse', 'selectedSection', 'authentication'];
function SectionReportCtrl($scope, $rootScope, $state, professors, $modal, profesorSeleccionado, selectedCourse, selectedSection) { function SectionReportCtrl($scope, $state, professors, $modal, profesorSeleccionado, selectedCourse, selectedSection, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.section = []; vm.section = [];
vm.professor = null; vm.professor = null;

View File

@@ -39,13 +39,15 @@
<td style="vertical-align:middle">{{ section.code }}</td> <td style="vertical-align:middle">{{ section.code }}</td>
<td style="vertical-align:middle">{{ section.semester }}</td> <td style="vertical-align:middle">{{ section.semester }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span class="glyphicon glyphicon-list-alt" <span title="Haga click para ver los reportes de esta sección"
class="glyphicon glyphicon-list-alt"
aria-hidden="true" aria-hidden="true"
ng-click="vm.sectionReport($index)" ng-click="vm.sectionReport($index)"
style="cursor:pointer"></span> style="cursor:pointer"></span>
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<span class="glyphicon glyphicon-list" <span title="Haga click para ver el listado de estudiantes de esta sección"
class="glyphicon glyphicon-list"
aria-hidden="true" aria-hidden="true"
ng-click="vm.listStudents($index)" ng-click="vm.listStudents($index)"
style="cursor:pointer"></span> style="cursor:pointer"></span>

View File

@@ -6,10 +6,11 @@
.controller('StudentAssistCtrl', StudentAssistCtrl) .controller('StudentAssistCtrl', StudentAssistCtrl)
StudentAssistCtrl.$inject = StudentAssistCtrl.$inject =
['$scope', '$rootScope','$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent']; ['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent', 'authentication'];
function StudentAssistCtrl($scope, $rootScope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent) { function StudentAssistCtrl($scope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.section = []; vm.section = [];
vm.lectures = 0; vm.lectures = 0;
vm.percentage = 0; vm.percentage = 0;

View File

@@ -6,10 +6,11 @@
.controller('StudentReportCtrl', StudentReportCtrl) .controller('StudentReportCtrl', StudentReportCtrl)
StudentReportCtrl.$inject = StudentReportCtrl.$inject =
['$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent']; ['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent', 'authentication'];
function StudentReportCtrl($scope, $rootScope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent) { function StudentReportCtrl($scope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent, authentication) {
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.section = []; vm.section = [];
vm.professor = null; vm.professor = null;

View File

@@ -32,7 +32,8 @@
<td style="vertical-align:middle">{{ student.name }}</td> <td style="vertical-align:middle">{{ student.name }}</td>
<td style="vertical-align:middle">{{ student.lastname }}</td> <td style="vertical-align:middle">{{ student.lastname }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span class="glyphicon glyphicon-list-alt" <span title="Haga click para ver la asistencia de este estudiante"
class="glyphicon glyphicon-list-alt"
aria-hidden="true" aria-hidden="true"
ng-click="vm.studentReports($index)" ng-click="vm.studentReports($index)"
style="cursor:pointer"></span> style="cursor:pointer"></span>

View File

@@ -2,11 +2,15 @@
<h3 class="modal-title">Crear Sección</h3> <h3 class="modal-title">Crear Sección</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary"
ng-click="ok(urlLo)">Aceptar</button> ng-show="vm.botonOk"
<button class="btn btn-warning" ng-show="botonCancelar" type="button" type="button"
ng-click="ok()">Aceptar</button>
<button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancelar</button> ng-click="cancel()">Cancelar</button>
</div> </div>

View File

@@ -2,13 +2,19 @@
<h3 class="modal-title">Eliminar Sección</h3> <h3 class="modal-title">Eliminar Sección</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary"
ng-show="vm.botonOk"
type="button"
ng-click="vm.eliminarMatricula(index)">OK</button> ng-click="vm.eliminarMatricula(index)">OK</button>
<button class="btn btn-warning" ng-show="botonCancelar" type="button" <button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancelar</button> ng-click="cancel()">Cancelar</button>
<button class="btn btn-primary" ng-show="otroBotonOk" type="button" <button class="btn btn-primary"
ng-show="vm.otroBotonOk"
type="button"
ng-click="ok(urlLo)">Aceptar</button> ng-click="ok(urlLo)">Aceptar</button>
</div> </div>

View File

@@ -2,13 +2,19 @@
<h3 class="modal-title">Liberar BT</h3> <h3 class="modal-title">Liberar BT</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary"
ng-show="vm.botonOk"
type="button"
ng-click="vm.freeBTAddress(index)">OK</button> ng-click="vm.freeBTAddress(index)">OK</button>
<button class="btn btn-warning" ng-show="botonCancelar" type="button" <button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancelar</button> ng-click="cancel()">Cancelar</button>
<button class="btn btn-primary" ng-show="otroBotonOk" type="button" <button class="btn btn-primary"
ng-click="ok(urlLo)">Aceptar</button> ng-show="vm.otroBotonOk"
type="button"
ng-click="ok()">Aceptar</button>
</div> </div>

View File

@@ -2,13 +2,19 @@
<h3 class="modal-title">Retirar Estudiante</h3> <h3 class="modal-title">Retirar Estudiante</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary"
ng-show="vm.botonOk"
type="button"
ng-click="vm.retirarEstudiante(index)">OK</button> ng-click="vm.retirarEstudiante(index)">OK</button>
<button class="btn btn-primary" ng-show="otroBotonOk" type="button" <button class="btn btn-primary"
ng-show="vm.otroBotonOk"
type="button"
ng-click="ok()">Aceptar</button> ng-click="ok()">Aceptar</button>
<button class="btn btn-warning" ng-show="botonCancelar" type="button" <button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancelar</button> ng-click="cancel()">Cancelar</button>
</div> </div>

View File

@@ -17,54 +17,33 @@
$urlRouterProvider.otherwise('/SectionList'); $urlRouterProvider.otherwise('/SectionList');
$stateProvider $stateProvider
.state('SectionList', { .state('SectionList', {
parent: 'index',
url: '/SectionList', url: '/SectionList',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/section/section_list.html', templateUrl: 'partials/section/section_list.html',
controller: 'SectionListCtrl', controller: 'SectionListCtrl',
controllerAs: 'vm' controllerAs: 'vm'
} }
} }
}) })
.state('SectionCreate', { .state('SectionCreate', {
parent: 'index',
url: '/SectionCreate', url: '/SectionCreate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/section/section_create.html', templateUrl: 'partials/section/section_create.html',
controller: 'SectionCreateCtrl', controller: 'SectionCreateCtrl',
controllerAs: 'vm' controllerAs: 'vm'
} }
} }
}) })
.state('SectionUpdate', { .state('SectionUpdate', {
parent: 'index',
url: '/SectionUpdate', url: '/SectionUpdate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/section/section_update.html', templateUrl: 'partials/section/section_update.html',
controller: 'SectionUpdateCtrl', controller: 'SectionUpdateCtrl',
controllerAs: 'vm' controllerAs: 'vm'

View File

@@ -6,16 +6,17 @@
.controller('SectionCreateCtrl', SectionCreateCtrl) .controller('SectionCreateCtrl', SectionCreateCtrl)
SectionCreateCtrl.$inject = SectionCreateCtrl.$inject =
['$scope','$rootScope', '$state', 'professors', '$modal', 'selectedCourse']; ['$scope', '$state', 'professors', '$modal', 'selectedCourse','authentication'];
function SectionCreateCtrl($scope, $rootScope, $state, professors, $modal, selectedCourse){ function SectionCreateCtrl($scope, $state, professors, $modal, selectedCourse, authentication){
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
var vm = this; var vm = this;
vm.course = {}; vm.course = {};
vm.itExists = false; vm.itExists = false;
vm.selectedCourse = selectedCourse; vm.selectedCourse = selectedCourse;
vm.submitted = false; vm.submitted = false;
vm.semester, vm.section, vm.materias; vm.semester, vm.section, vm.materias;
$rootScope.mensaje = ""; vm.mensaje = "";
vm.students = []; vm.students = [];
professors.get({ id: professorid }, professors.get({ id: professorid },
@@ -47,15 +48,9 @@
}; };
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/section/modal/create_section_modal.html', templateUrl: 'partials/section/modal/create_section_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return $rootScope.items;
}
}
}); });
@@ -72,19 +67,17 @@
vm.professor.courses[vm.index].sections.push(vm.package); vm.professor.courses[vm.index].sections.push(vm.package);
professors.update({ id: professorid }, vm.professor, professors.update({ id: professorid }, vm.professor,
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Sección " + vm.name + " creada"; vm.mensaje = "Sección " + vm.name + " creada";
}, },
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Error creando la seccion " + vm.name; vm.mensaje = "Error creando la seccion " + vm.name;
}); });
}else{ }else{
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Sección Duplicada, " + vm.name + " existe en el semestre "+ vm.semester + "."; vm.mensaje = "Sección Duplicada, " + vm.name + " existe en el semestre "+ vm.semester + ".";
} }
}else{
vm.submitted = true;
} }
}; };

View File

@@ -5,10 +5,11 @@
.module('app.section') .module('app.section')
.controller('SectionListCtrl', SectionListCtrl) .controller('SectionListCtrl', SectionListCtrl)
SectionListCtrl.$inject = [ '$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection']; SectionListCtrl.$inject = [ '$scope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'authentication'];
function SectionListCtrl ( $scope, $rootScope, $state, professors, $modal, selectedCourse, selectedSection ){ function SectionListCtrl ( $scope, $state, professors, $modal, selectedCourse, selectedSection, authentication ){
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.section = []; vm.section = [];
vm.professor = null; vm.professor = null;
@@ -29,58 +30,43 @@
}); });
/**************************Eliminar Matricula**************************/
/* En este proceso, primero se llama a un Modal el cual se cerciora que
el usuario se asegure de eliminar la matricula escogida, el usuario al
confirmar su decision llama automaticamente a la funcion que hara la
llamada a servicio que borrara la matricula de la base de datos.
*/
vm.createSection = function () { vm.createSection = function () {
$state.go('SectionCreate'); $state.go('SectionCreate');
}; };
vm.eliminarMatriculaModal = function (index) { vm.eliminarMatriculaModal = function (index) {
$rootScope.index = index; $scope.index = index;
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.otroBotonOk = false; vm.otroBotonOk = false;
$rootScope.botonCancelar = true; vm.botonCancelar = true;
$rootScope.rsplice = false; vm.rsplice = false;
var name = vm.section[index].name; var name = vm.section[index].name;
$rootScope.mensaje = "¿Seguro que desea eliminar la sección "+name+"?"; vm.mensaje = "¿Seguro que desea eliminar la sección "+name+"?";
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: '/partials/section/modal/delete_section_modal.html', templateUrl: '/partials/section/modal/delete_section_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return "";
}
}
}); });
}; };
vm.eliminarMatricula = function (index) { vm.eliminarMatricula = function (index) {
$rootScope.botonOk = false; vm.botonOk = false;
$rootScope.otroBotonOk = true; vm.otroBotonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
var name = vm.section[index].name; var name = vm.section[index].name;
vm.professor.courses[vm.index].sections.splice(index, 1); vm.professor.courses[vm.index].sections.splice(index, 1);
professors.update({ id: professorid }, vm.professor, professors.update({ id: professorid }, vm.professor,
function () { function () {
$rootScope.rsplice = true; vm.rsplice = true;
$rootScope.mensaje = "Sección " + name + " eliminada"; vm.mensaje = "Sección " + name + " eliminada";
}, },
function () { function () {
$rootScope.mensaje = "Error eliminando la sección " + name; vm.mensaje = "Error eliminando la sección " + name;
}); });
}; };
/*************************Fin de Eliminar Matricula*******************/
vm.modificarMatricula = function (index) { vm.modificarMatricula = function (index) {
selectedSection._id = vm.section[index]._id; selectedSection._id = vm.section[index]._id;
selectedCourse.index = vm.index; selectedCourse.index = vm.index;

View File

@@ -12,23 +12,15 @@
<tr> <tr>
<th width="20%"> <th width="20%">
Sección Sección
<span ng-show="sortType == 'name' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'name' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%"> <th width="20%">
Nombre de la Materia Nombre de la Materia
<span ng-show="sortType == 'course' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'course' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%"> <th width="20%">
Codigo de la Materia Codigo de la Materia
<span ng-show="sortType == 'code' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'code' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%"> <th width="20%">
Semestre Semestre
<span ng-show="sortType == 'semester' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'semester' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="10%" style="text-align: center"> <th width="10%" style="text-align: center">
Matricula Matricula
@@ -45,14 +37,16 @@
<td style="vertical-align:middle">{{ section.code }}</td> <td style="vertical-align:middle">{{ section.code }}</td>
<td style="vertical-align:middle">{{ section.semester }}</td> <td style="vertical-align:middle">{{ section.semester }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span title="Click aqui para Modificar la Matricula" <span title="Haga click para modificar la matricula"
class="glyphicon glyphicon-edit" aria-hidden="true" class="glyphicon glyphicon-edit"
aria-hidden="true"
ng-click="vm.modificarMatricula($index)" ng-click="vm.modificarMatricula($index)"
style="cursor:pointer"></span> style="cursor:pointer"></span>
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<span title="Click aqui para Eliminar la Matricula" <span title="Haga click para eliminar la matricula"
class="glyphicon glyphicon-remove" aria-hidden="true" class="glyphicon glyphicon-remove"
aria-hidden="true"
ng-click="vm.eliminarMatriculaModal($index)" ng-click="vm.eliminarMatriculaModal($index)"
style="cursor:pointer"></span> style="cursor:pointer"></span>
</td> </td>

View File

@@ -5,9 +5,10 @@
.module('app.section') .module('app.section')
.controller('SectionUpdateCtrl', SectionUpdateCtrl) .controller('SectionUpdateCtrl', SectionUpdateCtrl)
SectionUpdateCtrl.$inject = ['$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse','data']; SectionUpdateCtrl.$inject = ['$scope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse','data', 'authentication'];
function SectionUpdateCtrl($scope, $rootScope, $state, professors, $modal, selectedSection, selectedCourse, data){ function SectionUpdateCtrl($scope, $state, professors, $modal, selectedSection, selectedCourse, data, authentication){
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
var vm = this; var vm = this;
vm.section = {}; vm.section = {};
vm.students = []; vm.students = [];
@@ -39,22 +40,15 @@
}; };
vm.freeBTAddressModal = function (index) { vm.freeBTAddressModal = function (index) {
$rootScope.index = index; $scope.index = index;
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.otroBotonOk = false; vm.otroBotonOk = false;
$rootScope.botonCancelar = true; vm.botonCancelar = true;
$rootScope.eliminarLoading = false; vm.mensaje = "¿Desea liberar la dirección de BT del estudiante "+ vm.students[index].lastname +", "+ vm.students[index].name + "?";
$rootScope.mensaje = "¿Desea liberar la dirección de BT del estudiante "+ vm.students[index].lastname +", "+ vm.students[index].name + "?";
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/section/modal/student_bt_removal_modal.html', templateUrl: 'partials/section/modal/student_bt_removal_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return "";
}
}
}); });
}; };
@@ -66,36 +60,30 @@
professors.update({ id: professorid }, vm.professor, professors.update({ id: professorid }, vm.professor,
function(){ function(){
$rootScope.botonOk = false; vm.botonOk = false;
$rootScope.otroBotonOk = true; vm.otroBotonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
$rootScope.mensaje = "Dirección BT de " + vm.student.lastname + ", " + vm.student.name + " fue liberada"; vm.mensaje = "Dirección BT de " + vm.student.lastname + ", " + vm.student.name + " fue liberada";
}, },
function(){ function(){
$rootScope.botonOk = false; vm.botonOk = false;
$rootScope.otroBotonOk = true; vm.otroBotonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
$rootScope.mensaje = "Error al liberar dirección de BT del estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre; vm.mensaje = "Error al liberar dirección de BT del estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre;
}); });
}; };
vm.retirarEstudianteModal = function (index) { vm.retirarEstudianteModal = function (index) {
$rootScope.index = index; $scope.index = index;
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.otroBotonOk = false; vm.otroBotonOk = false;
$rootScope.botonCancelar = true; vm.botonCancelar = true;
$rootScope.eliminarLoading = false; vm.eliminarLoading = false;
$rootScope.mensaje = "¿Desea retirar al estudiante "+ vm.students[index].lastname +", "+ vm.students[index].name + "?"; vm.mensaje = "¿Desea retirar al estudiante "+ vm.students[index].lastname +", "+ vm.students[index].name + "?";
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/section/modal/update_section_modal.html', templateUrl: 'partials/section/modal/update_section_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return "";
}
}
}); });
}; };
@@ -104,16 +92,16 @@
professors.update({ id: professorid }, vm.professor, professors.update({ id: professorid }, vm.professor,
function (){ function (){
$rootScope.botonOk = false; vm.botonOk = false;
$rootScope.otroBotonOk = true; vm.otroBotonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
$rootScope.mensaje = "Sección "+ vm.section.name +" actualizada"; vm.mensaje = "Sección "+ vm.section.name +" actualizada";
}, },
function (){ function (){
$rootScope.botonOk = false; vm.botonOk = false;
$rootScope.otroBotonOk = true; vm.otroBotonOk = true;
$rootScope.botonCancelar = false; vm.botonCancelar = false;
$rootScope.mensaje = "Error al actualizar la Sección "+ vm.section.name; vm.mensaje = "Error al actualizar la Sección "+ vm.section.name;
}); });
}; };

View File

@@ -12,31 +12,21 @@
<tr> <tr>
<th width="10%" style="text-align: center"> <th width="10%" style="text-align: center">
Cedula Cedula
<span ng-show="sortType == 'id' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'id' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%" style="text-align: center"> <th width="20%" style="text-align: center">
Nombre Nombre
<span ng-show="sortType == 'name' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'name' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%" style="text-align: center"> <th width="20%" style="text-align: center">
Apellido Apellido
<span ng-show="sortType == 'lastname' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'lastname' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="20%" style="text-align: center"> <th width="20%" style="text-align: center">
Correo Correo
<span ng-show="sortType == 'email' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'email' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="10%" style="text-align: center"> <th width="10%" style="text-align: center">
Actualizar Correo Actualizar Correo
</th> </th>
<th width="10%" style="text-align: center"> <th width="10%" style="text-align: center">
Dirección BT Dirección BT
<span ng-show="sortType == 'email' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'email' && sortReverse" class="fa fa-caret-up"></span>
</th> </th>
<th width="10%" style="text-align: center"> <th width="10%" style="text-align: center">
Liberar Dirección BT Liberar Dirección BT
@@ -53,20 +43,23 @@
<td style="vertical-align:middle">{{ student.lastname }}</td> <td style="vertical-align:middle">{{ student.lastname }}</td>
<td style="vertical-align:middle">{{ student.email }}</td> <td style="vertical-align:middle">{{ student.email }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span class="glyphicon glyphicon-envelope" <span title="Haga click para actualizar dirección de correo del estudiante"
class="glyphicon glyphicon-envelope"
aria-hidden="true" aria-hidden="true"
ng-click="vm.mailUpdate($index)" ng-click="vm.mailUpdate($index)"
style="cursor:pointer;"></span> style="cursor:pointer;"></span>
</td> </td>
<td style="vertical-align:middle">{{ student.btaddress }}</td> <td style="vertical-align:middle">{{ student.btaddress }}</td>
<td style="text-align: center"> <td style="text-align: center">
<span class="glyphicon glyphicon-signal" <span title="Haga click para liberar la dirección MAC del telefono del estudiante"
class="glyphicon glyphicon-signal"
aria-hidden="true" aria-hidden="true"
ng-click="vm.freeBTAddressModal($index)" ng-click="vm.freeBTAddressModal($index)"
style="cursor:pointer;"></span> style="cursor:pointer;"></span>
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<span class="glyphicon glyphicon-remove" <span title="Haga click para retirar al estudiante de la sección"
class="glyphicon glyphicon-remove"
aria-hidden="true" aria-hidden="true"
ng-click="vm.retirarEstudianteModal($index)" ng-click="vm.retirarEstudianteModal($index)"
style="cursor:pointer;"></span> style="cursor:pointer;"></span>

View File

@@ -0,0 +1,17 @@
(function(){
'use strict';
angular
.module('app')
.controller('NavbarCtrl', NavbarCtrl)
NavbarCtrl.$inject = ['$scope', 'authentication', '$state'];
function NavbarCtrl($scope, authentication, $state) {
var vm = this;
vm.logout = function () {
authentication.logout();
$state.go('login');
};
};
})();

View File

@@ -15,7 +15,13 @@
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<div class="container-fluid"> <div class="container-fluid">
</br> </br>
<a href="#login" class="btn-danger btn" style=" margin: 10px"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Salir</a> <button class="btn-danger btn"
style=" margin: 10px"
ng-click= "vm.logout()">
<span class="glyphicon glyphicon-log-out"
aria-hidden="true"></span>
Salir
</button>
</div> </div>
</ul> </ul>
</div> </div>

View File

@@ -5,13 +5,27 @@
.module('app') .module('app')
.controller('SidebarCtrl', SidebarCtrl) .controller('SidebarCtrl', SidebarCtrl)
SidebarCtrl.$inject = ['$scope']; SidebarCtrl.$inject = ['$scope', 'authentication'];
function SidebarCtrl($scope) { function SidebarCtrl($scope, authentication) {
var that = this; var that = this;
$scope.showChilds = function(item){ $scope.showChilds = function(index){
item.active = !item.active; $scope.items[index].active = !$scope.items[index].active;
collapseAnother(index);
}; };
var collapseAnother = function(index){
for(var i=0; i<$scope.items.length; i++){
if(i!=index){
$scope.items[i].active = false;
}
}
};
$scope.items = [];
var permission = authentication.currentUser();
if(permission.role=='admin'){
$scope.items = [ $scope.items = [
{ {
text: 'Módulo de Administración', text: 'Módulo de Administración',
@@ -25,7 +39,11 @@
text: 'Nuevo Profesor' text: 'Nuevo Profesor'
} }
] ]
}, }
];
}
if(permission.role=='professor'){
$scope.items = [
{ {
text: 'Módulo de Materias', text: 'Módulo de Materias',
subItems: [ subItems: [
@@ -49,5 +67,6 @@
] ]
} }
]; ];
}
}; };
})(); })();

View File

@@ -4,10 +4,14 @@
<div class="row"> <div class="row">
<div class="col-sm-3 col-md-2 sidebar"> <div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar"> <ul class="nav nav-sidebar">
<li ng-repeat="item in items" ng-click="showChilds(item)"> <li ng-repeat="item in items"
ng-click="showChilds($index)">
<a>{{item.text}}</a> <a>{{item.text}}</a>
<ul class="nav nav-sidebar text-center"> <ul class="nav nav-sidebar text-center">
<li ng-repeat="subItem in item.subItems" ng-show="item.active"> <li ng-repeat="subItem in item.subItems"
ng-show="item.active"
ng-click="showChilds($index)"
ui-sref-active="active">
<a data-ui-sref="{{ subItem.state ? subItem.state : false }}">{{subItem.text}} <a data-ui-sref="{{ subItem.state ? subItem.state : false }}">{{subItem.text}}
</li> </li>
</ul> </ul>

View File

@@ -2,8 +2,11 @@
<h3 class="modal-title">Crear Estudiante</h3> <h3 class="modal-title">Crear Estudiante</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" ng-click="ok(urlLo)">Aceptar</button> <button class="btn btn-primary"
ng-show="vm.botonOk"
type="button"
ng-click="ok()">Aceptar</button>
</div> </div>

View File

@@ -2,13 +2,19 @@
<h3 class="modal-title">Eliminar Estudiante</h3> <h3 class="modal-title">Eliminar Estudiante</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="acceptButton" type="button" <button class="btn btn-primary"
ng-click="ok(urlLo)">Aceptar</button> ng-show="vm.acceptButton"
<button class="btn btn-primary" ng-show="botonOK" type="button" type="button"
ng-click="ok()">Aceptar</button>
<button class="btn btn-primary"
ng-show="vm.botonOK"
type="button"
ng-click="vm.eliminarEstudiante(index)">OK</button> ng-click="vm.eliminarEstudiante(index)">OK</button>
<button class="btn btn-warning" ng-show="botonCancelar" type="button" <button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancelar</button> ng-click="cancel()">Cancelar</button>
</div> </div>

View File

@@ -2,11 +2,15 @@
<h3 class="modal-title">Actualizar Estudiante</h3> <h3 class="modal-title">Actualizar Estudiante</h3>
</div> </div>
<div style="text-align: center" class="modal-body"> <div style="text-align: center" class="modal-body">
{{ mensaje }} {{ vm.mensaje }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-show="botonOk" type="button" <button class="btn btn-primary"
ng-show="vm.botonOk"
type="button"
ng-click="ok()">Aceptar</button> ng-click="ok()">Aceptar</button>
<button class="btn btn-warning" ng-show="botonCancelar" type="button" <button class="btn btn-warning"
ng-show="vm.botonCancelar"
type="button"
ng-click="cancel()">Cancelar</button> ng-click="cancel()">Cancelar</button>
</div> </div>

View File

@@ -18,16 +18,10 @@
$stateProvider $stateProvider
.state('StudentCreate', { .state('StudentCreate', {
parent: 'index',
url: '/StudentCreate', url: '/StudentCreate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/students/student_create.html', templateUrl: 'partials/students/student_create.html',
controller: 'StudentCreateCtrl', controller: 'StudentCreateCtrl',
controllerAs: 'vm' controllerAs: 'vm'
@@ -35,16 +29,10 @@
} }
}) })
.state('StudentUpdate', { .state('StudentUpdate', {
parent: 'index',
url: '/StudentUpdate', url: '/StudentUpdate',
views: { views: {
sidebar: { 'content@': {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'SidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/students/student_update.html', templateUrl: 'partials/students/student_update.html',
controller: 'StudentUpdateCtrl', controller: 'StudentUpdateCtrl',
controllerAs: 'vm' controllerAs: 'vm'

View File

@@ -5,15 +5,16 @@
.module('app.student') .module('app.student')
.controller('StudentCreateCtrl', StudentCreateCtrl) .controller('StudentCreateCtrl', StudentCreateCtrl)
StudentCreateCtrl.$inject = ['$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse']; StudentCreateCtrl.$inject = ['$scope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse', 'authentication'];
function StudentCreateCtrl($scope, $rootScope, $state, professors, $modal, selectedSection, selectedCourse){ function StudentCreateCtrl($scope, $state, professors, $modal, selectedSection, selectedCourse, authentication){
var vm = this; var vm = this;
var duplicated = false; var duplicated = false;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.professor = {}; vm.professor = {};
$rootScope.mensaje = ""; vm.mensaje = "";
$rootScope.actOk = false; vm.actOk = false;
professors.get({ id: professorid }, professors.get({ id: professorid },
function (successResult){ function (successResult){
@@ -25,7 +26,6 @@
}); });
vm.submit = function() { vm.submit = function() {
if (vm.data_input_form.$valid){ if (vm.data_input_form.$valid){
var person = { var person = {
"id": vm.estudiante.Cedula, "id": vm.estudiante.Cedula,
@@ -34,18 +34,11 @@
"email": vm.estudiante.Correo "email": vm.estudiante.Correo
}; };
$rootScope.crearEstudianteLoading = true; vm.botonOk = false;
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/students/modal/create_students_modal.html', templateUrl: 'partials/students/modal/create_students_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return $rootScope.items;
}
}
}); });
angular.forEach (vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students, angular.forEach (vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students,
@@ -57,24 +50,18 @@
professors.update({ id: professorid }, vm.professor, professors.update({ id: professorid }, vm.professor,
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.urlLo = 'actualizarMatricula'; vm.mensaje = "Estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre + " agregado";
$rootScope.mensaje = "Estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre + " agregado";
$rootScope.crearEstudianteLoading = false;
}, },
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Error al agregar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre; vm.mensaje = "Error al agregar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre;
$rootScope.crearEstudianteLoading = false;
}); });
} else { } else {
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Estudiante con cedula " + vm.estudiante.Cedula + " ya esta en la lista."; vm.mensaje = "Estudiante con cedula " + vm.estudiante.Cedula + " ya esta en la lista.";
$rootScope.crearEstudianteLoading = false;
} }
}else{
vm.submitted = true;
} }
} }
@@ -87,17 +74,8 @@
$scope.modalInstance.dismiss('cancel'); $scope.modalInstance.dismiss('cancel');
}; };
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
vm.back = function () { vm.back = function () {
$state.go('SectionUpdate'); $state.go('SectionUpdate');
}; };
return vm;
}; };
})(); })();

View File

@@ -5,14 +5,15 @@
.module('app.student') .module('app.student')
.controller('StudentUpdateCtrl', StudentUpdateCtrl) .controller('StudentUpdateCtrl', StudentUpdateCtrl)
StudentUpdateCtrl.$inject = ['$scope', '$rootScope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse', 'data']; StudentUpdateCtrl.$inject = ['$scope', '$state', 'professors', '$modal', 'selectedSection', 'selectedCourse', 'data', 'authentication'];
function StudentUpdateCtrl($scope, $rootScope, $state, professors, $modal, selectedSection, selectedCourse, data){ function StudentUpdateCtrl($scope, $state, professors, $modal, selectedSection, selectedCourse, data, authentication){
var vm = this; var vm = this;
var professorid = $rootScope.professorId; var user = authentication.currentUser();
var professorid = user._id;
vm.professor = {}; vm.professor = {};
$rootScope.mensaje = ""; vm.mensaje = "";
$rootScope.actOk = false; vm.actOk = false;
vm.newMail = null; vm.newMail = null;
vm.student = data.Student vm.student = data.Student
@@ -36,18 +37,11 @@
if (vm.data_input_form.$valid){ if (vm.data_input_form.$valid){
vm.student.email = vm.newMail; vm.student.email = vm.newMail;
$rootScope.crearEstudianteLoading = true; vm.botonOk = false;
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({ $scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/students/modal/update_students_modal.html', templateUrl: 'partials/students/modal/update_students_modal.html',
scope: $scope, scope: $scope,
size: 'sm', size: 'sm'
resolve: {
items: function () {
return $rootScope.items;
}
}
}); });
vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students.splice(data.Index, 1); vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students.splice(data.Index, 1);
@@ -56,12 +50,12 @@
professors.update({ id: professorid }, vm.professor, professors.update({ id: professorid }, vm.professor,
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Estudiante " + vm.student.lastname + ", " + vm.student.name + " actualizado"; vm.mensaje = "Estudiante " + vm.student.lastname + ", " + vm.student.name + " actualizado";
}, },
function(){ function(){
$rootScope.botonOk = true; vm.botonOk = true;
$rootScope.mensaje = "Error al actualizar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre; vm.mensaje = "Error al actualizar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre;
}); });
} }
}; };

View File

@@ -1,16 +1,30 @@
var mongoose = require('mongoose'); var mongoose = require('mongoose');
var express = require('express'); var express = require('express');
var path = require ('path');
var favicon = require ('serve-favicon');
var logger = require('morgan');
var cookieparser = require('cookie-parser');
var app = express(); var app = express();
var db = mongoose.connection; var db = mongoose.connection;
//var Professor = require('./models/professor'); var crypto = require('crypto');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
var jwbt = require('jsonwebtoken');
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport('smtps://reynaldo.reyes.4@gmail.com:zwvdhyensrwnfipt@smtp.gmail.com');
var jwt = require('express-jwt');
var auth = jwt({
secret: 'MY_SECRET',
userProperty: 'payload'
});
app.use(express.static(__dirname)); app.use(express.static(__dirname));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(function (err, req, res, next) {
var nodemailer = require('nodemailer'); if (err.name === 'UnauthorizedError') {
res.status(401);
// create reusable transporter object using the default SMTP transport res.json({"message" : err.name + ": " + err.message});
var transporter = nodemailer.createTransport('smtps://reynaldo.reyes.4@gmail.com:zwvdhyensrwnfipt@smtp.gmail.com'); }
});
db.on('error', console.error); db.on('error', console.error);
db.once('open', function() { db.once('open', function() {
@@ -47,21 +61,59 @@ db.once('open', function() {
}); });
var professorSchema = new mongoose.Schema({ var professorSchema = new mongoose.Schema({
id: Number, id: {
type: Number,
unique: true,
required: true
},
name: String, name: String,
lastname: String, lastname: String,
email: String, email: String,
number: String, number: String,
role: String, role: String,
password: String, hash: String,
salt: String,
courses: [courseSchema] courses: [courseSchema]
}); });
var Professor = mongoose.model('Professor', professorSchema); professorSchema.methods.setPassword = function(password){
this.salt = crypto.randomBytes(16).toString('hex');
this.hash = crypto.pbkdf2Sync(password, this.salt, 1000, 64).toString('hex');
};
//Professor CRUD professorSchema.methods.validPassword = function(password){
var hash = crypto.pbkdf2Sync(password, this.salt, 1000, 64).toString('hex');
return this.hash === hash;
};
app.get('/professors', function(req, res){ professorSchema.methods.generateJwt = function() {
var profile = {
_id: this._id,
role: this.role
};
return jwbt.sign(profile, "MY_SECRET", { expiresIn: 18000 });
};
var Professor = mongoose.model('professor', professorSchema);
var passport = require('passport')
, LocalStrategy = require('passport-local').Strategy;
passport.use(new LocalStrategy({
usernameField: 'id'
},
function(username, password, done) {
Professor.findOne({ id: username }, function (err, professor) {
if (err) return done(err);
if (!professor) return done(null, false, {message: 'professor not found'});
if (!professor.validPassword(password)) return done(null, false, {message: 'Password is wrong'});
return done(null, professor);
});
}));
app.use(passport.initialize());
app.get('/professors', auth, function(req, res){
console.log('Received GET ALL professors request'); console.log('Received GET ALL professors request');
Professor.find(function(err, docs){ Professor.find(function(err, docs){
//console.log(docs); //console.log(docs);
@@ -69,7 +121,7 @@ db.once('open', function() {
}) })
}); });
app.get('/professors/:id', function(req, res){ app.get('/professors/:id', auth, function(req, res){
console.log('Received GET professor request'); console.log('Received GET professor request');
console.log(req.params); console.log(req.params);
Professor.findById(req.params.id, Professor.findById(req.params.id,
@@ -90,11 +142,9 @@ db.once('open', function() {
email: req.body.email, email: req.body.email,
number: req.body.number, number: req.body.number,
role: req.body.role, role: req.body.role,
password: req.body.password, course: [{ name:"Materia" }]
course: [
{ name:"Materia" }
]
}) })
professor.setPassword(req.body.password);
professor.save( professor.save(
function(err, docs){ function(err, docs){
@@ -106,19 +156,18 @@ db.once('open', function() {
text: 'Este es un correo automatizado para informarle que ha sido registrado en la aplicación M.A.S.A. sus credenciales son: '+ req.body.id +' / '+ req.body.password, text: 'Este es un correo automatizado para informarle que ha sido registrado en la aplicación M.A.S.A. sus credenciales son: '+ req.body.id +' / '+ req.body.password,
html: 'Este es un correo automatizado para informarle que ha sido registrado en la aplicación <b> M.A.S.A.</b> sus credenciales son: '+ req.body.id +' / '+ req.body.password html: 'Este es un correo automatizado para informarle que ha sido registrado en la aplicación <b> M.A.S.A.</b> sus credenciales son: '+ req.body.id +' / '+ req.body.password
}; };
// send mail with defined transport object // send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){ transporter.sendMail(mailOptions, function(error, info){
if(error){ if(error) return console.log(error);
return console.log(error);
}
console.log('Message sent: ' + info.response); console.log('Message sent: ' + info.response);
}); });
res.json(docs); var token = professor.generateJwt();
res.status(200);
res.json({"token" : token});
}) })
}); });
app.delete('/professors/:id', function(req, res){ app.delete('/professors/:id', auth, function(req, res){
console.log("Received DELETE professor request..."); console.log("Received DELETE professor request...");
console.log(req.params); console.log(req.params);
Professor.findByIdAndRemove(req.params.id, Professor.findByIdAndRemove(req.params.id,
@@ -128,7 +177,7 @@ db.once('open', function() {
}); });
}); });
app.put('/professors/:id', function(req, res){ app.put('/professors/:id', auth, function(req, res){
console.log("Received UPDATE professor request"); console.log("Received UPDATE professor request");
console.log("params:" + req.params); console.log("params:" + req.params);
console.log("body:" + req.body); console.log("body:" + req.body);
@@ -147,9 +196,30 @@ db.once('open', function() {
}); });
}); });
}); });
app.post('/login', function(req, res){
passport.authenticate('local', function(err, professor, info){
var token;
// If Passport throws/catches an error
if (err) {
res.status(404).json(err);
return;
}
// If a user is found
if(professor){
token = professor.generateJwt();
res.status(200);
res.json({
"token" : token
});
// If user is not found
} else {
res.status(401).json(info);
}
})(req, res);
});
}); });
mongoose.connect('mongodb://localhost/AttendanceDB'); mongoose.connect('mongodb://localhost/AttendanceDB');
app.listen(3000); app.listen(3000);
console.log("server running on port 3000"); console.log("server running on port 3000");

View File

@@ -1,7 +1,7 @@
{ {
"name": "masa-front", "name": "masa",
"version": "1.0.0", "version": "1.0.0",
"description": "Frontend for M.A.S.A. App.", "description": "NPM Package for M.A.S.A. App.",
"main": "app/index.html", "main": "app/index.html",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
@@ -17,8 +17,16 @@
}, },
"dependencies": { "dependencies": {
"body-parser": "latest", "body-parser": "latest",
"express" : "latest", "cookie-parser": "^1.4.1",
"gulp":"latest", "express": "latest",
"mongoose":"latest" "express-jwt": "^3.4.0",
"favicon": "0.0.2",
"gulp": "latest",
"jsonwebtoken": "^6.2.0",
"mongoose": "latest",
"morgan": "^1.7.0",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"serve-favicon": "^2.3.0"
} }
} }