Skip to content

Commit

Permalink
ui: Add links_service_graph() function.
Browse files Browse the repository at this point in the history
Also change links_adm_menu to respect the new hash structure.
  • Loading branch information
rjuju committed Jul 23, 2014
1 parent b1a15ae commit 7020f2b
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions ui/lib/OPM/WhNagios.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,46 @@ sub links_adm_menu {
my ( $self, $ctrl ) = ( shift, shift );
my $args = @_;
my $value = {
class => 'glyphicon glyphicon-cog',
title => 'wh_nagios',
cr_regex => '^wh_nagios',
href => $ctrl->url_for( 'wh_nagios_services', @_ )
a => {
href => $ctrl->url_for( 'wh_nagios_services' )
},
i => {
class => 'glyphicon glyphicon-cog',
},
display => 'wh_nagios'
};
return [$value];
}

# Display admin links in graph pages
sub links_service_graph {
my ( $self, $ctrl ) = ( shift, shift );
my $arg = shift;
my $ret = [];
my $dbh = $ctrl->database();
my $sql = $dbh->prepare("SELECT g.id_service, s.service
FROM public.get_graph( ? ) g
JOIN public.get_service( g.id_service ) s ON true
WHERE g.warehouse = 'wh_nagios'"
);
$sql->execute( $arg->{id_graph} );
while ( my $row = $sql->fetchrow_hashref() ) {
my $value = {
a => {
class => 'btn btn-default btn-sm',
title => $ctrl->l("Admin") . " (" .$row->{service} . ")",
href => $ctrl->url_for('wh_nagios_service', id => $row->{id_service})
},
i => {
class => 'fa fa-cog'
},
display => ''
};
push @{ $ret }, $value;
}
return $ret;
}

sub format_state {
my $whstate = shift ;
my $class = 'default';
Expand Down

0 comments on commit 7020f2b

Please sign in to comment.