observium sparklines plugin; support X:: namespace
This commit is contained in:
		| @@ -21,8 +21,9 @@ sub _load_web_plugins { | ||||
|   my $plugin_list = shift; | ||||
|  | ||||
|   foreach my $plugin (@$plugin_list) { | ||||
|       $plugin =~ s/^X::/+App::NetdiscoX::Web::Plugin::/; | ||||
|       $plugin = 'App::Netdisco::Web::Plugin::'. $plugin | ||||
|         unless $plugin =~ m/^\+/; | ||||
|         if $plugin !~ m/^\+/; | ||||
|       $plugin =~ s/^\+//; | ||||
|  | ||||
|       debug "loading Netdisco plugin $plugin"; | ||||
|   | ||||
| @@ -5,10 +5,12 @@ use Dancer::Plugin::Ajax; | ||||
| use Dancer::Plugin::DBIC; | ||||
|  | ||||
| hook 'before' => sub { | ||||
|   # list of port detail columns | ||||
|   var('port_columns' => [ | ||||
|   my @default_port_columns_left = ( | ||||
|     { name => 'c_admin',       label => 'Port Controls',     default => ''   }, | ||||
|     { name => 'c_port',        label => 'Port',              default => 'on' }, | ||||
|   ); | ||||
|  | ||||
|   my @default_port_columns_right = ( | ||||
|     { name => 'c_descr',       label => 'Description',       default => ''   }, | ||||
|     { name => 'c_type',        label => 'Type',              default => ''   }, | ||||
|     { name => 'c_duplex',      label => 'Duplex',            default => ''   }, | ||||
| @@ -24,7 +26,21 @@ hook 'before' => sub { | ||||
|     { name => 'c_neighbors',   label => 'Connected Devices', default => 'on' }, | ||||
|     { name => 'c_stp',         label => 'Spanning Tree',     default => ''   }, | ||||
|     { name => 'c_up',          label => 'Status',            default => ''   }, | ||||
|   ]); | ||||
|   ); | ||||
|  | ||||
|   # build list of port detail columns | ||||
|   my @port_columns = (); | ||||
|  | ||||
|   push @port_columns, | ||||
|     grep {$_->{position} eq 'left'} @{ setting('_extra_device_port_cols') }; | ||||
|   push @port_columns, @default_port_columns_left; | ||||
|   push @port_columns, | ||||
|     grep {$_->{position} eq 'mid'} @{ setting('_extra_device_port_cols') }; | ||||
|   push @port_columns, @default_port_columns_right; | ||||
|   push @port_columns, | ||||
|     grep {$_->{position} eq 'right'} @{ setting('_extra_device_port_cols') }; | ||||
|  | ||||
|   var('port_columns' => \@port_columns); | ||||
|  | ||||
|   # view settings for port connected devices | ||||
|   var('connected_properties' => [ | ||||
|   | ||||
| @@ -4,6 +4,7 @@ use Dancer ':syntax'; | ||||
| use Dancer::Plugin; | ||||
|  | ||||
| set( | ||||
|   '_extra_device_port_cols' => [], | ||||
|   '_navbar_items' => [], | ||||
|   '_search_tabs'  => [], | ||||
|   '_device_tabs'  => [], | ||||
| @@ -29,6 +30,26 @@ register 'register_template_path' => sub { | ||||
|     $path; | ||||
| }; | ||||
|  | ||||
| register 'register_device_port_column' => sub { | ||||
|   my ($self, $config) = plugin_args(@_); | ||||
|   $config->{default} ||= ''; | ||||
|   $config->{position} ||= 'right'; | ||||
|  | ||||
|   if (!length $config->{name} or !length $config->{label}) { | ||||
|       error "bad config to register_device_port_column"; | ||||
|       return; | ||||
|   } | ||||
|  | ||||
|   foreach my $item (@{ setting('_extra_device_port_cols') }) { | ||||
|       if ($item->{name} eq $config->{name}) { | ||||
|           $item = $config; | ||||
|           return; | ||||
|       } | ||||
|   } | ||||
|  | ||||
|   push @{ setting('_extra_device_port_cols') }, $config; | ||||
| }; | ||||
|  | ||||
| register 'register_navbar_item' => sub { | ||||
|   my ($self, $config) = plugin_args(@_); | ||||
|  | ||||
|   | ||||
							
								
								
									
										15
									
								
								Netdisco/lib/App/NetdiscoX/Web/Plugin/ObserviumSparklines.pm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Netdisco/lib/App/NetdiscoX/Web/Plugin/ObserviumSparklines.pm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| package App::NetdiscoX::Web::Plugin::ObserviumSparklines; | ||||
|  | ||||
| use Dancer ':syntax'; | ||||
| use Dancer::Plugin::DBIC; | ||||
|  | ||||
| use App::Netdisco::Web::Plugin; | ||||
|  | ||||
| register_device_port_column({ | ||||
|   name  => 'c_observiumsparklines', | ||||
|   position => 'mid', | ||||
|   label => 'Traffic', | ||||
|   default => 'on', | ||||
| }); | ||||
|  | ||||
| true; | ||||
		Reference in New Issue
	
	Block a user