summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-03-06 19:48:47 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-03-06 19:48:47 +0100
commit7614dc8ff0318e14e1cd7a590ee817ce5050923e (patch)
treeddd51c1a74ed8610610e061cbe5ad62ea6a42ab0
parent4080ac1b6ab3bcd33ac1e370b217f433cebad1f1 (diff)
barform: add optional filters (TODO: Lol Encoding)
-rw-r--r--index.pl42
-rw-r--r--public/css/default.css16
-rw-r--r--templates/barform.html.ep48
3 files changed, 105 insertions, 1 deletions
diff --git a/index.pl b/index.pl
index 108539c..a44c0bd 100644
--- a/index.pl
+++ b/index.pl
@@ -91,6 +91,46 @@ helper barplot_args => sub {
};
};
+helper barplot_filters => sub {
+ my ($self) = @_;
+ my $dbh = $self->app->dbh;
+
+ my $ret = {
+ lines => [
+ map { $_->[0] } @{
+ $dbh->selectall_arrayref(
+"select distinct train_type || ' ' || line_no as line from $table order by line"
+ )
+ }
+ ],
+ train_types => [
+ q{},
+ map { $_->[0] } @{
+ $dbh->selectall_arrayref(
+ "select distinct train_type from $table order by train_type"
+ )
+ }
+ ],
+ stations => [
+ q{},
+ map { $_->[0] } @{
+ $dbh->selectall_arrayref(
+ "select distinct station from $table order by station")
+ }
+ ],
+ destinations => [
+ q{},
+ map { $_->[0] } @{
+ $dbh->selectall_arrayref(
+"select distinct destination from $table order by destination"
+ )
+ }
+ ],
+ };
+
+ return $ret;
+};
+
helper count_unique_column => sub {
my ( $self, $column ) = @_;
my $dbh = $self->app->dbh;
@@ -294,7 +334,7 @@ get '/2ddata.tsv' => sub {
get '/' => sub {
my $self = shift;
- $self->render('intro', version => $VERSION);
+ $self->render( 'intro', version => $VERSION );
return;
};
diff --git a/public/css/default.css b/public/css/default.css
index 7b37068..dec73f2 100644
--- a/public/css/default.css
+++ b/public/css/default.css
@@ -10,6 +10,22 @@ input.dimension {
width: 4em;
}
+input.delay {
+ width: 3em;
+}
+
+div.field {
+ width: 100%;
+ clear: both;
+}
+
+div.field div.desc {
+ float: left;
+ width: 12em;
+ text-align: right;
+ padding-right: 0.5em;
+}
+
svg {
font: 10px sans-serif;
}
diff --git a/templates/barform.html.ep b/templates/barform.html.ep
index 62c8bda..6b23fe2 100644
--- a/templates/barform.html.ep
+++ b/templates/barform.html.ep
@@ -1,3 +1,4 @@
+<div>
% if (not defined param('want_msg')) {
% param(want_msg => 0);
% }
@@ -25,4 +26,51 @@ x
%= text_field 'height' => 500, class => 'dimension'
Pixel.
%= submit_button 'Go'
+<br/>
+% my $filter_opts = $self->barplot_filters;
+Optionale Einschränkungen:
+<div class="field">
+ <div class="desc">
+ Linie:
+ </div>
+ <div>
+ %= select_field filter_line => [map {[$_, $_]} @{$filter_opts->{lines}} ]
+ </div>
+</div>
+<div class="field">
+ <div class="desc">
+ Zugtyp:
+ </div>
+ <div>
+ %= select_field filter_train_type => [map {[$_, $_]} @{$filter_opts->{train_types}} ]
+ </div>
+</div>
+<div class="field">
+ <div class="desc">
+ Bahnhof:
+ </div>
+ <div>
+ %= select_field filter_station => [map {[$_, $_]} @{$filter_opts->{stations}} ]
+ </div>
+</div>
+<div class="field">
+ <div class="desc">
+ Zielbahnhof:
+ </div>
+ <div>
+ %= select_field filter_destination => [map {[$_, $_]} @{$filter_opts->{destinations}} ]
+ </div>
+</div>
+<div class="field">
+ <div class="desc">
+ Verspätung zwischen
+ </div>
+ <div>
+ %= text_field 'filter_delay_min', class => 'delay', placeholder => '-∞'
+ und
+ %= text_field 'filter_delay_max', class => 'delay', placeholder => '+∞'
+ Minuten (inklusive).
+ </div>
+</div>
% end
+<div>