diff --git a/ISSUES b/ISSUES index d131d23d4e..138d621886 100644 --- a/ISSUES +++ b/ISSUES @@ -1,5 +1,2 @@ -- DataTable field doesn't preserve checked value correctly if other - fields don't validate (id gets set to 1 for all rows, and all boxes - are checked). - Modal needs more flexible width. It breaks when making screen narrower than 816px, and if no DataTable field is there, it can be narrower also. diff --git a/lib/NGCP/Panel/Controller/Contact.pm b/lib/NGCP/Panel/Controller/Contact.pm index d5fdee6527..db2f938704 100644 --- a/lib/NGCP/Panel/Controller/Contact.pm +++ b/lib/NGCP/Panel/Controller/Contact.pm @@ -24,9 +24,9 @@ sub list :Chained('/') :PathPart('contact') :CaptureArgs(0) { my $contacts = [ {id => 1, firstname => 'Foo1', lastname => '1Bar', email => 'foo1@example.org' }, - {id => 1, firstname => 'Foo2', lastname => '2Bar', email => 'foo2@example.org' }, - {id => 1, firstname => 'Foo3', lastname => '3Bar', email => 'foo3@example.org' }, - {id => 1, firstname => 'Foo4', lastname => '4Bar', email => 'foo4@example.org' }, + {id => 2, firstname => 'Foo2', lastname => '2Bar', email => 'foo2@example.org' }, + {id => 3, firstname => 'Foo3', lastname => '3Bar', email => 'foo3@example.org' }, + {id => 4, firstname => 'Foo4', lastname => '4Bar', email => 'foo4@example.org' }, ]; $c->stash(contacts => $contacts); $c->stash(template => 'contact/list.tt'); diff --git a/lib/NGCP/Panel/Controller/Dashboard.pm b/lib/NGCP/Panel/Controller/Dashboard.pm index 06f43f89c7..adc2925261 100644 --- a/lib/NGCP/Panel/Controller/Dashboard.pm +++ b/lib/NGCP/Panel/Controller/Dashboard.pm @@ -28,14 +28,15 @@ Dashboard index sub index :Path :Args(0) { my ($self, $c) = @_; + my $plugin_finder = NGCP::Panel::Widget->new; + my $widget_templates = []; - my $finder = NGCP::Panel::Widget->new; - foreach($finder->instantiate_plugins($c)) { + foreach($plugin_finder->instantiate_plugins($c, 'dashboard_widgets')) { $_->handle($c); push @{ $widget_templates }, $_->template; } - $c->stash(widgets => $widget_templates); + $c->stash(template => 'dashboard.tt'); delete $c->session->{redirect_targets}; } diff --git a/lib/NGCP/Panel/Controller/Root.pm b/lib/NGCP/Panel/Controller/Root.pm index 65a50ba7e5..00ecb65506 100644 --- a/lib/NGCP/Panel/Controller/Root.pm +++ b/lib/NGCP/Panel/Controller/Root.pm @@ -4,6 +4,8 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } +use NGCP::Panel::Widget; + # # Sets the actions in this controller to be registered with no prefix # so they function identically to actions created in MyApp.pm @@ -64,6 +66,16 @@ sub auto :Private { } $c->log->debug("*** Root::auto grant access for authenticated user"); + + # load top menu widgets + my $plugin_finder = NGCP::Panel::Widget->new; + my $topmenu_templates = []; + foreach($plugin_finder->instantiate_plugins($c, 'topmenu_widgets')) { + $_->handle($c); + push @{ $topmenu_templates }, $_->template; + } + $c->stash(topmenu => $topmenu_templates); + return 1; } diff --git a/lib/NGCP/Panel/Widget.pm b/lib/NGCP/Panel/Widget.pm index bb6461745f..1202131877 100644 --- a/lib/NGCP/Panel/Widget.pm +++ b/lib/NGCP/Panel/Widget.pm @@ -15,14 +15,14 @@ sub filter { } sub instantiate_plugins { - my ($self, $c) = @_; + my ($self, $c, $type_filter) = @_; my @plugins = map { s/^.*:://; $_; } $self->_plugin_locator->plugins; my @instances = (); foreach(@plugins) { my $inst = NGCP::Panel::Widget->new; $inst->load_plugin($_); - if($inst->filter($c)) { + if($inst->filter($c, $type_filter)) { push @instances, $inst; } } diff --git a/lib/NGCP/Panel/Widget/Plugin/AdminBillingOverview.pm b/lib/NGCP/Panel/Widget/Plugin/AdminBillingOverview.pm index cb8c546738..467fc09f4e 100644 --- a/lib/NGCP/Panel/Widget/Plugin/AdminBillingOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/AdminBillingOverview.pm @@ -7,6 +7,12 @@ has 'template' => ( default => 'widgets/admin_billing_overview.tt' ); +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + around handle => sub { my ($foo, $self, $c) = @_; @@ -14,15 +20,16 @@ around handle => sub { return; }; -around filter => sub { - my ($foo, $self, $c) = @_; +sub filter { + my ($self, $c, $type) = @_; return $self if( + $type eq $self->type && $c->check_user_roles(qw/administrator/) && ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' ); return; -}; +} 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/AdminPeeringOverview.pm b/lib/NGCP/Panel/Widget/Plugin/AdminPeeringOverview.pm index c877ab7304..dc01c1f019 100644 --- a/lib/NGCP/Panel/Widget/Plugin/AdminPeeringOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/AdminPeeringOverview.pm @@ -7,6 +7,12 @@ has 'template' => ( default => 'widgets/admin_peering_overview.tt' ); +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + around handle => sub { my ($foo, $self, $c) = @_; @@ -14,15 +20,16 @@ around handle => sub { return; }; -around filter => sub { - my ($foo, $self, $c) = @_; +sub filter { + my ($self, $c, $type) = @_; return $self if( + $type eq $self->type && $c->check_user_roles(qw/administrator/) && ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' ); return; -}; +} 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm b/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm index 1c449ed22f..b990bb8ee3 100644 --- a/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/AdminResellerOverview.pm @@ -7,6 +7,12 @@ has 'template' => ( default => 'widgets/admin_reseller_overview.tt' ); +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + around handle => sub { my ($foo, $self, $c) = @_; @@ -14,15 +20,16 @@ around handle => sub { return; }; -around filter => sub { - my ($foo, $self, $c) = @_; +sub filter { + my ($self, $c, $type) = @_; return $self if( + $type eq $self->type && $c->check_user_roles(qw/administrator/) && ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' ); return; -}; +} 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/AdminSystemOverview.pm b/lib/NGCP/Panel/Widget/Plugin/AdminSystemOverview.pm index db6d801fed..3865e69d2f 100644 --- a/lib/NGCP/Panel/Widget/Plugin/AdminSystemOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/AdminSystemOverview.pm @@ -7,6 +7,12 @@ has 'template' => ( default => 'widgets/admin_system_overview.tt' ); +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + around handle => sub { my ($foo, $self, $c) = @_; @@ -14,15 +20,16 @@ around handle => sub { return; }; -around filter => sub { - my ($foo, $self, $c) = @_; +sub filter { + my ($self, $c, $type) = @_; return $self if( + $type eq $self->type && $c->check_user_roles(qw/administrator/) && ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' ); return; -}; +} 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/AdminTopMenuSettings.pm b/lib/NGCP/Panel/Widget/Plugin/AdminTopMenuSettings.pm new file mode 100644 index 0000000000..54325d8669 --- /dev/null +++ b/lib/NGCP/Panel/Widget/Plugin/AdminTopMenuSettings.pm @@ -0,0 +1,32 @@ +package NGCP::Panel::Widget::Plugin::AdminTopMenuSettings; +use Moose::Role; + +has 'template' => ( + is => 'ro', + isa => 'Str', + default => 'widgets/admin_topmenu_settings.tt' +); + +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'topmenu_widgets', +); + +around handle => sub { + my ($foo, $self, $c) = @_; + return; +}; + +sub filter { + my ($self, $c, $type) = @_; + + return $self if( + $type eq $self->type && + $c->check_user_roles(qw/administrator/) + ); + return; +} + +1; +# vim: set syntax=perl tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm b/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm index 7d641d515d..675532cdc0 100644 --- a/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm +++ b/lib/NGCP/Panel/Widget/Plugin/ResellerDomainOverview.pm @@ -7,6 +7,12 @@ has 'template' => ( default => 'widgets/reseller_domain_overview.tt' ); +has 'type' => ( + is => 'ro', + isa => 'Str', + default => 'dashboard_widgets', +); + around handle => sub { my ($foo, $self, $c) = @_; @@ -14,15 +20,16 @@ around handle => sub { return; }; -around filter => sub { - my ($foo, $self, $c) = @_; +sub filter { + my ($self, $c, $type) = @_; return $self if( + $type eq $self->type && $c->check_user_roles(qw/reseller/) && ref $c->controller eq 'NGCP::Panel::Controller::Dashboard' ); return; -}; +} 1; # vim: set tabstop=4 expandtab: diff --git a/share/layout/body.tt b/share/layout/body.tt index 089e3ea5a0..af000a7687 100644 --- a/share/layout/body.tt +++ b/share/layout/body.tt @@ -65,62 +65,14 @@ diff --git a/share/templates/helpers/datatables.tt b/share/templates/helpers/datatables.tt index b8513f7393..a481057e71 100644 --- a/share/templates/helpers/datatables.tt +++ b/share/templates/helpers/datatables.tt @@ -105,7 +105,7 @@ $.extend( $.fn.dataTableExt.oStdClasses, { } ); $(document).ready(function() { - $('#maintable') + $('#[% helper.name.remove('[\s+\.]') %]_table') .dataTable( { "sDom": "<'row'<'span6'r><'span6'f>>t<'row'<'span6'i><'span6'p>>", "bProcessing": true, @@ -166,7 +166,7 @@ $(document).ready(function() {
- +
[% FOREACH t IN helper.column_titles -%] diff --git a/share/templates/widgets/admin_topmenu_settings.tt b/share/templates/widgets/admin_topmenu_settings.tt new file mode 100644 index 0000000000..d412249ec8 --- /dev/null +++ b/share/templates/widgets/admin_topmenu_settings.tt @@ -0,0 +1,23 @@ + +[% # vim: set tabstop=4 syntax=html expandtab: -%]