use MojoFacets::Import::HTMLTable;
use MojoFacets::Import::CSV;
use MojoFacets::Import::CouchDB;
+use MojoFacets::Import::SQL;
our $loaded;
our $filters;
} elsif ( -d $file && $file =~ m/\.html$/ ) {
$file =~ s/$data_dir\/*//;
push @files, $file;
- } elsif ( -f $file && $file =~ m/\.(csv|storabe|couchdb)$/i ) {
+ } elsif ( -f $file && $file =~ m/\.(csv|storabe|couchdb|sql)$/i ) {
$file =~ s/$data_dir\/*//;
push @files, $file;
} else {
if ( -f $full_path ) {
if ( $full_path =~ m/.csv/i ) {
$data = MojoFacets::Import::CSV->new( full_path => $full_path )->data;
+ } elsif ( $full_path =~ m/.sql/i ) {
+ $data = MojoFacets::Import::SQL->new( full_path => $full_path )->data;
} elsif ( $full_path =~ m/.couchdb/i ) {
$data = MojoFacets::Import::CouchDB->new( full_path => $full_path )->data;
} elsif ( $full_path =~ m/.storable/ ) {
#warn "# filter $name ",dump($filtered_items);
+ # invalidate filters on other datasets
+ foreach my $dataset ( grep { exists $loaded->{$_}->{filters}->{$name} } keys %$loaded ) {
+ delete $loaded->{$dataset}->{filters}->{$name};
+ delete $loaded->{$dataset}->{filtered};
+ }
+
$loaded->{$path}->{filters}->{$name} = $filtered_items;
warn "filter $name with ", scalar keys %$filtered_items, " items created\n";
}
#warn "__commit_path_code $path $i ",dump( $update );
}
+# uses templates/admin.html.ep
+sub _switch_dataset {
+ my $self = shift;
+
+ my $datasets;
+
+ foreach my $path ( keys %$loaded ) {
+ next unless exists $loaded->{$path}->{data};
+ push @$datasets, $path;
+ }
+
+ warn "# datasets ",dump($datasets);
+
+ $self->stash( 'datasets' => $datasets );
+}
+
sub items {
my $self = shift;
+ $self->_switch_dataset;
+
if ( my $show = $self->param('id') ) {
$self->param('show', $show);
warn "show $show\n";