Skip to content

Commit

Permalink
Merge pull request #3 from kayanalmeida/master
Browse files Browse the repository at this point in the history
Utilizando o estilo nos novos inputs; inserindo o datetimepicker e forma...
  • Loading branch information
vitor-costa committed Dec 6, 2014
2 parents 87c8198 + 0ab6e40 commit 617724d
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 18 deletions.
5 changes: 5 additions & 0 deletions public/css/bootstrap-datetimepicker.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added public/fonts/glyphicons-halflings-regular.woff
Binary file not shown.
22 changes: 16 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/moment-with-locales.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry"></script>
<script type="text/javascript" src="date-pt-BR.js"></script>
<script type="text/javascript" src="rawCollectedData.js"></script>
<script type="text/javascript" src="relatorioCodigo.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
Expand Down Expand Up @@ -168,12 +170,20 @@ <h1> Preencha as informações abaixo</h1>
</div>
</div>

<input type="checkbox" id="dateNow" checked=true> Obter dados em tempo real <br>
Obter dados do histórico <br>
Data inicial (YYYYMMDDHH)
<input type="textbox" id="initialDate">
Data final (YYYYMMDDHH)
<input type="textbox" id="finalDate">
<div class="form-group" >
<div class="col-sm-11 col-md-offset-1">
<input type="checkbox" id="dateNow" checked=true> Obter dados em tempo real</div>
</div>
<div class="form-group" >
<label for="initialDate" class="col-sm-2 control-label" data-date-format="DD/MM/YYYY - HH" >Data inicial</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="initialDate" placeholder="Insira a Dara e Hora" data-date-format="DD/MM/YYYY - HH:00">
</div>
<label for="maxs" class="col-sm-2 control-label">Data final</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="finalDate" placeholder="Insira a Dara e Hora" data-date-format="DD/MM/YYYY - HH:00">
</div>
</div>

<div class="form-group">
<div class="col-sm-offset-5 col-sm-6">
Expand Down
1 change: 1 addition & 0 deletions public/js/bootstrap-datetimepicker.min.js

Large diffs are not rendered by default.

51 changes: 39 additions & 12 deletions public/relatorioCodigo.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,16 @@ window.onload = function() {
url = "http://rest.riob.us/all?callback=?";
}
else {
url = "http://localhost:3002/api/" + initialDate + "/" + finalDate;
//converting to correct format, from datetime input, using moment js
if (initialDate.length == 0 && finalDate.length == 0 ){
alert("Por favor, preencha as datas, ou marque a opção 'Obter dados em tempo real'. ")

}
else {
initialDate = moment(initialDate,"DD/MM/YYYY - HH").format("YYYYMMDDHH");
finalDate = moment(finalDate,"DD/MM/YYYY - HH").format("YYYYMMDDHH");
url = "http://localhost:3002/api/" + initialDate + "/" + finalDate;
}
}

$.getJSON(url, function(data, status) {
Expand Down Expand Up @@ -238,30 +247,48 @@ window.onload = function() {

$(function(){
$('.checkbox').hide();
if (window.location.href.indexOf('report') > 0){

}
$('ul[role=menu] a').click(function(event) {
//When the user clicks on a report, the page animates and show related fields
var inputName = $(this).data('input-id');
showForm(inputName);

});
$('ul[role=menu] a').first().trigger('click')

$('ul[role=menu] a').first().trigger('click');

//generating datetimepicker for initialDate and finalDate
$('[id*=Date]').datetimepicker({
useMinutes: false,
useSeconds: false
});

$("#initialDate").on("dp.change",function (e) {
//The final date must have as minimun value the initial date
$('#finalDate').data("DateTimePicker").setMinDate(e.date);
});
// when the page loads, the initial and final date must be disabled
$('[id*=Date]').prop('disabled', true);

$('#dateNow').on('change',function(event) {
event.preventDefault();
//when the dateNow checkbox changes, the fields become available or no
$('[id*=Date]').prop('disabled', $(this).prop('checked') );
});
})
function showForm(form){
//Making fade transition to hide previous report and show the other
var formTitle = $('a[data-input-id='+form+']').html();
$('.dropdown-toggle').html( formTitle + '<span class="caret"/>');
$('h1').html(formTitle);
$('[data-form-name]:visible').fadeOut('fast', function() {
$('[data-form-name='+form+']').fadeIn('fast',function() {
$('input[value='+form+']').trigger('click')
});
});
});
}
var t ;

function generateTable(answerArray,report){
t = answerArray;
//placing server's answer on a better format for the user...
if (answerArray.length > 1){}
switch (report) {
case "empty-lines":
Expand All @@ -277,7 +304,7 @@ function generateTable(answerArray,report){
$('#resposta > table > thead').append('<th> Código da Linha </th>');
for (var i in answerArray.emptyLinesBuses){
var linha = $('<tr>');
linha.append('<td>' + moment(answerArray.emptyLinesBuses[i][0]).format('MM/DD/YYYY hh:mm') + ' </td>');
linha.append('<td>' + moment(answerArray.emptyLinesBuses[i][0]).format('DD/MM/YYYY hh:mm') + ' </td>');
linha.append('<td>' + answerArray.emptyLinesBuses[i][1] + ' </td>');
$('#resposta > table > tbody').append(linha);

Expand All @@ -298,7 +325,7 @@ function generateTable(answerArray,report){
$('#resposta > table > thead').append('<th> Código da Linha </th>');
for (var i in answerArray.stopedBuses){
var linha = $('<tr>');
linha.append('<td>' + moment(answerArray.stopedBuses[i][0]).format('MM/DD/YYYY hh:mm') + ' </td>');
linha.append('<td>' + moment(answerArray.stopedBuses[i][0]).format('DD/MM/YYYY hh:mm') + ' </td>');
linha.append('<td>' + answerArray.stopedBuses[i][1] + ' </td>');
$('#resposta > table > tbody').append(linha);

Expand All @@ -319,7 +346,7 @@ function generateTable(answerArray,report){
$('#resposta > table > thead').append('<th> Código da Linha </th>');
for (var i in answerArray.outDatedBuses){
var linha = $('<tr>');
linha.append('<td>' + moment(answerArray.outDatedBuses[i][0]).format('MM/DD/YYYY hh:mm') + ' </td>');
linha.append('<td>' + moment(answerArray.outDatedBuses[i][0]).format('DD/MM/YYYY hh:mm') + ' </td>');
linha.append('<td>' + answerArray.outDatedBuses[i][1] + ' </td>');
$('#resposta > table > tbody').append(linha);

Expand Down Expand Up @@ -363,7 +390,7 @@ function generateTable(answerArray,report){

for (var i in answerArray.buses){
var linha = $('<tr>');
linha.append('<td>' + moment(answerArray.buses[i][0]).format('MM/DD/YYYY hh:mm') + ' </td>');
linha.append('<td>' + moment(answerArray.buses[i][0]).format('DD/MM/YYYY hh:mm') + ' </td>');
linha.append('<td>' + answerArray.buses[i][1] + ' </td>');
linha.append('<td>' + answerArray.buses[i][5] + ' Km/h' + ' </td>');

Expand Down

0 comments on commit 617724d

Please sign in to comment.