From f4f7bb4086cdaf2699c6d028b76e99b3e9be1e90 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 27 Feb 2011 00:52:29 +0000 Subject: torrus virtual ports, RT#10574 --- httemplate/browse/torrus_srvderive.html | 26 +++++++++++++++++ httemplate/edit/process/torrus_srvderive.html | 21 ++++++++++++++ httemplate/edit/torrus_srvderive.html | 37 ++++++++++++++++++++++++ httemplate/elements/checkboxes-table-name.html | 1 + httemplate/elements/checkboxes.html | 4 +++ httemplate/elements/menu.html | 13 +++++++-- httemplate/elements/select-torrus_serviceid.html | 14 ++------- 7 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 httemplate/browse/torrus_srvderive.html create mode 100644 httemplate/edit/process/torrus_srvderive.html create mode 100644 httemplate/edit/torrus_srvderive.html (limited to 'httemplate') diff --git a/httemplate/browse/torrus_srvderive.html b/httemplate/browse/torrus_srvderive.html new file mode 100644 index 000000000..92cbb6928 --- /dev/null +++ b/httemplate/browse/torrus_srvderive.html @@ -0,0 +1,26 @@ +<% include( 'elements/browse.html', + 'title' => 'Virtual network ports', + 'name_singular' => 'port', + 'menubar' => [ 'Add a new virtual port' => + $p.'edit/torrus_srvderive.html', + ], + 'query' => { 'table' => 'torrus_srvderive' }, + 'count_query' => 'SELECT COUNT(*) FROM torrus_srvderive', + 'header' => [ 'Virtual Port', 'Components', ], + 'fields' => [ 'serviceid', $components_sub, ], + 'links' => [ $link, '', ], + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $link = [ $p.'edit/torrus_srvderive.html?', 'derivenum' ]; + +my $components_sub = sub { + my $torrus_srvderive = shift; + join('
', $torrus_srvderive->component_serviceids); +}; + + diff --git a/httemplate/edit/process/torrus_srvderive.html b/httemplate/edit/process/torrus_srvderive.html new file mode 100644 index 000000000..c3260bc8a --- /dev/null +++ b/httemplate/edit/process/torrus_srvderive.html @@ -0,0 +1,21 @@ +<% include( 'elements/process.html', + 'table' => 'torrus_srvderive', + 'viewall_dir' => 'browse', + 'process_m2name' => { + 'link_table' => 'torrus_srvderive_component', + 'num_col' => 'derivenum', + 'name_col' => 'serviceid', + 'names_list' => \@serviceids, + 'param_style' => 'link_table.value checkboxes', + }, + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $nms = new FS::NetworkMonitoringSystem; +my @serviceids = $nms->torrus_serviceids; + + diff --git a/httemplate/edit/torrus_srvderive.html b/httemplate/edit/torrus_srvderive.html new file mode 100644 index 000000000..51e23377c --- /dev/null +++ b/httemplate/edit/torrus_srvderive.html @@ -0,0 +1,37 @@ +<% include( 'elements/edit.html', + 'name_singular' => 'virtual port', + 'table' => 'torrus_srvderive', + 'labels' => { 'serviceid' => 'Virtual Port serviceid', + }, + 'fields' => [ 'serviceid', + ], + 'viewall_dir' => 'browse', + 'html_bottom' => $html_bottom_sub, + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $html_bottom_sub = sub { + my $torrus_srvderive = shift; + + my $nms = new FS::NetworkMonitoringSystem; + my @serviceids = $nms->torrus_serviceids; + + ntable('#cccccc',2).''. + include( '/elements/checkboxes-table-name.html', + 'source_obj' => $torrus_srvderive, + 'link_table' => 'torrus_srvderive_component', + 'num_col' => 'derivenum', + 'name_col' => 'serviceid', + 'names_list' => \@serviceids, + 'disable_links' => 1, + ). + ''; + +}; + + + diff --git a/httemplate/elements/checkboxes-table-name.html b/httemplate/elements/checkboxes-table-name.html index 31652f330..8ee2f7736 100644 --- a/httemplate/elements/checkboxes-table-name.html +++ b/httemplate/elements/checkboxes-table-name.html @@ -45,6 +45,7 @@ Example: 'names_list' => $opt{'names_list'}, 'checked_callback' => $checked_callback, 'element_name_prefix' => $opt{'link_table'}. '.', + 'disable_links' => $opt{'disable_links'}, ) %> diff --git a/httemplate/elements/checkboxes.html b/httemplate/elements/checkboxes.html index b120adab7..69ef18fb9 100644 --- a/httemplate/elements/checkboxes.html +++ b/httemplate/elements/checkboxes.html @@ -29,6 +29,8 @@ Example: +% unless ( $opt{'disable_links'} ) { + +% } + % my $num=0; % foreach my $item ( @{ $opt{'names_list'} } ) { % diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 651b04d28..d0741596b 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -501,6 +501,10 @@ tie my %config_phone, 'Tie::IxHash', 'View/Edit bulk DID vendors' => [ $fsurl.'browse/did_vendor.html', 'Bulk DID vendors' ], ; +tie my %config_nms, 'Tie::IxHash', + 'View/Edit virtual ports' => [ $fsurl.'browse/torrus_srvderive.html', '' ], +; + tie my %config_misc, 'Tie::IxHash'; $config_misc{'Message templates'} = [ $fsurl.'browse/msg_template.html', 'Templates for customer notices' ] if $curuser->access_right('Edit templates') @@ -545,11 +549,14 @@ $config_menu{'Ticketing'} = [ \%config_ticketing, '' ] if $conf->config('ticket_system') && FS::TicketSystem->access_right(\%session, 'ShowConfigTab'); $config_menu{'Dialup'} = [ \%config_dialup, '' ] - if ( $curuser->access_right('Dialup configuration') ); + if $curuser->access_right('Dialup configuration'); $config_menu{'Broadband'} = [ \%config_broadband, '' ] - if ( $curuser->access_right('Broadband configuration') ); + if $curuser->access_right('Broadband configuration'); $config_menu{'Phone'} = [ \%config_phone, '' ] - if ( $curuser->access_right('Configuration') ); + if $curuser->access_right('Configuration'); +$config_menu{'Network Monitoring'} = [ \%config_nms, '' ] + if $curuser->access_right('Configuration') + && $conf->config('network_monitoring_system') eq 'Torrus_Internal'; $config_menu{'Miscellaneous'} = [ \%config_misc, '' ] if $curuser->access_right('Configuration' ) || $curuser->access_right('Edit advertising sources') diff --git a/httemplate/elements/select-torrus_serviceid.html b/httemplate/elements/select-torrus_serviceid.html index 34e8e930f..e13a6e80d 100644 --- a/httemplate/elements/select-torrus_serviceid.html +++ b/httemplate/elements/select-torrus_serviceid.html @@ -4,7 +4,7 @@ % } -% foreach my $serviceid ( keys %serviceid ) { +% foreach my $serviceid ( @serviceids ) { @@ -18,15 +18,7 @@ my %opt = @_; my $value = $opt{'curr_value'} || $opt{'value'}; -#is this going to get too slow or will the index make it okay? -my $sth = dbh->prepare("SELECT DISTINCT(serviceid) FROM srvexport") - or die dbh->errstr; -$sth->execute or die $sth->errstr; -my %serviceid = (); -while ( my $row = $sth->fetchrow_arrayref ) { - my $serviceid = $row->[0]; - $serviceid =~ s/_(IN|OUT)$//; - $serviceid{$serviceid}=1; -} +my $nms = new FS::NetworkMonitoringSystem; +my @serviceids = $nms->torrus_serviceids; -- cgit v1.2.1
( select all | @@ -37,6 +39,8 @@ Example: )