Update routes, mongoose schema and web flow

This commit is contained in:
Reynaldo Reyes
2016-03-27 23:24:28 -04:30
parent b8b65e64d7
commit 7fff896e43
34 changed files with 735 additions and 631 deletions

View File

@@ -0,0 +1,170 @@
(function(){
'use strict';
angular
.module('app.course')
.controller('listarMateriaCtrl',listarMateriaCtrl)
.controller('crearMateriaCtrl', crearMateriaCtrl)
listarMateriaCtrl.$inject =
['$scope', '$rootScope', '$location', 'professors', '$modal', 'profesorSeleccionado', 'selectedCourse'];
function listarMateriaCtrl($scope, $rootScope, $location, professors, $modal, profesorSeleccionado, selectedCourse) {
var vm = this;
var professorid = '56f5fd3a20047f3c15b05f0e';
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
vm.course = vm.professor.courses;
},
function (){
console.log("Error al obtener los datos.");
});
vm.listarSecciones = function (index) {
selectedCourse._id = vm.course[index]._id;
$location.url('listarMatricula');
};
vm.eliminarMateriaModal = function (index) {
$rootScope.index = index;
$rootScope.botonOk = true;
$rootScope.otroBotonOk = false;
$rootScope.botonCancelar = true;
$rootScope.rsplice = false;
$rootScope.mensaje = "¿Seguro que desea eliminar la materia?";
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: '/partials/course/modal/delete_course_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return "";
}
}
});
};
vm.eliminarMateria = function (index) {
$rootScope.botonOk = false;
$rootScope.otroBotonOk = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarMateria';
var name = vm.course[index].name;
vm.professor.courses.splice(index, 1);
professors.update({ id: professorid }, vm.professor,
function () {
$rootScope.mensaje = "Materia " + name + " eliminada";
},
function () {
$rootScope.mensaje = "Error eliminando la materia" + name;
});
};
/*vm.modificarMateria = function (index) {
$location.url('modificarMateria');
};*/
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
crearMateriaCtrl.$inject =
['$scope','$rootScope', '$modal', '$location', 'professors'];
function crearMateriaCtrl($scope, $rootScope, $modal, $location, professors) {
var vm = this;
vm.submitted = false;
vm.mayorque = false;
$rootScope.mensaje = "";
var professorid = '56f5fd3a20047f3c15b05f0e';
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
},
function (){
console.log("Error al obtener los datos.");
});
vm.submit = function() {
if (vm.data_input_form.$valid){
vm.course = {
"code": vm.course.code,
"name": vm.course.name,
"credits": vm.course.credits,
"description" : vm.course.description,
};
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl:
'/partials/course/modal/create_course_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
});
vm.professor.courses.push(vm.course);
professors.update({ id: professorid }, vm.professor,
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'listarMateria';
$rootScope.mensaje =
"Materia " + vm.course.name + " creada";
},
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'listarMateria';
$rootScope.mensaje =
"Error creando la materia " + vm.course.name;
});
}else{
vm.submitted = true;
}
}
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
})();

View File

@@ -0,0 +1,57 @@
(function(){
'use strict';
angular
.module("app.course", ['ui.router', 'ui.bootstrap'])
.run(addStateToScope)
.config(getRoutes);
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
function addStateToScope($rootScope, $state, $stateParams){
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
};
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/listarMaterias');
$stateProvider
.state('listarMateria', {
url: '/listarMateria',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/course/list_course.html',
controller: 'listarMateriaCtrl',
controllerAs: "vm"
}
}
})
.state('crearMateria', {
url: '/crearMateria',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/course/create_course.html',
controller: 'crearMateriaCtrl',
controllerAs: "vm"
}
}
})
};
})();

View File

@@ -0,0 +1,12 @@
(function(){
'use strict';
angular
.module('app.course')
.factory('courses', courses);
courses.$inject = ['$resource','$rootScope'];
function courses($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/courses/:id', null);
};
})();

View File

@@ -7,52 +7,52 @@
<thead>
<tr>
<th width="10%">
<a href="" ng-click="sortType = 'code';
sortReverse = !sortReverse">
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>
</a>
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 width="20%">
<a href="" ng-click="sortType = 'name';
sortReverse = !sortReverse">
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>
</a>
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 width="10%">
<a href=""
ng-click="sortType = 'credits';
sortReverse = !sortReverse">
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>
</a>
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 width="50%" style="text-align: center">
<a href="">
Descripción
</a>
<th width="40%" style="text-align: center">
Descripción
</th>
<th width="10%" style="text-align: center">
<a>Eliminar</a>
Secciones
</th>
<th width="10%" style="text-align: center">
Eliminar
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="course in vm.course | orderBy:sortType:sortReverse | filter:searchUser">
<tr ng-repeat="course in vm.course">
<td style="vertical-align:middle">{{ course.code }}</td>
<td style="vertical-align:middle">{{ course.name }}</td>
<td style="vertical-align:middle">{{ course.credits }}</td>
<td style="vertical-align:middle">{{ course.description }}</td>
<td style="text-align: center">
<span
title="Click aqui para ver Secciones"
class="glyphicon glyphicon-list"
aria-hidden="true"
ng-click="vm.listarSecciones($index)"
style="cursor:pointer"></span>
</td>
<td style="text-align: center">
<span
title="Click aqui para Eliminar la Materia"
@@ -61,10 +61,8 @@
ng-click="vm.eliminarMateriaModal($index)"
style="cursor:pointer"></span>
</td>
</tr>
</tbody>
</table>
</div>
<div ng-show=false > {{ vm.eliminarMateriaSplice(index, rsplice) }}</div>
</div>

View File

@@ -0,0 +1,86 @@
(function(){
'use strict';
angular
.module('app.login')
.controller('loginCtrl', loginCtrl)
loginCtrl.$inject = ['$rootScope', '$scope', '$location'];
function loginCtrl($rootScope, $scope, $location){
/*var vm = this;
vm.user = user;
vm.submitted = false;
vm.mayorque = false;
$rootScope.items = "";
$rootScope.mensaje = "";
vm.submit = function() {
if (vm.data_input_form.$valid){
vm.pkg = {
"Nickname": vm.user.Nickname,
"Password": $rootScope.password
};
$rootScope.mensaje = "";
$rootScope.bcancel = false;
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'LoginModal.html',
scope: $scope,
size: 'sm',
resolve: {
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(){
});
}else{
vm.submitted = true;
}
}
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
return vm; */
};
})();

View File

@@ -0,0 +1,65 @@
<form name="vm.data_input_form" role="form" novalidate ng-submit="vm.submit()">
<div class="row clearfix">
<div class="col-md-10 column well">
<h4 style="text-align: center">Ingrese sus Datos</h4>
<div class="row" >
<div class="col-md-4 column">
</div>
<div class="col-md-4 column">
<label for="nickname">Cedula de Identidad del Profesor</label>
<input type="text" class="form-control" id="nickname" name="nickname" ng-model="vm.user.Nickname" required/>
<div class="error" ng-show="vm.submitted && vm.data_input_form.nickname.$invalid">
<small class="error" ng-show="vm.data_input_form.nickname.$error.required">
{{'TAG_NICK_NAME_ERROR'}}
</small>
</div>
</div>
</div>
<div class="row clearfix"><div class="col-md-12 column"><br><br></div></div>
<div class="row">
<div class="col-md-4 column">
</div>
<div class="col-md-4 column">
<label for="password">Contraseña</label>
<input type="password" class="form-control" id="password" name="password" ng-model="vm.user.Password" maxlength="8" required/>
<div ng-show=false> {{ vm.password = vm.user.Password }}</div>
<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">
{{'TAG_PASSWORD_ERROR'}}
</small>
</div>
<div ng-show=false>{{getHash(vm.password)}}</div>
</div>
</div>
</div> <!-- end column -->
</div> <!-- end row -->
<div class="row clearfix">
<div class="col-md-2 column">
<div class="form-group">
<label>&nbsp;</label>
<p class="input-group">
<span class="input-group-btn">
<button type="submit" id="submit" class="btn-primary btn" >Ingresar</button>
</span>
</p>
</div>
</div>
</div> <!-- end row -->
<script type="text/ng-template" id="myModalContentLogin.html">
<div class="modal-header">
<h3 class="modal-title">Censys</h3>
</div>
<div style="text-align: center" class="modal-body">
<div ng-show="loadingLogin" style="text-align: center" class="loading"><img src="img/login-loading.gif"></div>
{{ mensaje }}
<div ng-show=false> {{ index }}</div>
</div>
<div class="modal-footer">
<div ng-show=false > {{ okLogin(actOk, urlLo) }}</div>
<button class="btn btn-warning" ng-show="bcancel" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
</form>

View File

@@ -0,0 +1,30 @@
(function(){
'use strict';
angular
.module("app.login", ['ui.router', 'ui.bootstrap'])
.run(addStateToScope)
.config(getRoutes);
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
function addStateToScope($rootScope, $state, $stateParams){
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
};
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/');
$stateProvider
.state('root', {
url: '',
views: {
content: {
templateUrl: 'partials/login/login.html',
controller: 'loginCtrl',
controllerAs: 'vm'
}
}
})
};
})();

View File

@@ -0,0 +1,49 @@
(function(){
'use strict';
angular
.module('app.login')
.factory('Login', Login)
.factory('GetRol', GetRol)
.factory('hash', hash)
.value('algoritmo','SHA-1')
.value('user',{})
.value('id',{})
Login.$inject = ['$resource','$rootScope'];
function Login($resource, $rootScope){
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

@@ -75,6 +75,15 @@
El Formato del Número de Teléfono es incorrecto.
</small>
</div>
<div class="col-md-4 column">
<label for="password">Contraseña</label>
<input type="password" class="form-control" ng-model="vm.profesor.Password" maxlength="8" required/>
<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">
La Contraseña del Profesor es obligatorio.
</small>
</div>
</div>
</div>
</div>
</div>

View File

@@ -6,31 +6,25 @@
<thead>
<tr>
<th width="20%">
<a href="" ng-click="sortType = 'Cedula'; sortReverse = !sortReverse">
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>
</a>
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 width="20%">
<a href="" ng-click="sortType = 'Nombre'; sortReverse = !sortReverse">
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>
</a>
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 width="20%">
<a href="" ng-click="sortType = 'Apellido'; sortReverse = !sortReverse">
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>
</a>
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 width="20%" style="text-align: center">
<a>Modificar</a>
Modificar
</th>
<th width="20%" style="text-align: center">
<a>Borrar</a>
Borrar
</th>
</tr>
</thead>
@@ -49,5 +43,4 @@
</tbody>
</table>
</div>
<div ng-show=false > {{ vm.removeProfesorSplice(index, rsplice) }}</div>
</div>

View File

@@ -0,0 +1,259 @@
(function(){
'use strict';
angular
.module('app.professor')
.controller('listarProfesorCtrl', listarProfesorCtrl)
.controller('crearProfesorCtrl', crearProfesorCtrl)
.controller('actualizarProfesorCtrl', actualizarProfesorCtrl)
listarProfesorCtrl.$inject =
[ '$scope', '$rootScope', '$location', 'professors', '$modal', 'profesorSeleccionado' ];
function listarProfesorCtrl( $scope, $rootScope, $location, professors, $modal, profesorSeleccionado ){
var vm = this;
vm.lista = true;
$rootScope.actOk = false;
$rootScope.loading = true;
$rootScope.table = false;
var profesorArray = [];
professors.query(
function (successResult){
vm.profesor = successResult;
angular.forEach(vm.profesor, function (value){
profesorArray.push({
Cedula:value.id,
Nombre:value.name,
Apellido:value.lastname,
Telefono:value.number,
Correo: value.email
});
});
$rootScope.loading = false;
$rootScope.table = true;
vm.listaProfesor = profesorArray;
},
function(){
console.log("Error al obtener los datos.");
});
vm.eliminarProfesorModal = function (index) {
$rootScope.index = index;
$rootScope.botonOK = true;
$rootScope.botonCancelar = true;
$rootScope.acceptButton = false;
$rootScope.rsplice = false;
$rootScope.mensaje = "¿Seguro que desea eliminar el Profesor?";
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/professor/modal/list_professor_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return "";
}
}
});
};
vm.eliminarProfesor = function (index) {
$rootScope.botonOK = false;
$rootScope.acceptButton = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarProfesor';
professors.delete({id: vm.profesor[index]._id},
function () {
$rootScope.rsplice = true;
$rootScope.mensaje =
"Profesor " + vm.profesor[index].name + " eliminado";
},
function () {
$rootScope.listarProfesorsLoading = false;
$rootScope.mensaje =
"Error eliminando al Profesor " + vm.profesor[index].name;
});
};
vm.removeProfesorSplice = function(index, rsplice) {
if(rsplice){
vm.listaProfesor.splice(index, 1);
$rootScope.rsplice = false;
}
};
vm.modificarProfesor = function (index) {
profesorSeleccionado._id = vm.profesor[index]._id;
profesorSeleccionado.Cedula = vm.profesor[index].id;
profesorSeleccionado.Nombre = vm.profesor[index].name;
profesorSeleccionado.Apellido= vm.profesor[index].lastname;
profesorSeleccionado.Telefono = vm.profesor[index].number;
profesorSeleccionado.Correo= vm.profesor[index].email;
$location.url('actualizarProfesor');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
return vm;
};
crearProfesorCtrl.$inject =
['$scope','$rootScope', '$location', 'professors', '$modal'];
function crearProfesorCtrl($scope, $rootScope, $location, professors, $modal){
var vm = this;
$rootScope.mensaje = "";
vm.submit = function() {
if (vm.data_input_form.$valid){
var professor = {
"id": vm.profesor.Cedula,
"name": vm.profesor.Nombre,
"lastname": vm.profesor.Apellido,
"email": vm.profesor.Correo,
"number": vm.profesor.Telefono,
"role": "professor",
"password": vm.profesor.Password
};
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/professor/modal/create_professor_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
});
professors.save(professor,
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'listarProfesor';
$rootScope.mensaje =
"Profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre + " agregado";
},
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'listarProfesor';
$rootScope.mensaje =
"Error al agregar al profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre;
});
}else{
vm.submitted = true;
}
}
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
actualizarProfesorCtrl.$inject =
['$scope','$rootScope', '$location', 'professors', '$modal', 'profesorSeleccionado' ];
function actualizarProfesorCtrl ( $scope, $rootScope, $location, professors, $modal, profesorSeleccionado ){
var vm = this;
vm.profesor = profesorSeleccionado;
$rootScope.mensaje = "";
$rootScope.actOk = false;
vm.submit = function() {
var professor = {
"id": vm.profesor.Cedula,
"name": vm.profesor.Nombre,
"lastname": vm.profesor.Apellido,
"email": vm.profesor.Correo,
"number": vm.profesor.Telefono,
"role": "professor",
"password": vm.profesor.Password
};
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/professor/modal/update_professor_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
});
professors.update({ id: vm.profesor._id}, professor,
function(){
$rootScope.botonOk = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarProfesor';
$rootScope.mensaje =
"Profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre + " actualizado";
},
function(){
$rootScope.botonOk = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarProfesor';
$rootScope.mensaje =
"Error al modificar al profesor " + vm.profesor.Apellido + ", " + vm.profesor.Nombre;
});
}
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
})();

View File

@@ -0,0 +1,75 @@
(function(){
'use strict';
angular
.module("app.professor", ['ui.router', 'ui.bootstrap'])
.run(addStateToScope)
.config(getRoutes);
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
function addStateToScope($rootScope, $state, $stateParams){
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
};
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/listarProfesor');
$stateProvider
.state('listarProfesor', {
url: '/listarProfesor',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/professor/list_professor.html',
controller: 'listarProfesorCtrl',
controllerAs: 'vm'
}
}
})
.state('crearProfesor', {
url: '/crearProfesor',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/professor/create_professor.html',
controller: 'crearProfesorCtrl',
controllerAs: 'vm'
}
}
})
.state('actualizarProfesor', {
url: '/actualizarProfesor',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/professor/update_professor.html',
controller: 'actualizarProfesorCtrl',
controllerAs: 'vm'
}
}
})
};
})();

View File

@@ -0,0 +1,18 @@
(function(){
'use strict';
angular
.module('app.professor')
.factory('professors', professors)
.value('selectedCourse',{})
.value('selectedSection',{})
.value('profesorSeleccionado',{});
professors.$inject = ['$resource','$rootScope'];
function professors($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/professors/:id', null,
{
'update': {method:'PUT'}
});
};
})();

View File

@@ -0,0 +1,105 @@
(function(){
'use strict';
angular
.module('app.reports')
.controller('poblacionNacimientoCtrl', poblacionNacimientoCtrl)
.controller('poblacionActivaCtrl', poblacionActivaCtrl)
.controller('hombresEdadCtrl', hombresEdadCtrl)
.controller('mujeresEdadCtrl', mujeresEdadCtrl)
.controller('comidasDiaCtrl', comidasDiaCtrl)
.controller('nivelEducacionCtrl', nivelEducacionCtrl)
.controller('serviciosHogaresCtrl', serviciosHogaresCtrl)
.controller('ingresosAnualesCtrl', ingresosAnualesCtrl)
poblacionNacimientoCtrl.$inject = ['$rootScope', 'ReportJson'];
function poblacionNacimientoCtrl($rootScope, ReportJson){
$rootScope.labelPoblacionNacimiento = ['Extranjeros', 'Residentes'];
ReportJson.get({id:$rootScope.elementId}, function(data) {
$rootScope.dataPoblacionNacimiento = data.Data[0].dataPoblacionNacimiento;
});
};
poblacionActivaCtrl.$inject = ['$rootScope', 'ReportJson'];
function poblacionActivaCtrl($rootScope, ReportJson){
$rootScope.labelsPoblacionActiva = ['Hombres', 'Mujeres'];
$rootScope.seriesPoblacionActiva = ['Economicamente Pasivos', 'Economicamente Activos'];
$rootScope.dataPoblacionActiva = [];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataPoblacionActiva = data.Data[0].dataPoblacionActiva;
});
};
hombresEdadCtrl.$inject = ['$rootScope', 'ReportJson'];
function hombresEdadCtrl($rootScope, ReportJson){
$rootScope.labelsHombresEdad = ['0-6', '7-12','13-18', '19-25','26-44', '45-60','61-99', '80-84', '90+'];
$rootScope.seriesHombresEdad = ['Hombres por Generacion'];
$rootScope.dataHombresEdad = [];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataHombresEdad = data.Data[0].dataHombresEdad;
});
};
mujeresEdadCtrl.$inject = ['$rootScope', 'ReportJson'];
function mujeresEdadCtrl($rootScope, ReportJson){
$rootScope.labelsMujeresEdad = ['0-6', '7-12','13-18', '19-25','26-44', '45-60','61-99', '80-84', '90+'];
$rootScope.seriesMujeresEdad = ['Mujeres por Generacion'];
$rootScope.dataMujeresEdad = [];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataMujeresEdad = data.Data[0].dataMujeresEdad;
});
};
comidasDiaCtrl.$inject = ['$rootScope', 'ReportJson'];
function comidasDiaCtrl($rootScope, ReportJson){
$rootScope.labelsComidasDia = ['Desayuno', 'Almuerzo', 'Cena'];
$rootScope.dataComidasDia = [];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataComidasDia = [data.Data[0].dataComidasDia];
});
};
nivelEducacionCtrl.$inject = ['$rootScope', 'ReportJson'];
function nivelEducacionCtrl($rootScope, ReportJson){
$rootScope.labelsNivelEducacion = ['Nivel de Educacion Superior', 'Nivel de Educacion Media'];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataNivelEducacion = data.Data[0].dataNivelEducacion;
});
};
serviciosHogaresCtrl.$inject = ['$rootScope', 'ReportJson'];
function serviciosHogaresCtrl($rootScope, ReportJson){
$rootScope.labelsServiciosHogares = ['Agua', 'Gas', 'Electricidad' , 'Linea Telefonica'];
$rootScope.dataServiciosHogares = [];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataServiciosHogares = [data.Data[0].dataServiciosHogares];
});
};
ingresosAnualesCtrl.$inject = ['$rootScope', 'ReportJson'];
function ingresosAnualesCtrl($rootScope, ReportJson){
$rootScope.labelsIngresosAnuales = ['Menos de 10.000', 'De 11.000 a 20.000', 'De 21.000 a 35.000' , 'De 35.000 a 50.000'];
ReportJson.get({id:$rootScope.elementId},function(data) {
$rootScope.dataIngresosAnuales = data.Data[0].dataIngresosAnuales;
});
};
})();

View File

@@ -0,0 +1,81 @@
(function(){
'use strict';
angular
.module("app.reports", ['ui.router', 'ui.bootstrap', 'chart.js'])
.run(addStateToScope)
.config(getRoutes);
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
function addStateToScope($rootScope, $state, $stateParams){
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
};
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/reportes');
$stateProvider
.state('poblacionNacimiento', {
url: '/reportes',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/reportes/reportes.html',
controller: 'poblacionNacimientoCtrl',
controllerAs: 'vm'
}
}
})
.state('poblacionActiva', {
url: '/poblacionActivaCtrl',
templateUrl: 'partials/reportes/reportes.html',
controller: 'poblacionActivaCtrl',
controllerAs: 'vm'
})
.state('hombresEdad', {
url: '/hombresEdad',
templateUrl: 'partials/reportes/reportes.html',
controller: 'hombresEdadCtrl',
controllerAs: 'vm'
})
.state('mujeresEdad', {
url: '/mujeresEdad',
templateUrl: 'partials/reportes/reportes.html',
controller: 'mujeresEdadCtrl',
controllerAs: 'vm'
})
.state('comidasDia', {
url: '/comidasDia',
templateUrl: 'partials/reportes/reportes.html',
controller: 'comidasDiaCtrl',
controllerAs: 'vm'
})
.state('nivelEducacion', {
url: '/nivelEducacion',
templateUrl: 'partials/reportes/reportes.html',
controller: 'nivelEducacionCtrl',
controllerAs: 'vm'
})
.state('serviciosHogares', {
url: '/serviciosHogares',
templateUrl: 'partials/reportes/reportes.html',
controller: 'serviciosHogaresCtrl',
controllerAs: 'vm'
})
.state('ingresosAnuales', {
url: '/ingresosAnuales',
templateUrl: 'partials/reportes/reportes.html',
controller: 'ingresosAnualesCtrl',
controllerAs: 'vm'
})
};
})();

View File

@@ -0,0 +1,16 @@
(function(){
'use strict';
angular
.module('app.reports')
.factory('ReportJson', ReportJson)
.value('id',{})
ReportJson.$inject = ['$resource','$rootScope'];
function ReportJson($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/api/reports/:id');
//var json="data/data.json";
//return $resource(json);
};
})();

View File

@@ -2,25 +2,21 @@
<form name="vm.data_input_form" role="form" novalidate
ng-submit="vm.submit()">
<div class="row clearfix">
<h4>Nueva Matricula</h4>
<h4>Nueva Sección</h4>
<br>
<div class="col-md-12 column well">
<div class="row">
<div class="col-md-4 column">
<label>Nombre de la Materia</label>
<select
class="form-control"
ng-model="vm.valorMateria"
ng-options="materia.name for materia in vm.materias"
>
<option value="">{{materia.name}}</option>
</select>
<input type="text" class="form-control"
name="materia" readonly="readonly"
ng-model="vm.course.name" required/>
</div>
<div class="col-md-4 column">
<label for="codigo">Codigo de la Materia</label>
<input type="text" class="form-control"
name="codigo" readonly="readonly"
ng-model="vm.valorMateria.code" required/>
ng-model="vm.course.code" required/>
</div>
<div class="col-md-4 column">
<label for="semestre">Semestre</label>
@@ -72,6 +68,49 @@
</p>
</div>
</div>
</div>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th width="20%">
<a href="" ng-click="sortType = 'Cedula';
sortReverse = !sortReverse">
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>
</a>
</th>
<th width="40%">
<a href="" ng-click="sortType = 'Apellido';
sortReverse = !sortReverse">
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>
</a>
</th>
<th width="40%">
<a href="" ng-click="sortType = 'Nombre';
sortReverse = !sortReverse">
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>
</a>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="student in vm.students">
<td style="vertical-align:middle">{{ student.id }}</td>
<td style="vertical-align:middle">{{ student.lastname }}</td>
<td style="vertical-align:middle">{{ student.name }}</td>
</tr>
</tbody>
</table>
</form>
</div>

View File

@@ -1,50 +1,42 @@
<div class="row clearfix">
<h4>Listado de Secciones</h4></br>
<div>
<button class="btn-success btn" ng-click="vm.createSection()" style="margin: 10px"> Crear Sección </button>
</br>
</br>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th width="20%">
<a href="" ng-click="sortType = 'name';
sortReverse = !sortReverse">
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>
</a>
</th>
<th width="20%">
<a href=""
ng-click="sortType = 'course'; sortReverse = !sortReverse">
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>
</a>
</th>
<th width="20%">
<a href="" ng-click="sortType = 'code'; sortReverse = !sortReverse">
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>
</a>
</th>
<th width="20%">
<a href="" ng-click="sortType = 'semester'; sortReverse = !sortReverse">
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>
</a>
</th>
<th width="10%" style="text-align: center">
<a>Modificar</a>
Modificar
</th>
<th width="10%" style="text-align: center">
<a>Borrar</a>
Borrar
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat = "section in vm.section | orderBy:sortType:sortReverse | filter:searchUser">
<tr ng-repeat = "section in vm.section">
<td style="vertical-align:middle">{{ section.name }}</td>
<td style="vertical-align:middle">{{ section.course }}</td>
<td style="vertical-align:middle">{{ section.code }}</td>
@@ -65,5 +57,5 @@
</tbody>
</table>
</div>
<div ng-show=false > {{ vm.eliminarMatriculaSplice(index, rsplice) }}</div>
<a href="#listarMateria" class="btn-warning btn" style=" margin: 10px">Regresar</a>
</div>

View File

@@ -0,0 +1,328 @@
(function(){
'use strict';
angular
.module('app.section')
.controller('listarMatriculaCtrl', listarMatriculaCtrl)
.controller('crearMatriculaCtrl', crearMatriculaCtrl)
.controller('actualizarMatriculaCtrl', actualizarMatriculaCtrl)
listarMatriculaCtrl.$inject = [ '$scope', '$rootScope', '$location', 'professors', '$modal', 'selectedCourse', 'selectedSection'];
function listarMatriculaCtrl ( $scope, $rootScope, $location, professors, $modal, selectedCourse, selectedSection ){
var vm = this;
var professorid = '56f5fd3a20047f3c15b05f0e';
vm.section = [];
vm.professor = null;
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
angular.forEach (vm.professor.courses,
function (value, key){
if (value._id == selectedCourse._id ) {
vm.index = key;
vm.section = value.sections;
}
});
},
function (){
console.log("Error al obtener los datos.");
});
/**************************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 () {
$location.url('crearMatricula');
};
vm.eliminarMatriculaModal = function (index) {
$rootScope.index = index;
$rootScope.botonOk = true;
$rootScope.otroBotonOk = false;
$rootScope.botonCancelar = true;
$rootScope.rsplice = false;
$rootScope.mensaje = "¿Seguro que desea eliminar la sección?";
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: '/partials/section/modal/delete_section_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return "";
}
}
});
};
vm.eliminarMatricula = function (index) {
$rootScope.botonOk = false;
$rootScope.otroBotonOk = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarMatricula';
var name = vm.section[index].name;
vm.professor.courses[vm.index].sections.splice(index, 1);
professors.update({ id: professorid }, vm.professor,
function () {
$rootScope.rsplice = true;
$rootScope.mensaje = "Sección " + name + " eliminada";
},
function () {
$rootScope.mensaje = "Error eliminando la sección " + name;
});
};
vm.eliminarMatriculaSplice = function (index, rsplice) {
if(rsplice){
}
};
/*************************Fin de Eliminar Matricula*******************/
vm.modificarMatricula = function (index) {
selectedSection._id = vm.section[index]._id;
selectedCourse.index = vm.index;
$location.url('actualizarMatricula');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
return vm;
};
crearMatriculaCtrl.$inject =
['$scope','$rootScope', '$location', 'professors', '$modal', 'selectedCourse'];
function crearMatriculaCtrl($scope, $rootScope, $location, professors, $modal, selectedCourse){
var professorid = '56f5fd3a20047f3c15b05f0e';
var vm = this;
vm.course = {};
vm.selectedCourse = selectedCourse;
vm.submitted = false;
vm.semester, vm.section, vm.materias;
$rootScope.mensaje = "";
vm.students = [];
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
angular.forEach (vm.professor.courses,
function (value, key){
if (value._id == vm.selectedCourse._id ) {
vm.index = key;
vm.section = value.sections;
vm.course.code = value.code;
vm.course.name = value.name;
}
});
},
function (){
console.log("Error al obtener los datos.");
});
vm.submit = function () {
if (vm.data_input_form.$valid){
vm.package = {
"name": vm.name,
"code": vm.course.code,
"course": vm.course.name,
"semester": vm.semester,
"students": vm.students
};
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/section/modal/create_section_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
});
vm.professor.courses[vm.index].sections.push(vm.package);
professors.update({ id: professorid }, vm.professor,
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'listarMatricula';
$rootScope.mensaje = "Sección " + vm.name + " creada";
},
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'listarMatricula';
$rootScope.mensaje = "Error creando la seccion " + vm.name;
});
}else{
vm.submitted = true;
}
};
var xlf = document.getElementById('xlf');
function handleFile(e) {
var files = e.target.files;
var i,f,z;
var student = {};
for (i = 0, f = files[i]; i != files.length; ++i) {
var reader = new FileReader();
var name = f.name;
reader.onload = function(e) {
var data = e.target.result;
var workbook = XLSX.read(data, {type: 'binary'});
var sheet = workbook.SheetNames[0];
var worksheet = workbook.Sheets[sheet];
/* Find desired cell containing semester and section */
vm.semester = worksheet['B5'].v;
vm.name = worksheet['B9'].v;
//$scope.$apply();
for (z in worksheet) {
/* all keys that do not begin with "!" correspond to cell addresses */
if (z[0] === '!') continue;
if ((z[0] >'B') && (z[1] > 0) && (z[2] > 1)) {
/* Cells that start in the C column represent the sttudent id in the worksheet, the same applies to name and lastname being in D and E columns*/
if (z[0] =='C') student.id = worksheet[z].v;
if (z[0] =='D') student.name = worksheet[z].v;
if (z[0] =='E') student.lastname = worksheet[z].v;
if (z[0] =='F') {
student.email = worksheet[z].v;
/*Since we are only going to use these 3 attributes from the students then we push only this data to the students array*/
vm.students.push(student);
student = {};
}
}
};
$scope.$apply();
};
reader.readAsBinaryString(f);
}
}
if(xlf.addEventListener) xlf.addEventListener('change', handleFile, false);
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
actualizarMatriculaCtrl.$inject = ['$scope', '$rootScope', '$location', 'professors', '$modal', 'selectedSection', 'selectedCourse'];
function actualizarMatriculaCtrl($scope, $rootScope, $location, professors, $modal, selectedSection, selectedCourse){
var professorid = '56f5fd3a20047f3c15b05f0e';
var vm = this;
vm.section = {};
vm.students = [];
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
angular.forEach (vm.professor.courses[selectedCourse.index].sections,
function (value, key){
if (value._id == selectedSection._id ) {
selectedSection.index = key;
vm.students = value.students;
vm.section = value;
}
});
},
function (){
console.log("Error al obtener los datos.");
});
vm.addStudent = function (index) {
$location.url('crearEstudiante');
};
vm.retirarEstudianteModal = function (index) {
$rootScope.index = index;
$rootScope.botonOk = true;
$rootScope.otroBotonOk = false;
$rootScope.botonCancelar = true;
$rootScope.eliminarLoading = false;
$rootScope.mensaje = "¿Desea retirar al estudiante "+ vm.students[index].lastname +", "+ vm.students[index].name + "?";
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/section/modal/update_section_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return "";
}
}
});
};
vm.retirarEstudiante = function (index) {
vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students.splice(index, 1);
professors.update({ id: professorid }, vm.professor,
function (){
$rootScope.botonOk = false;
$rootScope.otroBotonOk = true;
$rootScope.botonCancelar = false;
$rootScope.mensaje = "Sección "+ vm.section.name +" actualizada";
},
function (){
$rootScope.botonOk = false;
$rootScope.otroBotonOk = true;
$rootScope.botonCancelar = false;
$rootScope.mensaje = "Error al actualizar la Sección "+ vm.section.name;
});
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
$scope.ok = function () {
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
return vm;
};
})();

View File

@@ -0,0 +1,78 @@
(function(){
'use strict';
angular
.module("app.section", ['ui.router', 'ui.bootstrap'])
.run(addStateToScope)
.config(getRoutes);
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
function addStateToScope($rootScope, $state, $stateParams){
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
};
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/listarMatricula');
$stateProvider
.state('listarMatricula', {
url: '/listarMatricula',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/section/list_section.html',
controller: 'listarMatriculaCtrl',
controllerAs: 'vm'
}
}
})
.state('crearMatricula', {
url: '/crearMatricula',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/section/create_section.html',
controller: 'crearMatriculaCtrl',
controllerAs: 'vm'
}
}
})
.state('actualizarMatricula', {
url: '/actualizarMatricula',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/section/update_section.html',
controller: 'actualizarMatriculaCtrl',
controllerAs: 'vm'
}
}
})
};
})();

View File

@@ -0,0 +1,16 @@
(function(){
'use strict';
angular
.module('app.section')
.factory('sections', sections)
.value('matriculaSeleccionada',{});
sections.$inject = ['$resource','$rootScope'];
function sections($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/sections/:id', null,
{
'update': {method:'PUT'}
});
};
})();

View File

@@ -1,41 +1,42 @@
<div class="row clearfix">
<h4>Estudiantes Inscritos en {{ vm.section.course }} - Seccion {{ vm.section.name }} - Semestre {{ vm.section.semester }}</h4>
<br>
<button class="btn-success btn" ng-click="vm.addStudent()" style="margin: 10px"> Agregar Estudiante </button><br><br>
<div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th width="20%">
<a href="" ng-click="sortType = 'id'; sortReverse = !sortReverse">
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>
</a>
<th width="10%">
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 width="20%">
<a href="" ng-click="sortType = 'name'; sortReverse = !sortReverse">
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>
</a>
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 width="20%">
<a href="" ng-click="sortType = 'lastname'; sortReverse = !sortReverse">
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>
</a>
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 width="20%" style="text-align: center">
<a>Retirar</a>
<th width="30%">
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 width="10%" style="text-align: center">
Retirar
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="student in vm.students | orderBy:sortType:sortReverse | filter:searchUser">
<tr ng-repeat="student in vm.students">
<td style="vertical-align:middle">{{ student.id }}</td>
<td style="vertical-align:middle">{{ student.name }}</td>
<td style="vertical-align:middle">{{ student.lastname }}</td>
<td style="vertical-align:middle">{{ student.email }}</td>
<td style="text-align: center">
<span title="Click aqui para Eliminar un Estudiante"
class="glyphicon glyphicon-remove" aria-hidden="true"
@@ -46,8 +47,6 @@
</tbody>
</table>
</div>
<button type="button" class="btn-primary btn" ng-click="vm.actualizarMatricula()">Guardar Cambios</button>
<div ng-show = false> {{ vm.retirarEstudianteSplice(index, rsplice) }}</div>
<div class="container-fluid ">
<a href="#listarMatricula" class="btn-warning btn" style=" margin: 10px">Regresar</a>
</div>

View File

@@ -13,8 +13,9 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<div class="container-fluid ">
<a href="#login" class="btn-warning btn" style=" margin: 10px">Salir</a>
<div class="container-fluid">
</br>
<a href="#login" class="btn-danger btn" style=" margin: 10px">Salir</a>
</div>
</ul>
</div>

View File

@@ -0,0 +1,69 @@
(function(){
'use strict';
angular
.module('app')
.controller('sidebarCtrl', sidebarCtrl)
sidebarCtrl.$inject = ['$scope'];
function sidebarCtrl($scope) {
var that = this;
$scope.showChilds = function(item){
item.active = !item.active;
};
$scope.items = [
{
text: 'Modulo de Administración',
subItems: [
{
state: 'listarProfesor',
text: 'Listar Profesores'
},
{
state: 'crearProfesor',
text: 'Agregar Profesores'
}
]
},
{
text: 'Modulo de Materias',
subItems: [
{
state: 'listarMateria',
text: 'Listar Materias'
},
{
state: 'crearMateria',
text: 'Agregar Materia'
}
]
},
{
text: 'Modulo de Reportes',
subItems: [
{
state: 'reportesAlumno',
text: 'Reportes por Alumno'
},
{
state: 'reportesClase',
text: 'Reportes por Clase'
},
{
state: 'reportesSeccion',
text: 'Reportes por Seccion'
},
{
state: 'reportesMateria',
text: 'Reportes por Materia'
}
]
}
];
};
})();

View File

@@ -46,7 +46,7 @@
<br><br></div></div>
<div class="row">
<div class="col-md-4 column">
<label for="correo">Direccion de Correo</label>
<label for="correo">Dirección de Correo</label>
<input type="correo" class="form-control"
name="correo" ng-model="vm.estudiante.Correo"
ng-pattern="/^[a-z]+[a-z0-9._]+@[a-z]+\.[a-z.]{2,5}$/" placeholder="me@example.com" required/>
@@ -62,17 +62,6 @@
</small>
</div>
</div>
<div class="col-md-4 column">
<label for="telefono">Numero de Telefono</label>
<input type="telefono" class="form-control"
name="telefono" ng-model="vm.estudiante.Telefono"
ng-pattern="/\d{4}-\d{3}-\d{4}/" maxlength="13"
placeholder="0424-123-9876"/>
<small class="error"
ng-show="vm.data_input_form.telefono.$error.pattern">
El Formato del Numero de Telefono es incorrecto.
</small>
</div>
</div>
</div>
</div>
@@ -83,11 +72,12 @@
<p class="input-group">
<span class="input-group-btn">
<button type="submit" class="btn-primary btn">
Agregar Alumno</button>
Agregar Alumno </button>
</span>
</p>
</div>
</div>
</div>
</form>
<a href="#actualizarMatricula" class="btn-warning btn" style=" margin: 10px">Regresar</a>
</div>

View File

@@ -0,0 +1,281 @@
(function(){
'use strict';
angular
.module('app.student')
.controller('listarEstudianteCtrl', listarEstudianteCtrl)
.controller('crearEstudianteCtrl', crearEstudianteCtrl)
.controller('actualizarEstudianteCtrl', actualizarEstudianteCtrl)
listarEstudianteCtrl.$inject = [ '$scope', '$rootScope', '$location', 'students', '$modal', 'estudianteSeleccionado' ];
function listarEstudianteCtrl( $scope, $rootScope, $location, students, $modal, estudianteSeleccionado ){
var vm = this;
vm.lista = true;
$rootScope.actOk = false;
$rootScope.loading = true;
$rootScope.table = false;
var estudiantesArray = [];
students.query(
function(data){
vm.estudiantes = data;
angular.forEach(vm.estudiantes, function (value){
estudiantesArray.push({
Cedula:value.id,
Nombre:value.name,
Apellido:value.lastname,
Telefono:value.number,
Correo: value.email
});
});
$rootScope.loading = false;
$rootScope.table = true;
vm.listaEstudiantes = estudiantesArray;
},
function(){
console.log("Error al obtener los datos.");
});
vm.eliminarEstudianteModal = function (index) {
$rootScope.index = index;
$rootScope.botonOK = true;
$rootScope.botonCancelar = true;
$rootScope.acceptButton = false;
$rootScope.rsplice = false;
$rootScope.listarEstudiantesLoading = true;
$rootScope.mensaje = "¿Seguro que desea eliminar el Estudiante?";
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/students/modal/list_students_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return "";
}
}
});
};
vm.eliminarEstudiante = function (index) {
$rootScope.botonOK = false;
$rootScope.acceptButton = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarEstudiante';
$rootScope.listarEstudiantesLoading = true;
students.delete({id: vm.estudiantes[index]._id},
function (successResult) {
$rootScope.listarEstudiantesLoading = false;
$rootScope.rsplice = true;
$rootScope.mensaje = "Usuario " + vm.estudiantes[index].name + " eliminado";
},
function (errorResult) {
$rootScope.listarEstudiantesLoading = false;
$rootScope.mensaje = "Error eliminando al Usuario " + vm.estudiantes[index].name;
});
};
vm.removeEstudianteSplice = function(index, rsplice) {
if(rsplice){
vm.listaEstudiantes.splice(index, 1);
$rootScope.rsplice = false;
}
};
vm.modificarEstudiante = function (index) {
estudianteSeleccionado._id = vm.estudiantes[index]._id;
estudianteSeleccionado.Cedula = vm.estudiantes[index].id;
estudianteSeleccionado.Nombre = vm.estudiantes[index].name;
estudianteSeleccionado.Apellido= vm.estudiantes[index].lastname;
estudianteSeleccionado.Telefono = vm.estudiantes[index].number;
estudianteSeleccionado.Correo= vm.estudiantes[index].email;
$location.url('actualizarEstudiante');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
return vm;
};
crearEstudianteCtrl.$inject = ['$scope', '$rootScope', '$location', 'professors', '$modal', 'selectedSection', 'selectedCourse'];
function crearEstudianteCtrl($scope, $rootScope, $location, professors, $modal, selectedSection, selectedCourse){
var vm = this;
var duplicated = false;
var professorid = '56f5fd3a20047f3c15b05f0e';
vm.professor = {};
$rootScope.mensaje = "";
$rootScope.actOk = false;
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
},
function (){
console.log("Error al obtener los datos.");
});
vm.submit = function() {
if (vm.data_input_form.$valid){
var person = {
"id": vm.estudiante.Cedula,
"name": vm.estudiante.Nombre,
"lastname": vm.estudiante.Apellido,
"email": vm.estudiante.Correo
};
$rootScope.crearEstudianteLoading = true;
$rootScope.botonOk = false;
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/students/modal/create_students_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
});
angular.forEach (vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students,
function (value){
if(value.id == vm.estudiante.Cedula) duplicated = true;
});
if (!duplicated){
vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students.push(person);
professors.update({ id: professorid }, vm.professor,
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'actualizarMatricula';
$rootScope.mensaje = "Estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre + " agregado";
$rootScope.crearEstudianteLoading = false;
},
function(){
$rootScope.botonOk = true;
$rootScope.urlLo = 'actualizarMatricula';
$rootScope.mensaje = "Error al agregar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre;
$rootScope.crearEstudianteLoading = false;
});
} else {
$rootScope.botonOk = true;
$rootScope.urlLo = 'actualizarMatricula';
$rootScope.mensaje = "Estudiante con cedula " + vm.estudiante.Cedula + " ya esta en la lista.";
$rootScope.crearEstudianteLoading = false;
}
}else{
vm.submitted = true;
}
}
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
actualizarEstudianteCtrl.$inject = [ '$scope','$rootScope', '$location', 'students', '$modal', 'estudianteSeleccionado' ];
function actualizarEstudianteCtrl ( $scope, $rootScope, $location, students, $modal, estudianteSeleccionado ){
var vm = this;
vm.estudiante = estudianteSeleccionado;
$rootScope.mensaje = "";
$rootScope.actOk = false;
vm.submit = function() {
var student = {
"_id": vm.estudiante._id,
"id": vm.estudiante.Cedula,
"name": vm.estudiante.Nombre,
"lastname": vm.estudiante.Apellido,
"email": vm.estudiante.Correo,
"number": vm.estudiante.Telefono,
};
$rootScope.botonOk = false;
$rootScope.modificarEstudianteLoading = true;
$scope.modalInstance = $modal.open({
animation: $rootScope.animationsEnabled,
templateUrl: 'partials/students/modal/update_students_modal.html',
scope: $scope,
size: 'sm',
resolve: {
items: function () {
return $rootScope.items;
}
}
});
students.update(student,
function(){
$rootScope.botonOk = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarEstudiante';
$rootScope.mensaje = "Estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre + " actualizado";
},
function(){
$rootScope.botonOk = true;
$rootScope.botonCancelar = false;
$rootScope.urlLo = 'listarEstudiante';
$rootScope.mensaje = "Error al modificar al estudiante " + vm.estudiante.Apellido + ", " + vm.estudiante.Nombre;
});
}
$scope.ok = function (urlLo) {
$location.url(urlLo);
$scope.modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$scope.modalInstance.dismiss('cancel');
};
$rootScope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$rootScope.opened = true;
};
return vm;
};
})();

View File

@@ -0,0 +1,75 @@
(function(){
'use strict';
angular
.module("app.student", ['ui.router', 'ui.bootstrap'])
.run(addStateToScope)
.config(getRoutes);
addStateToScope.$inject = ['$rootScope', '$state', '$stateParams'];
function addStateToScope($rootScope, $state, $stateParams){
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
};
getRoutes.$inject = ['$stateProvider', '$urlRouterProvider'];
function getRoutes($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/listarEstudiante');
$stateProvider
.state('listarEstudiante', {
url: '/listarEstudiante',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/students/list_students.html',
controller: 'listarEstudianteCtrl',
controllerAs: 'vm'
}
}
})
.state('crearEstudiante', {
url: '/crearEstudiante',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/students/create_students.html',
controller: 'crearEstudianteCtrl',
controllerAs: 'vm'
}
}
})
.state('actualizarEstudiante', {
url: '/actualizarEstudiante',
views: {
sidebar: {
templateUrl: 'partials/sidebar/sidebar.html',
controller: 'sidebarCtrl'
},
navbar: {
templateUrl: 'partials/sidebar/navbar.html'
},
content: {
templateUrl: 'partials/students/update_students.html',
controller: 'actualizarEstudianteCtrl',
controllerAs: 'vm'
}
}
})
};
})();

View File

@@ -0,0 +1,16 @@
(function(){
'use strict';
angular
.module('app.student')
.factory('students', students)
.value('estudianteSeleccionado',{});
students.$inject = ['$resource','$rootScope'];
function students($resource, $rootScope){
return $resource('http://'+$rootScope.domainUrl+'/students/:id', null,
{
'update': {method:'PUT'}
});
};
})();