| 1 | package App::Netdisco::Web::CustomFields; | ||
| 2 | |||
| 3 | use Dancer ':syntax'; | ||
| 4 | |||
| 5 | use App::Netdisco::Web::Plugin; | ||
| 6 | use App::Netdisco::Util::CustomFields; | ||
| 7 | |||
| 8 | foreach my $config (@{ setting('custom_fields')->{'device'} || [] }) { | ||
| 9 | next unless $config->{'name'}; | ||
| 10 | |||
| 11 | register_device_details({ | ||
| 12 | %{ $config }, | ||
| 13 | field => ('cf_' . $config->{'name'}), | ||
| 14 | label => ($config->{'label'} || ucfirst $config->{'name'}), | ||
| 15 | }); | ||
| 16 | } | ||
| 17 | |||
| 18 | foreach my $config (@{ setting('custom_fields')->{'device_port'} || [] }) { | ||
| 19 | next unless $config->{'name'}; | ||
| 20 | |||
| 21 | register_device_port_column({ | ||
| 22 | position => 'right', # or "mid" or "right" | ||
| 23 | default => undef, # or "checked" | ||
| 24 | %{ $config }, | ||
| 25 | field => ('cf_' . $config->{'name'}), | ||
| 26 | label => ($config->{'label'} || ucfirst $config->{'name'}), | ||
| 27 | }); | ||
| 28 | } | ||
| 29 | |||
| 30 | true; |