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

@@ -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">
<div class="container-fluid">
</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>
</ul>
</div>

View File

@@ -5,49 +5,68 @@
.module('app')
.controller('SidebarCtrl', SidebarCtrl)
SidebarCtrl.$inject = ['$scope'];
function SidebarCtrl($scope) {
SidebarCtrl.$inject = ['$scope', 'authentication'];
function SidebarCtrl($scope, authentication) {
var that = this;
$scope.showChilds = function(item){
item.active = !item.active;
$scope.showChilds = function(index){
$scope.items[index].active = !$scope.items[index].active;
collapseAnother(index);
};
$scope.items = [
{
text: 'Módulo de Administración',
subItems: [
{
state: 'ProfessorList',
text: 'Listado de Profesores'
},
{
state: 'ProfessorCreate',
text: 'Nuevo Profesor'
}
]
},
{
text: 'Módulo de Materias',
subItems: [
{
state: 'CourseList',
text: 'Listado de Materias'
},
{
state: 'CourseCreate',
text: 'Nueva Materia'
}
]
},
{
text: 'Módulo de Reportes',
subItems: [
{
state: 'courseReport',
text: 'Reportes por Materia'
}
]
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 = [
{
text: 'Módulo de Administración',
subItems: [
{
state: 'ProfessorList',
text: 'Listado de Profesores'
},
{
state: 'ProfessorCreate',
text: 'Nuevo Profesor'
}
]
}
];
}
if(permission.role=='professor'){
$scope.items = [
{
text: 'Módulo de Materias',
subItems: [
{
state: 'CourseList',
text: 'Listado de Materias'
},
{
state: 'CourseCreate',
text: 'Nueva Materia'
}
]
},
{
text: 'Módulo de Reportes',
subItems: [
{
state: 'courseReport',
text: 'Reportes por Materia'
}
]
}
];
}
};
})();

View File

@@ -4,10 +4,14 @@
<div class="row">
<div class="col-sm-3 col-md-2 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>
<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}}
</li>
</ul>