diff options
author | Daniel Friesel <derf@finalrewind.org> | 2015-03-28 18:11:50 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2015-03-28 18:11:50 +0100 |
commit | 001fa0d3bcc098aaca80ba4b1538796ef0d9e308 (patch) | |
tree | 51bb312c19d49c31f43da30b0ed65b4eab830b72 | |
parent | 156404df7fd1ad5ed6e8501d55ef9ba164817e21 (diff) |
add train_no filter selector
-rw-r--r-- | index.pl | 34 | ||||
-rw-r--r-- | public/css/default.css | 4 | ||||
-rw-r--r-- | templates/bargraph.html.ep | 2 | ||||
-rw-r--r-- | templates/filterform.html.ep | 8 |
4 files changed, 40 insertions, 8 deletions
@@ -223,6 +223,7 @@ helper parse_filter_args => sub { my %filter = ( line => scalar $self->param('filter_line'), + train_no => scalar $self->param('filter_train_no'), train_type => scalar $self->param('filter_train_type'), station => scalar $self->param('filter_station'), destination => scalar $self->param('filter_destination'), @@ -238,6 +239,8 @@ helper parse_filter_args => sub { = length( $filter{delay_min} ) ? int( $filter{delay_min} ) : undef; $filter{delay_max} = length( $filter{delay_max} ) ? int( $filter{delay_max} ) : undef; + $filter{train_no} + = length( $filter{train_no} ) ? int( $filter{train_no} ) : undef; if ( $filter{line} ) { my ( $train_type, $line_no ) = split( /\./, $filter{line} ); @@ -258,6 +261,9 @@ helper parse_filter_args => sub { if ( defined $filter{delay_max} ) { $where_clause .= " and delay <= $filter{delay_max}"; } + if ( defined $filter{train_no} ) { + $where_clause .= " and train_no = $filter{train_no}"; + } return ( \%filter, $where_clause ); }; @@ -561,13 +567,27 @@ get '/bar' => sub { 'Linie ' . $self->translate_filter_arg( 'line', @translate_args ) ); } if ( $self->param('filter_train_type') ) { - push( - @title_filter_strings, - 'Zugtyp ' - . $self->translate_filter_arg( - 'train_type', $self->param('filter_train_type') - ) - ); + if ( $self->param('filter_train_no') ) { + push( + @title_filter_strings, + $self->translate_filter_arg( 'train_type', + $self->param('filter_train_type') ) + . q{ } + . $self->param('filter_train_no') + ); + } + else { + push( + @title_filter_strings, + 'Zugtyp ' + . $self->translate_filter_arg( + 'train_type', $self->param('filter_train_type') + ) + ); + } + } + elsif ( $self->param('filter_train_no') ) { + push( @title_filter_strings, 'Zug ' . $self->param('filter_train_no') ); } if ( $self->param('filter_station') ) { push( diff --git a/public/css/default.css b/public/css/default.css index 974e421..2b081e2 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -34,6 +34,10 @@ input.delay { width: 3em; } +input.train_no { + width: 4em; +} + div.field { width: 100%; clear: both; diff --git a/templates/bargraph.html.ep b/templates/bargraph.html.ep index f626fbd..da3510e 100644 --- a/templates/bargraph.html.ep +++ b/templates/bargraph.html.ep @@ -2,7 +2,7 @@ %= javascript begin -show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>&msgnum=<%= param('msgnum') %>&filter_line=<%= param('filter_line') %>&filter_train_type=<%= param('filter_train_type') %>&filter_station=<%= param('filter_station') %>&filter_destination=<%= param('filter_destination') %>&filter_delay_min=<%= param('filter_delay_min') %>&filter_delay_max=<%= param('filter_delay_max') %>', +show_bargraph('/2ddata.tsv?aggregate=<%= param('xsource') %>&metric=<%= param('ysource') %>&msgnum=<%= param('msgnum') %>&filter_line=<%= param('filter_line') %>&filter_train_no=<%= param('filter_train_no') %>&filter_train_type=<%= param('filter_train_type') %>&filter_station=<%= param('filter_station') %>&filter_destination=<%= param('filter_destination') %>&filter_delay_min=<%= param('filter_delay_min') %>&filter_delay_max=<%= param('filter_delay_max') %>', '<%== param('title') %>', '<%= param('xlabel') %>', '<%= param('ylabel') %>', '<%= param('yformat') %>', '<%= param('width') %>', '<%= param('height') %>'); diff --git a/templates/filterform.html.ep b/templates/filterform.html.ep index 186b7d6..844ecb7 100644 --- a/templates/filterform.html.ep +++ b/templates/filterform.html.ep @@ -17,6 +17,14 @@ </div> <div class="field"> <div class="desc"> + Zugnummer: + </div> + <div> + %= text_field 'filter_train_no', class => 'train_no' + </div> +</div> +<div class="field"> + <div class="desc"> Bahnhof: </div> <div> |