Skip to content

Commit

Permalink
Add table with absences count
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuino committed Sep 13, 2017
1 parent 475b4e5 commit e1a8d80
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .publish
Submodule .publish updated from 81ceeb to 92b9f7
26 changes: 25 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,38 @@ <h1>Presença dos vereadores</h1>
<div class="row" ng-show="infoSessao">
<h3> {{ infoSessao.legislature }}, {{infoSessao.session}}, {{infoSessao.date}} </h3>
<div class="table-responsive">
<table class="table">
<table class="table table-bordered table-stripped">
<thead>
<tr>
<th>Vereador</th>
<th>Presença?</th>
</tr>
</thead>
<tr ng-repeat="(vereador, presenca) in infoSessao.attendance" ng-class="classeParaPresenca(presenca)">
<td>{{ vereador }}</td>
<td>{{ presenca }}</td>
</tr>
</table>
</div>
</div>
<div class="row" ng-show="faltas">
<h3> Total Faltas </h3>
<div class="table">
<table class="table table-bordered table-stripped">
<thead>
<tr>
<th>Vereador</th>
<th>Total Faltas</th>
</tr>
</thead>
<tr ng-repeat="(vereador, totalFaltas) in faltas">
<td>{{ vereador }}</td>
<td>{{ totalFaltas }}</td>
</tr>
</table>
</div>
</div>

<!-- ENDDATA -->
</div>
</section>
Expand Down
1 change: 1 addition & 0 deletions app/js/controllers/presenca.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
$scope.carregaSessoes();
$scope.sessao = $scope.sessoes[$scope.sessoes.length - 1];
$scope.carregaInfoSessao();
$scope.faltas = presencaService.faltas();
});


Expand Down
19 changes: 17 additions & 2 deletions app/js/services/presenca.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
legislaturas = [];
dadosSessoes = [];
sessoes = {}
contagemFaltas = {}

function loadData(success) {
$http.get('./data/sessionAttendance.json').then(function(response) {
Expand All @@ -16,6 +17,16 @@
sessoes[legislatura] = [];
}
sessoes[legislatura].push(sessao)

$.each(sessao.attendance, function(k, v) {
if(!contagemFaltas[k]) {
contagemFaltas[k] = 0;
}
if(v === 'NÃO') {
contagemFaltas[k] += 1;
}
});

}
// TODO: sort sessions correctly
for(var i = 0; i < legislatura.length; i++){
Expand Down Expand Up @@ -48,12 +59,16 @@
return infoSessao;
}

function faltas() {
return contagemFaltas;
}

return {
loadData: loadData,
todasLegislaturas: todasLegislaturas,
sessaoParaLegislatura: sessaoParaLegislatura,
infoSessao: infoSessao

infoSessao: infoSessao,
faltas: faltas
}
}

Expand Down

0 comments on commit e1a8d80

Please sign in to comment.